From 0485003e891b886d910522211b7e5bbcae5c1adf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E6=99=A8=20=28Leo=20Cheng=29?= Date: Sun, 26 Jul 2026 19:54:33 +0800 Subject: [PATCH 1/6] core: implement FusedIterator for StepBy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 林晨 (Leo Cheng) --- library/core/src/iter/adapters/step_by.rs | 7 ++++++- library/coretests/tests/iter/adapters/step_by.rs | 13 +++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/library/core/src/iter/adapters/step_by.rs b/library/core/src/iter/adapters/step_by.rs index 3a1ff98ec3343..aa4e46743a316 100644 --- a/library/core/src/iter/adapters/step_by.rs +++ b/library/core/src/iter/adapters/step_by.rs @@ -1,5 +1,5 @@ use crate::intrinsics; -use crate::iter::{TrustedLen, TrustedRandomAccess, from_fn}; +use crate::iter::{FusedIterator, TrustedLen, TrustedRandomAccess, from_fn}; use crate::num::NonZero; use crate::ops::{Range, Try}; use crate::range::RangeIter; @@ -136,6 +136,11 @@ where #[stable(feature = "iterator_step_by", since = "1.28.0")] impl ExactSizeIterator for StepBy where I: ExactSizeIterator {} +// StepBy stops yielding items once the underlying iterator does, so it is fused +// whenever the underlying iterator is fused. +#[stable(feature = "step_by_fused", since = "CURRENT_RUSTC_VERSION")] +impl FusedIterator for StepBy where I: FusedIterator {} + // SAFETY: This adapter is shortening. TrustedLen requires the upper bound to be calculated correctly. // These requirements can only be satisfied when the upper bound of the inner iterator's upper // bound is never `None`. I: TrustedRandomAccess happens to provide this guarantee while diff --git a/library/coretests/tests/iter/adapters/step_by.rs b/library/coretests/tests/iter/adapters/step_by.rs index 810c014fdc8d9..7580b6fb9f8af 100644 --- a/library/coretests/tests/iter/adapters/step_by.rs +++ b/library/coretests/tests/iter/adapters/step_by.rs @@ -418,3 +418,16 @@ fn test_step_by_nth_non_fused_on_non_first_take() { // so we should expect `StepBy::nth` to return `None` assert_eq!(iter.nth(usize::MAX), None) } + +#[test] +fn test_step_by_fused() { + // `StepBy` is fused whenever the underlying iterator is fused. + fn assert_fused(_: I) {} + assert_fused((0..10).step_by(3)); + + // Once the underlying fused iterator is exhausted, `StepBy` keeps yielding `None`. + let mut it = (0..3).step_by(5); + assert_eq!(it.next(), Some(0)); + assert_eq!(it.next(), None); + assert_eq!(it.next(), None); +} From 9a8b45df34d1e3c932d99d7f4af8923201cc1bf4 Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Wed, 18 Feb 2026 13:21:49 -0800 Subject: [PATCH 2/6] tests/ui/union: add annotations for reference rules --- tests/ui/union/access_union_field.rs | 2 ++ tests/ui/union/access_union_field.stderr | 4 +-- tests/ui/union/field_checks.rs | 7 +++++ tests/ui/union/field_checks.stderr | 10 +++---- tests/ui/union/issue-41073.rs | 2 ++ tests/ui/union/issue-41073.stderr | 2 +- tests/ui/union/issue-81199.rs | 2 ++ tests/ui/union/issue-81199.stderr | 6 ++-- tests/ui/union/issue-99375.rs | 2 ++ tests/ui/union/union-assignop.rs | 2 ++ tests/ui/union/union-assignop.stderr | 12 ++++---- tests/ui/union/union-backcomp.rs | 1 + .../union/union-borrow-move-parent-sibling.rs | 1 + .../union-borrow-move-parent-sibling.stderr | 20 ++++++------- tests/ui/union/union-copy.rs | 1 + tests/ui/union/union-copy.stderr | 4 +-- tests/ui/union/union-drop-assign.rs | 1 + tests/ui/union/union-drop.rs | 2 ++ tests/ui/union/union-empty.rs | 1 + tests/ui/union/union-empty.stderr | 2 +- tests/ui/union/union-fields-2.rs | 4 +++ tests/ui/union/union-fields-2.stderr | 26 ++++++++--------- tests/ui/union/union-inherent-method.rs | 1 + tests/ui/union/union-manuallydrop-rpass.rs | 2 ++ tests/ui/union/union-overwrite.rs | 2 ++ tests/ui/union/union-packed.rs | 1 + tests/ui/union/union-pat-in-param.rs | 1 + tests/ui/union/union-pat-in-param.stderr | 4 +-- tests/ui/union/union-pat-refutability.rs | 3 ++ tests/ui/union/union-trait-impl.rs | 1 + tests/ui/union/union-transmute.rs | 2 ++ tests/ui/union/union-unsafe.rs | 5 ++++ tests/ui/union/union-unsafe.stderr | 28 +++++++++---------- tests/ui/union/union-with-drop-fields.rs | 1 + tests/ui/union/union-with-drop-fields.stderr | 6 ++-- tests/ui/union/union_destructure.rs | 1 + 36 files changed, 110 insertions(+), 62 deletions(-) diff --git a/tests/ui/union/access_union_field.rs b/tests/ui/union/access_union_field.rs index 4183119725eca..2fbb924e390e0 100644 --- a/tests/ui/union/access_union_field.rs +++ b/tests/ui/union/access_union_field.rs @@ -1,3 +1,5 @@ +//@ reference: items.union.fields.read-safety +//@ reference: type.union.safety #![allow(unused_variables)] union Foo { diff --git a/tests/ui/union/access_union_field.stderr b/tests/ui/union/access_union_field.stderr index 4c46bb44a1d33..c56a6067e45bc 100644 --- a/tests/ui/union/access_union_field.stderr +++ b/tests/ui/union/access_union_field.stderr @@ -1,5 +1,5 @@ error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/access_union_field.rs:10:13 + --> $DIR/access_union_field.rs:12:13 | LL | let a = foo.bar; | ^^^^^^^ access to union field @@ -7,7 +7,7 @@ LL | let a = foo.bar; = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/access_union_field.rs:11:13 + --> $DIR/access_union_field.rs:13:13 | LL | let b = foo.baz; | ^^^^^^^ access to union field diff --git a/tests/ui/union/field_checks.rs b/tests/ui/union/field_checks.rs index bb4eccb4cf896..551ae2d6fbcbe 100644 --- a/tests/ui/union/field_checks.rs +++ b/tests/ui/union/field_checks.rs @@ -1,3 +1,10 @@ +//@ reference: items.union.drop +//@ reference: items.union.field-restrictions +//@ reference: items.union.field-copy +//@ reference: items.union.field-references +//@ reference: items.union.field-manually-drop +//@ reference: items.union.field-tuple +//@ reference: type.union.constraint use std::mem::ManuallyDrop; union U1 { // OK diff --git a/tests/ui/union/field_checks.stderr b/tests/ui/union/field_checks.stderr index 32407a749709c..b9440a12602db 100644 --- a/tests/ui/union/field_checks.stderr +++ b/tests/ui/union/field_checks.stderr @@ -1,5 +1,5 @@ error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union - --> $DIR/field_checks.rs:24:5 + --> $DIR/field_checks.rs:31:5 | LL | a: String, | ^^^^^^^^^ @@ -11,7 +11,7 @@ LL | a: std::mem::ManuallyDrop, | +++++++++++++++++++++++ + error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union - --> $DIR/field_checks.rs:28:5 + --> $DIR/field_checks.rs:35:5 | LL | a: std::cell::RefCell, | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | a: std::mem::ManuallyDrop>, | +++++++++++++++++++++++ + error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union - --> $DIR/field_checks.rs:32:5 + --> $DIR/field_checks.rs:39:5 | LL | a: T, | ^^^^ @@ -35,7 +35,7 @@ LL | a: std::mem::ManuallyDrop, | +++++++++++++++++++++++ + error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union - --> $DIR/field_checks.rs:44:5 + --> $DIR/field_checks.rs:51:5 | LL | nest: U5, | ^^^^^^^^ @@ -47,7 +47,7 @@ LL | nest: std::mem::ManuallyDrop, | +++++++++++++++++++++++ + error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union - --> $DIR/field_checks.rs:48:5 + --> $DIR/field_checks.rs:55:5 | LL | nest: [U5; 0], | ^^^^^^^^^^^^^ diff --git a/tests/ui/union/issue-41073.rs b/tests/ui/union/issue-41073.rs index f7a82b4e7cf5d..3536b9fd20375 100644 --- a/tests/ui/union/issue-41073.rs +++ b/tests/ui/union/issue-41073.rs @@ -1,3 +1,5 @@ +//@ reference: items.union.field-restrictions +//@ reference: type.union.constraint union Test { a: A, //~ ERROR field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union b: B diff --git a/tests/ui/union/issue-41073.stderr b/tests/ui/union/issue-41073.stderr index c9b6903b1bfba..d66e3753ae658 100644 --- a/tests/ui/union/issue-41073.stderr +++ b/tests/ui/union/issue-41073.stderr @@ -1,5 +1,5 @@ error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union - --> $DIR/issue-41073.rs:2:5 + --> $DIR/issue-41073.rs:4:5 | LL | a: A, | ^^^^ diff --git a/tests/ui/union/issue-81199.rs b/tests/ui/union/issue-81199.rs index 2083ee15d87bd..89460f2f4b43f 100644 --- a/tests/ui/union/issue-81199.rs +++ b/tests/ui/union/issue-81199.rs @@ -1,3 +1,5 @@ +//@ reference: items.union.field-restrictions +//@ reference: type.union.constraint #[repr(C)] union PtrRepr { const_ptr: *const T, diff --git a/tests/ui/union/issue-81199.stderr b/tests/ui/union/issue-81199.stderr index 46f5de8d4fd8a..a36aa4bf98c46 100644 --- a/tests/ui/union/issue-81199.stderr +++ b/tests/ui/union/issue-81199.stderr @@ -1,5 +1,5 @@ error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union - --> $DIR/issue-81199.rs:5:5 + --> $DIR/issue-81199.rs:7:5 | LL | components: PtrComponents, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -11,14 +11,14 @@ LL | components: std::mem::ManuallyDrop>, | +++++++++++++++++++++++ + error[E0277]: the trait bound `T: Pointee` is not satisfied - --> $DIR/issue-81199.rs:5:17 + --> $DIR/issue-81199.rs:7:17 | LL | components: PtrComponents, | ^^^^^^^^^^^^^^^^ the trait `Pointee` is not implemented for `T` | = note: `T` implements similarly named trait `std::ptr::Pointee`, but not `Pointee` note: required by a bound in `PtrComponents` - --> $DIR/issue-81199.rs:11:25 + --> $DIR/issue-81199.rs:13:25 | LL | struct PtrComponents { | ^^^^^^^ required by this bound in `PtrComponents` diff --git a/tests/ui/union/issue-99375.rs b/tests/ui/union/issue-99375.rs index ead083b21b1e9..cc0a7adbaf8db 100644 --- a/tests/ui/union/issue-99375.rs +++ b/tests/ui/union/issue-99375.rs @@ -1,4 +1,6 @@ //@ check-pass +//@ reference: items.union.field-copy +//@ reference: items.union.field-tuple union URes { uninit: (), diff --git a/tests/ui/union/union-assignop.rs b/tests/ui/union/union-assignop.rs index 6122aef0565e0..fdffa4a535ff0 100644 --- a/tests/ui/union/union-assignop.rs +++ b/tests/ui/union/union-assignop.rs @@ -1,3 +1,5 @@ +//@ reference: items.union.fields.read-safety +//@ reference: items.union.fields.write-safety use std::ops::AddAssign; use std::mem::ManuallyDrop; diff --git a/tests/ui/union/union-assignop.stderr b/tests/ui/union/union-assignop.stderr index 6b2ebfb509961..087c599dbc1ae 100644 --- a/tests/ui/union/union-assignop.stderr +++ b/tests/ui/union/union-assignop.stderr @@ -1,5 +1,5 @@ error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/union-assignop.rs:16:5 + --> $DIR/union-assignop.rs:18:5 | LL | foo.a += 5; | ^^^^^ access to union field @@ -7,7 +7,7 @@ LL | foo.a += 5; = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/union-assignop.rs:17:6 + --> $DIR/union-assignop.rs:19:6 | LL | *foo.b += NonCopy; | ^^^^^ access to union field @@ -15,7 +15,7 @@ LL | *foo.b += NonCopy; = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/union-assignop.rs:18:6 + --> $DIR/union-assignop.rs:20:6 | LL | *foo.b = NonCopy; | ^^^^^ access to union field @@ -23,7 +23,7 @@ LL | *foo.b = NonCopy; = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/union-assignop.rs:20:5 + --> $DIR/union-assignop.rs:22:5 | LL | foo.a; | ^^^^^ access to union field @@ -31,7 +31,7 @@ LL | foo.a; = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/union-assignop.rs:22:5 + --> $DIR/union-assignop.rs:24:5 | LL | foo.b; | ^^^^^ access to union field @@ -39,7 +39,7 @@ LL | foo.b; = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/union-assignop.rs:24:13 + --> $DIR/union-assignop.rs:26:13 | LL | foo.b = foo.b; | ^^^^^ access to union field diff --git a/tests/ui/union/union-backcomp.rs b/tests/ui/union/union-backcomp.rs index a71813968e841..46b5eb48f0c4a 100644 --- a/tests/ui/union/union-backcomp.rs +++ b/tests/ui/union/union-backcomp.rs @@ -1,4 +1,5 @@ //@ run-pass +//@ reference: lex.keywords.weak.union #![allow(path_statements)] #![allow(dead_code)] diff --git a/tests/ui/union/union-borrow-move-parent-sibling.rs b/tests/ui/union/union-borrow-move-parent-sibling.rs index 5b0b44232e411..435fa7fbd1540 100644 --- a/tests/ui/union/union-borrow-move-parent-sibling.rs +++ b/tests/ui/union/union-borrow-move-parent-sibling.rs @@ -1,3 +1,4 @@ +//@ reference: items.union.ref.borrow #![allow(unused)] use std::ops::{Deref, DerefMut}; diff --git a/tests/ui/union/union-borrow-move-parent-sibling.stderr b/tests/ui/union/union-borrow-move-parent-sibling.stderr index 461ee407e2ddb..0655cd0908113 100644 --- a/tests/ui/union/union-borrow-move-parent-sibling.stderr +++ b/tests/ui/union/union-borrow-move-parent-sibling.stderr @@ -1,5 +1,5 @@ error[E0502]: cannot borrow `u` (via `u.y`) as immutable because it is also borrowed as mutable (via `u.x`) - --> $DIR/union-borrow-move-parent-sibling.rs:53:13 + --> $DIR/union-borrow-move-parent-sibling.rs:54:13 | LL | let a = &mut (*u.x).0; | --- mutable borrow occurs here (via `u.x`) @@ -11,7 +11,7 @@ LL | use_borrow(a); = note: `u.y` is a field of the union `U`, so it overlaps the field `u.x` error[E0507]: cannot move out of dereference of `ManuallyDrop<((MockVec, MockVec), MockVec)>` - --> $DIR/union-borrow-move-parent-sibling.rs:59:13 + --> $DIR/union-borrow-move-parent-sibling.rs:60:13 | LL | let a = u.x.0; | ^^^^^ move occurs because value has type `(MockVec, MockVec)`, which does not implement the `Copy` trait @@ -22,7 +22,7 @@ LL | let a = &u.x.0; | + error[E0382]: use of moved value: `u` - --> $DIR/union-borrow-move-parent-sibling.rs:61:13 + --> $DIR/union-borrow-move-parent-sibling.rs:62:13 | LL | let u = U { x: ManuallyDrop::new(((MockVec::new(), MockVec::new()), MockVec::new())) }; | - move occurs because `u` has type `U`, which does not implement the `Copy` trait @@ -33,7 +33,7 @@ LL | let b = u.y; | ^^^ value used here after move | note: if `U` implemented `Clone`, you could clone the value - --> $DIR/union-borrow-move-parent-sibling.rs:43:1 + --> $DIR/union-borrow-move-parent-sibling.rs:44:1 | LL | union U { | ^^^^^^^ consider implementing `Clone` for this type @@ -42,7 +42,7 @@ LL | let a = u.x; | --- you could clone this value error[E0502]: cannot borrow `u` (via `u.y`) as immutable because it is also borrowed as mutable (via `u.x`) - --> $DIR/union-borrow-move-parent-sibling.rs:67:13 + --> $DIR/union-borrow-move-parent-sibling.rs:68:13 | LL | let a = &mut ((*u.x).0).0; | --- mutable borrow occurs here (via `u.x`) @@ -54,13 +54,13 @@ LL | use_borrow(a); = note: `u.y` is a field of the union `U`, so it overlaps the field `u.x` error[E0507]: cannot move out of dereference of `ManuallyDrop<((MockVec, MockVec), MockVec)>` - --> $DIR/union-borrow-move-parent-sibling.rs:73:13 + --> $DIR/union-borrow-move-parent-sibling.rs:74:13 | LL | let a = (u.x.0).0; | ^^^^^^^^^ move occurs because value has type `MockVec`, which does not implement the `Copy` trait | note: if `MockVec` implemented `Clone`, you could clone the value - --> $DIR/union-borrow-move-parent-sibling.rs:25:1 + --> $DIR/union-borrow-move-parent-sibling.rs:26:1 | LL | struct MockVec { | ^^^^^^^^^^^^^^^^^ consider implementing `Clone` for this type @@ -73,7 +73,7 @@ LL | let a = &(u.x.0).0; | + error[E0382]: use of moved value: `u` - --> $DIR/union-borrow-move-parent-sibling.rs:75:13 + --> $DIR/union-borrow-move-parent-sibling.rs:76:13 | LL | let u = U { x: ManuallyDrop::new(((MockVec::new(), MockVec::new()), MockVec::new())) }; | - move occurs because `u` has type `U`, which does not implement the `Copy` trait @@ -84,7 +84,7 @@ LL | let b = u.y; | ^^^ value used here after move | note: if `U` implemented `Clone`, you could clone the value - --> $DIR/union-borrow-move-parent-sibling.rs:43:1 + --> $DIR/union-borrow-move-parent-sibling.rs:44:1 | LL | union U { | ^^^^^^^ consider implementing `Clone` for this type @@ -93,7 +93,7 @@ LL | let a = u.x; | --- you could clone this value error[E0502]: cannot borrow `u` (via `u.x`) as immutable because it is also borrowed as mutable (via `u.y`) - --> $DIR/union-borrow-move-parent-sibling.rs:81:13 + --> $DIR/union-borrow-move-parent-sibling.rs:82:13 | LL | let a = &mut *u.y; | --- mutable borrow occurs here (via `u.y`) diff --git a/tests/ui/union/union-copy.rs b/tests/ui/union/union-copy.rs index 7ad0a11c6ac6e..40b43b8f3466e 100644 --- a/tests/ui/union/union-copy.rs +++ b/tests/ui/union/union-copy.rs @@ -1,3 +1,4 @@ +//@ reference: lang-types.copy.constraint #[derive(Clone)] union U { a: u8 diff --git a/tests/ui/union/union-copy.stderr b/tests/ui/union/union-copy.stderr index bd63908b49a2c..60cb49147b659 100644 --- a/tests/ui/union/union-copy.stderr +++ b/tests/ui/union/union-copy.stderr @@ -1,5 +1,5 @@ error[E0204]: the trait `Copy` cannot be implemented for this type - --> $DIR/union-copy.rs:12:15 + --> $DIR/union-copy.rs:13:15 | LL | a: std::mem::ManuallyDrop | --------------------------------- this field does not implement `Copy` @@ -8,7 +8,7 @@ LL | impl Copy for W {} | ^ | note: the `Copy` impl for `ManuallyDrop` requires that `String: Copy` - --> $DIR/union-copy.rs:8:8 + --> $DIR/union-copy.rs:9:8 | LL | a: std::mem::ManuallyDrop | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/union/union-drop-assign.rs b/tests/ui/union/union-drop-assign.rs index 710a6f6205e01..ac3120fc2f25c 100644 --- a/tests/ui/union/union-drop-assign.rs +++ b/tests/ui/union/union-drop-assign.rs @@ -1,4 +1,5 @@ //@ run-pass +//@ reference: items.union.drop #![allow(unused_assignments)] // Drop works for union itself. diff --git a/tests/ui/union/union-drop.rs b/tests/ui/union/union-drop.rs index 9a2911599dfe2..4e3ce06014c82 100644 --- a/tests/ui/union/union-drop.rs +++ b/tests/ui/union/union-drop.rs @@ -1,4 +1,6 @@ //@ run-pass +//@ reference: destructors.manually-suppressing +//@ reference: items.union.drop #![allow(dead_code)] #![allow(unused_variables)] diff --git a/tests/ui/union/union-empty.rs b/tests/ui/union/union-empty.rs index 79b7e68ee6beb..60b6668b6e245 100644 --- a/tests/ui/union/union-empty.rs +++ b/tests/ui/union/union-empty.rs @@ -1,3 +1,4 @@ +//@ reference: items.union.fieldless union U {} //~ ERROR unions cannot have zero fields fn main() {} diff --git a/tests/ui/union/union-empty.stderr b/tests/ui/union/union-empty.stderr index 03a939769c78b..aeec4eca5a996 100644 --- a/tests/ui/union/union-empty.stderr +++ b/tests/ui/union/union-empty.stderr @@ -1,5 +1,5 @@ error: unions cannot have zero fields - --> $DIR/union-empty.rs:1:1 + --> $DIR/union-empty.rs:2:1 | LL | union U {} | ^^^^^^^^^^ diff --git a/tests/ui/union/union-fields-2.rs b/tests/ui/union/union-fields-2.rs index 71b204fcdc5b8..2c4dc241bc43a 100644 --- a/tests/ui/union/union-fields-2.rs +++ b/tests/ui/union/union-fields-2.rs @@ -1,3 +1,7 @@ +//@ reference: expr.struct.field.union-constraint +//@ reference: items.union.init.intro +//@ reference: items.union.pattern.one-field +//@ reference: patterns.struct.constraint-union union U { a: u8, b: u16, diff --git a/tests/ui/union/union-fields-2.stderr b/tests/ui/union/union-fields-2.stderr index 142186885caa8..4cfd2271f3f79 100644 --- a/tests/ui/union/union-fields-2.stderr +++ b/tests/ui/union/union-fields-2.stderr @@ -1,17 +1,17 @@ error[E0784]: union expressions should have exactly one field - --> $DIR/union-fields-2.rs:7:13 + --> $DIR/union-fields-2.rs:11:13 | LL | let u = U {}; | ^ error[E0784]: union expressions should have exactly one field - --> $DIR/union-fields-2.rs:9:13 + --> $DIR/union-fields-2.rs:13:13 | LL | let u = U { a: 0, b: 1 }; | ^ error[E0560]: union `U` has no field named `c` - --> $DIR/union-fields-2.rs:10:29 + --> $DIR/union-fields-2.rs:14:29 | LL | let u = U { a: 0, b: 1, c: 2 }; | ^ `U` does not have this field @@ -19,61 +19,61 @@ LL | let u = U { a: 0, b: 1, c: 2 }; = note: all struct fields are already assigned error[E0784]: union expressions should have exactly one field - --> $DIR/union-fields-2.rs:10:13 + --> $DIR/union-fields-2.rs:14:13 | LL | let u = U { a: 0, b: 1, c: 2 }; | ^ error[E0784]: union expressions should have exactly one field - --> $DIR/union-fields-2.rs:12:13 + --> $DIR/union-fields-2.rs:16:13 | LL | let u = U { ..u }; | ^ error[E0436]: functional record update syntax requires a struct - --> $DIR/union-fields-2.rs:12:19 + --> $DIR/union-fields-2.rs:16:19 | LL | let u = U { ..u }; | ^ error: union patterns should have exactly one field - --> $DIR/union-fields-2.rs:15:9 + --> $DIR/union-fields-2.rs:19:9 | LL | let U {} = u; | ^^^^ error: union patterns should have exactly one field - --> $DIR/union-fields-2.rs:17:9 + --> $DIR/union-fields-2.rs:21:9 | LL | let U { a, b } = u; | ^^^^^^^^^^ error: union patterns should have exactly one field - --> $DIR/union-fields-2.rs:18:9 + --> $DIR/union-fields-2.rs:22:9 | LL | let U { a, b, c } = u; | ^^^^^^^^^^^^^ error[E0026]: union `U` does not have a field named `c` - --> $DIR/union-fields-2.rs:18:19 + --> $DIR/union-fields-2.rs:22:19 | LL | let U { a, b, c } = u; | ^ union `U` does not have this field error: union patterns should have exactly one field - --> $DIR/union-fields-2.rs:20:9 + --> $DIR/union-fields-2.rs:24:9 | LL | let U { .. } = u; | ^^^^^^^^ error: `..` cannot be used in union patterns - --> $DIR/union-fields-2.rs:20:9 + --> $DIR/union-fields-2.rs:24:9 | LL | let U { .. } = u; | ^^^^^^^^ error: `..` cannot be used in union patterns - --> $DIR/union-fields-2.rs:22:9 + --> $DIR/union-fields-2.rs:26:9 | LL | let U { a, .. } = u; | ^^^^^^^^^^^ diff --git a/tests/ui/union/union-inherent-method.rs b/tests/ui/union/union-inherent-method.rs index a3f962fb87211..86a62ff18cd3d 100644 --- a/tests/ui/union/union-inherent-method.rs +++ b/tests/ui/union/union-inherent-method.rs @@ -1,4 +1,5 @@ //@ run-pass +//@ reference: items.impl.inherent.associated-items.allowed-items union U { a: u8, diff --git a/tests/ui/union/union-manuallydrop-rpass.rs b/tests/ui/union/union-manuallydrop-rpass.rs index c1be39c20e613..f69fc2d36fe1e 100644 --- a/tests/ui/union/union-manuallydrop-rpass.rs +++ b/tests/ui/union/union-manuallydrop-rpass.rs @@ -1,4 +1,6 @@ //@ run-pass +//@ reference: items.union.field-copy +//@ reference: items.union.field-manually-drop #![allow(dead_code)] use std::mem::needs_drop; diff --git a/tests/ui/union/union-overwrite.rs b/tests/ui/union/union-overwrite.rs index cd9a370ff6663..5cb6152ced33a 100644 --- a/tests/ui/union/union-overwrite.rs +++ b/tests/ui/union/union-overwrite.rs @@ -1,4 +1,6 @@ //@ run-pass +//@ reference: items.union.common-storage +//@ reference: items.union.fields.read #[repr(C)] #[derive(Copy, Clone)] diff --git a/tests/ui/union/union-packed.rs b/tests/ui/union/union-packed.rs index b1ab211eae829..790c82364060f 100644 --- a/tests/ui/union/union-packed.rs +++ b/tests/ui/union/union-packed.rs @@ -1,4 +1,5 @@ //@ run-pass +//@ reference: layout.repr.alignment.intro #![allow(dead_code)] #![allow(non_snake_case)] diff --git a/tests/ui/union/union-pat-in-param.rs b/tests/ui/union/union-pat-in-param.rs index 8454bfb20dcb8..6a65a5c060006 100644 --- a/tests/ui/union/union-pat-in-param.rs +++ b/tests/ui/union/union-pat-in-param.rs @@ -1,3 +1,4 @@ +//@ reference: items.union.pattern.safety union U { a: &'static i32, b: usize, diff --git a/tests/ui/union/union-pat-in-param.stderr b/tests/ui/union/union-pat-in-param.stderr index b9709b7cc9bf1..b1eb70f79bcaf 100644 --- a/tests/ui/union/union-pat-in-param.stderr +++ b/tests/ui/union/union-pat-in-param.stderr @@ -1,5 +1,5 @@ error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/union-pat-in-param.rs:6:12 + --> $DIR/union-pat-in-param.rs:7:12 | LL | fn fun(U { a }: U) { | ^ access to union field @@ -7,7 +7,7 @@ LL | fn fun(U { a }: U) { = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/union-pat-in-param.rs:14:24 + --> $DIR/union-pat-in-param.rs:15:24 | LL | let closure = |U { a }| { | ^ access to union field diff --git a/tests/ui/union/union-pat-refutability.rs b/tests/ui/union/union-pat-refutability.rs index 826bd42cd2113..3f4c06f1e03e5 100644 --- a/tests/ui/union/union-pat-refutability.rs +++ b/tests/ui/union/union-pat-refutability.rs @@ -1,4 +1,7 @@ //@ run-pass +//@ reference: items.union.pattern.intro +//@ reference: items.union.pattern.safety +//@ reference: patterns.struct.refutable #![allow(dead_code)] diff --git a/tests/ui/union/union-trait-impl.rs b/tests/ui/union/union-trait-impl.rs index d48ae18dd0e5e..238189ea82a81 100644 --- a/tests/ui/union/union-trait-impl.rs +++ b/tests/ui/union/union-trait-impl.rs @@ -1,4 +1,5 @@ //@ run-pass +//@ reference: items.union.ref.use use std::fmt; diff --git a/tests/ui/union/union-transmute.rs b/tests/ui/union/union-transmute.rs index 72ac4a85d593b..879ee7a23dbd8 100644 --- a/tests/ui/union/union-transmute.rs +++ b/tests/ui/union/union-transmute.rs @@ -1,4 +1,6 @@ //@ run-pass +//@ reference: items.union.common-storage +//@ reference: type.union.access union U { a: (u8, u8), diff --git a/tests/ui/union/union-unsafe.rs b/tests/ui/union/union-unsafe.rs index beb074f4e8ebc..62d307927cccd 100644 --- a/tests/ui/union/union-unsafe.rs +++ b/tests/ui/union/union-unsafe.rs @@ -1,3 +1,8 @@ +//@ reference: items.union.fields.read-safety +//@ reference: items.union.fields.write-safety +//@ reference: items.union.pattern.safety +//@ reference: safety.unsafe-union-access +//@ reference: type.union.safety use std::cell::RefCell; use std::mem::ManuallyDrop; use std::ops::Deref; diff --git a/tests/ui/union/union-unsafe.stderr b/tests/ui/union/union-unsafe.stderr index 01f4d95eb649d..36543085ba82c 100644 --- a/tests/ui/union/union-unsafe.stderr +++ b/tests/ui/union/union-unsafe.stderr @@ -1,5 +1,5 @@ error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/union-unsafe.rs:36:6 + --> $DIR/union-unsafe.rs:41:6 | LL | *(u.p) = 13; | ^^^^^ access to union field @@ -7,7 +7,7 @@ LL | *(u.p) = 13; = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/union-unsafe.rs:50:26 + --> $DIR/union-unsafe.rs:55:26 | LL | let _p = &raw const *(u.p); | ^^^^^ access to union field @@ -15,7 +15,7 @@ LL | let _p = &raw const *(u.p); = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/union-unsafe.rs:62:6 + --> $DIR/union-unsafe.rs:67:6 | LL | *u3.a = T::default(); | ^^^^ access to union field @@ -23,7 +23,7 @@ LL | *u3.a = T::default(); = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/union-unsafe.rs:68:6 + --> $DIR/union-unsafe.rs:73:6 | LL | *u3.a = T::default(); | ^^^^ access to union field @@ -31,7 +31,7 @@ LL | *u3.a = T::default(); = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/union-unsafe.rs:76:13 + --> $DIR/union-unsafe.rs:81:13 | LL | let a = u1.a; | ^^^^ access to union field @@ -39,7 +39,7 @@ LL | let a = u1.a; = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/union-unsafe.rs:91:29 + --> $DIR/union-unsafe.rs:96:29 | LL | let _a = &raw const vec[u4.a]; | ^^^^ access to union field @@ -47,7 +47,7 @@ LL | let _a = &raw const vec[u4.a]; = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/union-unsafe.rs:93:14 + --> $DIR/union-unsafe.rs:98:14 | LL | let U1 { a } = u1; | ^ access to union field @@ -55,7 +55,7 @@ LL | let U1 { a } = u1; = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/union-unsafe.rs:94:20 + --> $DIR/union-unsafe.rs:99:20 | LL | if let U1 { a: 12 } = u1 {} | ^^ access to union field @@ -63,7 +63,7 @@ LL | if let U1 { a: 12 } = u1 {} = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/union-unsafe.rs:95:25 + --> $DIR/union-unsafe.rs:100:25 | LL | if let Some(U1 { a: 13 }) = Some(u1) {} | ^^ access to union field @@ -71,7 +71,7 @@ LL | if let Some(U1 { a: 13 }) = Some(u1) {} = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/union-unsafe.rs:100:6 + --> $DIR/union-unsafe.rs:105:6 | LL | *u2.a = String::from("new"); | ^^^^ access to union field @@ -79,7 +79,7 @@ LL | *u2.a = String::from("new"); = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/union-unsafe.rs:104:6 + --> $DIR/union-unsafe.rs:109:6 | LL | *u3.a = 1; | ^^^^ access to union field @@ -87,7 +87,7 @@ LL | *u3.a = 1; = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/union-unsafe.rs:108:6 + --> $DIR/union-unsafe.rs:113:6 | LL | *u3.a = String::from("new"); | ^^^^ access to union field @@ -95,7 +95,7 @@ LL | *u3.a = String::from("new"); = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/union-unsafe.rs:117:28 + --> $DIR/union-unsafe.rs:122:28 | LL | let _p = &raw const (**a.b).c; | ^^^ access to union field @@ -103,7 +103,7 @@ LL | let _p = &raw const (**a.b).c; = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/union-unsafe.rs:148:27 + --> $DIR/union-unsafe.rs:153:27 | LL | let _p = &raw const (*a.b).c; | ^^^ access to union field diff --git a/tests/ui/union/union-with-drop-fields.rs b/tests/ui/union/union-with-drop-fields.rs index ae147e9bd2b5d..949b478f2ecb4 100644 --- a/tests/ui/union/union-with-drop-fields.rs +++ b/tests/ui/union/union-with-drop-fields.rs @@ -1,3 +1,4 @@ +//@ reference: items.union.field-restrictions #![allow(dead_code)] union U { diff --git a/tests/ui/union/union-with-drop-fields.stderr b/tests/ui/union/union-with-drop-fields.stderr index 6328be565408e..290fcec201ca2 100644 --- a/tests/ui/union/union-with-drop-fields.stderr +++ b/tests/ui/union/union-with-drop-fields.stderr @@ -1,5 +1,5 @@ error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union - --> $DIR/union-with-drop-fields.rs:8:5 + --> $DIR/union-with-drop-fields.rs:9:5 | LL | a: String, | ^^^^^^^^^ @@ -11,7 +11,7 @@ LL | a: std::mem::ManuallyDrop, | +++++++++++++++++++++++ + error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union - --> $DIR/union-with-drop-fields.rs:16:5 + --> $DIR/union-with-drop-fields.rs:17:5 | LL | a: S, | ^^^^ @@ -23,7 +23,7 @@ LL | a: std::mem::ManuallyDrop, | +++++++++++++++++++++++ + error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union - --> $DIR/union-with-drop-fields.rs:21:5 + --> $DIR/union-with-drop-fields.rs:22:5 | LL | a: T, | ^^^^ diff --git a/tests/ui/union/union_destructure.rs b/tests/ui/union/union_destructure.rs index e7095926eb164..9c445c9986296 100644 --- a/tests/ui/union/union_destructure.rs +++ b/tests/ui/union/union_destructure.rs @@ -1,4 +1,5 @@ //@ run-pass +//@ reference: items.union.pattern.safety #![allow(unreachable_patterns)] #[derive(Copy, Clone)] From e6c3b3d18fe11506e1a8bd1a9722a50861e2df1c Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Wed, 12 Aug 2026 16:07:21 -0700 Subject: [PATCH 3/6] tests/ui/rust-2018: add annotations for reference rules --- tests/ui/rust-2018/async-ident-allowed.rs | 1 + tests/ui/rust-2018/async-ident-allowed.stderr | 4 +-- tests/ui/rust-2018/async-ident.fixed | 2 ++ tests/ui/rust-2018/async-ident.rs | 2 ++ tests/ui/rust-2018/async-ident.stderr | 28 +++++++++---------- tests/ui/rust-2018/dyn-keyword.fixed | 2 ++ tests/ui/rust-2018/dyn-keyword.rs | 2 ++ tests/ui/rust-2018/dyn-keyword.stderr | 4 +-- .../edition-lint-fully-qualified-paths.fixed | 1 + .../edition-lint-fully-qualified-paths.rs | 1 + .../edition-lint-fully-qualified-paths.stderr | 8 +++--- tests/ui/rust-2018/edition-lint-paths.fixed | 1 + tests/ui/rust-2018/edition-lint-paths.rs | 1 + tests/ui/rust-2018/edition-lint-paths.stderr | 20 ++++++------- tests/ui/rust-2018/try-ident.fixed | 2 ++ tests/ui/rust-2018/try-ident.rs | 2 ++ tests/ui/rust-2018/try-ident.stderr | 6 ++-- tests/ui/rust-2018/try-macro.fixed | 2 ++ tests/ui/rust-2018/try-macro.rs | 2 ++ tests/ui/rust-2018/try-macro.stderr | 4 +-- 20 files changed, 58 insertions(+), 37 deletions(-) diff --git a/tests/ui/rust-2018/async-ident-allowed.rs b/tests/ui/rust-2018/async-ident-allowed.rs index 342fafc67e20a..2c76dd7bf0fc1 100644 --- a/tests/ui/rust-2018/async-ident-allowed.rs +++ b/tests/ui/rust-2018/async-ident-allowed.rs @@ -1,4 +1,5 @@ //@ edition:2015 +//@ reference: lex.keywords.strict.edition2018 #![deny(rust_2018_compatibility)] diff --git a/tests/ui/rust-2018/async-ident-allowed.stderr b/tests/ui/rust-2018/async-ident-allowed.stderr index 1bdfc7bae1028..a83421a98c429 100644 --- a/tests/ui/rust-2018/async-ident-allowed.stderr +++ b/tests/ui/rust-2018/async-ident-allowed.stderr @@ -1,5 +1,5 @@ error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident-allowed.rs:9:9 + --> $DIR/async-ident-allowed.rs:10:9 | LL | let async = 3; | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -7,7 +7,7 @@ LL | let async = 3; = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see note: the lint level is defined here - --> $DIR/async-ident-allowed.rs:3:9 + --> $DIR/async-ident-allowed.rs:4:9 | LL | #![deny(rust_2018_compatibility)] | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rust-2018/async-ident.fixed b/tests/ui/rust-2018/async-ident.fixed index 639a8a245fb41..90600200f066e 100644 --- a/tests/ui/rust-2018/async-ident.fixed +++ b/tests/ui/rust-2018/async-ident.fixed @@ -3,6 +3,8 @@ //@ edition:2015 //@ run-rustfix +//@ reference: ident.raw.allowed +//@ reference: lex.keywords.strict.edition2018 fn r#async() {} //~ ERROR async //~^ WARN this is accepted in the current edition diff --git a/tests/ui/rust-2018/async-ident.rs b/tests/ui/rust-2018/async-ident.rs index 7921f05f48126..2c948b6fab812 100644 --- a/tests/ui/rust-2018/async-ident.rs +++ b/tests/ui/rust-2018/async-ident.rs @@ -3,6 +3,8 @@ //@ edition:2015 //@ run-rustfix +//@ reference: ident.raw.allowed +//@ reference: lex.keywords.strict.edition2018 fn async() {} //~ ERROR async //~^ WARN this is accepted in the current edition diff --git a/tests/ui/rust-2018/async-ident.stderr b/tests/ui/rust-2018/async-ident.stderr index 2c4cb7e1d96e1..c9a5e29ef95ea 100644 --- a/tests/ui/rust-2018/async-ident.stderr +++ b/tests/ui/rust-2018/async-ident.stderr @@ -1,5 +1,5 @@ error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:7:4 + --> $DIR/async-ident.rs:9:4 | LL | fn async() {} | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -14,7 +14,7 @@ LL | #![deny(keyword_idents)] = note: `#[deny(keyword_idents_2018)]` implied by `#[deny(keyword_idents)]` error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:12:19 + --> $DIR/async-ident.rs:14:19 | LL | ($async:expr, async) => {}; | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -23,7 +23,7 @@ LL | ($async:expr, async) => {}; = note: for more information, see error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:17:6 + --> $DIR/async-ident.rs:19:6 | LL | foo!(async); | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -32,7 +32,7 @@ LL | foo!(async); = note: for more information, see error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:26:11 + --> $DIR/async-ident.rs:28:11 | LL | trait async {} | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -41,7 +41,7 @@ LL | trait async {} = note: for more information, see error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:30:10 + --> $DIR/async-ident.rs:32:10 | LL | impl async for MyStruct {} | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -50,7 +50,7 @@ LL | impl async for MyStruct {} = note: for more information, see error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:36:12 + --> $DIR/async-ident.rs:38:12 | LL | static async: u32 = 0; | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -59,7 +59,7 @@ LL | static async: u32 = 0; = note: for more information, see error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:42:11 + --> $DIR/async-ident.rs:44:11 | LL | const async: u32 = 0; | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -68,7 +68,7 @@ LL | const async: u32 = 0; = note: for more information, see error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:48:15 + --> $DIR/async-ident.rs:50:15 | LL | impl Foo { fn async() {} } | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -77,7 +77,7 @@ LL | impl Foo { fn async() {} } = note: for more information, see error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:53:12 + --> $DIR/async-ident.rs:55:12 | LL | struct async {} | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -86,7 +86,7 @@ LL | struct async {} = note: for more information, see error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:56:9 + --> $DIR/async-ident.rs:58:9 | LL | let async: async = async {}; | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -95,7 +95,7 @@ LL | let async: async = async {}; = note: for more information, see error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:56:16 + --> $DIR/async-ident.rs:58:16 | LL | let async: async = async {}; | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -104,7 +104,7 @@ LL | let async: async = async {}; = note: for more information, see error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:56:24 + --> $DIR/async-ident.rs:58:24 | LL | let async: async = async {}; | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -113,7 +113,7 @@ LL | let async: async = async {}; = note: for more information, see error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:67:19 + --> $DIR/async-ident.rs:69:19 | LL | () => (pub fn async() {}) | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` @@ -122,7 +122,7 @@ LL | () => (pub fn async() {}) = note: for more information, see error: `async` is a keyword in the 2018 edition - --> $DIR/async-ident.rs:74:6 + --> $DIR/async-ident.rs:76:6 | LL | (async) => (1) | ^^^^^ help: you can use a raw identifier to stay compatible: `r#async` diff --git a/tests/ui/rust-2018/dyn-keyword.fixed b/tests/ui/rust-2018/dyn-keyword.fixed index e0233382e85ed..27421a52cbbc9 100644 --- a/tests/ui/rust-2018/dyn-keyword.fixed +++ b/tests/ui/rust-2018/dyn-keyword.fixed @@ -1,5 +1,7 @@ //@ edition:2015 //@ run-rustfix +//@ reference: ident.raw.allowed +//@ reference: lex.keywords.strict.edition2018 #![allow(unused_variables)] #![deny(keyword_idents)] diff --git a/tests/ui/rust-2018/dyn-keyword.rs b/tests/ui/rust-2018/dyn-keyword.rs index 876e83b5e89e6..69e419d4b7430 100644 --- a/tests/ui/rust-2018/dyn-keyword.rs +++ b/tests/ui/rust-2018/dyn-keyword.rs @@ -1,5 +1,7 @@ //@ edition:2015 //@ run-rustfix +//@ reference: ident.raw.allowed +//@ reference: lex.keywords.strict.edition2018 #![allow(unused_variables)] #![deny(keyword_idents)] diff --git a/tests/ui/rust-2018/dyn-keyword.stderr b/tests/ui/rust-2018/dyn-keyword.stderr index 733583f32b9b9..5e9f2e22ffd47 100644 --- a/tests/ui/rust-2018/dyn-keyword.stderr +++ b/tests/ui/rust-2018/dyn-keyword.stderr @@ -1,5 +1,5 @@ error: `dyn` is a keyword in the 2018 edition - --> $DIR/dyn-keyword.rs:8:9 + --> $DIR/dyn-keyword.rs:10:9 | LL | let dyn = (); | ^^^ help: you can use a raw identifier to stay compatible: `r#dyn` @@ -7,7 +7,7 @@ LL | let dyn = (); = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see note: the lint level is defined here - --> $DIR/dyn-keyword.rs:5:9 + --> $DIR/dyn-keyword.rs:7:9 | LL | #![deny(keyword_idents)] | ^^^^^^^^^^^^^^ diff --git a/tests/ui/rust-2018/edition-lint-fully-qualified-paths.fixed b/tests/ui/rust-2018/edition-lint-fully-qualified-paths.fixed index d685c4944baf1..d0a18b911da09 100644 --- a/tests/ui/rust-2018/edition-lint-fully-qualified-paths.fixed +++ b/tests/ui/rust-2018/edition-lint-fully-qualified-paths.fixed @@ -1,5 +1,6 @@ //@ edition: 2015 //@ run-rustfix +//@ reference: paths.qualifiers.global-root.edition2018 #![deny(absolute_paths_not_starting_with_crate)] diff --git a/tests/ui/rust-2018/edition-lint-fully-qualified-paths.rs b/tests/ui/rust-2018/edition-lint-fully-qualified-paths.rs index 7a5ecf2720a5b..0271a30197ed2 100644 --- a/tests/ui/rust-2018/edition-lint-fully-qualified-paths.rs +++ b/tests/ui/rust-2018/edition-lint-fully-qualified-paths.rs @@ -1,5 +1,6 @@ //@ edition: 2015 //@ run-rustfix +//@ reference: paths.qualifiers.global-root.edition2018 #![deny(absolute_paths_not_starting_with_crate)] diff --git a/tests/ui/rust-2018/edition-lint-fully-qualified-paths.stderr b/tests/ui/rust-2018/edition-lint-fully-qualified-paths.stderr index b59604f6427e3..218a6fa58b46d 100644 --- a/tests/ui/rust-2018/edition-lint-fully-qualified-paths.stderr +++ b/tests/ui/rust-2018/edition-lint-fully-qualified-paths.stderr @@ -1,5 +1,5 @@ error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-fully-qualified-paths.rs:19:25 + --> $DIR/edition-lint-fully-qualified-paths.rs:20:25 | LL | let _: ::Bar = (); | ^^^^^^^^^^ help: use `crate`: `crate::foo::Foo` @@ -7,13 +7,13 @@ LL | let _: ::Bar = (); = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see note: the lint level is defined here - --> $DIR/edition-lint-fully-qualified-paths.rs:4:9 + --> $DIR/edition-lint-fully-qualified-paths.rs:5:9 | LL | #![deny(absolute_paths_not_starting_with_crate)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-fully-qualified-paths.rs:19:25 + --> $DIR/edition-lint-fully-qualified-paths.rs:20:25 | LL | let _: ::Bar = (); | ^^^^^^^^^^ help: use `crate`: `crate::foo::Foo` @@ -23,7 +23,7 @@ LL | let _: ::Bar = (); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-fully-qualified-paths.rs:25:13 + --> $DIR/edition-lint-fully-qualified-paths.rs:26:13 | LL | let _: <::foo::Baz as foo::Foo>::Bar = (); | ^^^^^^^^^^ help: use `crate`: `crate::foo::Baz` diff --git a/tests/ui/rust-2018/edition-lint-paths.fixed b/tests/ui/rust-2018/edition-lint-paths.fixed index 9664b461161ad..2a690a9635564 100644 --- a/tests/ui/rust-2018/edition-lint-paths.fixed +++ b/tests/ui/rust-2018/edition-lint-paths.fixed @@ -1,6 +1,7 @@ //@ edition: 2015 //@ aux-build:edition-lint-paths.rs //@ run-rustfix +//@ reference: paths.qualifiers.global-root.edition2018 #![deny(absolute_paths_not_starting_with_crate)] #![allow(unused)] diff --git a/tests/ui/rust-2018/edition-lint-paths.rs b/tests/ui/rust-2018/edition-lint-paths.rs index 39cdad3ab98b2..4ae636d9b4de5 100644 --- a/tests/ui/rust-2018/edition-lint-paths.rs +++ b/tests/ui/rust-2018/edition-lint-paths.rs @@ -1,6 +1,7 @@ //@ edition: 2015 //@ aux-build:edition-lint-paths.rs //@ run-rustfix +//@ reference: paths.qualifiers.global-root.edition2018 #![deny(absolute_paths_not_starting_with_crate)] #![allow(unused)] diff --git a/tests/ui/rust-2018/edition-lint-paths.stderr b/tests/ui/rust-2018/edition-lint-paths.stderr index 26db6e402a9e2..d4313ae484f7f 100644 --- a/tests/ui/rust-2018/edition-lint-paths.stderr +++ b/tests/ui/rust-2018/edition-lint-paths.stderr @@ -1,5 +1,5 @@ error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:12:9 + --> $DIR/edition-lint-paths.rs:13:9 | LL | use bar::Bar; | ^^^^^^^^ help: use `crate`: `crate::bar::Bar` @@ -7,13 +7,13 @@ LL | use bar::Bar; = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see note: the lint level is defined here - --> $DIR/edition-lint-paths.rs:5:9 + --> $DIR/edition-lint-paths.rs:6:9 | LL | #![deny(absolute_paths_not_starting_with_crate)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:19:9 + --> $DIR/edition-lint-paths.rs:20:9 | LL | use bar; | ^^^ help: use `crate`: `crate::bar` @@ -22,7 +22,7 @@ LL | use bar; = note: for more information, see error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:25:9 + --> $DIR/edition-lint-paths.rs:26:9 | LL | use {main, Bar as SomethingElse}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}` @@ -31,7 +31,7 @@ LL | use {main, Bar as SomethingElse}; = note: for more information, see error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:25:9 + --> $DIR/edition-lint-paths.rs:26:9 | LL | use {main, Bar as SomethingElse}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}` @@ -41,7 +41,7 @@ LL | use {main, Bar as SomethingElse}; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:25:9 + --> $DIR/edition-lint-paths.rs:26:9 | LL | use {main, Bar as SomethingElse}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}` @@ -51,7 +51,7 @@ LL | use {main, Bar as SomethingElse}; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:40:5 + --> $DIR/edition-lint-paths.rs:41:5 | LL | use bar::Bar; | ^^^^^^^^ help: use `crate`: `crate::bar::Bar` @@ -60,7 +60,7 @@ LL | use bar::Bar; = note: for more information, see error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:52:9 + --> $DIR/edition-lint-paths.rs:53:9 | LL | use *; | ^ help: use `crate`: `crate::*` @@ -69,7 +69,7 @@ LL | use *; = note: for more information, see error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:57:6 + --> $DIR/edition-lint-paths.rs:58:6 | LL | impl ::foo::SomeTrait for u32 {} | ^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::SomeTrait` @@ -78,7 +78,7 @@ LL | impl ::foo::SomeTrait for u32 {} = note: for more information, see error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:62:13 + --> $DIR/edition-lint-paths.rs:63:13 | LL | let x = ::bar::Bar; | ^^^^^^^^^^ help: use `crate`: `crate::bar::Bar` diff --git a/tests/ui/rust-2018/try-ident.fixed b/tests/ui/rust-2018/try-ident.fixed index b514c6d075654..47b4f3325ad94 100644 --- a/tests/ui/rust-2018/try-ident.fixed +++ b/tests/ui/rust-2018/try-ident.fixed @@ -1,6 +1,8 @@ //@ edition: 2015 //@ run-rustfix //@ check-pass +//@ reference: ident.raw.allowed +//@ reference: lex.keywords.reserved.edition2018 #![warn(rust_2018_compatibility)] diff --git a/tests/ui/rust-2018/try-ident.rs b/tests/ui/rust-2018/try-ident.rs index 2b8bb9234e559..01f23b9b3c0ac 100644 --- a/tests/ui/rust-2018/try-ident.rs +++ b/tests/ui/rust-2018/try-ident.rs @@ -1,6 +1,8 @@ //@ edition: 2015 //@ run-rustfix //@ check-pass +//@ reference: ident.raw.allowed +//@ reference: lex.keywords.reserved.edition2018 #![warn(rust_2018_compatibility)] diff --git a/tests/ui/rust-2018/try-ident.stderr b/tests/ui/rust-2018/try-ident.stderr index 3af2196ce35bf..0bc9dd438b1fb 100644 --- a/tests/ui/rust-2018/try-ident.stderr +++ b/tests/ui/rust-2018/try-ident.stderr @@ -1,5 +1,5 @@ warning: `try` is a keyword in the 2018 edition - --> $DIR/try-ident.rs:8:5 + --> $DIR/try-ident.rs:10:5 | LL | try(); | ^^^ help: you can use a raw identifier to stay compatible: `r#try` @@ -7,14 +7,14 @@ LL | try(); = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see note: the lint level is defined here - --> $DIR/try-ident.rs:5:9 + --> $DIR/try-ident.rs:7:9 | LL | #![warn(rust_2018_compatibility)] | ^^^^^^^^^^^^^^^^^^^^^^^ = note: `#[warn(keyword_idents_2018)]` implied by `#[warn(rust_2018_compatibility)]` warning: `try` is a keyword in the 2018 edition - --> $DIR/try-ident.rs:13:4 + --> $DIR/try-ident.rs:15:4 | LL | fn try() { | ^^^ help: you can use a raw identifier to stay compatible: `r#try` diff --git a/tests/ui/rust-2018/try-macro.fixed b/tests/ui/rust-2018/try-macro.fixed index f2d8cf2bd9a5f..0ba6e7dcd877c 100644 --- a/tests/ui/rust-2018/try-macro.fixed +++ b/tests/ui/rust-2018/try-macro.fixed @@ -3,6 +3,8 @@ //@ edition: 2015 //@ run-rustfix //@ check-pass +//@ reference: ident.raw.allowed +//@ reference: lex.keywords.reserved.edition2018 #![warn(rust_2018_compatibility)] #![allow(dead_code)] diff --git a/tests/ui/rust-2018/try-macro.rs b/tests/ui/rust-2018/try-macro.rs index fec8eaa1786b3..705e3cdde7fae 100644 --- a/tests/ui/rust-2018/try-macro.rs +++ b/tests/ui/rust-2018/try-macro.rs @@ -3,6 +3,8 @@ //@ edition: 2015 //@ run-rustfix //@ check-pass +//@ reference: ident.raw.allowed +//@ reference: lex.keywords.reserved.edition2018 #![warn(rust_2018_compatibility)] #![allow(dead_code)] diff --git a/tests/ui/rust-2018/try-macro.stderr b/tests/ui/rust-2018/try-macro.stderr index 89366381c8c6e..c2e2b5b7438f6 100644 --- a/tests/ui/rust-2018/try-macro.stderr +++ b/tests/ui/rust-2018/try-macro.stderr @@ -1,5 +1,5 @@ warning: `try` is a keyword in the 2018 edition - --> $DIR/try-macro.rs:13:5 + --> $DIR/try-macro.rs:15:5 | LL | try!(x); | ^^^ help: you can use a raw identifier to stay compatible: `r#try` @@ -7,7 +7,7 @@ LL | try!(x); = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see note: the lint level is defined here - --> $DIR/try-macro.rs:7:9 + --> $DIR/try-macro.rs:9:9 | LL | #![warn(rust_2018_compatibility)] | ^^^^^^^^^^^^^^^^^^^^^^^ From 0594f7c86a9dfebc5501eb1a72ba5e459206f6a1 Mon Sep 17 00:00:00 2001 From: HNO3Miracle Date: Wed, 5 Aug 2026 18:09:51 +0800 Subject: [PATCH 4/6] cargotest: replace Servo with Stylo Signed-off-by: HNO3Miracle --- src/doc/rustc-dev-guide/src/tests/ecosystem.md | 2 +- src/tools/cargotest/main.rs | 14 ++++---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/tests/ecosystem.md b/src/doc/rustc-dev-guide/src/tests/ecosystem.md index eee07dd079bbf..9e5b3a1e1c11d 100644 --- a/src/doc/rustc-dev-guide/src/tests/ecosystem.md +++ b/src/doc/rustc-dev-guide/src/tests/ecosystem.md @@ -14,7 +14,7 @@ CI. See the [Crater chapter](crater.md) for more details. ### `cargotest` `cargotest` is a small tool which runs `cargo test` on a few sample projects -(such as `servo`, `ripgrep`, `tokei`, etc.). This runs as part of CI and ensures +(such as `stylo`, `ripgrep`, `tokei`, etc.). This runs as part of CI and ensures there aren't any significant regressions: ```console diff --git a/src/tools/cargotest/main.rs b/src/tools/cargotest/main.rs index e920d49eb2e44..82531f328da66 100644 --- a/src/tools/cargotest/main.rs +++ b/src/tools/cargotest/main.rs @@ -70,13 +70,11 @@ const TEST_REPOS: &[Test] = &[ ], }, Test { - name: "servo", - repo: "https://github.com/servo/servo", - sha: "785a344e32db58d4e631fd3cae17fd1f29a721ab", + name: "stylo", + repo: "https://github.com/servo/stylo", + sha: "127b0b5cab6a6927552e889debb20beb031b79d1", lock: None, - // Only test Stylo a.k.a. Quantum CSS, the parts of Servo going into Firefox. - // This takes much less time to build than all of Servo and supports stable Rust. - packages: &["selectors"], + packages: &["selectors", "stylo"], features: None, manifest_path: None, filters: &[], @@ -213,10 +211,6 @@ fn run_cargo_test( .env("CFG_DISABLE_CROSS_TESTS", "1") // Relax #![deny(warnings)] in some crates .env("RUSTFLAGS", "--cap-lints warn") - // servo tries to use 'lld-link.exe' on windows, but we don't - // have lld on our PATH in CI. Override it to use 'link.exe' - .env("CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER", "link.exe") - .env("CARGO_TARGET_I686_PC_WINDOWS_MSVC_LINKER", "link.exe") .current_dir(crate_path) .status() .unwrap(); From c7b97738dbc390a861b43ad81ef73b0bfa46a1da Mon Sep 17 00:00:00 2001 From: zakrad <49591476+zakrad@users.noreply.github.com> Date: Fri, 14 Aug 2026 10:42:05 +0330 Subject: [PATCH 5/6] Revert "Add regression test for const fn returning Vec of boxed dyn Any" This reverts commit 78f7e7925269387ac40ac27ffda9300d3036fb59. --- tests/ui/consts/const-fn-vec-box-dyn-any-84170.rs | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 tests/ui/consts/const-fn-vec-box-dyn-any-84170.rs diff --git a/tests/ui/consts/const-fn-vec-box-dyn-any-84170.rs b/tests/ui/consts/const-fn-vec-box-dyn-any-84170.rs deleted file mode 100644 index 64de852f46d6f..0000000000000 --- a/tests/ui/consts/const-fn-vec-box-dyn-any-84170.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Regression test for #84170: a `const fn` returning `Vec>` was rejected -// with E0723 "trait bounds other than `Sized` on const fn parameters are unstable" even -// though no trait object value is created. -//@ check-pass - -#![allow(dead_code)] - -const fn newv() -> Vec> { - Vec::new() -} - -const fn new(_val: &Vec>) {} - -fn main() {} From 990c0689cb68ec95ae229afbe884874894354f35 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 14 Aug 2026 14:41:07 -0700 Subject: [PATCH 6/6] rustc.1: `-O` is `-C opt-level=3` --- src/doc/man/rustc.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/man/rustc.1 b/src/doc/man/rustc.1 index 2a91774d671ac..2731a7257cdd2 100644 --- a/src/doc/man/rustc.1 +++ b/src/doc/man/rustc.1 @@ -62,7 +62,7 @@ Comma separated list of compiler information to print on stdout. Equivalent to \fI\-C\ debuginfo=2\fR. .TP \fB\-O\fR -Equivalent to \fI\-C\ opt\-level=2\fR. +Equivalent to \fI\-C\ opt\-level=3\fR. .TP \fB\-o\fR \fIFILENAME\fR Write output to \fIFILENAME\fR. Ignored if multiple \fI\-\-emit\fR outputs are specified which