diff options
Diffstat (limited to 'tests')
999 files changed, 8887 insertions, 4020 deletions
diff --git a/tests/assembly/x86-stack-probes.rs b/tests/assembly/stack-probes.rs index 64a4efc0e18..6466df3ff7d 100644 --- a/tests/assembly/x86-stack-probes.rs +++ b/tests/assembly/stack-probes.rs @@ -1,10 +1,12 @@ -// revisions: x86_64 i686 +// revisions: x86_64 i686 aarch64 // assembly-output: emit-asm -//[x86_64] compile-flags: --target x86_64-unknown-linux-gnu +//[x86_64] compile-flags: --target x86_64-unknown-linux-gnu -C llvm-args=-x86-asm-syntax=intel //[x86_64] needs-llvm-components: x86 -//[i686] compile-flags: --target i686-unknown-linux-gnu +//[i686] compile-flags: --target i686-unknown-linux-gnu -C llvm-args=-x86-asm-syntax=intel //[i686] needs-llvm-components: x86 -// compile-flags: -C llvm-args=-x86-asm-syntax=intel +//[aarch64] compile-flags: --target aarch64-unknown-linux-gnu +//[aarch64] needs-llvm-components: aarch64 +//[aarch64] min-llvm-version: 18 #![feature(no_core, lang_items)] #![crate_type = "lib"] @@ -28,6 +30,7 @@ pub fn small_stack_probe(x: u8, f: fn(&mut [u8; 8192])) { // CHECK-NOT: __rust_probestack // x86_64: sub rsp, 4096 // i686: sub esp, 4096 + // aarch64: sub sp, sp, #1, lsl #12 f(&mut [x; 8192]); } @@ -37,5 +40,6 @@ pub fn big_stack_probe(x: u8, f: fn(&[u8; 65536])) { // CHECK-NOT: __rust_probestack // x86_64: sub rsp, 4096 // i686: sub esp, 4096 + // aarch64: sub sp, sp, #1, lsl #12 f(&mut [x; 65536]); } diff --git a/tests/codegen/debug-accessibility/crate-enum.rs b/tests/codegen/debug-accessibility/crate-enum.rs new file mode 100644 index 00000000000..eeea18dd815 --- /dev/null +++ b/tests/codegen/debug-accessibility/crate-enum.rs @@ -0,0 +1,26 @@ +// compile-flags: -C debuginfo=2 +// ignore-tidy-linelength + +#![allow(dead_code)] + +// Checks that visibility information is present in the debuginfo for crate-visibility enums. + +mod module { + use std::hint::black_box; + + pub(crate) enum CrateFooEnum { + A, + B(u32), + C { x: u32 }, + } + + // NONMSVC: {{!.*}} = !DICompositeType(tag: DW_TAG_structure_type, name: "CrateFooEnum"{{.*}}flags: DIFlagProtected{{.*}}) + // MSVC: {{!.*}} = !DICompositeType(tag: DW_TAG_union_type, name: "enum2$<crate_enum::module::CrateFooEnum>"{{.*}}flags: DIFlagProtected{{.*}}) + pub fn use_everything() { + black_box(CrateFooEnum::A); + } +} + +fn main() { + module::use_everything(); +} diff --git a/tests/codegen/debug-accessibility/crate-struct.rs b/tests/codegen/debug-accessibility/crate-struct.rs new file mode 100644 index 00000000000..68d126a3478 --- /dev/null +++ b/tests/codegen/debug-accessibility/crate-struct.rs @@ -0,0 +1,23 @@ +// compile-flags: -C debuginfo=2 + +#![allow(dead_code)] + +// Checks that visibility information is present in the debuginfo for crate-visibility structs. + +mod module { + use std::hint::black_box; + + pub(crate) struct CrateFooStruct { + x: u32, + } + + // CHECK: {{!.*}} = !DICompositeType(tag: DW_TAG_structure_type, name: "CrateFooStruct"{{.*}}flags: DIFlagProtected{{.*}}) + + pub fn use_everything() { + black_box(CrateFooStruct { x: 2 }); + } +} + +fn main() { + module::use_everything(); +} diff --git a/tests/codegen/debug-accessibility/private-enum.rs b/tests/codegen/debug-accessibility/private-enum.rs new file mode 100644 index 00000000000..7f81026ddec --- /dev/null +++ b/tests/codegen/debug-accessibility/private-enum.rs @@ -0,0 +1,21 @@ +// compile-flags: -C debuginfo=2 +// ignore-tidy-linelength + +#![allow(dead_code)] + +// Checks that visibility information is present in the debuginfo for private enums. + +use std::hint::black_box; + +enum PrivateFooEnum { + A, + B(u32), + C { x: u32 }, +} + +// NONMSVC: {{!.*}} = !DICompositeType(tag: DW_TAG_structure_type, name: "PrivateFooEnum"{{.*}}flags: DIFlagPrivate{{.*}}) +// MSVC: {{!.*}} = !DICompositeType(tag: DW_TAG_union_type, name: "enum2$<private_enum::PrivateFooEnum>"{{.*}}flags: DIFlagPrivate{{.*}}) + +fn main() { + black_box(PrivateFooEnum::A); +} diff --git a/tests/codegen/debug-accessibility/private-struct.rs b/tests/codegen/debug-accessibility/private-struct.rs new file mode 100644 index 00000000000..43b260f9024 --- /dev/null +++ b/tests/codegen/debug-accessibility/private-struct.rs @@ -0,0 +1,17 @@ +// compile-flags: -C debuginfo=2 + +#![allow(dead_code)] + +// Checks that visibility information is present in the debuginfo for private structs. + +use std::hint::black_box; + +struct PrivateFooStruct { + x: u32, +} + +// CHECK: {{!.*}} = !DICompositeType(tag: DW_TAG_structure_type, name: "PrivateFooStruct"{{.*}}flags: DIFlagPrivate{{.*}}) + +fn main() { + black_box(PrivateFooStruct { x: 1 }); +} diff --git a/tests/codegen/debug-accessibility/public-enum.rs b/tests/codegen/debug-accessibility/public-enum.rs new file mode 100644 index 00000000000..29ae5fd6421 --- /dev/null +++ b/tests/codegen/debug-accessibility/public-enum.rs @@ -0,0 +1,21 @@ +// compile-flags: -C debuginfo=2 +// ignore-tidy-linelength + +#![allow(dead_code)] + +// Checks that visibility information is present in the debuginfo for types and their fields. + +use std::hint::black_box; + +pub enum PublicFooEnum { + A, + B(u32), + C { x: u32 }, +} + +// NONMSVC: {{!.*}} = !DICompositeType(tag: DW_TAG_structure_type, name: "PublicFooEnum"{{.*}}flags: DIFlagPublic{{.*}}) +// MSVC: {{!.*}} = !DICompositeType(tag: DW_TAG_union_type, name: "enum2$<public_enum::PublicFooEnum>"{{.*}}flags: DIFlagPublic{{.*}}) + +fn main() { + black_box(PublicFooEnum::A); +} diff --git a/tests/codegen/debug-accessibility/public-struct.rs b/tests/codegen/debug-accessibility/public-struct.rs new file mode 100644 index 00000000000..e7cd9b40d09 --- /dev/null +++ b/tests/codegen/debug-accessibility/public-struct.rs @@ -0,0 +1,17 @@ +// compile-flags: -C debuginfo=2 + +#![allow(dead_code)] + +// Checks that visibility information is present in the debuginfo for public structs. + +use std::hint::black_box; + +pub struct PublicFooStruct { + x: u32, +} + +// CHECK: {{!.*}} = !DICompositeType(tag: DW_TAG_structure_type, name: "PublicFooStruct"{{.*}}flags: DIFlagPublic{{.*}}) + +fn main() { + black_box(PublicFooStruct { x: 4 }); +} diff --git a/tests/codegen/debug-accessibility/struct-fields.rs b/tests/codegen/debug-accessibility/struct-fields.rs new file mode 100644 index 00000000000..76831bdc6c6 --- /dev/null +++ b/tests/codegen/debug-accessibility/struct-fields.rs @@ -0,0 +1,30 @@ +// compile-flags: -C debuginfo=2 + +#![allow(dead_code)] + +// Checks that visibility information is present in the debuginfo for struct fields. + +mod module { + use std::hint::black_box; + + struct StructFields { + a: u32, + pub(crate) b: u32, + pub(super) c: u32, + pub d: u32, + } + + // CHECK: [[StructFields:!.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "StructFields"{{.*}}flags: DIFlagPrivate{{.*}}) + // CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: [[StructFields]]{{.*}}flags: DIFlagPrivate{{.*}}) + // CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: [[StructFields]]{{.*}}flags: DIFlagProtected{{.*}}) + // CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: [[StructFields]]{{.*}}flags: DIFlagProtected{{.*}}) + // CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "d", scope: [[StructFields]]{{.*}}flags: DIFlagPublic{{.*}}) + + pub fn use_everything() { + black_box(StructFields { a: 1, b: 2, c: 3, d: 4 }); + } +} + +fn main() { + module::use_everything(); +} diff --git a/tests/codegen/debug-accessibility/super-enum.rs b/tests/codegen/debug-accessibility/super-enum.rs new file mode 100644 index 00000000000..9d83fb45bd0 --- /dev/null +++ b/tests/codegen/debug-accessibility/super-enum.rs @@ -0,0 +1,27 @@ +// compile-flags: -C debuginfo=2 +// ignore-tidy-linelength + +#![allow(dead_code)] + +// Checks that visibility information is present in the debuginfo for super-visibility enums. + +mod module { + use std::hint::black_box; + + pub(super) enum SuperFooEnum { + A, + B(u32), + C { x: u32 }, + } + + // NONMSVC: {{!.*}} = !DICompositeType(tag: DW_TAG_structure_type, name: "SuperFooEnum"{{.*}}flags: DIFlagProtected{{.*}}) + // MSVC: {{!.*}} = !DICompositeType(tag: DW_TAG_union_type, name: "enum2$<super_enum::module::SuperFooEnum>"{{.*}}flags: DIFlagProtected{{.*}}) + + pub fn use_everything() { + black_box(SuperFooEnum::A); + } +} + +fn main() { + module::use_everything(); +} diff --git a/tests/codegen/debug-accessibility/super-struct.rs b/tests/codegen/debug-accessibility/super-struct.rs new file mode 100644 index 00000000000..481006c3965 --- /dev/null +++ b/tests/codegen/debug-accessibility/super-struct.rs @@ -0,0 +1,23 @@ +// compile-flags: -C debuginfo=2 + +#![allow(dead_code)] + +// Checks that visibility information is present in the debuginfo for super-visibility structs. + +mod module { + use std::hint::black_box; + + pub(super) struct SuperFooStruct { + x: u32, + } + + // CHECK: {{!.*}} = !DICompositeType(tag: DW_TAG_structure_type, name: "SuperFooStruct"{{.*}}flags: DIFlagProtected{{.*}}) + + pub fn use_everything() { + black_box(SuperFooStruct { x: 3 }); + } +} + +fn main() { + module::use_everything(); +} diff --git a/tests/codegen/debug-accessibility/tuple-fields.rs b/tests/codegen/debug-accessibility/tuple-fields.rs new file mode 100644 index 00000000000..1163ba2c7c3 --- /dev/null +++ b/tests/codegen/debug-accessibility/tuple-fields.rs @@ -0,0 +1,24 @@ +// compile-flags: -C debuginfo=2 + +#![allow(dead_code)] + +// Checks that visibility information is present in the debuginfo for tuple struct fields. + +mod module { + use std::hint::black_box; + + struct TupleFields(u32, pub(crate) u32, pub(super) u32, pub u32); + + // CHECK: [[TupleFields:!.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "TupleFields"{{.*}}flags: DIFlagPrivate{{.*}}) + // CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "__0", scope: [[TupleFields]]{{.*}}flags: DIFlagPrivate{{.*}}) + // CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "__1", scope: [[TupleFields]]{{.*}}flags: DIFlagProtected{{.*}}) + // CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "__2", scope: [[TupleFields]]{{.*}}flags: DIFlagProtected{{.*}}) + // CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "__3", scope: [[TupleFields]]{{.*}}flags: DIFlagPublic{{.*}}) + pub fn use_everything() { + black_box(TupleFields(1, 2, 3, 4)); + } +} + +fn main() { + module::use_everything(); +} diff --git a/tests/codegen/default-hidden-visibility.rs b/tests/codegen/default-hidden-visibility.rs new file mode 100644 index 00000000000..9e5e545f0d9 --- /dev/null +++ b/tests/codegen/default-hidden-visibility.rs @@ -0,0 +1,31 @@ +// Verifies that `Session::default_hidden_visibility` is affected when using the related cmdline +// flag. This is a regression test for https://github.com/rust-lang/compiler-team/issues/656. See +// also https://github.com/rust-lang/rust/issues/73295 and +// https://github.com/rust-lang/rust/issues/37530. + +// revisions:DEFAULT YES NO +//[YES] compile-flags: -Zdefault-hidden-visibility=yes +//[NO] compile-flags: -Zdefault-hidden-visibility=no + +// The test scenario is specifically about visibility of symbols exported out of dynamically linked +// libraries. +#![crate_type = "dylib"] + +// The test scenario needs to use a Rust-public, but non-explicitly-exported symbol +// (e.g. the test doesn't use `#[no_mangle]`, because currently it implies that +// the symbol should be exported; we don't want that - we want to test the *default* +// export setting instead). +#[used] +pub static tested_symbol: [u8; 6] = *b"foobar"; + +// Exact LLVM IR differs depending on the target triple (e.g. `hidden constant` +// vs `internal constant` vs `constant`). Because of this, we only apply the +// specific test expectations below to one specific target triple. If needed, +// additional targets can be covered by adding copies of this test file with +// a different `only-X` directive. +// +// only-x86_64-unknown-linux-gnu + +// DEFAULT: @{{.*}}default_hidden_visibility{{.*}}tested_symbol{{.*}} = constant +// YES: @{{.*}}default_hidden_visibility{{.*}}tested_symbol{{.*}} = hidden constant +// NO: @{{.*}}default_hidden_visibility{{.*}}tested_symbol{{.*}} = constant diff --git a/tests/codegen/inherit_overflow.rs b/tests/codegen/inherit_overflow.rs index 39909d7abfd..fa9ee0ae12a 100644 --- a/tests/codegen/inherit_overflow.rs +++ b/tests/codegen/inherit_overflow.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmir-enable-passes=+Inline,+ConstProp --crate-type lib +// compile-flags: -Zmir-enable-passes=+Inline,+GVN --crate-type lib // revisions: ASSERT NOASSERT //[ASSERT] compile-flags: -Coverflow-checks=on //[NOASSERT] compile-flags: -Coverflow-checks=off diff --git a/tests/codegen/issues/issue-86106.rs b/tests/codegen/issues/issue-86106.rs index 15aef344ac0..5f71d46fb20 100644 --- a/tests/codegen/issues/issue-86106.rs +++ b/tests/codegen/issues/issue-86106.rs @@ -9,9 +9,12 @@ // CHECK-LABEL: define {{(dso_local )?}}void @string_new #[no_mangle] pub fn string_new() -> String { - // CHECK: store ptr inttoptr + // CHECK-NOT: load i8 + // CHECK: store i{{32|64}} // CHECK-NEXT: getelementptr - // CHECK-NEXT: call void @llvm.memset + // CHECK-NEXT: store ptr + // CHECK-NEXT: getelementptr + // CHECK-NEXT: store i{{32|64}} // CHECK-NEXT: ret void String::new() } @@ -19,9 +22,12 @@ pub fn string_new() -> String { // CHECK-LABEL: define {{(dso_local )?}}void @empty_to_string #[no_mangle] pub fn empty_to_string() -> String { - // CHECK: store ptr inttoptr + // CHECK-NOT: load i8 + // CHECK: store i{{32|64}} + // CHECK-NEXT: getelementptr + // CHECK-NEXT: store ptr // CHECK-NEXT: getelementptr - // CHECK-NEXT: call void @llvm.memset + // CHECK-NEXT: store i{{32|64}} // CHECK-NEXT: ret void "".to_string() } @@ -32,9 +38,12 @@ pub fn empty_to_string() -> String { // CHECK-LABEL: @empty_vec #[no_mangle] pub fn empty_vec() -> Vec<u8> { - // CHECK: store ptr inttoptr + // CHECK: store i{{32|64}} + // CHECK-NOT: load i8 // CHECK-NEXT: getelementptr - // CHECK-NEXT: call void @llvm.memset + // CHECK-NEXT: store ptr + // CHECK-NEXT: getelementptr + // CHECK-NEXT: store i{{32|64}} // CHECK-NEXT: ret void vec![] } @@ -42,9 +51,12 @@ pub fn empty_vec() -> Vec<u8> { // CHECK-LABEL: @empty_vec_clone #[no_mangle] pub fn empty_vec_clone() -> Vec<u8> { - // CHECK: store ptr inttoptr + // CHECK: store i{{32|64}} + // CHECK-NOT: load i8 + // CHECK-NEXT: getelementptr + // CHECK-NEXT: store ptr // CHECK-NEXT: getelementptr - // CHECK-NEXT: call void @llvm.memset + // CHECK-NEXT: store i{{32|64}} // CHECK-NEXT: ret void vec![].clone() } diff --git a/tests/codegen/overaligned-constant.rs b/tests/codegen/overaligned-constant.rs new file mode 100644 index 00000000000..89e49738991 --- /dev/null +++ b/tests/codegen/overaligned-constant.rs @@ -0,0 +1,36 @@ +// GVN may create indirect constants with higher alignment than their type requires. Verify that we +// do not ICE during codegen, and that the LLVM constant has the higher alignment. +// +// compile-flags: -Zmir-opt-level=0 -Zmir-enable-passes=+GVN +// compile-flags: -Cno-prepopulate-passes +// only-64bit + +struct S(i32); + +struct SmallStruct(f32, Option<S>, &'static [f32]); + +// CHECK: @0 = private unnamed_addr constant +// CHECK-SAME: , align 8 + +fn main() { + // CHECK-LABEL: @_ZN20overaligned_constant4main + // CHECK: [[full:%_.*]] = alloca %SmallStruct, align 8 + // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[full]], ptr align 8 @0, i64 32, i1 false) + // CHECK: %b.0 = load i32, ptr @0, align 4, + // CHECK: %b.1 = load i32, ptr getelementptr inbounds ({{.*}}), align 4 + let mut s = S(1); + + s.0 = 3; + + // SMALL_VAL corresponds to a MIR allocation with alignment 8. + const SMALL_VAL: SmallStruct = SmallStruct(4., Some(S(1)), &[]); + + // In pre-codegen MIR: + // `a` is a scalar 4. + // `b` is an indirect constant at `SMALL_VAL`'s alloc with 0 offset. + // `c` is the empty slice. + // + // As a consequence, during codegen, we create a LLVM allocation for `SMALL_VAL`, with + // alignment 8, but only use the `Option<S>` field, at offset 0 with alignment 4. + let SmallStruct(a, b, c) = SMALL_VAL; +} diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-masked-load.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-masked-load.rs index 7b1fb320894..e573b7d21bd 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-masked-load.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-masked-load.rs @@ -21,7 +21,7 @@ extern "platform-intrinsic" { #[no_mangle] pub unsafe fn load_f32x2(mask: Vec2<i32>, pointer: *const f32, values: Vec2<f32>) -> Vec2<f32> { - // CHECK: call <2 x float> @llvm.masked.load.v2f32.p0(ptr {{.*}}, i32 {{.*}}, <2 x i1> {{.*}}, <2 x float> {{.*}}) + // CHECK: call <2 x float> @llvm.masked.load.v2f32.p0(ptr {{.*}}, i32 4, <2 x i1> {{.*}}, <2 x float> {{.*}}) simd_masked_load(mask, pointer, values) } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-masked-store.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-masked-store.rs index d8a37020f23..91656622216 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-masked-store.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-masked-store.rs @@ -20,7 +20,7 @@ extern "platform-intrinsic" { // CHECK-LABEL: @store_f32x2 #[no_mangle] pub unsafe fn store_f32x2(mask: Vec2<i32>, pointer: *mut f32, values: Vec2<f32>) { - // CHECK: call void @llvm.masked.store.v2f32.p0(<2 x float> {{.*}}, ptr {{.*}}, i32 {{.*}}, <2 x i1> {{.*}}) + // CHECK: call void @llvm.masked.store.v2f32.p0(<2 x float> {{.*}}, ptr {{.*}}, i32 4, <2 x i1> {{.*}}) simd_masked_store(mask, pointer, values) } diff --git a/tests/codegen/stack-probes-inline.rs b/tests/codegen/stack-probes-inline.rs index 058c363969f..34027e91850 100644 --- a/tests/codegen/stack-probes-inline.rs +++ b/tests/codegen/stack-probes-inline.rs @@ -2,7 +2,9 @@ // or `StackProbeType::InlineOrCall` when running on newer LLVM. // compile-flags: -C no-prepopulate-passes -// revisions: powerpc powerpc64 powerpc64le s390x i686 x86_64 +// revisions: aarch64 powerpc powerpc64 powerpc64le s390x i686 x86_64 +//[aarch64] compile-flags: --target aarch64-unknown-linux-gnu +//[aarch64] needs-llvm-components: aarch64 //[powerpc] compile-flags: --target powerpc-unknown-linux-gnu //[powerpc] needs-llvm-components: powerpc //[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu diff --git a/tests/coverage/assert_not.cov-map b/tests/coverage/assert_not.cov-map new file mode 100644 index 00000000000..788bc5dbf58 --- /dev/null +++ b/tests/coverage/assert_not.cov-map @@ -0,0 +1,16 @@ +Function name: assert_not::main +Raw bytes (33): 0x[01, 01, 02, 05, 00, 0d, 00, 05, 01, 06, 01, 01, 12, 05, 02, 05, 00, 14, 02, 01, 05, 00, 14, 0d, 01, 05, 00, 16, 06, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(1), rhs = Zero +- expression 1 operands: lhs = Counter(3), rhs = Zero +Number of file 0 mappings: 5 +- Code(Counter(0)) at (prev + 6, 1) to (start + 1, 18) +- Code(Counter(1)) at (prev + 2, 5) to (start + 0, 20) +- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 20) + = (c1 - Zero) +- Code(Counter(3)) at (prev + 1, 5) to (start + 0, 22) +- Code(Expression(1, Sub)) at (prev + 1, 1) to (start + 0, 2) + = (c3 - Zero) + diff --git a/tests/coverage/assert_not.coverage b/tests/coverage/assert_not.coverage new file mode 100644 index 00000000000..4cfdab974ed --- /dev/null +++ b/tests/coverage/assert_not.coverage @@ -0,0 +1,12 @@ + LL| |// edition: 2021 + LL| | + LL| |// Regression test for <https://github.com/rust-lang/rust/issues/118904>. + LL| |// `assert!(true)` and `assert!(!false)` should have similar coverage spans. + LL| | + LL| 1|fn main() { + LL| 1| assert!(true); + LL| 1| assert!(!false); + LL| 1| assert!(!!true); + LL| 1| assert!(!!!false); + LL| 1|} + diff --git a/tests/coverage/assert_not.rs b/tests/coverage/assert_not.rs new file mode 100644 index 00000000000..95204fcadd1 --- /dev/null +++ b/tests/coverage/assert_not.rs @@ -0,0 +1,11 @@ +// edition: 2021 + +// Regression test for <https://github.com/rust-lang/rust/issues/118904>. +// `assert!(true)` and `assert!(!false)` should have similar coverage spans. + +fn main() { + assert!(true); + assert!(!false); + assert!(!!true); + assert!(!!!false); +} diff --git a/tests/coverage/async.cov-map b/tests/coverage/async.cov-map index e4354a1af87..6bdcca40ed6 100644 --- a/tests/coverage/async.cov-map +++ b/tests/coverage/async.cov-map @@ -1,20 +1,20 @@ Function name: async::c -Raw bytes (9): 0x[01, 01, 00, 01, 01, 05, 01, 00, 19] +Raw bytes (9): 0x[01, 01, 00, 01, 01, 07, 01, 00, 19] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 5, 1) to (start + 0, 25) +- Code(Counter(0)) at (prev + 7, 1) to (start + 0, 25) Function name: async::c::{closure#0} -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 05, 19, 01, 0e, 05, 02, 09, 00, 0a, 02, 02, 09, 00, 0a, 07, 02, 01, 00, 02] +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 07, 19, 01, 0e, 05, 02, 09, 00, 0a, 02, 02, 09, 00, 0a, 07, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 2 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) - expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 -- Code(Counter(0)) at (prev + 5, 25) to (start + 1, 14) +- Code(Counter(0)) at (prev + 7, 25) to (start + 1, 14) - Code(Counter(1)) at (prev + 2, 9) to (start + 0, 10) - Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 10) = (c0 - c1) @@ -22,136 +22,84 @@ Number of file 0 mappings: 4 = (c1 + (c0 - c1)) Function name: async::d -Raw bytes (9): 0x[01, 01, 00, 01, 01, 0d, 01, 00, 14] +Raw bytes (9): 0x[01, 01, 00, 01, 01, 0f, 01, 00, 14] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 13, 1) to (start + 0, 20) +- Code(Counter(0)) at (prev + 15, 1) to (start + 0, 20) Function name: async::d::{closure#0} -Raw bytes (9): 0x[01, 01, 00, 01, 01, 0d, 14, 00, 19] +Raw bytes (9): 0x[01, 01, 00, 01, 01, 0f, 14, 00, 19] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 13, 20) to (start + 0, 25) +- Code(Counter(0)) at (prev + 15, 20) to (start + 0, 25) Function name: async::e (unused) -Raw bytes (9): 0x[01, 01, 00, 01, 00, 0f, 01, 00, 14] +Raw bytes (9): 0x[01, 01, 00, 01, 00, 11, 01, 00, 14] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Zero) at (prev + 15, 1) to (start + 0, 20) +- Code(Zero) at (prev + 17, 1) to (start + 0, 20) Function name: async::e::{closure#0} (unused) -Raw bytes (9): 0x[01, 01, 00, 01, 00, 0f, 14, 00, 19] +Raw bytes (9): 0x[01, 01, 00, 01, 00, 11, 14, 00, 19] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Zero) at (prev + 15, 20) to (start + 0, 25) - -Function name: async::executor::block_on::<core::pin::Pin<&mut async::i::{closure#0}>> -Raw bytes (40): 0x[01, 01, 03, 0b, 05, 01, 05, 01, 05, 06, 01, 6e, 05, 0a, 36, 02, 0d, 20, 00, 23, 0b, 00, 27, 00, 49, 02, 01, 17, 00, 1a, 05, 01, 0e, 00, 0f, 02, 02, 05, 00, 06] -Number of files: 1 -- file 0 => global file 1 -Number of expressions: 3 -- expression 0 operands: lhs = Expression(2, Add), rhs = Counter(1) -- expression 1 operands: lhs = Counter(0), rhs = Counter(1) -- expression 2 operands: lhs = Counter(0), rhs = Counter(1) -Number of file 0 mappings: 6 -- Code(Counter(0)) at (prev + 110, 5) to (start + 10, 54) -- Code(Expression(0, Sub)) at (prev + 13, 32) to (start + 0, 35) - = ((c0 + c1) - c1) -- Code(Expression(2, Add)) at (prev + 0, 39) to (start + 0, 73) - = (c0 + c1) -- Code(Expression(0, Sub)) at (prev + 1, 23) to (start + 0, 26) - = ((c0 + c1) - c1) -- Code(Counter(1)) at (prev + 1, 14) to (start + 0, 15) -- Code(Expression(0, Sub)) at (prev + 2, 5) to (start + 0, 6) - = ((c0 + c1) - c1) - -Function name: async::executor::block_on::VTABLE::{closure#0} -Raw bytes (9): 0x[01, 01, 00, 01, 01, 72, 11, 00, 31] -Number of files: 1 -- file 0 => global file 1 -Number of expressions: 0 -Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 114, 17) to (start + 0, 49) - -Function name: async::executor::block_on::VTABLE::{closure#1} -Raw bytes (9): 0x[01, 01, 00, 01, 01, 73, 11, 00, 31] -Number of files: 1 -- file 0 => global file 1 -Number of expressions: 0 -Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 115, 17) to (start + 0, 49) - -Function name: async::executor::block_on::VTABLE::{closure#2} -Raw bytes (9): 0x[01, 01, 00, 01, 01, 74, 11, 00, 31] -Number of files: 1 -- file 0 => global file 1 -Number of expressions: 0 -Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 116, 17) to (start + 0, 49) - -Function name: async::executor::block_on::VTABLE::{closure#3} -Raw bytes (9): 0x[01, 01, 00, 01, 01, 75, 11, 00, 13] -Number of files: 1 -- file 0 => global file 1 -Number of expressions: 0 -Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 117, 17) to (start + 0, 19) +- Code(Zero) at (prev + 17, 20) to (start + 0, 25) Function name: async::f -Raw bytes (9): 0x[01, 01, 00, 01, 01, 11, 01, 00, 14] +Raw bytes (9): 0x[01, 01, 00, 01, 01, 13, 01, 00, 14] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 17, 1) to (start + 0, 20) +- Code(Counter(0)) at (prev + 19, 1) to (start + 0, 20) Function name: async::f::{closure#0} -Raw bytes (9): 0x[01, 01, 00, 01, 01, 11, 14, 00, 19] +Raw bytes (9): 0x[01, 01, 00, 01, 01, 13, 14, 00, 19] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 17, 20) to (start + 0, 25) +- Code(Counter(0)) at (prev + 19, 20) to (start + 0, 25) Function name: async::foo (unused) -Raw bytes (9): 0x[01, 01, 00, 01, 00, 13, 01, 00, 1e] +Raw bytes (9): 0x[01, 01, 00, 01, 00, 15, 01, 00, 1e] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Zero) at (prev + 19, 1) to (start + 0, 30) +- Code(Zero) at (prev + 21, 1) to (start + 0, 30) Function name: async::foo::{closure#0} (unused) -Raw bytes (9): 0x[01, 01, 00, 01, 00, 13, 1e, 00, 2d] +Raw bytes (9): 0x[01, 01, 00, 01, 00, 15, 1e, 00, 2d] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Zero) at (prev + 19, 30) to (start + 0, 45) +- Code(Zero) at (prev + 21, 30) to (start + 0, 45) Function name: async::g -Raw bytes (9): 0x[01, 01, 00, 01, 01, 15, 01, 00, 17] +Raw bytes (9): 0x[01, 01, 00, 01, 01, 17, 01, 00, 17] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 21, 1) to (start + 0, 23) +- Code(Counter(0)) at (prev + 23, 1) to (start + 0, 23) Function name: async::g::{closure#0} (unused) -Raw bytes (69): 0x[01, 01, 00, 0d, 00, 15, 17, 01, 0c, 00, 02, 09, 00, 0a, 00, 00, 0e, 00, 11, 00, 00, 12, 00, 17, 00, 00, 1b, 00, 1c, 00, 00, 20, 00, 22, 00, 01, 09, 00, 0a, 00, 00, 0e, 00, 11, 00, 00, 12, 00, 17, 00, 00, 1b, 00, 1c, 00, 00, 20, 00, 22, 00, 01, 0e, 00, 10, 00, 02, 01, 00, 02] +Raw bytes (69): 0x[01, 01, 00, 0d, 00, 17, 17, 01, 0c, 00, 02, 09, 00, 0a, 00, 00, 0e, 00, 11, 00, 00, 12, 00, 17, 00, 00, 1b, 00, 1c, 00, 00, 20, 00, 22, 00, 01, 09, 00, 0a, 00, 00, 0e, 00, 11, 00, 00, 12, 00, 17, 00, 00, 1b, 00, 1c, 00, 00, 20, 00, 22, 00, 01, 0e, 00, 10, 00, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 13 -- Code(Zero) at (prev + 21, 23) to (start + 1, 12) +- Code(Zero) at (prev + 23, 23) to (start + 1, 12) - Code(Zero) at (prev + 2, 9) to (start + 0, 10) - Code(Zero) at (prev + 0, 14) to (start + 0, 17) - Code(Zero) at (prev + 0, 18) to (start + 0, 23) @@ -166,20 +114,20 @@ Number of file 0 mappings: 13 - Code(Zero) at (prev + 2, 1) to (start + 0, 2) Function name: async::h -Raw bytes (9): 0x[01, 01, 00, 01, 01, 1d, 01, 00, 16] +Raw bytes (9): 0x[01, 01, 00, 01, 01, 1f, 01, 00, 16] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 29, 1) to (start + 0, 22) +- Code(Counter(0)) at (prev + 31, 1) to (start + 0, 22) Function name: async::h::{closure#0} (unused) -Raw bytes (44): 0x[01, 01, 00, 08, 00, 1d, 16, 03, 0c, 00, 04, 09, 00, 0a, 00, 00, 0e, 00, 13, 00, 00, 14, 00, 19, 00, 00, 1a, 00, 1b, 00, 00, 20, 00, 22, 00, 01, 0e, 00, 10, 00, 02, 01, 00, 02] +Raw bytes (44): 0x[01, 01, 00, 08, 00, 1f, 16, 03, 0c, 00, 04, 09, 00, 0a, 00, 00, 0e, 00, 13, 00, 00, 14, 00, 19, 00, 00, 1a, 00, 1b, 00, 00, 20, 00, 22, 00, 01, 0e, 00, 10, 00, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 8 -- Code(Zero) at (prev + 29, 22) to (start + 3, 12) +- Code(Zero) at (prev + 31, 22) to (start + 3, 12) - Code(Zero) at (prev + 4, 9) to (start + 0, 10) - Code(Zero) at (prev + 0, 14) to (start + 0, 19) - Code(Zero) at (prev + 0, 20) to (start + 0, 25) @@ -189,22 +137,22 @@ Number of file 0 mappings: 8 - Code(Zero) at (prev + 2, 1) to (start + 0, 2) Function name: async::i -Raw bytes (9): 0x[01, 01, 00, 01, 01, 26, 01, 00, 13] +Raw bytes (9): 0x[01, 01, 00, 01, 01, 28, 01, 00, 13] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 38, 1) to (start + 0, 19) +- Code(Counter(0)) at (prev + 40, 1) to (start + 0, 19) Function name: async::i::{closure#0} -Raw bytes (78): 0x[01, 01, 02, 07, 21, 19, 1d, 0e, 01, 26, 13, 04, 0c, 0d, 05, 09, 00, 0a, 01, 00, 0e, 00, 12, 05, 00, 13, 00, 18, 09, 00, 1c, 00, 21, 0d, 00, 27, 00, 2a, 15, 00, 2b, 00, 30, 1d, 01, 09, 00, 0a, 11, 00, 0e, 00, 11, 25, 00, 12, 00, 17, 29, 00, 1b, 00, 20, 1d, 00, 24, 00, 26, 21, 01, 0e, 00, 10, 03, 02, 01, 00, 02] +Raw bytes (78): 0x[01, 01, 02, 07, 21, 19, 1d, 0e, 01, 28, 13, 04, 0c, 0d, 05, 09, 00, 0a, 01, 00, 0e, 00, 12, 05, 00, 13, 00, 18, 09, 00, 1c, 00, 21, 0d, 00, 27, 00, 2a, 15, 00, 2b, 00, 30, 1d, 01, 09, 00, 0a, 11, 00, 0e, 00, 11, 25, 00, 12, 00, 17, 29, 00, 1b, 00, 20, 1d, 00, 24, 00, 26, 21, 01, 0e, 00, 10, 03, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 2 - expression 0 operands: lhs = Expression(1, Add), rhs = Counter(8) - expression 1 operands: lhs = Counter(6), rhs = Counter(7) Number of file 0 mappings: 14 -- Code(Counter(0)) at (prev + 38, 19) to (start + 4, 12) +- Code(Counter(0)) at (prev + 40, 19) to (start + 4, 12) - Code(Counter(3)) at (prev + 5, 9) to (start + 0, 10) - Code(Counter(0)) at (prev + 0, 14) to (start + 0, 18) - Code(Counter(1)) at (prev + 0, 19) to (start + 0, 24) @@ -221,14 +169,14 @@ Number of file 0 mappings: 14 = ((c6 + c7) + c8) Function name: async::j -Raw bytes (53): 0x[01, 01, 02, 07, 0d, 05, 09, 09, 01, 31, 01, 13, 0c, 05, 14, 09, 00, 0a, 01, 00, 0e, 00, 1b, 05, 00, 1f, 00, 27, 09, 01, 09, 00, 0a, 11, 00, 0e, 00, 1a, 09, 00, 1e, 00, 20, 0d, 01, 0e, 00, 10, 03, 02, 01, 00, 02] +Raw bytes (53): 0x[01, 01, 02, 07, 0d, 05, 09, 09, 01, 33, 01, 13, 0c, 05, 14, 09, 00, 0a, 01, 00, 0e, 00, 1b, 05, 00, 1f, 00, 27, 09, 01, 09, 00, 0a, 11, 00, 0e, 00, 1a, 09, 00, 1e, 00, 20, 0d, 01, 0e, 00, 10, 03, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 2 - expression 0 operands: lhs = Expression(1, Add), rhs = Counter(3) - expression 1 operands: lhs = Counter(1), rhs = Counter(2) Number of file 0 mappings: 9 -- Code(Counter(0)) at (prev + 49, 1) to (start + 19, 12) +- Code(Counter(0)) at (prev + 51, 1) to (start + 19, 12) - Code(Counter(1)) at (prev + 20, 9) to (start + 0, 10) - Code(Counter(0)) at (prev + 0, 14) to (start + 0, 27) - Code(Counter(1)) at (prev + 0, 31) to (start + 0, 39) @@ -240,14 +188,14 @@ Number of file 0 mappings: 9 = ((c1 + c2) + c3) Function name: async::j::c -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 33, 05, 01, 12, 05, 02, 0d, 00, 0e, 02, 0a, 0d, 00, 0e, 07, 02, 05, 00, 06] +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 35, 05, 01, 12, 05, 02, 0d, 00, 0e, 02, 0a, 0d, 00, 0e, 07, 02, 05, 00, 06] Number of files: 1 - file 0 => global file 1 Number of expressions: 2 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) - expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 -- Code(Counter(0)) at (prev + 51, 5) to (start + 1, 18) +- Code(Counter(0)) at (prev + 53, 5) to (start + 1, 18) - Code(Counter(1)) at (prev + 2, 13) to (start + 0, 14) - Code(Expression(0, Sub)) at (prev + 10, 13) to (start + 0, 14) = (c0 - c1) @@ -255,35 +203,35 @@ Number of file 0 mappings: 4 = (c1 + (c0 - c1)) Function name: async::j::d -Raw bytes (9): 0x[01, 01, 00, 01, 01, 42, 05, 00, 17] +Raw bytes (9): 0x[01, 01, 00, 01, 01, 44, 05, 00, 17] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 66, 5) to (start + 0, 23) +- Code(Counter(0)) at (prev + 68, 5) to (start + 0, 23) Function name: async::j::f -Raw bytes (9): 0x[01, 01, 00, 01, 01, 43, 05, 00, 17] +Raw bytes (9): 0x[01, 01, 00, 01, 01, 45, 05, 00, 17] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 67, 5) to (start + 0, 23) +- Code(Counter(0)) at (prev + 69, 5) to (start + 0, 23) Function name: async::k (unused) -Raw bytes (29): 0x[01, 01, 00, 05, 00, 4b, 01, 01, 0c, 00, 02, 0e, 00, 10, 00, 01, 0e, 00, 10, 00, 01, 0e, 00, 10, 00, 02, 01, 00, 02] +Raw bytes (29): 0x[01, 01, 00, 05, 00, 4d, 01, 01, 0c, 00, 02, 0e, 00, 10, 00, 01, 0e, 00, 10, 00, 01, 0e, 00, 10, 00, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 5 -- Code(Zero) at (prev + 75, 1) to (start + 1, 12) +- Code(Zero) at (prev + 77, 1) to (start + 1, 12) - Code(Zero) at (prev + 2, 14) to (start + 0, 16) - Code(Zero) at (prev + 1, 14) to (start + 0, 16) - Code(Zero) at (prev + 1, 14) to (start + 0, 16) - Code(Zero) at (prev + 2, 1) to (start + 0, 2) Function name: async::l -Raw bytes (37): 0x[01, 01, 04, 01, 07, 05, 09, 0f, 02, 09, 05, 05, 01, 53, 01, 01, 0c, 02, 02, 0e, 00, 10, 05, 01, 0e, 00, 10, 09, 01, 0e, 00, 10, 0b, 02, 01, 00, 02] +Raw bytes (37): 0x[01, 01, 04, 01, 07, 05, 09, 0f, 02, 09, 05, 05, 01, 55, 01, 01, 0c, 02, 02, 0e, 00, 10, 05, 01, 0e, 00, 10, 09, 01, 0e, 00, 10, 0b, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 4 @@ -292,7 +240,7 @@ Number of expressions: 4 - expression 2 operands: lhs = Expression(3, Add), rhs = Expression(0, Sub) - expression 3 operands: lhs = Counter(2), rhs = Counter(1) Number of file 0 mappings: 5 -- Code(Counter(0)) at (prev + 83, 1) to (start + 1, 12) +- Code(Counter(0)) at (prev + 85, 1) to (start + 1, 12) - Code(Expression(0, Sub)) at (prev + 2, 14) to (start + 0, 16) = (c0 - (c1 + c2)) - Code(Counter(1)) at (prev + 1, 14) to (start + 0, 16) @@ -301,26 +249,26 @@ Number of file 0 mappings: 5 = ((c2 + c1) + (c0 - (c1 + c2))) Function name: async::m -Raw bytes (9): 0x[01, 01, 00, 01, 01, 5b, 01, 00, 19] +Raw bytes (9): 0x[01, 01, 00, 01, 01, 5d, 01, 00, 19] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 91, 1) to (start + 0, 25) +- Code(Counter(0)) at (prev + 93, 1) to (start + 0, 25) Function name: async::m::{closure#0} (unused) -Raw bytes (9): 0x[01, 01, 00, 01, 00, 5b, 19, 00, 22] +Raw bytes (9): 0x[01, 01, 00, 01, 00, 5d, 19, 00, 22] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Zero) at (prev + 91, 25) to (start + 0, 34) +- Code(Zero) at (prev + 93, 25) to (start + 0, 34) Function name: async::main -Raw bytes (9): 0x[01, 01, 00, 01, 01, 5d, 01, 08, 02] +Raw bytes (9): 0x[01, 01, 00, 01, 01, 5f, 01, 08, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 93, 1) to (start + 8, 2) +- Code(Counter(0)) at (prev + 95, 1) to (start + 8, 2) diff --git a/tests/coverage/async.coverage b/tests/coverage/async.coverage index 07bc16c2d92..015e03d5165 100644 --- a/tests/coverage/async.coverage +++ b/tests/coverage/async.coverage @@ -1,6 +1,8 @@ + LL| |#![feature(coverage_attribute)] + LL| |#![feature(noop_waker)] LL| |#![allow(unused_assignments, dead_code)] - LL| | - LL| |// compile-flags: --edition=2018 -C opt-level=1 + LL| |// edition: 2018 + LL| |// compile-flags: -Copt-level=1 LL| | LL| 1|async fn c(x: u8) -> u8 { LL| 1| if x == 8 { @@ -108,32 +110,21 @@ LL| 1|} LL| | LL| |mod executor { - LL| | use core::{ - LL| | future::Future, - LL| | pin::Pin, - LL| | task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, - LL| | }; - LL| | - LL| 1| pub fn block_on<F: Future>(mut future: F) -> F::Output { - LL| 1| let mut future = unsafe { Pin::new_unchecked(&mut future) }; - LL| 1| use std::hint::unreachable_unchecked; - LL| 1| static VTABLE: RawWakerVTable = RawWakerVTable::new( - LL| 1| |_| unsafe { unreachable_unchecked() }, // clone - ^0 - LL| 1| |_| unsafe { unreachable_unchecked() }, // wake - ^0 - LL| 1| |_| unsafe { unreachable_unchecked() }, // wake_by_ref - ^0 - LL| 1| |_| (), - LL| 1| ); - LL| 1| let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; - LL| 1| let mut context = Context::from_waker(&waker); + LL| | use core::future::Future; + LL| | use core::pin::pin; + LL| | use core::task::{Context, Poll, Waker}; + LL| | + LL| | #[coverage(off)] + LL| | pub fn block_on<F: Future>(mut future: F) -> F::Output { + LL| | let mut future = pin!(future); + LL| | let waker = Waker::noop(); + LL| | let mut context = Context::from_waker(&waker); LL| | LL| | loop { - LL| 1| if let Poll::Ready(val) = future.as_mut().poll(&mut context) { - LL| 1| break val; - LL| 0| } + LL| | if let Poll::Ready(val) = future.as_mut().poll(&mut context) { + LL| | break val; + LL| | } LL| | } - LL| 1| } + LL| | } LL| |} diff --git a/tests/coverage/async.rs b/tests/coverage/async.rs index efd9e62d64e..abc9e5f7f64 100644 --- a/tests/coverage/async.rs +++ b/tests/coverage/async.rs @@ -1,6 +1,8 @@ +#![feature(coverage_attribute)] +#![feature(noop_waker)] #![allow(unused_assignments, dead_code)] - -// compile-flags: --edition=2018 -C opt-level=1 +// edition: 2018 +// compile-flags: -Copt-level=1 async fn c(x: u8) -> u8 { if x == 8 { @@ -101,22 +103,14 @@ fn main() { } mod executor { - use core::{ - future::Future, - pin::Pin, - task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, - }; + use core::future::Future; + use core::pin::pin; + use core::task::{Context, Poll, Waker}; + #[coverage(off)] pub fn block_on<F: Future>(mut future: F) -> F::Output { - let mut future = unsafe { Pin::new_unchecked(&mut future) }; - use std::hint::unreachable_unchecked; - static VTABLE: RawWakerVTable = RawWakerVTable::new( - |_| unsafe { unreachable_unchecked() }, // clone - |_| unsafe { unreachable_unchecked() }, // wake - |_| unsafe { unreachable_unchecked() }, // wake_by_ref - |_| (), - ); - let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; + let mut future = pin!(future); + let waker = Waker::noop(); let mut context = Context::from_waker(&waker); loop { diff --git a/tests/coverage/async2.cov-map b/tests/coverage/async2.cov-map index 23f26ee4e5f..28f319bfb80 100644 --- a/tests/coverage/async2.cov-map +++ b/tests/coverage/async2.cov-map @@ -1,130 +1,56 @@ Function name: async2::async_func -Raw bytes (9): 0x[01, 01, 00, 01, 01, 0b, 01, 00, 17] +Raw bytes (9): 0x[01, 01, 00, 01, 01, 0d, 01, 00, 17] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 11, 1) to (start + 0, 23) +- Code(Counter(0)) at (prev + 13, 1) to (start + 0, 23) Function name: async2::async_func::{closure#0} -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 0b, 17, 03, 09, 05, 03, 0a, 02, 06, 02, 02, 06, 00, 07, 07, 01, 01, 00, 02] +Raw bytes (26): 0x[01, 01, 01, 05, 00, 04, 01, 0d, 17, 03, 09, 05, 03, 0a, 02, 06, 00, 02, 06, 00, 07, 03, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of expressions: 1 +- expression 0 operands: lhs = Counter(1), rhs = Zero Number of file 0 mappings: 4 -- Code(Counter(0)) at (prev + 11, 23) to (start + 3, 9) +- Code(Counter(0)) at (prev + 13, 23) to (start + 3, 9) - Code(Counter(1)) at (prev + 3, 10) to (start + 2, 6) -- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) - = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) - = (c1 + (c0 - c1)) +- Code(Zero) at (prev + 2, 6) to (start + 0, 7) +- Code(Expression(0, Add)) at (prev + 1, 1) to (start + 0, 2) + = (c1 + Zero) Function name: async2::async_func_just_println -Raw bytes (9): 0x[01, 01, 00, 01, 01, 13, 01, 00, 24] +Raw bytes (9): 0x[01, 01, 00, 01, 01, 15, 01, 00, 24] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 19, 1) to (start + 0, 36) +- Code(Counter(0)) at (prev + 21, 1) to (start + 0, 36) Function name: async2::async_func_just_println::{closure#0} -Raw bytes (9): 0x[01, 01, 00, 01, 01, 13, 24, 02, 02] -Number of files: 1 -- file 0 => global file 1 -Number of expressions: 0 -Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 19, 36) to (start + 2, 2) - -Function name: async2::executor::block_on::<async2::async_func::{closure#0}> -Raw bytes (40): 0x[01, 01, 03, 0b, 05, 01, 05, 01, 05, 06, 01, 27, 05, 0a, 36, 02, 0d, 20, 00, 23, 0b, 00, 27, 00, 49, 02, 01, 17, 00, 1a, 05, 01, 0e, 00, 0f, 02, 02, 05, 00, 06] -Number of files: 1 -- file 0 => global file 1 -Number of expressions: 3 -- expression 0 operands: lhs = Expression(2, Add), rhs = Counter(1) -- expression 1 operands: lhs = Counter(0), rhs = Counter(1) -- expression 2 operands: lhs = Counter(0), rhs = Counter(1) -Number of file 0 mappings: 6 -- Code(Counter(0)) at (prev + 39, 5) to (start + 10, 54) -- Code(Expression(0, Sub)) at (prev + 13, 32) to (start + 0, 35) - = ((c0 + c1) - c1) -- Code(Expression(2, Add)) at (prev + 0, 39) to (start + 0, 73) - = (c0 + c1) -- Code(Expression(0, Sub)) at (prev + 1, 23) to (start + 0, 26) - = ((c0 + c1) - c1) -- Code(Counter(1)) at (prev + 1, 14) to (start + 0, 15) -- Code(Expression(0, Sub)) at (prev + 2, 5) to (start + 0, 6) - = ((c0 + c1) - c1) - -Function name: async2::executor::block_on::<async2::async_func_just_println::{closure#0}> -Raw bytes (40): 0x[01, 01, 03, 0b, 05, 01, 05, 01, 05, 06, 01, 27, 05, 0a, 36, 02, 0d, 20, 00, 23, 0b, 00, 27, 00, 49, 02, 01, 17, 00, 1a, 05, 01, 0e, 00, 0f, 02, 02, 05, 00, 06] -Number of files: 1 -- file 0 => global file 1 -Number of expressions: 3 -- expression 0 operands: lhs = Expression(2, Add), rhs = Counter(1) -- expression 1 operands: lhs = Counter(0), rhs = Counter(1) -- expression 2 operands: lhs = Counter(0), rhs = Counter(1) -Number of file 0 mappings: 6 -- Code(Counter(0)) at (prev + 39, 5) to (start + 10, 54) -- Code(Expression(0, Sub)) at (prev + 13, 32) to (start + 0, 35) - = ((c0 + c1) - c1) -- Code(Expression(2, Add)) at (prev + 0, 39) to (start + 0, 73) - = (c0 + c1) -- Code(Expression(0, Sub)) at (prev + 1, 23) to (start + 0, 26) - = ((c0 + c1) - c1) -- Code(Counter(1)) at (prev + 1, 14) to (start + 0, 15) -- Code(Expression(0, Sub)) at (prev + 2, 5) to (start + 0, 6) - = ((c0 + c1) - c1) - -Function name: async2::executor::block_on::VTABLE::{closure#0} -Raw bytes (9): 0x[01, 01, 00, 01, 01, 2b, 11, 00, 31] -Number of files: 1 -- file 0 => global file 1 -Number of expressions: 0 -Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 43, 17) to (start + 0, 49) - -Function name: async2::executor::block_on::VTABLE::{closure#1} -Raw bytes (9): 0x[01, 01, 00, 01, 01, 2c, 11, 00, 31] -Number of files: 1 -- file 0 => global file 1 -Number of expressions: 0 -Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 44, 17) to (start + 0, 49) - -Function name: async2::executor::block_on::VTABLE::{closure#2} -Raw bytes (9): 0x[01, 01, 00, 01, 01, 2d, 11, 00, 31] -Number of files: 1 -- file 0 => global file 1 -Number of expressions: 0 -Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 45, 17) to (start + 0, 49) - -Function name: async2::executor::block_on::VTABLE::{closure#3} -Raw bytes (9): 0x[01, 01, 00, 01, 01, 2e, 11, 00, 13] +Raw bytes (9): 0x[01, 01, 00, 01, 01, 15, 24, 02, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 46, 17) to (start + 0, 19) +- Code(Counter(0)) at (prev + 21, 36) to (start + 2, 2) Function name: async2::main -Raw bytes (9): 0x[01, 01, 00, 01, 01, 17, 01, 07, 02] +Raw bytes (9): 0x[01, 01, 00, 01, 01, 19, 01, 07, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 23, 1) to (start + 7, 2) +- Code(Counter(0)) at (prev + 25, 1) to (start + 7, 2) Function name: async2::non_async_func -Raw bytes (26): 0x[01, 01, 01, 05, 00, 04, 01, 03, 01, 03, 09, 05, 03, 0a, 02, 06, 00, 02, 06, 00, 07, 03, 01, 01, 00, 02] +Raw bytes (26): 0x[01, 01, 01, 05, 00, 04, 01, 05, 01, 03, 09, 05, 03, 0a, 02, 06, 00, 02, 06, 00, 07, 03, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 1 - expression 0 operands: lhs = Counter(1), rhs = Zero Number of file 0 mappings: 4 -- Code(Counter(0)) at (prev + 3, 1) to (start + 3, 9) +- Code(Counter(0)) at (prev + 5, 1) to (start + 3, 9) - Code(Counter(1)) at (prev + 3, 10) to (start + 2, 6) - Code(Zero) at (prev + 2, 6) to (start + 0, 7) - Code(Expression(0, Add)) at (prev + 1, 1) to (start + 0, 2) diff --git a/tests/coverage/async2.coverage b/tests/coverage/async2.coverage index fcb0a3aed64..acd83de9493 100644 --- a/tests/coverage/async2.coverage +++ b/tests/coverage/async2.coverage @@ -1,4 +1,6 @@ - LL| |// compile-flags: --edition=2018 + LL| |#![feature(coverage_attribute)] + LL| |#![feature(noop_waker)] + LL| |// edition: 2018 LL| | LL| 1|fn non_async_func() { LL| 1| println!("non_async_func was covered"); @@ -32,73 +34,21 @@ LL| 1|} LL| | LL| |mod executor { - LL| | use core::{ - LL| | future::Future, - LL| | pin::Pin, - LL| | task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, - LL| | }; + LL| | use core::future::Future; + LL| | use core::pin::pin; + LL| | use core::task::{Context, Poll, Waker}; LL| | - LL| 2| pub fn block_on<F: Future>(mut future: F) -> F::Output { - LL| 2| let mut future = unsafe { Pin::new_unchecked(&mut future) }; - LL| 2| use std::hint::unreachable_unchecked; - LL| 2| static VTABLE: RawWakerVTable = RawWakerVTable::new( - LL| 2| |_| unsafe { unreachable_unchecked() }, // clone - ^0 - LL| 2| |_| unsafe { unreachable_unchecked() }, // wake - ^0 - LL| 2| |_| unsafe { unreachable_unchecked() }, // wake_by_ref - ^0 - LL| 2| |_| (), - LL| 2| ); - LL| 2| let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; - LL| 2| let mut context = Context::from_waker(&waker); + LL| | #[coverage(off)] + LL| | pub fn block_on<F: Future>(mut future: F) -> F::Output { + LL| | let mut future = pin!(future); + LL| | let waker = Waker::noop(); + LL| | let mut context = Context::from_waker(&waker); LL| | LL| | loop { - LL| 2| if let Poll::Ready(val) = future.as_mut().poll(&mut context) { - LL| 2| break val; - LL| 0| } + LL| | if let Poll::Ready(val) = future.as_mut().poll(&mut context) { + LL| | break val; + LL| | } LL| | } - LL| 2| } - ------------------ - | async2::executor::block_on::<async2::async_func::{closure#0}>: - | LL| 1| pub fn block_on<F: Future>(mut future: F) -> F::Output { - | LL| 1| let mut future = unsafe { Pin::new_unchecked(&mut future) }; - | LL| 1| use std::hint::unreachable_unchecked; - | LL| 1| static VTABLE: RawWakerVTable = RawWakerVTable::new( - | LL| 1| |_| unsafe { unreachable_unchecked() }, // clone - | LL| 1| |_| unsafe { unreachable_unchecked() }, // wake - | LL| 1| |_| unsafe { unreachable_unchecked() }, // wake_by_ref - | LL| 1| |_| (), - | LL| 1| ); - | LL| 1| let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; - | LL| 1| let mut context = Context::from_waker(&waker); - | LL| | - | LL| | loop { - | LL| 1| if let Poll::Ready(val) = future.as_mut().poll(&mut context) { - | LL| 1| break val; - | LL| 0| } - | LL| | } - | LL| 1| } - ------------------ - | async2::executor::block_on::<async2::async_func_just_println::{closure#0}>: - | LL| 1| pub fn block_on<F: Future>(mut future: F) -> F::Output { - | LL| 1| let mut future = unsafe { Pin::new_unchecked(&mut future) }; - | LL| 1| use std::hint::unreachable_unchecked; - | LL| 1| static VTABLE: RawWakerVTable = RawWakerVTable::new( - | LL| 1| |_| unsafe { unreachable_unchecked() }, // clone - | LL| 1| |_| unsafe { unreachable_unchecked() }, // wake - | LL| 1| |_| unsafe { unreachable_unchecked() }, // wake_by_ref - | LL| 1| |_| (), - | LL| 1| ); - | LL| 1| let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; - | LL| 1| let mut context = Context::from_waker(&waker); - | LL| | - | LL| | loop { - | LL| 1| if let Poll::Ready(val) = future.as_mut().poll(&mut context) { - | LL| 1| break val; - | LL| 0| } - | LL| | } - | LL| 1| } - ------------------ + LL| | } LL| |} diff --git a/tests/coverage/async2.rs b/tests/coverage/async2.rs index 2884ff297af..393573f7dc9 100644 --- a/tests/coverage/async2.rs +++ b/tests/coverage/async2.rs @@ -1,4 +1,6 @@ -// compile-flags: --edition=2018 +#![feature(coverage_attribute)] +#![feature(noop_waker)] +// edition: 2018 fn non_async_func() { println!("non_async_func was covered"); @@ -30,22 +32,14 @@ fn main() { } mod executor { - use core::{ - future::Future, - pin::Pin, - task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, - }; + use core::future::Future; + use core::pin::pin; + use core::task::{Context, Poll, Waker}; + #[coverage(off)] pub fn block_on<F: Future>(mut future: F) -> F::Output { - let mut future = unsafe { Pin::new_unchecked(&mut future) }; - use std::hint::unreachable_unchecked; - static VTABLE: RawWakerVTable = RawWakerVTable::new( - |_| unsafe { unreachable_unchecked() }, // clone - |_| unsafe { unreachable_unchecked() }, // wake - |_| unsafe { unreachable_unchecked() }, // wake_by_ref - |_| (), - ); - let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; + let mut future = pin!(future); + let waker = Waker::noop(); let mut context = Context::from_waker(&waker); loop { diff --git a/tests/coverage/async_block.cov-map b/tests/coverage/async_block.cov-map new file mode 100644 index 00000000000..104133f6e67 --- /dev/null +++ b/tests/coverage/async_block.cov-map @@ -0,0 +1,32 @@ +Function name: async_block::main +Raw bytes (38): 0x[01, 01, 02, 01, 05, 03, 05, 06, 01, 05, 01, 00, 0b, 05, 01, 09, 00, 0a, 03, 00, 0e, 00, 13, 05, 00, 14, 01, 16, 05, 07, 0a, 02, 06, 06, 03, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Expression(0, Add), rhs = Counter(1) +Number of file 0 mappings: 6 +- Code(Counter(0)) at (prev + 5, 1) to (start + 0, 11) +- Code(Counter(1)) at (prev + 1, 9) to (start + 0, 10) +- Code(Expression(0, Add)) at (prev + 0, 14) to (start + 0, 19) + = (c0 + c1) +- Code(Counter(1)) at (prev + 0, 20) to (start + 1, 22) +- Code(Counter(1)) at (prev + 7, 10) to (start + 2, 6) +- Code(Expression(1, Sub)) at (prev + 3, 1) to (start + 0, 2) + = ((c0 + c1) - c1) + +Function name: async_block::main::{closure#0} +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 07, 1c, 01, 17, 05, 01, 18, 02, 0e, 02, 02, 14, 02, 0e, 07, 03, 09, 00, 0a] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 7, 28) to (start + 1, 23) +- Code(Counter(1)) at (prev + 1, 24) to (start + 2, 14) +- Code(Expression(0, Sub)) at (prev + 2, 20) to (start + 2, 14) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 3, 9) to (start + 0, 10) + = (c1 + (c0 - c1)) + diff --git a/tests/coverage/async_block.coverage b/tests/coverage/async_block.coverage new file mode 100644 index 00000000000..297397ca26c --- /dev/null +++ b/tests/coverage/async_block.coverage @@ -0,0 +1,37 @@ + LL| |#![feature(coverage_attribute)] + LL| |#![feature(noop_waker)] + LL| |// edition: 2021 + LL| | + LL| 1|fn main() { + LL| 17| for i in 0..16 { + ^16 + LL| 16| let future = async { + LL| 16| if i >= 12 { + LL| 4| println!("big"); + LL| 12| } else { + LL| 12| println!("small"); + LL| 12| } + LL| 16| }; + LL| 16| executor::block_on(future); + LL| 16| } + LL| 1|} + LL| | + LL| |mod executor { + LL| | use core::future::Future; + LL| | use core::pin::pin; + LL| | use core::task::{Context, Poll, Waker}; + LL| | + LL| | #[coverage(off)] + LL| | pub fn block_on<F: Future>(mut future: F) -> F::Output { + LL| | let mut future = pin!(future); + LL| | let waker = Waker::noop(); + LL| | let mut context = Context::from_waker(&waker); + LL| | + LL| | loop { + LL| | if let Poll::Ready(val) = future.as_mut().poll(&mut context) { + LL| | break val; + LL| | } + LL| | } + LL| | } + LL| |} + diff --git a/tests/coverage/async_block.rs b/tests/coverage/async_block.rs new file mode 100644 index 00000000000..9d8647bf1f2 --- /dev/null +++ b/tests/coverage/async_block.rs @@ -0,0 +1,35 @@ +#![feature(coverage_attribute)] +#![feature(noop_waker)] +// edition: 2021 + +fn main() { + for i in 0..16 { + let future = async { + if i >= 12 { + println!("big"); + } else { + println!("small"); + } + }; + executor::block_on(future); + } +} + +mod executor { + use core::future::Future; + use core::pin::pin; + use core::task::{Context, Poll, Waker}; + + #[coverage(off)] + pub fn block_on<F: Future>(mut future: F) -> F::Output { + let mut future = pin!(future); + let waker = Waker::noop(); + let mut context = Context::from_waker(&waker); + + loop { + if let Poll::Ready(val) = future.as_mut().poll(&mut context) { + break val; + } + } + } +} diff --git a/tests/coverage/closure_macro_async.cov-map b/tests/coverage/closure_macro_async.cov-map index 7f8666948d9..14b1525ca0e 100644 --- a/tests/coverage/closure_macro_async.cov-map +++ b/tests/coverage/closure_macro_async.cov-map @@ -1,28 +1,28 @@ Function name: closure_macro_async::load_configuration_files -Raw bytes (9): 0x[01, 01, 00, 01, 01, 1d, 01, 02, 02] +Raw bytes (9): 0x[01, 01, 00, 01, 01, 1e, 01, 02, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 29, 1) to (start + 2, 2) +- Code(Counter(0)) at (prev + 30, 1) to (start + 2, 2) Function name: closure_macro_async::test -Raw bytes (9): 0x[01, 01, 00, 01, 01, 21, 01, 00, 2b] +Raw bytes (9): 0x[01, 01, 00, 01, 01, 22, 01, 00, 2b] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 33, 1) to (start + 0, 43) +- Code(Counter(0)) at (prev + 34, 1) to (start + 0, 43) Function name: closure_macro_async::test::{closure#0} -Raw bytes (43): 0x[01, 01, 02, 01, 05, 05, 02, 07, 01, 21, 2b, 01, 21, 02, 02, 09, 00, 0f, 05, 00, 12, 00, 13, 02, 00, 12, 00, 13, 05, 00, 54, 00, 55, 02, 02, 09, 02, 0b, 07, 03, 01, 00, 02] +Raw bytes (43): 0x[01, 01, 02, 01, 05, 05, 02, 07, 01, 22, 2b, 01, 21, 02, 02, 09, 00, 0f, 05, 00, 12, 00, 13, 02, 00, 12, 00, 13, 05, 00, 54, 00, 55, 02, 02, 09, 02, 0b, 07, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 2 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) - expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 7 -- Code(Counter(0)) at (prev + 33, 43) to (start + 1, 33) +- Code(Counter(0)) at (prev + 34, 43) to (start + 1, 33) - Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 15) = (c0 - c1) - Code(Counter(1)) at (prev + 0, 18) to (start + 0, 19) @@ -35,10 +35,10 @@ Number of file 0 mappings: 7 = (c1 + (c0 - c1)) Function name: closure_macro_async::test::{closure#0}::{closure#0} -Raw bytes (9): 0x[01, 01, 00, 01, 01, 23, 12, 00, 54] +Raw bytes (9): 0x[01, 01, 00, 01, 01, 24, 12, 00, 54] Number of files: 1 - file 0 => global file 1 Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 35, 18) to (start + 0, 84) +- Code(Counter(0)) at (prev + 36, 18) to (start + 0, 84) diff --git a/tests/coverage/closure_macro_async.coverage b/tests/coverage/closure_macro_async.coverage index 74247f1bc6f..2c9bd4ac97a 100644 --- a/tests/coverage/closure_macro_async.coverage +++ b/tests/coverage/closure_macro_async.coverage @@ -1,5 +1,6 @@ - LL| |// compile-flags: --edition=2018 LL| |#![feature(coverage_attribute)] + LL| |#![feature(noop_waker)] + LL| |// edition: 2018 LL| | LL| |macro_rules! bail { LL| | ($msg:literal $(,)?) => { @@ -46,27 +47,14 @@ LL| |} LL| | LL| |mod executor { - LL| | use core::{ - LL| | future::Future, - LL| | pin::Pin, - LL| | task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, - LL| | }; + LL| | use core::future::Future; + LL| | use core::pin::pin; + LL| | use core::task::{Context, Poll, Waker}; LL| | LL| | #[coverage(off)] LL| | pub fn block_on<F: Future>(mut future: F) -> F::Output { - LL| | let mut future = unsafe { Pin::new_unchecked(&mut future) }; - LL| | use std::hint::unreachable_unchecked; - LL| | static VTABLE: RawWakerVTable = RawWakerVTable::new( - LL| | #[coverage(off)] - LL| | |_| unsafe { unreachable_unchecked() }, // clone - LL| | #[coverage(off)] - LL| | |_| unsafe { unreachable_unchecked() }, // wake - LL| | #[coverage(off)] - LL| | |_| unsafe { unreachable_unchecked() }, // wake_by_ref - LL| | #[coverage(off)] - LL| | |_| (), - LL| | ); - LL| | let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; + LL| | let mut future = pin!(future); + LL| | let waker = Waker::noop(); LL| | let mut context = Context::from_waker(&waker); LL| | LL| | loop { diff --git a/tests/coverage/closure_macro_async.rs b/tests/coverage/closure_macro_async.rs index b4275599e59..a7f0cabb4c2 100644 --- a/tests/coverage/closure_macro_async.rs +++ b/tests/coverage/closure_macro_async.rs @@ -1,5 +1,6 @@ -// compile-flags: --edition=2018 #![feature(coverage_attribute)] +#![feature(noop_waker)] +// edition: 2018 macro_rules! bail { ($msg:literal $(,)?) => { @@ -45,27 +46,14 @@ fn main() { } mod executor { - use core::{ - future::Future, - pin::Pin, - task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, - }; + use core::future::Future; + use core::pin::pin; + use core::task::{Context, Poll, Waker}; #[coverage(off)] pub fn block_on<F: Future>(mut future: F) -> F::Output { - let mut future = unsafe { Pin::new_unchecked(&mut future) }; - use std::hint::unreachable_unchecked; - static VTABLE: RawWakerVTable = RawWakerVTable::new( - #[coverage(off)] - |_| unsafe { unreachable_unchecked() }, // clone - #[coverage(off)] - |_| unsafe { unreachable_unchecked() }, // wake - #[coverage(off)] - |_| unsafe { unreachable_unchecked() }, // wake_by_ref - #[coverage(off)] - |_| (), - ); - let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; + let mut future = pin!(future); + let waker = Waker::noop(); let mut context = Context::from_waker(&waker); loop { diff --git a/tests/coverage/no_spans_if_not.cov-map b/tests/coverage/no_spans_if_not.cov-map new file mode 100644 index 00000000000..5277267ec1b --- /dev/null +++ b/tests/coverage/no_spans_if_not.cov-map @@ -0,0 +1,8 @@ +Function name: no_spans_if_not::main +Raw bytes (9): 0x[01, 01, 00, 01, 01, 0b, 01, 02, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 11, 1) to (start + 2, 2) + diff --git a/tests/coverage/no_spans_if_not.coverage b/tests/coverage/no_spans_if_not.coverage new file mode 100644 index 00000000000..1b6bbc75a04 --- /dev/null +++ b/tests/coverage/no_spans_if_not.coverage @@ -0,0 +1,30 @@ + LL| |// edition: 2021 + LL| | + LL| |// If the span extractor can't find any relevant spans for a function, + LL| |// but the function contains coverage span-marker statements (e.g. inserted + LL| |// for `if !`), coverage codegen may think that it is instrumented and + LL| |// consequently complain that it has no spans. + LL| |// + LL| |// Regression test for <https://github.com/rust-lang/rust/issues/118850>, + LL| |// "A used function should have had coverage mapping data but did not". + LL| | + LL| 1|fn main() { + LL| 1| affected_function(); + LL| 1|} + LL| | + LL| |macro_rules! macro_that_defines_a_function { + LL| | (fn $name:ident () $body:tt) => { + LL| | fn $name () $body + LL| | } + LL| |} + LL| | + LL| |macro_that_defines_a_function! { + LL| | fn affected_function() { + LL| | if !false { + LL| | () + LL| | } else { + LL| | () + LL| | } + LL| | } + LL| |} + diff --git a/tests/coverage/no_spans_if_not.rs b/tests/coverage/no_spans_if_not.rs new file mode 100644 index 00000000000..2bbdc11cd5e --- /dev/null +++ b/tests/coverage/no_spans_if_not.rs @@ -0,0 +1,29 @@ +// edition: 2021 + +// If the span extractor can't find any relevant spans for a function, +// but the function contains coverage span-marker statements (e.g. inserted +// for `if !`), coverage codegen may think that it is instrumented and +// consequently complain that it has no spans. +// +// Regression test for <https://github.com/rust-lang/rust/issues/118850>, +// "A used function should have had coverage mapping data but did not". + +fn main() { + affected_function(); +} + +macro_rules! macro_that_defines_a_function { + (fn $name:ident () $body:tt) => { + fn $name () $body + } +} + +macro_that_defines_a_function! { + fn affected_function() { + if !false { + () + } else { + () + } + } +} diff --git a/tests/coverage/partial_eq.cov-map b/tests/coverage/partial_eq.cov-map index 3549116db7a..3a803e3c18f 100644 --- a/tests/coverage/partial_eq.cov-map +++ b/tests/coverage/partial_eq.cov-map @@ -25,18 +25,18 @@ Number of file 0 mappings: 2 - Code(Zero) at (prev + 0, 32) to (start + 0, 33) Function name: <partial_eq::Version as core::cmp::PartialOrd>::partial_cmp -Raw bytes (22): 0x[01, 01, 04, 07, 0b, 05, 09, 0f, 15, 0d, 11, 02, 01, 04, 27, 00, 28, 03, 00, 30, 00, 31] +Raw bytes (22): 0x[01, 01, 04, 07, 0b, 00, 09, 0f, 15, 00, 11, 02, 01, 04, 27, 00, 28, 03, 00, 30, 00, 31] Number of files: 1 - file 0 => global file 1 Number of expressions: 4 - expression 0 operands: lhs = Expression(1, Add), rhs = Expression(2, Add) -- expression 1 operands: lhs = Counter(1), rhs = Counter(2) +- expression 1 operands: lhs = Zero, rhs = Counter(2) - expression 2 operands: lhs = Expression(3, Add), rhs = Counter(5) -- expression 3 operands: lhs = Counter(3), rhs = Counter(4) +- expression 3 operands: lhs = Zero, rhs = Counter(4) Number of file 0 mappings: 2 - Code(Counter(0)) at (prev + 4, 39) to (start + 0, 40) - Code(Expression(0, Add)) at (prev + 0, 48) to (start + 0, 49) - = ((c1 + c2) + ((c3 + c4) + c5)) + = ((Zero + c2) + ((Zero + c4) + c5)) Function name: <partial_eq::Version as core::fmt::Debug>::fmt Raw bytes (9): 0x[01, 01, 00, 01, 01, 04, 11, 00, 16] diff --git a/tests/incremental/hashes/for_loops.rs b/tests/incremental/hashes/for_loops.rs index 98c762e4097..84a04ff913b 100644 --- a/tests/incremental/hashes/for_loops.rs +++ b/tests/incremental/hashes/for_loops.rs @@ -103,9 +103,9 @@ pub fn change_iterable() { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, promoted_mir")] +#[rustc_clean(cfg="cfail2", except="hir_owner_nodes, promoted_mir, optimized_mir")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, promoted_mir")] +#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, promoted_mir, optimized_mir")] #[rustc_clean(cfg="cfail6")] pub fn change_iterable() { let mut _x = 0; diff --git a/tests/incremental/string_constant.rs b/tests/incremental/string_constant.rs index e15a8d18f85..47cd100b136 100644 --- a/tests/incremental/string_constant.rs +++ b/tests/incremental/string_constant.rs @@ -1,5 +1,5 @@ // revisions: cfail1 cfail2 -// compile-flags: -Z query-dep-graph +// compile-flags: -Z query-dep-graph -Copt-level=0 // build-pass (FIXME(62277): could be check-pass?) #![allow(warnings)] diff --git a/tests/incremental/thinlto/cgu_invalidated_via_import.rs b/tests/incremental/thinlto/cgu_invalidated_via_import.rs index 5fe435d796f..a81b4f7e9d0 100644 --- a/tests/incremental/thinlto/cgu_invalidated_via_import.rs +++ b/tests/incremental/thinlto/cgu_invalidated_via_import.rs @@ -4,7 +4,7 @@ // revisions: cfail1 cfail2 cfail3 // compile-flags: -Z query-dep-graph -O -// build-pass (FIXME(62277): could be check-pass?) +// build-pass #![feature(rustc_attrs)] #![crate_type="rlib"] @@ -14,14 +14,14 @@ kind="no")] #![rustc_expected_cgu_reuse(module="cgu_invalidated_via_import-foo", cfg="cfail3", - kind="post-lto")] + kind="pre-lto")] // Should be "post-lto", see issue #119076 #![rustc_expected_cgu_reuse(module="cgu_invalidated_via_import-bar", cfg="cfail2", kind="pre-lto")] #![rustc_expected_cgu_reuse(module="cgu_invalidated_via_import-bar", cfg="cfail3", - kind="post-lto")] + kind="pre-lto")] // Should be "post-lto", see issue #119076 mod foo { diff --git a/tests/incremental/thinlto/cgu_keeps_identical_fn.rs b/tests/incremental/thinlto/cgu_keeps_identical_fn.rs index 368a726ea90..9e840f67ab2 100644 --- a/tests/incremental/thinlto/cgu_keeps_identical_fn.rs +++ b/tests/incremental/thinlto/cgu_keeps_identical_fn.rs @@ -5,25 +5,29 @@ // revisions: cfail1 cfail2 cfail3 // compile-flags: -Z query-dep-graph -O -// build-pass (FIXME(62277): could be check-pass?) +// build-pass #![feature(rustc_attrs)] #![crate_type = "rlib"] -#![rustc_expected_cgu_reuse(module = "cgu_keeps_identical_fn-foo", cfg = "cfail2", kind = "no")] +#![rustc_expected_cgu_reuse( + module = "cgu_keeps_identical_fn-foo", + cfg = "cfail2", + kind = "pre-lto" +)] #![rustc_expected_cgu_reuse( module = "cgu_keeps_identical_fn-foo", cfg = "cfail3", - kind = "post-lto" + kind = "pre-lto" // Should be "post-lto", see issue #119076 )] #![rustc_expected_cgu_reuse( module = "cgu_keeps_identical_fn-bar", cfg = "cfail2", - kind = "post-lto" + kind = "pre-lto" // Should be "post-lto", see issue #119076 )] #![rustc_expected_cgu_reuse( module = "cgu_keeps_identical_fn-bar", cfg = "cfail3", - kind = "post-lto" + kind = "pre-lto" // Should be "post-lto", see issue #119076 )] mod foo { diff --git a/tests/incremental/thinlto/independent_cgus_dont_affect_each_other.rs b/tests/incremental/thinlto/independent_cgus_dont_affect_each_other.rs index 045f2011958..45eb1382874 100644 --- a/tests/incremental/thinlto/independent_cgus_dont_affect_each_other.rs +++ b/tests/incremental/thinlto/independent_cgus_dont_affect_each_other.rs @@ -3,7 +3,7 @@ // revisions: cfail1 cfail2 cfail3 // compile-flags: -Z query-dep-graph -O -// build-pass (FIXME(62277): could be check-pass?) +// build-pass #![feature(rustc_attrs)] #![crate_type="rlib"] @@ -13,21 +13,21 @@ kind="no")] #![rustc_expected_cgu_reuse(module="independent_cgus_dont_affect_each_other-foo", cfg="cfail3", - kind="post-lto")] + kind="pre-lto")] // Should be "post-lto", see issue #119076 #![rustc_expected_cgu_reuse(module="independent_cgus_dont_affect_each_other-bar", cfg="cfail2", kind="pre-lto")] #![rustc_expected_cgu_reuse(module="independent_cgus_dont_affect_each_other-bar", cfg="cfail3", - kind="post-lto")] + kind="pre-lto")] // Should be "post-lto", see issue #119076 #![rustc_expected_cgu_reuse(module="independent_cgus_dont_affect_each_other-baz", cfg="cfail2", - kind="post-lto")] + kind="pre-lto")] // Should be "post-lto", see issue #119076 #![rustc_expected_cgu_reuse(module="independent_cgus_dont_affect_each_other-baz", cfg="cfail3", - kind="post-lto")] + kind="pre-lto")] // Should be "post-lto", see issue #119076 mod foo { #[cfg(cfail1)] diff --git a/tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir b/tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir index 59e27512464..3a9c80caa1e 100644 --- a/tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir +++ b/tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir @@ -11,7 +11,6 @@ CoroutineWitness(DefId(0:4 ~ async_await[ccf8]::a::{closure#0}), []), (), ], - Static, ), source_info: SourceInfo { span: $DIR/async_await.rs:16:5: 16:14 (#9), @@ -29,7 +28,6 @@ CoroutineWitness(DefId(0:4 ~ async_await[ccf8]::a::{closure#0}), []), (), ], - Static, ), source_info: SourceInfo { span: $DIR/async_await.rs:17:5: 17:14 (#11), diff --git a/tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir b/tests/mir-opt/const_allocation.main.GVN.after.32bit.mir index 9cc4c7c4d76..f089c6741fe 100644 --- a/tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir +++ b/tests/mir-opt/const_allocation.main.GVN.after.32bit.mir @@ -1,4 +1,4 @@ -// MIR for `main` after ConstProp +// MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -7,10 +7,10 @@ fn main() -> () { bb0: { StorageLive(_1); - StorageLive(_2); + nop; _2 = const {ALLOC9: &&[(Option<i32>, &[&str])]}; _1 = (*_2); - StorageDead(_2); + nop; StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir b/tests/mir-opt/const_allocation.main.GVN.after.64bit.mir index faa9d20f2d5..9cbbaf302be 100644 --- a/tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir +++ b/tests/mir-opt/const_allocation.main.GVN.after.64bit.mir @@ -1,4 +1,4 @@ -// MIR for `main` after ConstProp +// MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -7,10 +7,10 @@ fn main() -> () { bb0: { StorageLive(_1); - StorageLive(_2); + nop; _2 = const {ALLOC9: &&[(Option<i32>, &[&str])]}; _1 = (*_2); - StorageDead(_2); + nop; StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/const_allocation.rs b/tests/mir-opt/const_allocation.rs index 577c61aeb7d..5b5fb524fdb 100644 --- a/tests/mir-opt/const_allocation.rs +++ b/tests/mir-opt/const_allocation.rs @@ -1,11 +1,11 @@ // skip-filecheck -// unit-test: ConstProp +// unit-test: GVN // ignore-endian-big // EMIT_MIR_FOR_EACH_BIT_WIDTH static FOO: &[(Option<i32>, &[&str])] = &[(None, &[]), (None, &["foo", "bar"]), (Some(42), &["meh", "mop", "möp"])]; -// EMIT_MIR const_allocation.main.ConstProp.after.mir +// EMIT_MIR const_allocation.main.GVN.after.mir fn main() { FOO; } diff --git a/tests/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir b/tests/mir-opt/const_allocation2.main.GVN.after.32bit.mir index 898835b46e4..dfa2d808128 100644 --- a/tests/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir +++ b/tests/mir-opt/const_allocation2.main.GVN.after.32bit.mir @@ -1,4 +1,4 @@ -// MIR for `main` after ConstProp +// MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -7,10 +7,10 @@ fn main() -> () { bb0: { StorageLive(_1); - StorageLive(_2); + nop; _2 = const {ALLOC9: &&[(Option<i32>, &[&u8])]}; _1 = (*_2); - StorageDead(_2); + nop; StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir b/tests/mir-opt/const_allocation2.main.GVN.after.64bit.mir index f5352c2aebb..02b66987169 100644 --- a/tests/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir +++ b/tests/mir-opt/const_allocation2.main.GVN.after.64bit.mir @@ -1,4 +1,4 @@ -// MIR for `main` after ConstProp +// MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -7,10 +7,10 @@ fn main() -> () { bb0: { StorageLive(_1); - StorageLive(_2); + nop; _2 = const {ALLOC9: &&[(Option<i32>, &[&u8])]}; _1 = (*_2); - StorageDead(_2); + nop; StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/const_allocation2.rs b/tests/mir-opt/const_allocation2.rs index 0fcfaad842c..171592889d5 100644 --- a/tests/mir-opt/const_allocation2.rs +++ b/tests/mir-opt/const_allocation2.rs @@ -1,8 +1,8 @@ // skip-filecheck -// unit-test: ConstProp +// unit-test: GVN // ignore-endian-big // EMIT_MIR_FOR_EACH_BIT_WIDTH -// EMIT_MIR const_allocation2.main.ConstProp.after.mir +// EMIT_MIR const_allocation2.main.GVN.after.mir fn main() { FOO; } diff --git a/tests/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir b/tests/mir-opt/const_allocation3.main.GVN.after.32bit.mir index 624047f5b6f..386a55ee6fa 100644 --- a/tests/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir +++ b/tests/mir-opt/const_allocation3.main.GVN.after.32bit.mir @@ -1,4 +1,4 @@ -// MIR for `main` after ConstProp +// MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -7,10 +7,10 @@ fn main() -> () { bb0: { StorageLive(_1); - StorageLive(_2); + nop; _2 = const {ALLOC4: &&Packed}; _1 = (*_2); - StorageDead(_2); + nop; StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/const_allocation3.main.ConstProp.after.64bit.mir b/tests/mir-opt/const_allocation3.main.GVN.after.64bit.mir index cdd4758e153..b9e98f8cd4c 100644 --- a/tests/mir-opt/const_allocation3.main.ConstProp.after.64bit.mir +++ b/tests/mir-opt/const_allocation3.main.GVN.after.64bit.mir @@ -1,4 +1,4 @@ -// MIR for `main` after ConstProp +// MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -7,10 +7,10 @@ fn main() -> () { bb0: { StorageLive(_1); - StorageLive(_2); + nop; _2 = const {ALLOC2: &&Packed}; _1 = (*_2); - StorageDead(_2); + nop; StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/const_allocation3.rs b/tests/mir-opt/const_allocation3.rs index b8c9f50977e..91a30f0587b 100644 --- a/tests/mir-opt/const_allocation3.rs +++ b/tests/mir-opt/const_allocation3.rs @@ -1,8 +1,8 @@ // skip-filecheck -// unit-test: ConstProp +// unit-test: GVN // ignore-endian-big // EMIT_MIR_FOR_EACH_BIT_WIDTH -// EMIT_MIR const_allocation3.main.ConstProp.after.mir +// EMIT_MIR const_allocation3.main.GVN.after.mir fn main() { FOO; } diff --git a/tests/mir-opt/const_debuginfo.main.ConstDebugInfo.diff b/tests/mir-opt/const_debuginfo.main.ConstDebugInfo.diff index 87c07279552..c1529dbee13 100644 --- a/tests/mir-opt/const_debuginfo.main.ConstDebugInfo.diff +++ b/tests/mir-opt/const_debuginfo.main.ConstDebugInfo.diff @@ -34,7 +34,8 @@ debug f => _10; let _11: std::option::Option<u16>; scope 7 { - debug o => _11; +- debug o => _11; ++ debug o => const Option::<u16>::Some(99_u16); let _12: Point; scope 8 { - debug p => _12; @@ -54,11 +55,11 @@ } bb0: { - StorageLive(_1); + nop; _1 = const 1_u8; - StorageLive(_2); + nop; _2 = const 2_u8; - StorageLive(_3); + nop; _3 = const 3_u8; StorageLive(_4); StorageLive(_5); @@ -79,17 +80,17 @@ StorageLive(_10); _10 = (const true, const false, const 123_u32); StorageLive(_11); - _11 = Option::<u16>::Some(const 99_u16); + _11 = const Option::<u16>::Some(99_u16); StorageLive(_12); _12 = const Point {{ x: 32_u32, y: 32_u32 }}; StorageLive(_13); - StorageLive(_14); + nop; _14 = const 32_u32; StorageLive(_15); _15 = const 32_u32; _13 = const 64_u32; StorageDead(_15); - StorageDead(_14); + nop; _0 = const (); StorageDead(_13); StorageDead(_12); @@ -97,9 +98,9 @@ StorageDead(_10); StorageDead(_9); StorageDead(_4); - StorageDead(_3); - StorageDead(_2); - StorageDead(_1); + nop; + nop; + nop; return; } } @@ -108,3 +109,7 @@ 20 00 00 00 20 00 00 00 │ ... ... } + ALLOC1 (size: 4, align: 2) { + 01 00 63 00 │ ..c. + } + diff --git a/tests/mir-opt/const_debuginfo.rs b/tests/mir-opt/const_debuginfo.rs index 0e5ac4b8bd6..db0c5dbb28f 100644 --- a/tests/mir-opt/const_debuginfo.rs +++ b/tests/mir-opt/const_debuginfo.rs @@ -1,5 +1,5 @@ // unit-test: ConstDebugInfo -// compile-flags: -C overflow-checks=no -Zmir-enable-passes=+ConstProp +// compile-flags: -C overflow-checks=no -Zmir-enable-passes=+GVN struct Point { x: u32, @@ -15,7 +15,7 @@ fn main() { // CHECK: debug sum => const 6_u8; // CHECK: debug s => const "hello, world!"; // CHECK: debug f => {{_.*}}; - // CHECK: debug o => {{_.*}}; + // CHECK: debug o => const Option::<u16>::Some(99_u16); // CHECK: debug p => const Point // CHECK: debug a => const 64_u32; let x = 1u8; diff --git a/tests/mir-opt/const_prop/address_of_pair.fn0.ConstProp.diff b/tests/mir-opt/const_prop/address_of_pair.fn0.GVN.diff index 6b96c24d460..2285962fad1 100644 --- a/tests/mir-opt/const_prop/address_of_pair.fn0.ConstProp.diff +++ b/tests/mir-opt/const_prop/address_of_pair.fn0.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `fn0` before ConstProp -+ // MIR for `fn0` after ConstProp +- // MIR for `fn0` before GVN ++ // MIR for `fn0` after GVN fn fn0() -> bool { let mut _0: bool; @@ -23,24 +23,34 @@ bb0: { StorageLive(_2); - _2 = (const 1_i32, const false); - StorageLive(_3); +- _2 = (const 1_i32, const false); +- StorageLive(_3); ++ _2 = const (1_i32, false); ++ nop; _3 = &raw mut (_2.1: bool); - _2 = (const 1_i32, const false); +- _2 = (const 1_i32, const false); ++ _2 = const (1_i32, false); StorageLive(_4); (*_3) = const true; _4 = const (); StorageDead(_4); - StorageLive(_5); +- StorageLive(_5); ++ nop; StorageLive(_6); _6 = (_2.1: bool); _5 = Not(move _6); StorageDead(_6); _0 = _5; - StorageDead(_5); - StorageDead(_3); +- StorageDead(_5); +- StorageDead(_3); ++ nop; ++ nop; StorageDead(_2); return; } ++ } ++ ++ ALLOC0 (size: 8, align: 4) { ++ 01 00 00 00 00 __ __ __ │ .....░░░ } diff --git a/tests/mir-opt/const_prop/address_of_pair.rs b/tests/mir-opt/const_prop/address_of_pair.rs index 730ebe2ca63..1ab8a602823 100644 --- a/tests/mir-opt/const_prop/address_of_pair.rs +++ b/tests/mir-opt/const_prop/address_of_pair.rs @@ -1,6 +1,6 @@ -// unit-test: ConstProp +// unit-test: GVN -// EMIT_MIR address_of_pair.fn0.ConstProp.diff +// EMIT_MIR address_of_pair.fn0.GVN.diff pub fn fn0() -> bool { // CHECK-LABEL: fn fn0( // CHECK: debug pair => [[pair:_.*]]; diff --git a/tests/mir-opt/const_prop/aggregate.foo.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/aggregate.foo.GVN.panic-abort.diff index 5e2db148de8..4f0f7fa8fa2 100644 --- a/tests/mir-opt/const_prop/aggregate.foo.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/aggregate.foo.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `foo` before ConstProp -+ // MIR for `foo` after ConstProp +- // MIR for `foo` before GVN ++ // MIR for `foo` after GVN fn foo(_1: u8) -> () { debug x => _1; @@ -25,7 +25,8 @@ StorageLive(_4); StorageLive(_5); _5 = _1; - _4 = (const 0_i32, move _5); +- _4 = (const 0_i32, move _5); ++ _4 = (const 0_i32, _1); StorageDead(_5); - _3 = (_4.0: i32); - _2 = Add(move _3, const 1_i32); @@ -38,7 +39,8 @@ StorageLive(_8); StorageLive(_9); _9 = _1; - _8 = (move _9, const 1_i32); +- _8 = (move _9, const 1_i32); ++ _8 = (_1, const 1_i32); StorageDead(_9); - _7 = (_8.1: i32); - _6 = Add(move _7, const 2_i32); diff --git a/tests/mir-opt/const_prop/aggregate.foo.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/aggregate.foo.GVN.panic-unwind.diff index 5e2db148de8..4f0f7fa8fa2 100644 --- a/tests/mir-opt/const_prop/aggregate.foo.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/aggregate.foo.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `foo` before ConstProp -+ // MIR for `foo` after ConstProp +- // MIR for `foo` before GVN ++ // MIR for `foo` after GVN fn foo(_1: u8) -> () { debug x => _1; @@ -25,7 +25,8 @@ StorageLive(_4); StorageLive(_5); _5 = _1; - _4 = (const 0_i32, move _5); +- _4 = (const 0_i32, move _5); ++ _4 = (const 0_i32, _1); StorageDead(_5); - _3 = (_4.0: i32); - _2 = Add(move _3, const 1_i32); @@ -38,7 +39,8 @@ StorageLive(_8); StorageLive(_9); _9 = _1; - _8 = (move _9, const 1_i32); +- _8 = (move _9, const 1_i32); ++ _8 = (_1, const 1_i32); StorageDead(_9); - _7 = (_8.1: i32); - _6 = Add(move _7, const 2_i32); diff --git a/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/aggregate.main.GVN.panic-abort.diff index a4911a6d48a..854e27445af 100644 --- a/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/aggregate.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -13,7 +13,8 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; StorageLive(_2); StorageLive(_3); _3 = (const 0_i32, const 1_u8, const 2_i32); @@ -35,7 +36,8 @@ StorageDead(_5); StorageDead(_4); _0 = const (); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/aggregate.main.GVN.panic-unwind.diff index b8b9fa5cc1c..f6c4b2c9240 100644 --- a/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/aggregate.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -13,7 +13,8 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; StorageLive(_2); StorageLive(_3); _3 = (const 0_i32, const 1_u8, const 2_i32); @@ -35,7 +36,8 @@ StorageDead(_5); StorageDead(_4); _0 = const (); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/aggregate.rs b/tests/mir-opt/const_prop/aggregate.rs index fa716b0843d..3dd37b5910e 100644 --- a/tests/mir-opt/const_prop/aggregate.rs +++ b/tests/mir-opt/const_prop/aggregate.rs @@ -1,8 +1,8 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// unit-test: ConstProp +// unit-test: GVN // compile-flags: -O -// EMIT_MIR aggregate.main.ConstProp.diff +// EMIT_MIR aggregate.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => [[x:_.*]]; @@ -15,7 +15,7 @@ fn main() { } // Verify that we still propagate if part of the aggregate is not known. -// EMIT_MIR aggregate.foo.ConstProp.diff +// EMIT_MIR aggregate.foo.GVN.diff fn foo(x: u8) { // CHECK-LABEL: fn foo( // CHECK: debug first => [[first:_.*]]; diff --git a/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/const_prop/array_index.main.GVN.32bit.panic-abort.diff index b2f58f8f771..f9537661e8c 100644 --- a/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/array_index.main.GVN.32bit.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,12 +18,11 @@ _2 = [const 0_u32, const 1_u32, const 2_u32, const 3_u32]; StorageLive(_3); _3 = const 2_usize; -- _4 = Len(_2); + _4 = Len(_2); - _5 = Lt(_3, _4); - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable]; -+ _4 = const 4_usize; -+ _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 4_usize, const 2_usize) -> [success: bb1, unwind unreachable]; ++ _5 = Lt(const 2_usize, _4); ++ assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, const 2_usize) -> [success: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/array_index.main.GVN.32bit.panic-unwind.diff index f9e3f8f171a..07886779fea 100644 --- a/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/array_index.main.GVN.32bit.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,12 +18,11 @@ _2 = [const 0_u32, const 1_u32, const 2_u32, const 3_u32]; StorageLive(_3); _3 = const 2_usize; -- _4 = Len(_2); + _4 = Len(_2); - _5 = Lt(_3, _4); - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; -+ _4 = const 4_usize; -+ _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 4_usize, const 2_usize) -> [success: bb1, unwind continue]; ++ _5 = Lt(const 2_usize, _4); ++ assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, const 2_usize) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/const_prop/array_index.main.GVN.64bit.panic-abort.diff index b2f58f8f771..f9537661e8c 100644 --- a/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/array_index.main.GVN.64bit.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,12 +18,11 @@ _2 = [const 0_u32, const 1_u32, const 2_u32, const 3_u32]; StorageLive(_3); _3 = const 2_usize; -- _4 = Len(_2); + _4 = Len(_2); - _5 = Lt(_3, _4); - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable]; -+ _4 = const 4_usize; -+ _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 4_usize, const 2_usize) -> [success: bb1, unwind unreachable]; ++ _5 = Lt(const 2_usize, _4); ++ assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, const 2_usize) -> [success: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/array_index.main.GVN.64bit.panic-unwind.diff index f9e3f8f171a..07886779fea 100644 --- a/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/array_index.main.GVN.64bit.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,12 +18,11 @@ _2 = [const 0_u32, const 1_u32, const 2_u32, const 3_u32]; StorageLive(_3); _3 = const 2_usize; -- _4 = Len(_2); + _4 = Len(_2); - _5 = Lt(_3, _4); - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; -+ _4 = const 4_usize; -+ _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 4_usize, const 2_usize) -> [success: bb1, unwind continue]; ++ _5 = Lt(const 2_usize, _4); ++ assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, const 2_usize) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/array_index.rs b/tests/mir-opt/const_prop/array_index.rs index c4c46d78f75..2ae5087751f 100644 --- a/tests/mir-opt/const_prop/array_index.rs +++ b/tests/mir-opt/const_prop/array_index.rs @@ -1,8 +1,8 @@ -// unit-test: ConstProp +// unit-test: GVN // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_BIT_WIDTH -// EMIT_MIR array_index.main.ConstProp.diff +// EMIT_MIR array_index.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => [[x:_.*]]; diff --git a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.GVN.panic-abort.diff index cead70110dc..4838efba6f9 100644 --- a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,7 +18,8 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; _1 = const 0_i32; StorageLive(_2); StorageLive(_3); @@ -47,7 +48,8 @@ StorageDead(_3); _0 = const (); StorageDead(_2); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.GVN.panic-unwind.diff index c9c4ba8548c..7f403d6efc1 100644 --- a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,7 +18,8 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; _1 = const 0_i32; StorageLive(_2); StorageLive(_3); @@ -47,7 +48,8 @@ StorageDead(_3); _0 = const (); StorageDead(_2); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/bad_op_div_by_zero.rs b/tests/mir-opt/const_prop/bad_op_div_by_zero.rs index 0e8765a0771..2ba53a80c43 100644 --- a/tests/mir-opt/const_prop/bad_op_div_by_zero.rs +++ b/tests/mir-opt/const_prop/bad_op_div_by_zero.rs @@ -1,7 +1,7 @@ -// unit-test: ConstProp +// unit-test: GVN // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// EMIT_MIR bad_op_div_by_zero.main.ConstProp.diff +// EMIT_MIR bad_op_div_by_zero.main.GVN.diff #[allow(unconditional_panic)] fn main() { // CHECK-LABEL: fn main( diff --git a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.GVN.panic-abort.diff index 2666fd9eb91..59f2eb86f50 100644 --- a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,7 +18,8 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; _1 = const 0_i32; StorageLive(_2); StorageLive(_3); @@ -47,7 +48,8 @@ StorageDead(_3); _0 = const (); StorageDead(_2); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.GVN.panic-unwind.diff index 679df90f16f..9b866082788 100644 --- a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,7 +18,8 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; _1 = const 0_i32; StorageLive(_2); StorageLive(_3); @@ -47,7 +48,8 @@ StorageDead(_3); _0 = const (); StorageDead(_2); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs b/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs index d895d9e2155..9ab57750de0 100644 --- a/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs +++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs @@ -1,7 +1,7 @@ -// unit-test: ConstProp +// unit-test: GVN // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// EMIT_MIR bad_op_mod_by_zero.main.ConstProp.diff +// EMIT_MIR bad_op_mod_by_zero.main.GVN.diff #[allow(unconditional_panic)] fn main() { // CHECK-LABEL: fn main( diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-abort.diff index e443c8991f9..a42f9291324 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -22,15 +22,18 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; StorageLive(_2); - StorageLive(_3); +- StorageLive(_3); ++ nop; _9 = const _; _3 = &(*_9); _2 = &raw const (*_3); _1 = move _2 as *const [i32] (PointerCoercion(Unsize)); StorageDead(_2); - StorageDead(_3); +- StorageDead(_3); ++ nop; StorageLive(_5); StorageLive(_6); _6 = const 3_usize; @@ -47,7 +50,8 @@ StorageDead(_6); _0 = const (); StorageDead(_5); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-unwind.diff index 592f43f4739..f2d6de6621b 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -22,15 +22,18 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; StorageLive(_2); - StorageLive(_3); +- StorageLive(_3); ++ nop; _9 = const _; _3 = &(*_9); _2 = &raw const (*_3); _1 = move _2 as *const [i32] (PointerCoercion(Unsize)); StorageDead(_2); - StorageDead(_3); +- StorageDead(_3); ++ nop; StorageLive(_5); StorageLive(_6); _6 = const 3_usize; @@ -47,7 +50,8 @@ StorageDead(_6); _0 = const (); StorageDead(_5); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-abort.diff index e443c8991f9..a42f9291324 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -22,15 +22,18 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; StorageLive(_2); - StorageLive(_3); +- StorageLive(_3); ++ nop; _9 = const _; _3 = &(*_9); _2 = &raw const (*_3); _1 = move _2 as *const [i32] (PointerCoercion(Unsize)); StorageDead(_2); - StorageDead(_3); +- StorageDead(_3); ++ nop; StorageLive(_5); StorageLive(_6); _6 = const 3_usize; @@ -47,7 +50,8 @@ StorageDead(_6); _0 = const (); StorageDead(_5); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-unwind.diff index 592f43f4739..f2d6de6621b 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -22,15 +22,18 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; StorageLive(_2); - StorageLive(_3); +- StorageLive(_3); ++ nop; _9 = const _; _3 = &(*_9); _2 = &raw const (*_3); _1 = move _2 as *const [i32] (PointerCoercion(Unsize)); StorageDead(_2); - StorageDead(_3); +- StorageDead(_3); ++ nop; StorageLive(_5); StorageLive(_6); _6 = const 3_usize; @@ -47,7 +50,8 @@ StorageDead(_6); _0 = const (); StorageDead(_5); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs index 266105c11f2..c6d63f0bf18 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs @@ -1,8 +1,8 @@ -// unit-test: ConstProp +// unit-test: GVN // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_BIT_WIDTH -// EMIT_MIR bad_op_unsafe_oob_for_slices.main.ConstProp.diff +// EMIT_MIR bad_op_unsafe_oob_for_slices.main.GVN.diff #[allow(unconditional_panic)] fn main() { // CHECK-LABEL: fn main( diff --git a/tests/mir-opt/const_prop/boolean_identities.rs b/tests/mir-opt/const_prop/boolean_identities.rs index 2aa038034d8..f6575ac8e54 100644 --- a/tests/mir-opt/const_prop/boolean_identities.rs +++ b/tests/mir-opt/const_prop/boolean_identities.rs @@ -1,13 +1,14 @@ -// unit-test: ConstProp +// unit-test: GVN -// EMIT_MIR boolean_identities.test.ConstProp.diff +// EMIT_MIR boolean_identities.test.GVN.diff pub fn test(x: bool, y: bool) -> bool { // CHECK-LABEL: fn test( // CHECK: debug a => [[a:_.*]]; // CHECK: debug b => [[b:_.*]]; - // CHECK: [[a]] = const true; - // CHECK: [[b]] = const false; - // CHECK: _0 = const false; + // FIXME(cjgillot) simplify algebraic identity + // CHECK-NOT: [[a]] = const true; + // CHECK-NOT: [[b]] = const false; + // CHECK-NOT: _0 = const false; let a = (y | true); let b = (x & false); a & b diff --git a/tests/mir-opt/const_prop/boolean_identities.test.ConstProp.diff b/tests/mir-opt/const_prop/boolean_identities.test.GVN.diff index 41e1acdff59..eca87af7527 100644 --- a/tests/mir-opt/const_prop/boolean_identities.test.ConstProp.diff +++ b/tests/mir-opt/const_prop/boolean_identities.test.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `test` before ConstProp -+ // MIR for `test` after ConstProp +- // MIR for `test` before GVN ++ // MIR for `test` after GVN fn test(_1: bool, _2: bool) -> bool { debug x => _1; @@ -19,30 +19,32 @@ } bb0: { - StorageLive(_3); +- StorageLive(_3); ++ nop; StorageLive(_4); _4 = _2; - _3 = BitOr(move _4, const true); -+ _3 = const true; ++ _3 = BitOr(_2, const true); StorageDead(_4); - StorageLive(_5); +- StorageLive(_5); ++ nop; StorageLive(_6); _6 = _1; - _5 = BitAnd(move _6, const false); -+ _5 = const false; ++ _5 = BitAnd(_1, const false); StorageDead(_6); StorageLive(_7); -- _7 = _3; -+ _7 = const true; + _7 = _3; StorageLive(_8); -- _8 = _5; + _8 = _5; - _0 = BitAnd(move _7, move _8); -+ _8 = const false; -+ _0 = const false; ++ _0 = BitAnd(_3, _5); StorageDead(_8); StorageDead(_7); - StorageDead(_5); - StorageDead(_3); +- StorageDead(_5); +- StorageDead(_3); ++ nop; ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/boxes.main.GVN.panic-abort.diff index c9670a5ee43..b3fdaa5ee82 100644 --- a/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/boxes.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/boxes.main.GVN.panic-unwind.diff index 64fe72be5c8..d0350c97253 100644 --- a/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/boxes.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/boxes.rs b/tests/mir-opt/const_prop/boxes.rs index 90a8e33e823..5227d7b8b8b 100644 --- a/tests/mir-opt/const_prop/boxes.rs +++ b/tests/mir-opt/const_prop/boxes.rs @@ -1,4 +1,4 @@ -// unit-test: ConstProp +// unit-test: GVN // compile-flags: -O // EMIT_MIR_FOR_EACH_PANIC_STRATEGY @@ -6,7 +6,7 @@ // Note: this test verifies that we, in fact, do not const prop `#[rustc_box]` -// EMIT_MIR boxes.main.ConstProp.diff +// EMIT_MIR boxes.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => [[x:_.*]]; diff --git a/tests/mir-opt/const_prop/cast.main.ConstProp.diff b/tests/mir-opt/const_prop/cast.main.GVN.diff index c63adcf1191..bc442c4e446 100644 --- a/tests/mir-opt/const_prop/cast.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/cast.main.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/cast.rs b/tests/mir-opt/const_prop/cast.rs index b81c2740a73..00a8bcd1adb 100644 --- a/tests/mir-opt/const_prop/cast.rs +++ b/tests/mir-opt/const_prop/cast.rs @@ -1,5 +1,5 @@ -// unit-test: ConstProp -// EMIT_MIR cast.main.ConstProp.diff +// unit-test: GVN +// EMIT_MIR cast.main.GVN.diff fn main() { // CHECK-LABEL: fn main( diff --git a/tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/checked_add.main.GVN.panic-abort.diff index 5a958cc7a47..d5117b2f638 100644 --- a/tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/checked_add.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/checked_add.main.GVN.panic-unwind.diff index ab48186aed9..2118d37672c 100644 --- a/tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/checked_add.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/checked_add.rs b/tests/mir-opt/const_prop/checked_add.rs index 571a5cc4e4d..0abcb5dd3d4 100644 --- a/tests/mir-opt/const_prop/checked_add.rs +++ b/tests/mir-opt/const_prop/checked_add.rs @@ -1,8 +1,8 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// unit-test: ConstProp +// unit-test: GVN // compile-flags: -C overflow-checks=on -// EMIT_MIR checked_add.main.ConstProp.diff +// EMIT_MIR checked_add.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => [[x:_.*]]; diff --git a/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-abort.diff index ba2e89f0a74..803e1d711de 100644 --- a/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `hello` before ConstProp -+ // MIR for `hello` after ConstProp +- // MIR for `hello` before GVN ++ // MIR for `hello` after GVN fn hello() -> () { let mut _0: (); @@ -8,9 +8,8 @@ bb0: { StorageLive(_1); -- _1 = const _; + _1 = const _; - switchInt(move _1) -> [0: bb2, otherwise: bb1]; -+ _1 = const false; + switchInt(const false) -> [0: bb2, otherwise: bb1]; } diff --git a/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-unwind.diff index e0a610f60a7..f40eb38c634 100644 --- a/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `hello` before ConstProp -+ // MIR for `hello` after ConstProp +- // MIR for `hello` before GVN ++ // MIR for `hello` after GVN fn hello() -> () { let mut _0: (); @@ -8,9 +8,8 @@ bb0: { StorageLive(_1); -- _1 = const _; + _1 = const _; - switchInt(move _1) -> [0: bb2, otherwise: bb1]; -+ _1 = const false; + switchInt(const false) -> [0: bb2, otherwise: bb1]; } diff --git a/tests/mir-opt/const_prop/control_flow_simplification.rs b/tests/mir-opt/const_prop/control_flow_simplification.rs index 5fc13e20275..3cb9a4911a9 100644 --- a/tests/mir-opt/const_prop/control_flow_simplification.rs +++ b/tests/mir-opt/const_prop/control_flow_simplification.rs @@ -1,6 +1,6 @@ // skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// unit-test: ConstProp +// unit-test: GVN // compile-flags: -Zmir-opt-level=1 trait NeedsDrop: Sized { @@ -9,7 +9,7 @@ trait NeedsDrop: Sized { impl<This> NeedsDrop for This {} -// EMIT_MIR control_flow_simplification.hello.ConstProp.diff +// EMIT_MIR control_flow_simplification.hello.GVN.diff // EMIT_MIR control_flow_simplification.hello.PreCodegen.before.mir fn hello<T>(){ if <bool>::NEEDS { diff --git a/tests/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff b/tests/mir-opt/const_prop/discriminant.main.GVN.32bit.diff index e02e7f320b8..70c3c3fe7e4 100644 --- a/tests/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/discriminant.main.GVN.32bit.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff b/tests/mir-opt/const_prop/discriminant.main.GVN.64bit.diff index e02e7f320b8..70c3c3fe7e4 100644 --- a/tests/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/discriminant.main.GVN.64bit.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/discriminant.rs b/tests/mir-opt/const_prop/discriminant.rs index 0ed683d629c..53874e9528e 100644 --- a/tests/mir-opt/const_prop/discriminant.rs +++ b/tests/mir-opt/const_prop/discriminant.rs @@ -1,4 +1,4 @@ -// unit-test: ConstProp +// unit-test: GVN // FIXME(wesleywiser): Ideally, we could const-prop away all of this and just be left with // `let x = 42` but that doesn't work because const-prop doesn't support `Operand::Indirect` @@ -6,7 +6,7 @@ // Fixing either of those will allow us to const-prop this away. // EMIT_MIR_FOR_EACH_BIT_WIDTH -// EMIT_MIR discriminant.main.ConstProp.diff +// EMIT_MIR discriminant.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: bb0: { diff --git a/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/indirect.main.GVN.panic-abort.diff index 530cfc6539a..8301a4c1aa8 100644 --- a/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/indirect.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/indirect.main.GVN.panic-unwind.diff index 08cf72e47a9..8dcbfd2c2c1 100644 --- a/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/indirect.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/indirect.rs b/tests/mir-opt/const_prop/indirect.rs index d3c42e3eb0b..d089418e898 100644 --- a/tests/mir-opt/const_prop/indirect.rs +++ b/tests/mir-opt/const_prop/indirect.rs @@ -1,8 +1,8 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// unit-test: ConstProp +// unit-test: GVN // compile-flags: -C overflow-checks=on -// EMIT_MIR indirect.main.ConstProp.diff +// EMIT_MIR indirect.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => [[x:_.*]]; diff --git a/tests/mir-opt/const_prop/indirect_mutation.bar.ConstProp.diff b/tests/mir-opt/const_prop/indirect_mutation.bar.GVN.diff index 4eafb8d0917..7dd80d64360 100644 --- a/tests/mir-opt/const_prop/indirect_mutation.bar.ConstProp.diff +++ b/tests/mir-opt/const_prop/indirect_mutation.bar.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `bar` before ConstProp -+ // MIR for `bar` after ConstProp +- // MIR for `bar` before GVN ++ // MIR for `bar` after GVN fn bar() -> () { let mut _0: (); @@ -19,12 +19,15 @@ bb0: { StorageLive(_1); - _1 = (const 1_i32,); +- _1 = (const 1_i32,); ++ _1 = const (1_i32,); StorageLive(_2); - StorageLive(_3); +- StorageLive(_3); ++ nop; _3 = &raw mut (_1.0: i32); (*_3) = const 5_i32; - StorageDead(_3); +- StorageDead(_3); ++ nop; _2 = const (); StorageDead(_2); StorageLive(_4); diff --git a/tests/mir-opt/const_prop/indirect_mutation.foo.ConstProp.diff b/tests/mir-opt/const_prop/indirect_mutation.foo.GVN.diff index 445d9895d6a..c4b647d9d2d 100644 --- a/tests/mir-opt/const_prop/indirect_mutation.foo.ConstProp.diff +++ b/tests/mir-opt/const_prop/indirect_mutation.foo.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `foo` before ConstProp -+ // MIR for `foo` after ConstProp +- // MIR for `foo` before GVN ++ // MIR for `foo` after GVN fn foo() -> () { let mut _0: (); @@ -16,11 +16,14 @@ bb0: { StorageLive(_1); - _1 = (const 1_i32,); - StorageLive(_2); +- _1 = (const 1_i32,); +- StorageLive(_2); ++ _1 = const (1_i32,); ++ nop; _2 = &mut (_1.0: i32); (*_2) = const 5_i32; - StorageDead(_2); +- StorageDead(_2); ++ nop; StorageLive(_3); StorageLive(_4); _4 = (_1.0: i32); diff --git a/tests/mir-opt/const_prop/indirect_mutation.rs b/tests/mir-opt/const_prop/indirect_mutation.rs index ec9da6e8e5c..a4236060c81 100644 --- a/tests/mir-opt/const_prop/indirect_mutation.rs +++ b/tests/mir-opt/const_prop/indirect_mutation.rs @@ -1,13 +1,13 @@ -// unit-test: ConstProp +// unit-test: GVN // Check that we do not propagate past an indirect mutation. #![feature(raw_ref_op)] -// EMIT_MIR indirect_mutation.foo.ConstProp.diff +// EMIT_MIR indirect_mutation.foo.GVN.diff fn foo() { // CHECK-LABEL: fn foo( // CHECK: debug u => _1; // CHECK: debug y => _3; - // CHECK: _1 = (const 1_i32,); + // CHECK: _1 = const (1_i32,); // CHECK: _2 = &mut (_1.0: i32); // CHECK: (*_2) = const 5_i32; // CHECK: _4 = (_1.0: i32); @@ -18,7 +18,7 @@ fn foo() { let y = { u.0 } == 5; } -// EMIT_MIR indirect_mutation.bar.ConstProp.diff +// EMIT_MIR indirect_mutation.bar.GVN.diff fn bar() { // CHECK-LABEL: fn bar( // CHECK: debug v => _1; diff --git a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-abort.diff index 11cdf9e09db..4c2df228eb8 100644 --- a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-unwind.diff index 181a2f287d6..c4e666b489e 100644 --- a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/inherit_overflow.rs b/tests/mir-opt/const_prop/inherit_overflow.rs index 5b561ae14ad..c5b1dbe37a9 100644 --- a/tests/mir-opt/const_prop/inherit_overflow.rs +++ b/tests/mir-opt/const_prop/inherit_overflow.rs @@ -1,10 +1,10 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// unit-test: ConstProp +// unit-test: GVN // compile-flags: -Zmir-enable-passes=+Inline // After inlining, this will contain a `CheckedBinaryOp`. // Propagating the overflow is ok as codegen will just skip emitting the panic. -// EMIT_MIR inherit_overflow.main.ConstProp.diff +// EMIT_MIR inherit_overflow.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: {{_.*}} = const (0_u8, true); diff --git a/tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff b/tests/mir-opt/const_prop/invalid_constant.main.GVN.diff index 10e978a683a..da5bf1cf42c 100644 --- a/tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/invalid_constant.main.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -35,17 +35,14 @@ StorageLive(_1); StorageLive(_2); _2 = InvalidChar { int: const 1114113_u32 }; -- _1 = (_2.1: char); -+ _1 = const {transmute(0x00110001): char}; + _1 = (_2.1: char); StorageDead(_2); StorageLive(_3); StorageLive(_4); StorageLive(_5); _5 = InvalidTag { int: const 4_u32 }; -- _4 = (_5.1: E); -- _3 = [move _4]; -+ _4 = const Scalar(0x00000004): E; -+ _3 = [const Scalar(0x00000004): E]; + _4 = (_5.1: E); + _3 = [move _4]; StorageDead(_4); StorageDead(_5); nop; diff --git a/tests/mir-opt/const_prop/invalid_constant.rs b/tests/mir-opt/const_prop/invalid_constant.rs index ff6b31a1ee2..142f148d064 100644 --- a/tests/mir-opt/const_prop/invalid_constant.rs +++ b/tests/mir-opt/const_prop/invalid_constant.rs @@ -1,5 +1,5 @@ // skip-filecheck -// unit-test: ConstProp +// unit-test: GVN // compile-flags: -Zmir-enable-passes=+RemoveZsts // Verify that we can pretty print invalid constants. @@ -15,7 +15,7 @@ enum E { A, B, C } enum Empty {} // EMIT_MIR invalid_constant.main.RemoveZsts.diff -// EMIT_MIR invalid_constant.main.ConstProp.diff +// EMIT_MIR invalid_constant.main.GVN.diff fn main() { // An invalid char. union InvalidChar { diff --git a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/issue_66971.main.GVN.panic-abort.diff index ff93c85e586..30e8916e2d0 100644 --- a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/issue_66971.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -11,8 +11,9 @@ StorageLive(_1); StorageLive(_2); StorageLive(_3); - _3 = (); +- _3 = (); - _2 = (move _3, const 0_u8, const 0_u8); ++ _3 = const (); + _2 = const ((), 0_u8, 0_u8); StorageDead(_3); - _1 = encode(move _2) -> [return: bb1, unwind unreachable]; @@ -29,9 +30,5 @@ + + ALLOC0 (size: 2, align: 1) { + 00 00 │ .. -+ } -+ -+ ALLOC1 (size: 2, align: 1) { -+ 00 00 │ .. } diff --git a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/issue_66971.main.GVN.panic-unwind.diff index 8790aad4559..4eb29b174a9 100644 --- a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/issue_66971.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -11,8 +11,9 @@ StorageLive(_1); StorageLive(_2); StorageLive(_3); - _3 = (); +- _3 = (); - _2 = (move _3, const 0_u8, const 0_u8); ++ _3 = const (); + _2 = const ((), 0_u8, 0_u8); StorageDead(_3); - _1 = encode(move _2) -> [return: bb1, unwind continue]; @@ -29,9 +30,5 @@ + + ALLOC0 (size: 2, align: 1) { + 00 00 │ .. -+ } -+ -+ ALLOC1 (size: 2, align: 1) { -+ 00 00 │ .. } diff --git a/tests/mir-opt/const_prop/issue_66971.rs b/tests/mir-opt/const_prop/issue_66971.rs index 49d598ff230..30f8ea1606a 100644 --- a/tests/mir-opt/const_prop/issue_66971.rs +++ b/tests/mir-opt/const_prop/issue_66971.rs @@ -1,8 +1,8 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// unit-test: ConstProp +// unit-test: GVN // Due to a bug in propagating scalar pairs the assertion below used to fail. In the expected -// outputs below, after ConstProp this is how _2 would look like with the bug: +// outputs below, after GVN this is how _2 would look like with the bug: // // _2 = (const Scalar(0x00) : (), const 0u8); // @@ -12,7 +12,7 @@ fn encode(this: ((), u8, u8)) { assert!(this.2 == 0); } -// EMIT_MIR issue_66971.main.ConstProp.diff +// EMIT_MIR issue_66971.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: = encode(const ((), 0_u8, 0_u8)) diff --git a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/issue_67019.main.GVN.panic-abort.diff index 3de9cdd79bc..fc0c8afd4cf 100644 --- a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/issue_67019.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/issue_67019.main.GVN.panic-unwind.diff index 72cf48b5cba..cf4089598e7 100644 --- a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/issue_67019.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/issue_67019.rs b/tests/mir-opt/const_prop/issue_67019.rs index f0a09e6e852..e589ed4edcc 100644 --- a/tests/mir-opt/const_prop/issue_67019.rs +++ b/tests/mir-opt/const_prop/issue_67019.rs @@ -1,5 +1,5 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// unit-test: ConstProp +// unit-test: GVN // This used to ICE in const-prop @@ -7,7 +7,7 @@ fn test(this: ((u8, u8),)) { assert!((this.0).0 == 1); } -// EMIT_MIR issue_67019.main.ConstProp.diff +// EMIT_MIR issue_67019.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: = test(const ((1_u8, 2_u8),)) diff --git a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/const_prop/large_array_index.main.GVN.32bit.panic-abort.diff index 20e2ee32698..cf36109fdcb 100644 --- a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/large_array_index.main.GVN.32bit.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,17 +18,16 @@ _2 = [const 0_u8; 5000]; StorageLive(_3); _3 = const 2_usize; -- _4 = Len(_2); + _4 = Len(_2); - _5 = Lt(_3, _4); - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable]; -+ _4 = const 5000_usize; -+ _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 5000_usize, const 2_usize) -> [success: bb1, unwind unreachable]; ++ _5 = Lt(const 2_usize, _4); ++ assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, const 2_usize) -> [success: bb1, unwind unreachable]; } bb1: { - _1 = _2[_3]; -+ _1 = _2[2 of 3]; ++ _1 = const 0_u8; StorageDead(_3); StorageDead(_2); _0 = const (); diff --git a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/large_array_index.main.GVN.32bit.panic-unwind.diff index 1bdbbbf7863..40ed9697180 100644 --- a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/large_array_index.main.GVN.32bit.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,17 +18,16 @@ _2 = [const 0_u8; 5000]; StorageLive(_3); _3 = const 2_usize; -- _4 = Len(_2); + _4 = Len(_2); - _5 = Lt(_3, _4); - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; -+ _4 = const 5000_usize; -+ _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 5000_usize, const 2_usize) -> [success: bb1, unwind continue]; ++ _5 = Lt(const 2_usize, _4); ++ assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, const 2_usize) -> [success: bb1, unwind continue]; } bb1: { - _1 = _2[_3]; -+ _1 = _2[2 of 3]; ++ _1 = const 0_u8; StorageDead(_3); StorageDead(_2); _0 = const (); diff --git a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/const_prop/large_array_index.main.GVN.64bit.panic-abort.diff index 20e2ee32698..cf36109fdcb 100644 --- a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/large_array_index.main.GVN.64bit.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,17 +18,16 @@ _2 = [const 0_u8; 5000]; StorageLive(_3); _3 = const 2_usize; -- _4 = Len(_2); + _4 = Len(_2); - _5 = Lt(_3, _4); - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable]; -+ _4 = const 5000_usize; -+ _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 5000_usize, const 2_usize) -> [success: bb1, unwind unreachable]; ++ _5 = Lt(const 2_usize, _4); ++ assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, const 2_usize) -> [success: bb1, unwind unreachable]; } bb1: { - _1 = _2[_3]; -+ _1 = _2[2 of 3]; ++ _1 = const 0_u8; StorageDead(_3); StorageDead(_2); _0 = const (); diff --git a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/large_array_index.main.GVN.64bit.panic-unwind.diff index 1bdbbbf7863..40ed9697180 100644 --- a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/large_array_index.main.GVN.64bit.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,17 +18,16 @@ _2 = [const 0_u8; 5000]; StorageLive(_3); _3 = const 2_usize; -- _4 = Len(_2); + _4 = Len(_2); - _5 = Lt(_3, _4); - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; -+ _4 = const 5000_usize; -+ _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 5000_usize, const 2_usize) -> [success: bb1, unwind continue]; ++ _5 = Lt(const 2_usize, _4); ++ assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, const 2_usize) -> [success: bb1, unwind continue]; } bb1: { - _1 = _2[_3]; -+ _1 = _2[2 of 3]; ++ _1 = const 0_u8; StorageDead(_3); StorageDead(_2); _0 = const (); diff --git a/tests/mir-opt/const_prop/large_array_index.rs b/tests/mir-opt/const_prop/large_array_index.rs index d98d166ff7c..12507b9434f 100644 --- a/tests/mir-opt/const_prop/large_array_index.rs +++ b/tests/mir-opt/const_prop/large_array_index.rs @@ -1,9 +1,9 @@ // skip-filecheck -// unit-test: ConstProp +// unit-test: GVN // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_BIT_WIDTH -// EMIT_MIR large_array_index.main.ConstProp.diff +// EMIT_MIR large_array_index.main.GVN.diff fn main() { // check that we don't propagate this, because it's too large let x: u8 = [0_u8; 5000][2]; diff --git a/tests/mir-opt/const_prop/mult_by_zero.rs b/tests/mir-opt/const_prop/mult_by_zero.rs index 2e9c63a1ca1..2fdb75c3100 100644 --- a/tests/mir-opt/const_prop/mult_by_zero.rs +++ b/tests/mir-opt/const_prop/mult_by_zero.rs @@ -1,9 +1,10 @@ -// unit-test: ConstProp +// unit-test: GVN -// EMIT_MIR mult_by_zero.test.ConstProp.diff +// EMIT_MIR mult_by_zero.test.GVN.diff fn test(x: i32) -> i32 { // CHECK: fn test( - // CHECK: _0 = const 0_i32; + // FIXME(cjgillot) simplify algebraic identity + // CHECK-NOT: _0 = const 0_i32; x * 0 } diff --git a/tests/mir-opt/const_prop/mult_by_zero.test.ConstProp.diff b/tests/mir-opt/const_prop/mult_by_zero.test.GVN.diff index 73b1da06423..e9fb34749c1 100644 --- a/tests/mir-opt/const_prop/mult_by_zero.test.ConstProp.diff +++ b/tests/mir-opt/const_prop/mult_by_zero.test.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `test` before ConstProp -+ // MIR for `test` after ConstProp +- // MIR for `test` before GVN ++ // MIR for `test` after GVN fn test(_1: i32) -> i32 { debug x => _1; @@ -10,7 +10,7 @@ StorageLive(_2); _2 = _1; - _0 = Mul(move _2, const 0_i32); -+ _0 = const 0_i32; ++ _0 = Mul(_1, const 0_i32); StorageDead(_2); return; } diff --git a/tests/mir-opt/const_prop/mutable_variable.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable.main.GVN.diff index ad8d9ddb074..11464e32400 100644 --- a/tests/mir-opt/const_prop/mutable_variable.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable.main.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -17,8 +17,7 @@ _1 = const 42_i32; _1 = const 99_i32; StorageLive(_2); -- _2 = _1; -+ _2 = const 99_i32; + _2 = _1; _0 = const (); StorageDead(_2); StorageDead(_1); diff --git a/tests/mir-opt/const_prop/mutable_variable.rs b/tests/mir-opt/const_prop/mutable_variable.rs index 6c74ea5b9f4..194f39f826e 100644 --- a/tests/mir-opt/const_prop/mutable_variable.rs +++ b/tests/mir-opt/const_prop/mutable_variable.rs @@ -1,13 +1,13 @@ -// unit-test: ConstProp +// unit-test: GVN -// EMIT_MIR mutable_variable.main.ConstProp.diff +// EMIT_MIR mutable_variable.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => [[x:_.*]]; // CHECK: debug y => [[y:_.*]]; // CHECK: [[x]] = const 42_i32; // CHECK: [[x]] = const 99_i32; - // CHECK: [[y]] = const 99_i32; + // CHECK: [[y]] = [[x]]; let mut x = 42; x = 99; let y = x; diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_aggregate.main.GVN.diff index c3ace9687e6..b6ff7b0fc23 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate.main.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,8 +18,7 @@ + _1 = const (42_i32, 43_i32); (_1.1: i32) = const 99_i32; StorageLive(_2); -- _2 = _1; -+ _2 = const (42_i32, 99_i32); + _2 = _1; _0 = const (); StorageDead(_2); StorageDead(_1); @@ -28,10 +27,6 @@ + } + + ALLOC0 (size: 8, align: 4) { -+ 2a 00 00 00 63 00 00 00 │ *...c... -+ } -+ -+ ALLOC1 (size: 8, align: 4) { + 2a 00 00 00 2b 00 00 00 │ *...+... } diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate.rs b/tests/mir-opt/const_prop/mutable_variable_aggregate.rs index a3829650290..b59132007aa 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate.rs +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate.rs @@ -1,13 +1,13 @@ -// unit-test: ConstProp +// unit-test: GVN -// EMIT_MIR mutable_variable_aggregate.main.ConstProp.diff +// EMIT_MIR mutable_variable_aggregate.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => [[x:_.*]]; // CHECK: debug y => [[y:_.*]]; // CHECK: [[x]] = const (42_i32, 43_i32); // CHECK: ([[x]].1: i32) = const 99_i32; - // CHECK: [[y]] = const (42_i32, 99_i32); + // CHECK: [[y]] = [[x]]; let mut x = (42, 43); x.1 = 99; let y = x; diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.GVN.diff index 106e27f8f27..bc60546cd19 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,17 +18,24 @@ bb0: { StorageLive(_1); - _1 = (const 42_i32, const 43_i32); - StorageLive(_2); +- _1 = (const 42_i32, const 43_i32); +- StorageLive(_2); ++ _1 = const (42_i32, 43_i32); ++ nop; _2 = &mut _1; ((*_2).1: i32) = const 99_i32; StorageLive(_3); _3 = _1; _0 = const (); StorageDead(_3); - StorageDead(_2); +- StorageDead(_2); ++ nop; StorageDead(_1); return; } ++ } ++ ++ ALLOC0 (size: 8, align: 4) { ++ 2a 00 00 00 2b 00 00 00 │ *...+... } diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs index 60f414ae286..1867f7300bd 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs @@ -1,12 +1,12 @@ -// unit-test: ConstProp +// unit-test: GVN -// EMIT_MIR mutable_variable_aggregate_mut_ref.main.ConstProp.diff +// EMIT_MIR mutable_variable_aggregate_mut_ref.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => [[x:_.*]]; // CHECK: debug z => [[z:_.*]]; // CHECK: debug y => [[y:_.*]]; - // CHECK: [[x]] = (const 42_i32, const 43_i32); + // CHECK: [[x]] = const (42_i32, 43_i32); // CHECK: [[z]] = &mut [[x]]; // CHECK: ((*[[z]]).1: i32) = const 99_i32; // CHECK: [[y]] = [[x]]; diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.GVN.panic-abort.diff index 34288c62fee..6480e480f8c 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -21,8 +21,7 @@ (_1.1: i32) = const 99_i32; (_1.0: i32) = const 42_i32; StorageLive(_2); -- _2 = (_1.1: i32); -+ _2 = const 99_i32; + _2 = (_1.1: i32); _0 = const (); StorageDead(_2); StorageDead(_1); diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.GVN.panic-unwind.diff index 7ba2b483dc3..fb757801082 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -21,8 +21,7 @@ (_1.1: i32) = const 99_i32; (_1.0: i32) = const 42_i32; StorageLive(_2); -- _2 = (_1.1: i32); -+ _2 = const 99_i32; + _2 = (_1.1: i32); _0 = const (); StorageDead(_2); StorageDead(_1); diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs index 888fcde2de6..d0a44d8f4a0 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs @@ -1,7 +1,7 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// unit-test: ConstProp +// unit-test: GVN -// EMIT_MIR mutable_variable_aggregate_partial_read.main.ConstProp.diff +// EMIT_MIR mutable_variable_aggregate_partial_read.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => [[x:_.*]]; @@ -9,7 +9,7 @@ fn main() { // CHECK: [[x]] = foo() // CHECK: ([[x]].1: i32) = const 99_i32; // CHECK: ([[x]].0: i32) = const 42_i32; - // CHECK: [[y]] = const 99_i32; + // CHECK: [[y]] = ([[x]].1: i32); let mut x: (i32, i32) = foo(); x.1 = 99; x.0 = 42; diff --git a/tests/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_no_prop.main.GVN.diff index 1f74bdcfd03..d02c392f6bd 100644 --- a/tests/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable_no_prop.main.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -22,12 +22,14 @@ _1 = const 42_u32; StorageLive(_2); StorageLive(_3); - StorageLive(_4); +- StorageLive(_4); ++ nop; _4 = const {ALLOC0: *mut u32}; _3 = (*_4); _1 = move _3; StorageDead(_3); - StorageDead(_4); +- StorageDead(_4); ++ nop; _2 = const (); StorageDead(_2); StorageLive(_5); diff --git a/tests/mir-opt/const_prop/mutable_variable_no_prop.rs b/tests/mir-opt/const_prop/mutable_variable_no_prop.rs index 49e9a701581..180e194928e 100644 --- a/tests/mir-opt/const_prop/mutable_variable_no_prop.rs +++ b/tests/mir-opt/const_prop/mutable_variable_no_prop.rs @@ -1,9 +1,9 @@ -// unit-test: ConstProp +// unit-test: GVN // Verify that we do not propagate the contents of this mutable static. static mut STATIC: u32 = 0x42424242; -// EMIT_MIR mutable_variable_no_prop.main.ConstProp.diff +// EMIT_MIR mutable_variable_no_prop.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => [[x:_.*]]; diff --git a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.GVN.panic-abort.diff index 85bd2b6e722..d1d23675bfd 100644 --- a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -22,7 +22,8 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; _1 = foo() -> [return: bb1, unwind unreachable]; } @@ -32,18 +33,19 @@ + _2 = const (1_i32, 2_i32); StorageLive(_3); _3 = _1; - (_2.1: i32) = move _3; +- (_2.1: i32) = move _3; ++ (_2.1: i32) = _1; StorageDead(_3); StorageLive(_4); _4 = (_2.1: i32); StorageLive(_5); -- _5 = (_2.0: i32); -+ _5 = const 1_i32; + _5 = (_2.0: i32); _0 = const (); StorageDead(_5); StorageDead(_4); StorageDead(_2); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } + } diff --git a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.GVN.panic-unwind.diff index 06e96e57a62..4d69c9ce2ef 100644 --- a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -22,7 +22,8 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; _1 = foo() -> [return: bb1, unwind continue]; } @@ -32,18 +33,19 @@ + _2 = const (1_i32, 2_i32); StorageLive(_3); _3 = _1; - (_2.1: i32) = move _3; +- (_2.1: i32) = move _3; ++ (_2.1: i32) = _1; StorageDead(_3); StorageLive(_4); _4 = (_2.1: i32); StorageLive(_5); -- _5 = (_2.0: i32); -+ _5 = const 1_i32; + _5 = (_2.0: i32); _0 = const (); StorageDead(_5); StorageDead(_4); StorageDead(_2); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } + } diff --git a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs index 04e347fc03d..585363572a5 100644 --- a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs +++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs @@ -1,7 +1,7 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// unit-test: ConstProp +// unit-test: GVN -// EMIT_MIR mutable_variable_unprop_assign.main.ConstProp.diff +// EMIT_MIR mutable_variable_unprop_assign.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug a => [[a:_.*]]; @@ -10,10 +10,9 @@ fn main() { // CHECK: debug z => [[z:_.*]]; // CHECK: [[a]] = foo() // CHECK: [[x]] = const (1_i32, 2_i32); - // CHECK: [[tmp:_.*]] = [[a]]; - // CHECK: ([[x]].1: i32) = move [[tmp]]; + // CHECK: ([[x]].1: i32) = [[a]]; // CHECK: [[y]] = ([[x]].1: i32); - // CHECK: [[z]] = const 1_i32; + // CHECK: [[z]] = ([[x]].0: i32); let a = foo(); let mut x: (i32, i32) = (1, 2); x.1 = a; diff --git a/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/offset_of.concrete.GVN.panic-abort.diff index 711db3d21dd..5d94797905d 100644 --- a/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/offset_of.concrete.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `concrete` before ConstProp -+ // MIR for `concrete` after ConstProp +- // MIR for `concrete` before GVN ++ // MIR for `concrete` after GVN fn concrete() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/offset_of.concrete.GVN.panic-unwind.diff index 49458145415..4d890742ee9 100644 --- a/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/offset_of.concrete.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `concrete` before ConstProp -+ // MIR for `concrete` after ConstProp +- // MIR for `concrete` before GVN ++ // MIR for `concrete` after GVN fn concrete() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/offset_of.generic.GVN.panic-abort.diff index 768970a7250..025241dd1bf 100644 --- a/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/offset_of.generic.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `generic` before ConstProp -+ // MIR for `generic` after ConstProp +- // MIR for `generic` before GVN ++ // MIR for `generic` after GVN fn generic() -> () { let mut _0: (); @@ -58,16 +58,20 @@ StorageDead(_4); StorageLive(_5); StorageLive(_6); - _6 = OffsetOf(Delta<T>, [(0, 1)]); - _5 = must_use::<usize>(move _6) -> [return: bb3, unwind unreachable]; +- _6 = OffsetOf(Delta<T>, [(0, 1)]); +- _5 = must_use::<usize>(move _6) -> [return: bb3, unwind unreachable]; ++ _6 = const 0_usize; ++ _5 = must_use::<usize>(const 0_usize) -> [return: bb3, unwind unreachable]; } bb3: { StorageDead(_6); StorageLive(_7); StorageLive(_8); - _8 = OffsetOf(Delta<T>, [(0, 2)]); - _7 = must_use::<usize>(move _8) -> [return: bb4, unwind unreachable]; +- _8 = OffsetOf(Delta<T>, [(0, 2)]); +- _7 = must_use::<usize>(move _8) -> [return: bb4, unwind unreachable]; ++ _8 = const 2_usize; ++ _7 = must_use::<usize>(const 2_usize) -> [return: bb4, unwind unreachable]; } bb4: { diff --git a/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/offset_of.generic.GVN.panic-unwind.diff index 04ccd2b36e0..27f2b2f7355 100644 --- a/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/offset_of.generic.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `generic` before ConstProp -+ // MIR for `generic` after ConstProp +- // MIR for `generic` before GVN ++ // MIR for `generic` after GVN fn generic() -> () { let mut _0: (); @@ -58,16 +58,20 @@ StorageDead(_4); StorageLive(_5); StorageLive(_6); - _6 = OffsetOf(Delta<T>, [(0, 1)]); - _5 = must_use::<usize>(move _6) -> [return: bb3, unwind continue]; +- _6 = OffsetOf(Delta<T>, [(0, 1)]); +- _5 = must_use::<usize>(move _6) -> [return: bb3, unwind continue]; ++ _6 = const 0_usize; ++ _5 = must_use::<usize>(const 0_usize) -> [return: bb3, unwind continue]; } bb3: { StorageDead(_6); StorageLive(_7); StorageLive(_8); - _8 = OffsetOf(Delta<T>, [(0, 2)]); - _7 = must_use::<usize>(move _8) -> [return: bb4, unwind continue]; +- _8 = OffsetOf(Delta<T>, [(0, 2)]); +- _7 = must_use::<usize>(move _8) -> [return: bb4, unwind continue]; ++ _8 = const 2_usize; ++ _7 = must_use::<usize>(const 2_usize) -> [return: bb4, unwind continue]; } bb4: { diff --git a/tests/mir-opt/const_prop/offset_of.rs b/tests/mir-opt/const_prop/offset_of.rs index 2571c3856f4..43ecbbed186 100644 --- a/tests/mir-opt/const_prop/offset_of.rs +++ b/tests/mir-opt/const_prop/offset_of.rs @@ -1,5 +1,5 @@ // skip-filecheck -// unit-test: ConstProp +// unit-test: GVN // EMIT_MIR_FOR_EACH_PANIC_STRATEGY #![feature(offset_of, offset_of_enum)] @@ -39,7 +39,7 @@ enum Zeta<T> { B(char), } -// EMIT_MIR offset_of.concrete.ConstProp.diff +// EMIT_MIR offset_of.concrete.GVN.diff fn concrete() { let x = offset_of!(Alpha, x); let y = offset_of!(Alpha, y); @@ -50,7 +50,7 @@ fn concrete() { let eC = offset_of!(Epsilon, C.c); } -// EMIT_MIR offset_of.generic.ConstProp.diff +// EMIT_MIR offset_of.generic.GVN.diff fn generic<T>() { let gx = offset_of!(Gamma<T>, x); let gy = offset_of!(Gamma<T>, y); diff --git a/tests/mir-opt/const_prop/overwrite_with_const_with_params.rs b/tests/mir-opt/const_prop/overwrite_with_const_with_params.rs index 4cf6d7c1396..2a3499bf2fe 100644 --- a/tests/mir-opt/const_prop/overwrite_with_const_with_params.rs +++ b/tests/mir-opt/const_prop/overwrite_with_const_with_params.rs @@ -1,4 +1,4 @@ -// unit-test: ConstProp +// unit-test: GVN // compile-flags: -O // Regression test for https://github.com/rust-lang/rust/issues/118328 @@ -10,7 +10,7 @@ impl<T> SizeOfConst<T> { const SIZE: usize = std::mem::size_of::<T>(); } -// EMIT_MIR overwrite_with_const_with_params.size_of.ConstProp.diff +// EMIT_MIR overwrite_with_const_with_params.size_of.GVN.diff fn size_of<T>() -> usize { // CHECK-LABEL: fn size_of( // CHECK: _1 = const 0_usize; diff --git a/tests/mir-opt/const_prop/overwrite_with_const_with_params.size_of.ConstProp.diff b/tests/mir-opt/const_prop/overwrite_with_const_with_params.size_of.GVN.diff index ad8318832d6..caa78b7316e 100644 --- a/tests/mir-opt/const_prop/overwrite_with_const_with_params.size_of.ConstProp.diff +++ b/tests/mir-opt/const_prop/overwrite_with_const_with_params.size_of.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `size_of` before ConstProp -+ // MIR for `size_of` after ConstProp +- // MIR for `size_of` before GVN ++ // MIR for `size_of` after GVN fn size_of() -> usize { let mut _0: usize; diff --git a/tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-abort.diff index bd1de7476a2..425bc3ff6c1 100644 --- a/tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -13,25 +13,30 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; StorageLive(_2); - StorageLive(_3); +- StorageLive(_3); ++ nop; _3 = const _; _2 = &raw const (*_3); _1 = move _2 as usize (PointerExposeAddress); StorageDead(_2); - StorageDead(_3); +- StorageDead(_3); ++ nop; StorageLive(_4); StorageLive(_5); _5 = _1; - _4 = read(move _5) -> [return: bb1, unwind unreachable]; +- _4 = read(move _5) -> [return: bb1, unwind unreachable]; ++ _4 = read(_1) -> [return: bb1, unwind unreachable]; } bb1: { StorageDead(_5); StorageDead(_4); _0 = const (); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-unwind.diff index 850b743feb1..e9360ab8d62 100644 --- a/tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -13,25 +13,30 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; StorageLive(_2); - StorageLive(_3); +- StorageLive(_3); ++ nop; _3 = const _; _2 = &raw const (*_3); _1 = move _2 as usize (PointerExposeAddress); StorageDead(_2); - StorageDead(_3); +- StorageDead(_3); ++ nop; StorageLive(_4); StorageLive(_5); _5 = _1; - _4 = read(move _5) -> [return: bb1, unwind continue]; +- _4 = read(move _5) -> [return: bb1, unwind continue]; ++ _4 = read(_1) -> [return: bb1, unwind continue]; } bb1: { StorageDead(_5); StorageDead(_4); _0 = const (); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/pointer_expose_address.rs b/tests/mir-opt/const_prop/pointer_expose_address.rs index 631aac901b9..8944232f71e 100644 --- a/tests/mir-opt/const_prop/pointer_expose_address.rs +++ b/tests/mir-opt/const_prop/pointer_expose_address.rs @@ -1,17 +1,16 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// unit-test: ConstProp +// unit-test: GVN #[inline(never)] fn read(_: usize) { } -// EMIT_MIR pointer_expose_address.main.ConstProp.diff +// EMIT_MIR pointer_expose_address.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: [[ptr:_.*]] = const _; // CHECK: [[ref:_.*]] = &raw const (*[[ptr]]); // CHECK: [[x:_.*]] = move [[ref]] as usize (PointerExposeAddress); - // CHECK: [[arg:_.*]] = [[x]]; - // CHECK: = read(move [[arg]]) + // CHECK: = read([[x]]) const FOO: &i32 = &1; let x = FOO as *const i32 as usize; read(x); diff --git a/tests/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff b/tests/mir-opt/const_prop/read_immutable_static.main.GVN.diff index e193c82d2c0..38f23505230 100644 --- a/tests/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/read_immutable_static.main.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -14,8 +14,10 @@ bb0: { StorageLive(_1); - StorageLive(_2); - StorageLive(_3); +- StorageLive(_2); +- StorageLive(_3); ++ nop; ++ nop; _3 = const {ALLOC0: &u8}; - _2 = (*_3); + _2 = const 2_u8; @@ -27,9 +29,11 @@ + _4 = const 2_u8; + _1 = const 4_u8; StorageDead(_4); - StorageDead(_2); +- StorageDead(_2); ++ nop; StorageDead(_5); - StorageDead(_3); +- StorageDead(_3); ++ nop; _0 = const (); StorageDead(_1); return; diff --git a/tests/mir-opt/const_prop/read_immutable_static.rs b/tests/mir-opt/const_prop/read_immutable_static.rs index 0fa18dd101a..a3d8fee65d7 100644 --- a/tests/mir-opt/const_prop/read_immutable_static.rs +++ b/tests/mir-opt/const_prop/read_immutable_static.rs @@ -1,8 +1,8 @@ -// unit-test: ConstProp +// unit-test: GVN static FOO: u8 = 2; -// EMIT_MIR read_immutable_static.main.ConstProp.diff +// EMIT_MIR read_immutable_static.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => [[x:_.*]]; diff --git a/tests/mir-opt/const_prop/ref_deref.main.ConstProp.diff b/tests/mir-opt/const_prop/ref_deref.main.GVN.diff index a54ae8d2fdd..8f9aa20524d 100644 --- a/tests/mir-opt/const_prop/ref_deref.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/ref_deref.main.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -13,11 +13,14 @@ bb0: { StorageLive(_1); - StorageLive(_2); +- StorageLive(_2); ++ nop; _4 = const _; _2 = &(*_4); - _1 = (*_2); - StorageDead(_2); +- _1 = (*_2); +- StorageDead(_2); ++ _1 = const 4_i32; ++ nop; _0 = const (); StorageDead(_1); return; diff --git a/tests/mir-opt/const_prop/ref_deref.rs b/tests/mir-opt/const_prop/ref_deref.rs index 5bceae749ff..67de110d8bb 100644 --- a/tests/mir-opt/const_prop/ref_deref.rs +++ b/tests/mir-opt/const_prop/ref_deref.rs @@ -1,9 +1,9 @@ -// unit-test: ConstProp +// unit-test: GVN -// EMIT_MIR ref_deref.main.ConstProp.diff +// EMIT_MIR ref_deref.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug a => [[a:_.*]]; - // CHECK: [[a]] = (*{{_.*}}); + // CHECK: [[a]] = const 4_i32; let a = *(&4); } diff --git a/tests/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff b/tests/mir-opt/const_prop/ref_deref_project.main.GVN.diff index 05a4e17742d..8d38888b7d6 100644 --- a/tests/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/ref_deref_project.main.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -13,11 +13,14 @@ bb0: { StorageLive(_1); - StorageLive(_2); +- StorageLive(_2); ++ nop; _4 = const _; _2 = &((*_4).1: i32); - _1 = (*_2); - StorageDead(_2); +- _1 = (*_2); +- StorageDead(_2); ++ _1 = const 5_i32; ++ nop; _0 = const (); StorageDead(_1); return; diff --git a/tests/mir-opt/const_prop/ref_deref_project.rs b/tests/mir-opt/const_prop/ref_deref_project.rs index 4b5c6730316..0f706b91b38 100644 --- a/tests/mir-opt/const_prop/ref_deref_project.rs +++ b/tests/mir-opt/const_prop/ref_deref_project.rs @@ -1,10 +1,10 @@ // This does not currently propagate (#67862) -// unit-test: ConstProp +// unit-test: GVN -// EMIT_MIR ref_deref_project.main.ConstProp.diff +// EMIT_MIR ref_deref_project.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug a => [[a:_.*]]; - // CHECK: [[a]] = (*{{_.*}}); + // CHECK: [[a]] = const 5_i32; let a = *(&(4, 5).1); } diff --git a/tests/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff b/tests/mir-opt/const_prop/reify_fn_ptr.main.GVN.diff index e7aa015d078..cde0cb32f75 100644 --- a/tests/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/reify_fn_ptr.main.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/reify_fn_ptr.rs b/tests/mir-opt/const_prop/reify_fn_ptr.rs index 33fdd4142c1..96077d5b773 100644 --- a/tests/mir-opt/const_prop/reify_fn_ptr.rs +++ b/tests/mir-opt/const_prop/reify_fn_ptr.rs @@ -1,5 +1,5 @@ -// unit-test: ConstProp -// EMIT_MIR reify_fn_ptr.main.ConstProp.diff +// unit-test: GVN +// EMIT_MIR reify_fn_ptr.main.GVN.diff fn main() { // CHECK-LABEL: fn main( diff --git a/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/const_prop/repeat.main.GVN.32bit.panic-abort.diff index a55bd029e99..a52e6e35483 100644 --- a/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/repeat.main.GVN.32bit.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -20,12 +20,11 @@ _3 = [const 42_u32; 8]; StorageLive(_4); _4 = const 2_usize; -- _5 = Len(_3); + _5 = Len(_3); - _6 = Lt(_4, _5); - assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind unreachable]; -+ _5 = const 8_usize; -+ _6 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 8_usize, const 2_usize) -> [success: bb1, unwind unreachable]; ++ _6 = Lt(const 2_usize, _5); ++ assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, const 2_usize) -> [success: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/repeat.main.GVN.32bit.panic-unwind.diff index d49ef2e0179..fe0acee71eb 100644 --- a/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/repeat.main.GVN.32bit.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -20,12 +20,11 @@ _3 = [const 42_u32; 8]; StorageLive(_4); _4 = const 2_usize; -- _5 = Len(_3); + _5 = Len(_3); - _6 = Lt(_4, _5); - assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind continue]; -+ _5 = const 8_usize; -+ _6 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 8_usize, const 2_usize) -> [success: bb1, unwind continue]; ++ _6 = Lt(const 2_usize, _5); ++ assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, const 2_usize) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/const_prop/repeat.main.GVN.64bit.panic-abort.diff index a55bd029e99..a52e6e35483 100644 --- a/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/repeat.main.GVN.64bit.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -20,12 +20,11 @@ _3 = [const 42_u32; 8]; StorageLive(_4); _4 = const 2_usize; -- _5 = Len(_3); + _5 = Len(_3); - _6 = Lt(_4, _5); - assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind unreachable]; -+ _5 = const 8_usize; -+ _6 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 8_usize, const 2_usize) -> [success: bb1, unwind unreachable]; ++ _6 = Lt(const 2_usize, _5); ++ assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, const 2_usize) -> [success: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/repeat.main.GVN.64bit.panic-unwind.diff index d49ef2e0179..fe0acee71eb 100644 --- a/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/repeat.main.GVN.64bit.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -20,12 +20,11 @@ _3 = [const 42_u32; 8]; StorageLive(_4); _4 = const 2_usize; -- _5 = Len(_3); + _5 = Len(_3); - _6 = Lt(_4, _5); - assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind continue]; -+ _5 = const 8_usize; -+ _6 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 8_usize, const 2_usize) -> [success: bb1, unwind continue]; ++ _6 = Lt(const 2_usize, _5); ++ assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, const 2_usize) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/repeat.rs b/tests/mir-opt/const_prop/repeat.rs index 9f688bbb53e..2c8717d25bb 100644 --- a/tests/mir-opt/const_prop/repeat.rs +++ b/tests/mir-opt/const_prop/repeat.rs @@ -1,8 +1,8 @@ -// unit-test: ConstProp +// unit-test: GVN // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_BIT_WIDTH -// EMIT_MIR repeat.main.ConstProp.diff +// EMIT_MIR repeat.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => [[x:_.*]]; diff --git a/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/return_place.add.GVN.panic-abort.diff index 974a42e5078..51f8227c36b 100644 --- a/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/return_place.add.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `add` before ConstProp -+ // MIR for `add` after ConstProp +- // MIR for `add` before GVN ++ // MIR for `add` after GVN fn add() -> u32 { let mut _0: u32; diff --git a/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/return_place.add.GVN.panic-unwind.diff index 55dbc700285..8174b4edea6 100644 --- a/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/return_place.add.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `add` before ConstProp -+ // MIR for `add` after ConstProp +- // MIR for `add` before GVN ++ // MIR for `add` after GVN fn add() -> u32 { let mut _0: u32; diff --git a/tests/mir-opt/const_prop/return_place.rs b/tests/mir-opt/const_prop/return_place.rs index 286543abb99..c207bcbdd62 100644 --- a/tests/mir-opt/const_prop/return_place.rs +++ b/tests/mir-opt/const_prop/return_place.rs @@ -1,8 +1,8 @@ -// unit-test: ConstProp +// unit-test: GVN // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -C overflow-checks=on -// EMIT_MIR return_place.add.ConstProp.diff +// EMIT_MIR return_place.add.GVN.diff // EMIT_MIR return_place.add.PreCodegen.before.mir fn add() -> u32 { // CHECK-LABEL: fn add( diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/scalar_literal_propagation.main.GVN.panic-abort.diff index c5c09c8edd7..0a20fb0e59e 100644 --- a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/scalar_literal_propagation.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -11,7 +11,8 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; _1 = const 1_u32; StorageLive(_2); StorageLive(_3); @@ -25,7 +26,8 @@ StorageDead(_3); StorageDead(_2); _0 = const (); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/scalar_literal_propagation.main.GVN.panic-unwind.diff index b256c56765e..8b9519d3adc 100644 --- a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/scalar_literal_propagation.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -11,7 +11,8 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; _1 = const 1_u32; StorageLive(_2); StorageLive(_3); @@ -25,7 +26,8 @@ StorageDead(_3); StorageDead(_2); _0 = const (); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.rs b/tests/mir-opt/const_prop/scalar_literal_propagation.rs index 782cd35d422..70d0eb53591 100644 --- a/tests/mir-opt/const_prop/scalar_literal_propagation.rs +++ b/tests/mir-opt/const_prop/scalar_literal_propagation.rs @@ -1,7 +1,7 @@ -// unit-test: ConstProp +// unit-test: GVN // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// EMIT_MIR scalar_literal_propagation.main.ConstProp.diff +// EMIT_MIR scalar_literal_propagation.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: = consume(const 1_u32) diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff index 7d5d036f460..8b2411e50ab 100644 --- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,33 +18,41 @@ bb0: { StorageLive(_1); - StorageLive(_2); +- StorageLive(_2); ++ nop; StorageLive(_3); StorageLive(_4); _9 = const _; - _4 = _9; - _3 = _4; - _2 = move _3 as &[u32] (PointerCoercion(Unsize)); +- _4 = _9; +- _3 = _4; +- _2 = move _3 as &[u32] (PointerCoercion(Unsize)); ++ _4 = const {ALLOC0<imm>: &[u32; 3]}; ++ _3 = const {ALLOC0<imm>: &[u32; 3]}; ++ _2 = const {ALLOC0<imm>: &[u32; 3]} as &[u32] (PointerCoercion(Unsize)); StorageDead(_3); StorageLive(_6); _6 = const 1_usize; -- _7 = Len((*_2)); + _7 = Len((*_2)); - _8 = Lt(_6, _7); - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind unreachable]; -+ _7 = const 3_usize; -+ _8 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb1, unwind unreachable]; ++ _8 = Lt(const 1_usize, _7); ++ assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, const 1_usize) -> [success: bb1, unwind unreachable]; } bb1: { - _1 = (*_2)[_6]; -+ _1 = const 2_u32; ++ _1 = (*_2)[1 of 2]; StorageDead(_6); StorageDead(_4); - StorageDead(_2); +- StorageDead(_2); ++ nop; _0 = const (); StorageDead(_1); return; } ++ } ++ ++ ALLOC0 (size: 12, align: 4) { ++ 01 00 00 00 02 00 00 00 03 00 00 00 │ ............ } diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff index fa4c5a71be5..9b20d243f87 100644 --- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,33 +18,41 @@ bb0: { StorageLive(_1); - StorageLive(_2); +- StorageLive(_2); ++ nop; StorageLive(_3); StorageLive(_4); _9 = const _; - _4 = _9; - _3 = _4; - _2 = move _3 as &[u32] (PointerCoercion(Unsize)); +- _4 = _9; +- _3 = _4; +- _2 = move _3 as &[u32] (PointerCoercion(Unsize)); ++ _4 = const {ALLOC0<imm>: &[u32; 3]}; ++ _3 = const {ALLOC0<imm>: &[u32; 3]}; ++ _2 = const {ALLOC0<imm>: &[u32; 3]} as &[u32] (PointerCoercion(Unsize)); StorageDead(_3); StorageLive(_6); _6 = const 1_usize; -- _7 = Len((*_2)); + _7 = Len((*_2)); - _8 = Lt(_6, _7); - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; -+ _7 = const 3_usize; -+ _8 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb1, unwind continue]; ++ _8 = Lt(const 1_usize, _7); ++ assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, const 1_usize) -> [success: bb1, unwind continue]; } bb1: { - _1 = (*_2)[_6]; -+ _1 = const 2_u32; ++ _1 = (*_2)[1 of 2]; StorageDead(_6); StorageDead(_4); - StorageDead(_2); +- StorageDead(_2); ++ nop; _0 = const (); StorageDead(_1); return; } ++ } ++ ++ ALLOC0 (size: 12, align: 4) { ++ 01 00 00 00 02 00 00 00 03 00 00 00 │ ............ } diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff index 7d5d036f460..8b2411e50ab 100644 --- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,33 +18,41 @@ bb0: { StorageLive(_1); - StorageLive(_2); +- StorageLive(_2); ++ nop; StorageLive(_3); StorageLive(_4); _9 = const _; - _4 = _9; - _3 = _4; - _2 = move _3 as &[u32] (PointerCoercion(Unsize)); +- _4 = _9; +- _3 = _4; +- _2 = move _3 as &[u32] (PointerCoercion(Unsize)); ++ _4 = const {ALLOC0<imm>: &[u32; 3]}; ++ _3 = const {ALLOC0<imm>: &[u32; 3]}; ++ _2 = const {ALLOC0<imm>: &[u32; 3]} as &[u32] (PointerCoercion(Unsize)); StorageDead(_3); StorageLive(_6); _6 = const 1_usize; -- _7 = Len((*_2)); + _7 = Len((*_2)); - _8 = Lt(_6, _7); - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind unreachable]; -+ _7 = const 3_usize; -+ _8 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb1, unwind unreachable]; ++ _8 = Lt(const 1_usize, _7); ++ assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, const 1_usize) -> [success: bb1, unwind unreachable]; } bb1: { - _1 = (*_2)[_6]; -+ _1 = const 2_u32; ++ _1 = (*_2)[1 of 2]; StorageDead(_6); StorageDead(_4); - StorageDead(_2); +- StorageDead(_2); ++ nop; _0 = const (); StorageDead(_1); return; } ++ } ++ ++ ALLOC0 (size: 12, align: 4) { ++ 01 00 00 00 02 00 00 00 03 00 00 00 │ ............ } diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff index fa4c5a71be5..9b20d243f87 100644 --- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,33 +18,41 @@ bb0: { StorageLive(_1); - StorageLive(_2); +- StorageLive(_2); ++ nop; StorageLive(_3); StorageLive(_4); _9 = const _; - _4 = _9; - _3 = _4; - _2 = move _3 as &[u32] (PointerCoercion(Unsize)); +- _4 = _9; +- _3 = _4; +- _2 = move _3 as &[u32] (PointerCoercion(Unsize)); ++ _4 = const {ALLOC0<imm>: &[u32; 3]}; ++ _3 = const {ALLOC0<imm>: &[u32; 3]}; ++ _2 = const {ALLOC0<imm>: &[u32; 3]} as &[u32] (PointerCoercion(Unsize)); StorageDead(_3); StorageLive(_6); _6 = const 1_usize; -- _7 = Len((*_2)); + _7 = Len((*_2)); - _8 = Lt(_6, _7); - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; -+ _7 = const 3_usize; -+ _8 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb1, unwind continue]; ++ _8 = Lt(const 1_usize, _7); ++ assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, const 1_usize) -> [success: bb1, unwind continue]; } bb1: { - _1 = (*_2)[_6]; -+ _1 = const 2_u32; ++ _1 = (*_2)[1 of 2]; StorageDead(_6); StorageDead(_4); - StorageDead(_2); +- StorageDead(_2); ++ nop; _0 = const (); StorageDead(_1); return; } ++ } ++ ++ ALLOC0 (size: 12, align: 4) { ++ 01 00 00 00 02 00 00 00 03 00 00 00 │ ............ } diff --git a/tests/mir-opt/const_prop/slice_len.rs b/tests/mir-opt/const_prop/slice_len.rs index 0bf44272698..79cd926df21 100644 --- a/tests/mir-opt/const_prop/slice_len.rs +++ b/tests/mir-opt/const_prop/slice_len.rs @@ -1,13 +1,16 @@ -// unit-test: ConstProp +// unit-test: GVN // compile-flags: -Zmir-enable-passes=+InstSimplify // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_BIT_WIDTH -// EMIT_MIR slice_len.main.ConstProp.diff +// EMIT_MIR slice_len.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug a => [[a:_.*]]; - // CHECK: assert(const true, - // CHECK: [[a]] = const 2_u32; + // CHECK: [[slice:_.*]] = const {{.*}} as &[u32] (PointerCoercion(Unsize)); + // FIXME(cjgillot) simplify Len and projection into unsized slice. + // CHECK-NOT: assert(const true, + // CHECK: [[a]] = (*[[slice]])[1 of 2]; + // CHECK-NOT: [[a]] = const 2_u32; let a = (&[1u32, 2, 3] as &[u32])[1]; } diff --git a/tests/mir-opt/const_prop/switch_int.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/switch_int.main.GVN.panic-abort.diff index 508cc15732c..ee9f2d5c7f5 100644 --- a/tests/mir-opt/const_prop/switch_int.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/switch_int.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/switch_int.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/switch_int.main.GVN.panic-unwind.diff index 1ce28e979a5..143d04ac984 100644 --- a/tests/mir-opt/const_prop/switch_int.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/switch_int.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/switch_int.rs b/tests/mir-opt/const_prop/switch_int.rs index d1cbaae49aa..c81b574d150 100644 --- a/tests/mir-opt/const_prop/switch_int.rs +++ b/tests/mir-opt/const_prop/switch_int.rs @@ -1,11 +1,11 @@ -// unit-test: ConstProp +// unit-test: GVN // compile-flags: -Zmir-enable-passes=+SimplifyConstCondition-after-const-prop // EMIT_MIR_FOR_EACH_PANIC_STRATEGY #[inline(never)] fn foo(_: i32) { } -// EMIT_MIR switch_int.main.ConstProp.diff +// EMIT_MIR switch_int.main.GVN.diff // EMIT_MIR switch_int.main.SimplifyConstCondition-after-const-prop.diff fn main() { // CHECK-LABEL: fn main( diff --git a/tests/mir-opt/const_prop/transmute.from_char.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.from_char.GVN.32bit.diff index febfebc8534..47dfb421ebc 100644 --- a/tests/mir-opt/const_prop/transmute.from_char.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.from_char.GVN.32bit.diff @@ -1,5 +1,5 @@ -- // MIR for `from_char` before ConstProp -+ // MIR for `from_char` after ConstProp +- // MIR for `from_char` before GVN ++ // MIR for `from_char` after GVN fn from_char() -> i32 { let mut _0: i32; diff --git a/tests/mir-opt/const_prop/transmute.from_char.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.from_char.GVN.64bit.diff index febfebc8534..47dfb421ebc 100644 --- a/tests/mir-opt/const_prop/transmute.from_char.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.from_char.GVN.64bit.diff @@ -1,5 +1,5 @@ -- // MIR for `from_char` before ConstProp -+ // MIR for `from_char` after ConstProp +- // MIR for `from_char` before GVN ++ // MIR for `from_char` after GVN fn from_char() -> i32 { let mut _0: i32; diff --git a/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.invalid_bool.GVN.32bit.diff index 38a1eb5a15b..f0c6f55f775 100644 --- a/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.invalid_bool.GVN.32bit.diff @@ -1,5 +1,5 @@ -- // MIR for `invalid_bool` before ConstProp -+ // MIR for `invalid_bool` after ConstProp +- // MIR for `invalid_bool` before GVN ++ // MIR for `invalid_bool` after GVN fn invalid_bool() -> bool { let mut _0: bool; diff --git a/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.invalid_bool.GVN.64bit.diff index 38a1eb5a15b..f0c6f55f775 100644 --- a/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.invalid_bool.GVN.64bit.diff @@ -1,5 +1,5 @@ -- // MIR for `invalid_bool` before ConstProp -+ // MIR for `invalid_bool` after ConstProp +- // MIR for `invalid_bool` before GVN ++ // MIR for `invalid_bool` after GVN fn invalid_bool() -> bool { let mut _0: bool; diff --git a/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.invalid_char.GVN.32bit.diff index 2c0998f77ea..a9e32d4d925 100644 --- a/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.invalid_char.GVN.32bit.diff @@ -1,5 +1,5 @@ -- // MIR for `invalid_char` before ConstProp -+ // MIR for `invalid_char` after ConstProp +- // MIR for `invalid_char` before GVN ++ // MIR for `invalid_char` after GVN fn invalid_char() -> char { let mut _0: char; diff --git a/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.invalid_char.GVN.64bit.diff index 2c0998f77ea..a9e32d4d925 100644 --- a/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.invalid_char.GVN.64bit.diff @@ -1,5 +1,5 @@ -- // MIR for `invalid_char` before ConstProp -+ // MIR for `invalid_char` after ConstProp +- // MIR for `invalid_char` before GVN ++ // MIR for `invalid_char` after GVN fn invalid_char() -> char { let mut _0: char; diff --git a/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.less_as_i8.GVN.32bit.diff index 7ac7bed8a5f..5e0c076b981 100644 --- a/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.less_as_i8.GVN.32bit.diff @@ -1,5 +1,5 @@ -- // MIR for `less_as_i8` before ConstProp -+ // MIR for `less_as_i8` after ConstProp +- // MIR for `less_as_i8` before GVN ++ // MIR for `less_as_i8` after GVN fn less_as_i8() -> i8 { let mut _0: i8; diff --git a/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.less_as_i8.GVN.64bit.diff index 7ac7bed8a5f..5e0c076b981 100644 --- a/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.less_as_i8.GVN.64bit.diff @@ -1,5 +1,5 @@ -- // MIR for `less_as_i8` before ConstProp -+ // MIR for `less_as_i8` after ConstProp +- // MIR for `less_as_i8` before GVN ++ // MIR for `less_as_i8` after GVN fn less_as_i8() -> i8 { let mut _0: i8; diff --git a/tests/mir-opt/const_prop/transmute.rs b/tests/mir-opt/const_prop/transmute.rs index 99988d05994..6ff0ba422f4 100644 --- a/tests/mir-opt/const_prop/transmute.rs +++ b/tests/mir-opt/const_prop/transmute.rs @@ -1,46 +1,46 @@ -// unit-test: ConstProp +// unit-test: GVN // compile-flags: -O --crate-type=lib // ignore-endian-big // EMIT_MIR_FOR_EACH_BIT_WIDTH use std::mem::transmute; -// EMIT_MIR transmute.less_as_i8.ConstProp.diff +// EMIT_MIR transmute.less_as_i8.GVN.diff pub fn less_as_i8() -> i8 { // CHECK-LABEL: fn less_as_i8( // CHECK: _0 = const -1_i8; unsafe { transmute(std::cmp::Ordering::Less) } } -// EMIT_MIR transmute.from_char.ConstProp.diff +// EMIT_MIR transmute.from_char.GVN.diff pub fn from_char() -> i32 { // CHECK-LABEL: fn from_char( // CHECK: _0 = const 82_i32; unsafe { transmute('R') } } -// EMIT_MIR transmute.valid_char.ConstProp.diff +// EMIT_MIR transmute.valid_char.GVN.diff pub fn valid_char() -> char { // CHECK-LABEL: fn valid_char( // CHECK: _0 = const 'R'; unsafe { transmute(0x52_u32) } } -// EMIT_MIR transmute.invalid_char.ConstProp.diff +// EMIT_MIR transmute.invalid_char.GVN.diff pub unsafe fn invalid_char() -> char { // CHECK-LABEL: fn invalid_char( // CHECK: _0 = const {transmute(0x7fffffff): char}; unsafe { transmute(i32::MAX) } } -// EMIT_MIR transmute.invalid_bool.ConstProp.diff +// EMIT_MIR transmute.invalid_bool.GVN.diff pub unsafe fn invalid_bool() -> bool { // CHECK-LABEL: fn invalid_bool( // CHECK: _0 = const {transmute(0xff): bool}; unsafe { transmute(-1_i8) } } -// EMIT_MIR transmute.undef_union_as_integer.ConstProp.diff +// EMIT_MIR transmute.undef_union_as_integer.GVN.diff pub unsafe fn undef_union_as_integer() -> u32 { // CHECK-LABEL: fn undef_union_as_integer( // CHECK: _1 = Union32 { @@ -49,16 +49,16 @@ pub unsafe fn undef_union_as_integer() -> u32 { unsafe { transmute(Union32 { unit: () }) } } -// EMIT_MIR transmute.unreachable_direct.ConstProp.diff +// EMIT_MIR transmute.unreachable_direct.GVN.diff pub unsafe fn unreachable_direct() -> ! { // CHECK-LABEL: fn unreachable_direct( - // CHECK: [[unit:_.*]] = (); - // CHECK: move [[unit]] as Never (Transmute); + // CHECK: = const (); + // CHECK: = const () as Never (Transmute); let x: Never = unsafe { transmute(()) }; match x {} } -// EMIT_MIR transmute.unreachable_ref.ConstProp.diff +// EMIT_MIR transmute.unreachable_ref.GVN.diff pub unsafe fn unreachable_ref() -> ! { // CHECK-LABEL: fn unreachable_ref( // CHECK: = const {0x1 as &Never}; @@ -66,7 +66,7 @@ pub unsafe fn unreachable_ref() -> ! { match *x {} } -// EMIT_MIR transmute.unreachable_mut.ConstProp.diff +// EMIT_MIR transmute.unreachable_mut.GVN.diff pub unsafe fn unreachable_mut() -> ! { // CHECK-LABEL: fn unreachable_mut( // CHECK: = const {0x1 as &mut Never}; @@ -74,7 +74,7 @@ pub unsafe fn unreachable_mut() -> ! { match *x {} } -// EMIT_MIR transmute.unreachable_box.ConstProp.diff +// EMIT_MIR transmute.unreachable_box.GVN.diff pub unsafe fn unreachable_box() -> ! { // CHECK-LABEL: fn unreachable_box( // CHECK: = const Box::<Never>( diff --git a/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.undef_union_as_integer.GVN.32bit.diff index afedf2a3061..c6a428019d8 100644 --- a/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.undef_union_as_integer.GVN.32bit.diff @@ -1,5 +1,5 @@ -- // MIR for `undef_union_as_integer` before ConstProp -+ // MIR for `undef_union_as_integer` after ConstProp +- // MIR for `undef_union_as_integer` before GVN ++ // MIR for `undef_union_as_integer` after GVN fn undef_union_as_integer() -> u32 { let mut _0: u32; @@ -11,7 +11,8 @@ bb0: { StorageLive(_1); StorageLive(_2); - _2 = (); +- _2 = (); ++ _2 = const (); _1 = Union32 { value: move _2 }; StorageDead(_2); _0 = move _1 as u32 (Transmute); diff --git a/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.undef_union_as_integer.GVN.64bit.diff index afedf2a3061..c6a428019d8 100644 --- a/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.undef_union_as_integer.GVN.64bit.diff @@ -1,5 +1,5 @@ -- // MIR for `undef_union_as_integer` before ConstProp -+ // MIR for `undef_union_as_integer` after ConstProp +- // MIR for `undef_union_as_integer` before GVN ++ // MIR for `undef_union_as_integer` after GVN fn undef_union_as_integer() -> u32 { let mut _0: u32; @@ -11,7 +11,8 @@ bb0: { StorageLive(_1); StorageLive(_2); - _2 = (); +- _2 = (); ++ _2 = const (); _1 = Union32 { value: move _2 }; StorageDead(_2); _0 = move _1 as u32 (Transmute); diff --git a/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.32bit.diff index 16519749b82..2ef83abfac0 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.32bit.diff @@ -1,5 +1,5 @@ -- // MIR for `unreachable_box` before ConstProp -+ // MIR for `unreachable_box` after ConstProp +- // MIR for `unreachable_box` before GVN ++ // MIR for `unreachable_box` after GVN fn unreachable_box() -> ! { let mut _0: !; diff --git a/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.64bit.diff index 16519749b82..2ef83abfac0 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.64bit.diff @@ -1,5 +1,5 @@ -- // MIR for `unreachable_box` before ConstProp -+ // MIR for `unreachable_box` after ConstProp +- // MIR for `unreachable_box` before GVN ++ // MIR for `unreachable_box` after GVN fn unreachable_box() -> ! { let mut _0: !; diff --git a/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_direct.GVN.32bit.diff index 896608e7eff..b2e91014625 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_direct.GVN.32bit.diff @@ -1,5 +1,5 @@ -- // MIR for `unreachable_direct` before ConstProp -+ // MIR for `unreachable_direct` after ConstProp +- // MIR for `unreachable_direct` before GVN ++ // MIR for `unreachable_direct` after GVN fn unreachable_direct() -> ! { let mut _0: !; @@ -14,8 +14,10 @@ bb0: { StorageLive(_1); StorageLive(_2); - _2 = (); - _1 = move _2 as Never (Transmute); +- _2 = (); +- _1 = move _2 as Never (Transmute); ++ _2 = const (); ++ _1 = const () as Never (Transmute); unreachable; } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_direct.GVN.64bit.diff index 896608e7eff..b2e91014625 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_direct.GVN.64bit.diff @@ -1,5 +1,5 @@ -- // MIR for `unreachable_direct` before ConstProp -+ // MIR for `unreachable_direct` after ConstProp +- // MIR for `unreachable_direct` before GVN ++ // MIR for `unreachable_direct` after GVN fn unreachable_direct() -> ! { let mut _0: !; @@ -14,8 +14,10 @@ bb0: { StorageLive(_1); StorageLive(_2); - _2 = (); - _1 = move _2 as Never (Transmute); +- _2 = (); +- _1 = move _2 as Never (Transmute); ++ _2 = const (); ++ _1 = const () as Never (Transmute); unreachable; } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.32bit.diff index c9d5ccf0bfd..93dfef96cf1 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.32bit.diff @@ -1,5 +1,5 @@ -- // MIR for `unreachable_mut` before ConstProp -+ // MIR for `unreachable_mut` after ConstProp +- // MIR for `unreachable_mut` before GVN ++ // MIR for `unreachable_mut` after GVN fn unreachable_mut() -> ! { let mut _0: !; @@ -13,11 +13,13 @@ bb0: { StorageLive(_1); - StorageLive(_2); +- StorageLive(_2); - _2 = const 1_usize as &mut Never (Transmute); ++ nop; + _2 = const {0x1 as &mut Never}; _1 = &mut (*_2); - StorageDead(_2); +- StorageDead(_2); ++ nop; unreachable; } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.64bit.diff index c9d5ccf0bfd..93dfef96cf1 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.64bit.diff @@ -1,5 +1,5 @@ -- // MIR for `unreachable_mut` before ConstProp -+ // MIR for `unreachable_mut` after ConstProp +- // MIR for `unreachable_mut` before GVN ++ // MIR for `unreachable_mut` after GVN fn unreachable_mut() -> ! { let mut _0: !; @@ -13,11 +13,13 @@ bb0: { StorageLive(_1); - StorageLive(_2); +- StorageLive(_2); - _2 = const 1_usize as &mut Never (Transmute); ++ nop; + _2 = const {0x1 as &mut Never}; _1 = &mut (*_2); - StorageDead(_2); +- StorageDead(_2); ++ nop; unreachable; } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_ref.GVN.32bit.diff index b684ba34c69..430d16c97a6 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_ref.GVN.32bit.diff @@ -1,5 +1,5 @@ -- // MIR for `unreachable_ref` before ConstProp -+ // MIR for `unreachable_ref` after ConstProp +- // MIR for `unreachable_ref` before GVN ++ // MIR for `unreachable_ref` after GVN fn unreachable_ref() -> ! { let mut _0: !; diff --git a/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_ref.GVN.64bit.diff index b684ba34c69..430d16c97a6 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_ref.GVN.64bit.diff @@ -1,5 +1,5 @@ -- // MIR for `unreachable_ref` before ConstProp -+ // MIR for `unreachable_ref` after ConstProp +- // MIR for `unreachable_ref` before GVN ++ // MIR for `unreachable_ref` after GVN fn unreachable_ref() -> ! { let mut _0: !; diff --git a/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.valid_char.GVN.32bit.diff index f215b3ca398..f9d002f96ab 100644 --- a/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.valid_char.GVN.32bit.diff @@ -1,5 +1,5 @@ -- // MIR for `valid_char` before ConstProp -+ // MIR for `valid_char` after ConstProp +- // MIR for `valid_char` before GVN ++ // MIR for `valid_char` after GVN fn valid_char() -> char { let mut _0: char; diff --git a/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.valid_char.GVN.64bit.diff index f215b3ca398..f9d002f96ab 100644 --- a/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.valid_char.GVN.64bit.diff @@ -1,5 +1,5 @@ -- // MIR for `valid_char` before ConstProp -+ // MIR for `valid_char` after ConstProp +- // MIR for `valid_char` before GVN ++ // MIR for `valid_char` after GVN fn valid_char() -> char { let mut _0: char; diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-abort.diff index f19650d5a83..c2f3fb1b3b5 100644 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -11,8 +11,9 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); - _1 = (const 1_u32, const 2_u32); ++ nop; + _1 = const (1_u32, 2_u32); StorageLive(_2); StorageLive(_3); @@ -26,20 +27,13 @@ StorageDead(_3); StorageDead(_2); _0 = const (); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } + } + + ALLOC0 (size: 8, align: 4) { + 01 00 00 00 02 00 00 00 │ ........ -+ } -+ -+ ALLOC1 (size: 8, align: 4) { -+ 01 00 00 00 02 00 00 00 │ ........ -+ } -+ -+ ALLOC2 (size: 8, align: 4) { -+ 01 00 00 00 02 00 00 00 │ ........ } diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-unwind.diff index 67307c42331..55d9a3b0cac 100644 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -11,8 +11,9 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); - _1 = (const 1_u32, const 2_u32); ++ nop; + _1 = const (1_u32, 2_u32); StorageLive(_2); StorageLive(_3); @@ -26,20 +27,13 @@ StorageDead(_3); StorageDead(_2); _0 = const (); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } + } + + ALLOC0 (size: 8, align: 4) { + 01 00 00 00 02 00 00 00 │ ........ -+ } -+ -+ ALLOC1 (size: 8, align: 4) { -+ 01 00 00 00 02 00 00 00 │ ........ -+ } -+ -+ ALLOC2 (size: 8, align: 4) { -+ 01 00 00 00 02 00 00 00 │ ........ } diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.rs b/tests/mir-opt/const_prop/tuple_literal_propagation.rs index dfc4a6f3fbb..6803612f0a5 100644 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.rs +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.rs @@ -1,6 +1,6 @@ -// unit-test: ConstProp +// unit-test: GVN // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// EMIT_MIR tuple_literal_propagation.main.ConstProp.diff +// EMIT_MIR tuple_literal_propagation.main.GVN.diff fn main() { // CHECK-LABEL: fn main( diff --git a/tests/mir-opt/const_prop/while_let_loops.change_loop_body.ConstProp.diff b/tests/mir-opt/const_prop/while_let_loops.change_loop_body.GVN.diff index f54908b4a38..9548afc9d40 100644 --- a/tests/mir-opt/const_prop/while_let_loops.change_loop_body.ConstProp.diff +++ b/tests/mir-opt/const_prop/while_let_loops.change_loop_body.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `change_loop_body` before ConstProp -+ // MIR for `change_loop_body` after ConstProp +- // MIR for `change_loop_body` before GVN ++ // MIR for `change_loop_body` after GVN fn change_loop_body() -> () { let mut _0: (); @@ -21,15 +21,17 @@ StorageLive(_1); _1 = const 0_i32; StorageLive(_3); - _3 = Option::<u32>::None; +- _3 = Option::<u32>::None; - _4 = discriminant(_3); - switchInt(move _4) -> [1: bb1, otherwise: bb3]; ++ _3 = const Option::<u32>::None; + _4 = const 0_isize; + switchInt(const 0_isize) -> [1: bb1, otherwise: bb3]; } bb1: { - switchInt(((_3 as Some).0: u32)) -> [0: bb2, otherwise: bb3]; +- switchInt(((_3 as Some).0: u32)) -> [0: bb2, otherwise: bb3]; ++ switchInt(const Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: u32) -> [0: bb2, otherwise: bb3]; } bb2: { @@ -50,5 +52,9 @@ StorageDead(_1); return; } ++ } ++ ++ ALLOC0 (size: 8, align: 4) { ++ 00 00 00 00 __ __ __ __ │ ....░░░░ } diff --git a/tests/mir-opt/const_prop/while_let_loops.rs b/tests/mir-opt/const_prop/while_let_loops.rs index 8b2a73438d6..d6527552bb0 100644 --- a/tests/mir-opt/const_prop/while_let_loops.rs +++ b/tests/mir-opt/const_prop/while_let_loops.rs @@ -1,5 +1,5 @@ -// unit-test: ConstProp -// EMIT_MIR while_let_loops.change_loop_body.ConstProp.diff +// unit-test: GVN +// EMIT_MIR while_let_loops.change_loop_body.GVN.diff pub fn change_loop_body() { // CHECK-LABEL: fn change_loop_body( diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff index ddfe2e8c831..6925fdb1e70 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff @@ -74,18 +74,18 @@ StorageDead(_7); StorageLive(_8); StorageLive(_9); - _8 = const {0x1 as *const [bool; 0]}; - _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + _8 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); + _5 = NonNull::<[bool; 0]> { pointer: _8 }; StorageDead(_9); StorageDead(_8); StorageDead(_6); - _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; StorageDead(_5); - _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); StorageDead(_4); - _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = Box::<[bool]>(_3, const std::alloc::Global); StorageDead(_3); - _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; + _1 = A { foo: move _2 }; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; @@ -97,15 +97,3 @@ } } - ALLOC2 (size: 8, align: 4) { - 01 00 00 00 00 00 00 00 │ ........ - } - - ALLOC1 (size: 8, align: 4) { - 01 00 00 00 00 00 00 00 │ ........ - } - - ALLOC0 (size: 8, align: 4) { - 01 00 00 00 00 00 00 00 │ ........ - } - diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff index 861295faa5a..82ad842505c 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff @@ -74,18 +74,18 @@ StorageDead(_7); StorageLive(_8); StorageLive(_9); - _8 = const {0x1 as *const [bool; 0]}; - _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + _8 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); + _5 = NonNull::<[bool; 0]> { pointer: _8 }; StorageDead(_9); StorageDead(_8); StorageDead(_6); - _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; StorageDead(_5); - _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); StorageDead(_4); - _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = Box::<[bool]>(_3, const std::alloc::Global); StorageDead(_3); - _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; + _1 = A { foo: move _2 }; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; @@ -101,15 +101,3 @@ } } - ALLOC2 (size: 8, align: 4) { - 01 00 00 00 00 00 00 00 │ ........ - } - - ALLOC1 (size: 8, align: 4) { - 01 00 00 00 00 00 00 00 │ ........ - } - - ALLOC0 (size: 8, align: 4) { - 01 00 00 00 00 00 00 00 │ ........ - } - diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff index cbb639edc53..6925fdb1e70 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff @@ -74,18 +74,18 @@ StorageDead(_7); StorageLive(_8); StorageLive(_9); - _8 = const {0x1 as *const [bool; 0]}; - _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + _8 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); + _5 = NonNull::<[bool; 0]> { pointer: _8 }; StorageDead(_9); StorageDead(_8); StorageDead(_6); - _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; StorageDead(_5); - _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); StorageDead(_4); - _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = Box::<[bool]>(_3, const std::alloc::Global); StorageDead(_3); - _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; + _1 = A { foo: move _2 }; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; @@ -97,15 +97,3 @@ } } - ALLOC2 (size: 16, align: 8) { - 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ - } - - ALLOC1 (size: 16, align: 8) { - 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ - } - - ALLOC0 (size: 16, align: 8) { - 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ - } - diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff index 656846e9f97..82ad842505c 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff @@ -74,18 +74,18 @@ StorageDead(_7); StorageLive(_8); StorageLive(_9); - _8 = const {0x1 as *const [bool; 0]}; - _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + _8 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); + _5 = NonNull::<[bool; 0]> { pointer: _8 }; StorageDead(_9); StorageDead(_8); StorageDead(_6); - _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; StorageDead(_5); - _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); StorageDead(_4); - _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = Box::<[bool]>(_3, const std::alloc::Global); StorageDead(_3); - _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; + _1 = A { foo: move _2 }; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; @@ -101,15 +101,3 @@ } } - ALLOC2 (size: 16, align: 8) { - 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ - } - - ALLOC1 (size: 16, align: 8) { - 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ - } - - ALLOC0 (size: 16, align: 8) { - 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ - } - diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff index 8363783e64e..13545aa464a 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -77,23 +77,18 @@ StorageLive(_8); StorageLive(_9); - _8 = _6 as *const [bool; 0] (PointerCoercion(MutToConstPointer)); -- _5 = NonNull::<[bool; 0]> { pointer: _8 }; -+ _8 = const {0x1 as *const [bool; 0]}; -+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; ++ _8 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); + _5 = NonNull::<[bool; 0]> { pointer: _8 }; StorageDead(_9); StorageDead(_8); StorageDead(_6); -- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; -+ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; StorageDead(_5); -- _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); -+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); StorageDead(_4); -- _2 = Box::<[bool]>(_3, const std::alloc::Global); -+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = Box::<[bool]>(_3, const std::alloc::Global); StorageDead(_3); -- _1 = A { foo: move _2 }; -+ _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; + _1 = A { foo: move _2 }; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; @@ -103,17 +98,5 @@ StorageDead(_1); return; } -+ } -+ -+ ALLOC2 (size: 8, align: 4) { -+ 01 00 00 00 00 00 00 00 │ ........ -+ } -+ -+ ALLOC1 (size: 8, align: 4) { -+ 01 00 00 00 00 00 00 00 │ ........ -+ } -+ -+ ALLOC0 (size: 8, align: 4) { -+ 01 00 00 00 00 00 00 00 │ ........ } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff index 19326b6a933..bf326915381 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -77,23 +77,18 @@ StorageLive(_8); StorageLive(_9); - _8 = _6 as *const [bool; 0] (PointerCoercion(MutToConstPointer)); -- _5 = NonNull::<[bool; 0]> { pointer: _8 }; -+ _8 = const {0x1 as *const [bool; 0]}; -+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; ++ _8 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); + _5 = NonNull::<[bool; 0]> { pointer: _8 }; StorageDead(_9); StorageDead(_8); StorageDead(_6); -- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; -+ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; StorageDead(_5); -- _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); -+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); StorageDead(_4); -- _2 = Box::<[bool]>(_3, const std::alloc::Global); -+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = Box::<[bool]>(_3, const std::alloc::Global); StorageDead(_3); -- _1 = A { foo: move _2 }; -+ _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; + _1 = A { foo: move _2 }; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; @@ -107,17 +102,5 @@ bb2 (cleanup): { resume; } -+ } -+ -+ ALLOC2 (size: 8, align: 4) { -+ 01 00 00 00 00 00 00 00 │ ........ -+ } -+ -+ ALLOC1 (size: 8, align: 4) { -+ 01 00 00 00 00 00 00 00 │ ........ -+ } -+ -+ ALLOC0 (size: 8, align: 4) { -+ 01 00 00 00 00 00 00 00 │ ........ } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff index 0d1e2430ce3..13545aa464a 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -77,23 +77,18 @@ StorageLive(_8); StorageLive(_9); - _8 = _6 as *const [bool; 0] (PointerCoercion(MutToConstPointer)); -- _5 = NonNull::<[bool; 0]> { pointer: _8 }; -+ _8 = const {0x1 as *const [bool; 0]}; -+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; ++ _8 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); + _5 = NonNull::<[bool; 0]> { pointer: _8 }; StorageDead(_9); StorageDead(_8); StorageDead(_6); -- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; -+ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; StorageDead(_5); -- _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); -+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); StorageDead(_4); -- _2 = Box::<[bool]>(_3, const std::alloc::Global); -+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = Box::<[bool]>(_3, const std::alloc::Global); StorageDead(_3); -- _1 = A { foo: move _2 }; -+ _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; + _1 = A { foo: move _2 }; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; @@ -103,17 +98,5 @@ StorageDead(_1); return; } -+ } -+ -+ ALLOC2 (size: 16, align: 8) { -+ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ -+ } -+ -+ ALLOC1 (size: 16, align: 8) { -+ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ -+ } -+ -+ ALLOC0 (size: 16, align: 8) { -+ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff index 35f1e5ba796..bf326915381 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -77,23 +77,18 @@ StorageLive(_8); StorageLive(_9); - _8 = _6 as *const [bool; 0] (PointerCoercion(MutToConstPointer)); -- _5 = NonNull::<[bool; 0]> { pointer: _8 }; -+ _8 = const {0x1 as *const [bool; 0]}; -+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; ++ _8 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); + _5 = NonNull::<[bool; 0]> { pointer: _8 }; StorageDead(_9); StorageDead(_8); StorageDead(_6); -- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; -+ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; StorageDead(_5); -- _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); -+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); StorageDead(_4); -- _2 = Box::<[bool]>(_3, const std::alloc::Global); -+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = Box::<[bool]>(_3, const std::alloc::Global); StorageDead(_3); -- _1 = A { foo: move _2 }; -+ _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; + _1 = A { foo: move _2 }; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; @@ -107,17 +102,5 @@ bb2 (cleanup): { resume; } -+ } -+ -+ ALLOC2 (size: 16, align: 8) { -+ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ -+ } -+ -+ ALLOC1 (size: 16, align: 8) { -+ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ -+ } -+ -+ ALLOC0 (size: 16, align: 8) { -+ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs index 1bb052736c0..8006bd510e1 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs @@ -1,6 +1,6 @@ // skip-filecheck // unit-test: DataflowConstProp -// compile-flags: -Zmir-enable-passes=+ConstProp,+Inline +// compile-flags: -Zmir-enable-passes=+GVN,+Inline // ignore-debug assertions change the output MIR // EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR_FOR_EACH_PANIC_STRATEGY @@ -9,7 +9,7 @@ struct A { foo: Box<[bool]>, } -// EMIT_MIR default_boxed_slice.main.ConstProp.diff +// EMIT_MIR default_boxed_slice.main.GVN.diff // EMIT_MIR default_boxed_slice.main.DataflowConstProp.diff fn main() { // ConstProp will create a constant of type `Box<[bool]>`. diff --git a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-abort.diff b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-abort.diff index 142e08f4d6c..993e0f1d1a6 100644 --- a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-abort.diff +++ b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-abort.diff @@ -4,12 +4,13 @@ fn main() -> () { let mut _0: (); let _1: main::Un; + let mut _2: u32; scope 1 { debug un => _1; scope 2 { } scope 4 (inlined std::mem::drop::<u32>) { - debug _x => const 1_u32; + debug _x => _2; } } scope 3 (inlined val) { @@ -18,6 +19,9 @@ bb0: { StorageLive(_1); _1 = Un { us: const 1_u32 }; + StorageLive(_2); + _2 = (_1.0: u32); + StorageDead(_2); StorageDead(_1); return; } diff --git a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff index 142e08f4d6c..993e0f1d1a6 100644 --- a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff +++ b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff @@ -4,12 +4,13 @@ fn main() -> () { let mut _0: (); let _1: main::Un; + let mut _2: u32; scope 1 { debug un => _1; scope 2 { } scope 4 (inlined std::mem::drop::<u32>) { - debug _x => const 1_u32; + debug _x => _2; } } scope 3 (inlined val) { @@ -18,6 +19,9 @@ bb0: { StorageLive(_1); _1 = Un { us: const 1_u32 }; + StorageLive(_2); + _2 = (_1.0: u32); + StorageDead(_2); StorageDead(_1); return; } diff --git a/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.panic-abort.diff b/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.panic-abort.diff index 97ca825092e..80b5681ad06 100644 --- a/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.panic-abort.diff +++ b/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.panic-abort.diff @@ -33,8 +33,8 @@ - StorageLive(_5); - _5 = _1; - StorageLive(_6); -- _6 = _2; -- _4 = g::<T>(move _5, move _6) -> [return: bb2, unwind unreachable]; +- _6 = _1; +- _4 = g::<T>(_1, _1) -> [return: bb2, unwind unreachable]; - } - - bb2: { @@ -48,20 +48,22 @@ - bb3: { StorageLive(_7); - StorageLive(_8); -- _8 = _2; +- _8 = _1; +- StorageLive(_9); +- _9 = _1; +- _7 = g::<T>(_1, _1) -> [return: bb4, unwind unreachable]; + nop; + nop; - StorageLive(_9); -- _9 = _2; -- _7 = g::<T>(move _8, move _9) -> [return: bb4, unwind unreachable]; -+ _9 = _1; -+ _7 = g::<T>(move _1, move _9) -> [return: bb2, unwind unreachable]; ++ nop; ++ nop; ++ _7 = g::<T>(_1, _1) -> [return: bb2, unwind unreachable]; } - bb4: { -+ bb2: { - StorageDead(_9); +- StorageDead(_9); - StorageDead(_8); ++ bb2: { ++ nop; + nop; StorageDead(_7); _0 = const (); diff --git a/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.panic-unwind.diff b/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.panic-unwind.diff index 7f730a77b06..eae7dd17b48 100644 --- a/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.panic-unwind.diff +++ b/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.panic-unwind.diff @@ -33,8 +33,8 @@ - StorageLive(_5); - _5 = _1; - StorageLive(_6); -- _6 = _2; -- _4 = g::<T>(move _5, move _6) -> [return: bb2, unwind continue]; +- _6 = _1; +- _4 = g::<T>(_1, _1) -> [return: bb2, unwind continue]; - } - - bb2: { @@ -48,20 +48,22 @@ - bb3: { StorageLive(_7); - StorageLive(_8); -- _8 = _2; +- _8 = _1; +- StorageLive(_9); +- _9 = _1; +- _7 = g::<T>(_1, _1) -> [return: bb4, unwind continue]; + nop; + nop; - StorageLive(_9); -- _9 = _2; -- _7 = g::<T>(move _8, move _9) -> [return: bb4, unwind continue]; -+ _9 = _1; -+ _7 = g::<T>(move _1, move _9) -> [return: bb2, unwind continue]; ++ nop; ++ nop; ++ _7 = g::<T>(_1, _1) -> [return: bb2, unwind continue]; } - bb4: { -+ bb2: { - StorageDead(_9); +- StorageDead(_9); - StorageDead(_8); ++ bb2: { ++ nop; + nop; StorageDead(_7); _0 = const (); diff --git a/tests/mir-opt/dest-prop/unreachable.rs b/tests/mir-opt/dest-prop/unreachable.rs index a47d2a0c8e2..0bde157ff61 100644 --- a/tests/mir-opt/dest-prop/unreachable.rs +++ b/tests/mir-opt/dest-prop/unreachable.rs @@ -4,7 +4,7 @@ // Regression test for issue #105428. // // compile-flags: --crate-type=lib -Zmir-opt-level=0 -// compile-flags: -Zmir-enable-passes=+ConstProp,+SimplifyConstCondition-after-const-prop,+DestinationPropagation +// compile-flags: -Zmir-enable-passes=+GVN,+SimplifyConstCondition-after-const-prop,+DestinationPropagation // EMIT_MIR unreachable.f.DestinationPropagation.diff pub fn f<T: Copy>(a: T) { diff --git a/tests/mir-opt/exponential_or.match_tuple.SimplifyCfg-initial.after.mir b/tests/mir-opt/exponential_or.match_tuple.SimplifyCfg-initial.after.mir index b04e09e88b8..596dcef85fd 100644 --- a/tests/mir-opt/exponential_or.match_tuple.SimplifyCfg-initial.after.mir +++ b/tests/mir-opt/exponential_or.match_tuple.SimplifyCfg-initial.after.mir @@ -38,22 +38,22 @@ fn match_tuple(_1: (u32, bool, Option<i32>, u32)) -> u32 { bb4: { _5 = Le(const 6_u32, (_1.3: u32)); - switchInt(move _5) -> [0: bb6, otherwise: bb5]; + switchInt(move _5) -> [0: bb5, otherwise: bb7]; } bb5: { - _6 = Le((_1.3: u32), const 9_u32); - switchInt(move _6) -> [0: bb6, otherwise: bb8]; + _3 = Le(const 13_u32, (_1.3: u32)); + switchInt(move _3) -> [0: bb1, otherwise: bb6]; } bb6: { - _3 = Le(const 13_u32, (_1.3: u32)); - switchInt(move _3) -> [0: bb1, otherwise: bb7]; + _4 = Le((_1.3: u32), const 16_u32); + switchInt(move _4) -> [0: bb1, otherwise: bb8]; } bb7: { - _4 = Le((_1.3: u32), const 16_u32); - switchInt(move _4) -> [0: bb1, otherwise: bb8]; + _6 = Le((_1.3: u32), const 9_u32); + switchInt(move _6) -> [0: bb5, otherwise: bb8]; } bb8: { diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.panic-abort.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-abort.diff index 298a6084899..0ba1bac0a03 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.panic-abort.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `float_to_exponential_common` before ConstProp -+ // MIR for `float_to_exponential_common` after ConstProp +- // MIR for `float_to_exponential_common` before GVN ++ // MIR for `float_to_exponential_common` after GVN fn float_to_exponential_common(_1: &mut Formatter<'_>, _2: &T, _3: bool) -> Result<(), std::fmt::Error> { debug fmt => _1; diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.panic-unwind.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-unwind.diff index 037f4f7cfac..27ea43ef12b 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `float_to_exponential_common` before ConstProp -+ // MIR for `float_to_exponential_common` after ConstProp +- // MIR for `float_to_exponential_common` before GVN ++ // MIR for `float_to_exponential_common` after GVN fn float_to_exponential_common(_1: &mut Formatter<'_>, _2: &T, _3: bool) -> Result<(), std::fmt::Error> { debug fmt => _1; diff --git a/tests/mir-opt/funky_arms.rs b/tests/mir-opt/funky_arms.rs index 14aad039946..eae158f9f77 100644 --- a/tests/mir-opt/funky_arms.rs +++ b/tests/mir-opt/funky_arms.rs @@ -9,7 +9,7 @@ extern crate core; use core::num::flt2dec; use std::fmt::{Formatter, Result}; -// EMIT_MIR funky_arms.float_to_exponential_common.ConstProp.diff +// EMIT_MIR funky_arms.float_to_exponential_common.GVN.diff pub fn float_to_exponential_common<T>(fmt: &mut Formatter<'_>, num: &T, upper: bool) -> Result where T: flt2dec::DecodableFloat, diff --git a/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-abort.diff b/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-abort.diff new file mode 100644 index 00000000000..4b1e3379114 --- /dev/null +++ b/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-abort.diff @@ -0,0 +1,104 @@ +- // MIR for `constant_index_overflow` before GVN ++ // MIR for `constant_index_overflow` after GVN + + fn constant_index_overflow(_1: &[T]) -> () { + debug x => _1; + let mut _0: (); + let _2: usize; + let mut _4: bool; + let mut _5: usize; + let mut _6: usize; + let mut _7: &[T]; + let _8: usize; + let mut _9: usize; + let mut _10: bool; + let _11: usize; + let mut _12: usize; + let mut _13: bool; + let mut _14: T; + scope 1 { + debug a => _2; + let _3: T; + scope 2 { + debug b => _3; + } + } + + bb0: { +- StorageLive(_2); +- _2 = const _ as usize (IntToInt); ++ nop; ++ _2 = const usize::MAX; + StorageLive(_3); + StorageLive(_4); + StorageLive(_5); +- _5 = _2; ++ _5 = const usize::MAX; + StorageLive(_6); + StorageLive(_7); + _7 = &(*_1); + _6 = core::slice::<impl [T]>::len(move _7) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_7); +- _4 = Lt(move _5, move _6); ++ _4 = Lt(const usize::MAX, move _6); + switchInt(move _4) -> [0: bb4, otherwise: bb2]; + } + + bb2: { + StorageDead(_6); + StorageDead(_5); + StorageLive(_8); +- _8 = _2; ++ _8 = const usize::MAX; + _9 = Len((*_1)); +- _10 = Lt(_8, _9); +- assert(move _10, "index out of bounds: the length is {} but the index is {}", move _9, _8) -> [success: bb3, unwind unreachable]; ++ _10 = Lt(const usize::MAX, _9); ++ assert(move _10, "index out of bounds: the length is {} but the index is {}", move _9, const usize::MAX) -> [success: bb3, unwind unreachable]; + } + + bb3: { +- _3 = (*_1)[_8]; ++ _3 = (*_1)[_2]; + StorageDead(_8); + goto -> bb6; + } + + bb4: { + StorageDead(_6); + StorageDead(_5); + StorageLive(_11); + _11 = const 0_usize; + _12 = Len((*_1)); +- _13 = Lt(_11, _12); +- assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, _11) -> [success: bb5, unwind unreachable]; ++ _13 = Lt(const 0_usize, _12); ++ assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, const 0_usize) -> [success: bb5, unwind unreachable]; + } + + bb5: { +- _3 = (*_1)[_11]; ++ _3 = (*_1)[0 of 1]; + StorageDead(_11); + goto -> bb6; + } + + bb6: { + StorageDead(_4); + StorageLive(_14); + _14 = _3; + _0 = opaque::<T>(move _14) -> [return: bb7, unwind unreachable]; + } + + bb7: { + StorageDead(_14); + StorageDead(_3); +- StorageDead(_2); ++ nop; + return; + } + } + diff --git a/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-unwind.diff b/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-unwind.diff new file mode 100644 index 00000000000..8abcd7e9387 --- /dev/null +++ b/tests/mir-opt/gvn.constant_index_overflow.GVN.panic-unwind.diff @@ -0,0 +1,104 @@ +- // MIR for `constant_index_overflow` before GVN ++ // MIR for `constant_index_overflow` after GVN + + fn constant_index_overflow(_1: &[T]) -> () { + debug x => _1; + let mut _0: (); + let _2: usize; + let mut _4: bool; + let mut _5: usize; + let mut _6: usize; + let mut _7: &[T]; + let _8: usize; + let mut _9: usize; + let mut _10: bool; + let _11: usize; + let mut _12: usize; + let mut _13: bool; + let mut _14: T; + scope 1 { + debug a => _2; + let _3: T; + scope 2 { + debug b => _3; + } + } + + bb0: { +- StorageLive(_2); +- _2 = const _ as usize (IntToInt); ++ nop; ++ _2 = const usize::MAX; + StorageLive(_3); + StorageLive(_4); + StorageLive(_5); +- _5 = _2; ++ _5 = const usize::MAX; + StorageLive(_6); + StorageLive(_7); + _7 = &(*_1); + _6 = core::slice::<impl [T]>::len(move _7) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_7); +- _4 = Lt(move _5, move _6); ++ _4 = Lt(const usize::MAX, move _6); + switchInt(move _4) -> [0: bb4, otherwise: bb2]; + } + + bb2: { + StorageDead(_6); + StorageDead(_5); + StorageLive(_8); +- _8 = _2; ++ _8 = const usize::MAX; + _9 = Len((*_1)); +- _10 = Lt(_8, _9); +- assert(move _10, "index out of bounds: the length is {} but the index is {}", move _9, _8) -> [success: bb3, unwind continue]; ++ _10 = Lt(const usize::MAX, _9); ++ assert(move _10, "index out of bounds: the length is {} but the index is {}", move _9, const usize::MAX) -> [success: bb3, unwind continue]; + } + + bb3: { +- _3 = (*_1)[_8]; ++ _3 = (*_1)[_2]; + StorageDead(_8); + goto -> bb6; + } + + bb4: { + StorageDead(_6); + StorageDead(_5); + StorageLive(_11); + _11 = const 0_usize; + _12 = Len((*_1)); +- _13 = Lt(_11, _12); +- assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, _11) -> [success: bb5, unwind continue]; ++ _13 = Lt(const 0_usize, _12); ++ assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, const 0_usize) -> [success: bb5, unwind continue]; + } + + bb5: { +- _3 = (*_1)[_11]; ++ _3 = (*_1)[0 of 1]; + StorageDead(_11); + goto -> bb6; + } + + bb6: { + StorageDead(_4); + StorageLive(_14); + _14 = _3; + _0 = opaque::<T>(move _14) -> [return: bb7, unwind continue]; + } + + bb7: { + StorageDead(_14); + StorageDead(_3); +- StorageDead(_2); ++ nop; + return; + } + } + diff --git a/tests/mir-opt/gvn.rs b/tests/mir-opt/gvn.rs index 6e082acdbd3..db131f7f97d 100644 --- a/tests/mir-opt/gvn.rs +++ b/tests/mir-opt/gvn.rs @@ -609,6 +609,22 @@ fn indirect_static() { }) } +/// Verify that having constant index `u64::MAX` does not yield to an overflow in rustc. +fn constant_index_overflow<T: Copy>(x: &[T]) { + // CHECK-LABEL: fn constant_index_overflow( + // CHECK: debug a => [[a:_.*]]; + // CHECK: debug b => [[b:_.*]]; + // CHECK: [[a]] = const usize::MAX; + // CHECK-NOT: = (*_1)[{{.*}} of 0]; + // CHECK: [[b]] = (*_1)[[[a]]]; + // CHECK-NOT: = (*_1)[{{.*}} of 0]; + // CHECK: [[b]] = (*_1)[0 of 1]; + // CHECK-NOT: = (*_1)[{{.*}} of 0]; + let a = u64::MAX as usize; + let b = if a < x.len() { x[a] } else { x[0] }; + opaque(b) +} + fn main() { subexpression_elimination(2, 4, 5); wrap_unwrap(5); @@ -627,6 +643,7 @@ fn main() { repeat(); fn_pointers(); indirect_static(); + constant_index_overflow(&[5, 3]); } #[inline(never)] @@ -653,3 +670,4 @@ fn identity<T>(x: T) -> T { // EMIT_MIR gvn.repeat.GVN.diff // EMIT_MIR gvn.fn_pointers.GVN.diff // EMIT_MIR gvn.indirect_static.GVN.diff +// EMIT_MIR gvn.constant_index_overflow.GVN.diff diff --git a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir index 62d7e839f5a..408cc5bb341 100644 --- a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir +++ b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir @@ -19,7 +19,7 @@ fn b(_1: &mut Box<T>) -> &mut T { _4 = &mut (*_1); StorageLive(_5); StorageLive(_6); - _5 = deref_copy (*_4); + _5 = (*_4); _6 = (((_5.0: std::ptr::Unique<T>).0: std::ptr::NonNull<T>).0: *const T); _3 = &mut (*_6); StorageDead(_6); diff --git a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir index bc0aa06a752..4d20f6c4419 100644 --- a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir +++ b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir @@ -17,7 +17,7 @@ fn d(_1: &Box<T>) -> &T { _3 = &(*_1); StorageLive(_4); StorageLive(_5); - _4 = deref_copy (*_3); + _4 = (*_3); _5 = (((_4.0: std::ptr::Unique<T>).0: std::ptr::NonNull<T>).0: *const T); _2 = &(*_5); StorageDead(_5); diff --git a/tests/mir-opt/issue_101973.inner.ConstProp.panic-abort.diff b/tests/mir-opt/issue_101973.inner.GVN.panic-abort.diff index 3748d148380..d2db8f61916 100644 --- a/tests/mir-opt/issue_101973.inner.ConstProp.panic-abort.diff +++ b/tests/mir-opt/issue_101973.inner.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `inner` before ConstProp -+ // MIR for `inner` after ConstProp +- // MIR for `inner` before GVN ++ // MIR for `inner` after GVN fn inner(_1: u32) -> i64 { debug fields => _1; diff --git a/tests/mir-opt/issue_101973.inner.ConstProp.panic-unwind.diff b/tests/mir-opt/issue_101973.inner.GVN.panic-unwind.diff index 9dab4233c56..514183b3bc0 100644 --- a/tests/mir-opt/issue_101973.inner.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/issue_101973.inner.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `inner` before ConstProp -+ // MIR for `inner` after ConstProp +- // MIR for `inner` before GVN ++ // MIR for `inner` after GVN fn inner(_1: u32) -> i64 { debug fields => _1; diff --git a/tests/mir-opt/issue_101973.rs b/tests/mir-opt/issue_101973.rs index 3de325bc170..83a4dfb20b5 100644 --- a/tests/mir-opt/issue_101973.rs +++ b/tests/mir-opt/issue_101973.rs @@ -1,7 +1,7 @@ // skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -O -C debug-assertions=on -// This needs inlining followed by ConstProp to reproduce, so we cannot use "unit-test". +// This needs inlining followed by GVN to reproduce, so we cannot use "unit-test". #[inline] pub fn imm8(x: u32) -> u32 { @@ -10,7 +10,7 @@ pub fn imm8(x: u32) -> u32 { out } -// EMIT_MIR issue_101973.inner.ConstProp.diff +// EMIT_MIR issue_101973.inner.GVN.diff #[inline(never)] pub fn inner(fields: u32) -> i64 { imm8(fields).rotate_right(((fields >> 8) & 0xf) << 1) as i32 as i64 diff --git a/tests/mir-opt/match_test.main.SimplifyCfg-initial.after.mir b/tests/mir-opt/match_test.main.SimplifyCfg-initial.after.mir index ebb2f70a475..5bf78b6150f 100644 --- a/tests/mir-opt/match_test.main.SimplifyCfg-initial.after.mir +++ b/tests/mir-opt/match_test.main.SimplifyCfg-initial.after.mir @@ -28,43 +28,43 @@ fn main() -> () { StorageLive(_3); PlaceMention(_1); _6 = Le(const 0_i32, _1); - switchInt(move _6) -> [0: bb4, otherwise: bb1]; + switchInt(move _6) -> [0: bb3, otherwise: bb8]; } bb1: { - _7 = Lt(_1, const 10_i32); - switchInt(move _7) -> [0: bb4, otherwise: bb2]; + falseEdge -> [real: bb9, imaginary: bb4]; } bb2: { - falseEdge -> [real: bb9, imaginary: bb6]; + _3 = const 3_i32; + goto -> bb14; } bb3: { - _3 = const 3_i32; - goto -> bb14; + _4 = Le(const 10_i32, _1); + switchInt(move _4) -> [0: bb5, otherwise: bb7]; } bb4: { - _4 = Le(const 10_i32, _1); - switchInt(move _4) -> [0: bb7, otherwise: bb5]; + falseEdge -> [real: bb12, imaginary: bb6]; } bb5: { - _5 = Le(_1, const 20_i32); - switchInt(move _5) -> [0: bb7, otherwise: bb6]; + switchInt(_1) -> [4294967295: bb6, otherwise: bb2]; } bb6: { - falseEdge -> [real: bb12, imaginary: bb8]; + falseEdge -> [real: bb13, imaginary: bb2]; } bb7: { - switchInt(_1) -> [4294967295: bb8, otherwise: bb3]; + _5 = Le(_1, const 20_i32); + switchInt(move _5) -> [0: bb5, otherwise: bb4]; } bb8: { - falseEdge -> [real: bb13, imaginary: bb3]; + _7 = Lt(_1, const 10_i32); + switchInt(move _7) -> [0: bb3, otherwise: bb1]; } bb9: { @@ -83,7 +83,7 @@ fn main() -> () { bb11: { StorageDead(_9); - falseEdge -> [real: bb3, imaginary: bb6]; + falseEdge -> [real: bb2, imaginary: bb4]; } bb12: { diff --git a/tests/mir-opt/nll/named_lifetimes_basic.rs b/tests/mir-opt/nll/named_lifetimes_basic.rs index 5a9312de284..bb22ce0ed95 100644 --- a/tests/mir-opt/nll/named_lifetimes_basic.rs +++ b/tests/mir-opt/nll/named_lifetimes_basic.rs @@ -4,8 +4,8 @@ // suitable variables and that we setup the outlives relationship // between R0 and R1 properly. -// compile-flags: -Zverbose -// ^^^^^^^^^ force compiler to dump more region information +// compile-flags: -Zverbose-internals +// ^^^^^^^^^^^^^^^^^^^ force compiler to dump more region information #![allow(warnings)] diff --git a/tests/mir-opt/nll/region_subtyping_basic.rs b/tests/mir-opt/nll/region_subtyping_basic.rs index 83f756acdc3..940f8d17344 100644 --- a/tests/mir-opt/nll/region_subtyping_basic.rs +++ b/tests/mir-opt/nll/region_subtyping_basic.rs @@ -3,8 +3,8 @@ // in the type of `p` includes the points after `&v[0]` up to (but not // including) the call to `use_x`. The `else` branch is not included. -// compile-flags:-Zverbose -// ^^^^^^^^^ force compiler to dump more region information +// compile-flags:-Zverbose-internals +// ^^^^^^^^^^^^^^^^^^^ force compiler to dump more region information #![allow(warnings)] diff --git a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.mir index 8304cb45b35..9c6c30214aa 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.mir @@ -55,7 +55,7 @@ fn checked_shl(_1: u32, _2: u32) -> Option<u32> { } bb3: { - _0 = Option::<u32>::None; + _0 = const Option::<u32>::None; goto -> bb4; } @@ -66,3 +66,7 @@ fn checked_shl(_1: u32, _2: u32) -> Option<u32> { return; } } + +ALLOC0 (size: 8, align: 4) { + 00 00 00 00 __ __ __ __ │ ....░░░░ +} diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff index d5628dc7a6e..5cb528c0d5f 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff @@ -55,8 +55,10 @@ - _2 = Option::<Layout>::None; + _2 = const Option::<Layout>::None; StorageLive(_10); - _10 = const 0_isize; - switchInt(const 0_isize) -> [0: bb1, 1: bb3, otherwise: bb2]; +- _10 = discriminant(_2); +- switchInt(move _10) -> [0: bb1, 1: bb3, otherwise: bb2]; ++ _10 = const 0_isize; ++ switchInt(const 0_isize) -> [0: bb1, 1: bb3, otherwise: bb2]; } bb1: { diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff index d28059458ae..1e1585f20ae 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff @@ -40,8 +40,10 @@ - _2 = Option::<Layout>::None; + _2 = const Option::<Layout>::None; StorageLive(_10); - _10 = const 0_isize; - switchInt(const 0_isize) -> [0: bb2, 1: bb4, otherwise: bb3]; +- _10 = discriminant(_2); +- switchInt(move _10) -> [0: bb2, 1: bb4, otherwise: bb3]; ++ _10 = const 0_isize; ++ switchInt(const 0_isize) -> [0: bb2, 1: bb4, otherwise: bb3]; } bb1: { diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff index d139fc73e21..e655af559a1 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff @@ -55,8 +55,10 @@ - _2 = Option::<Layout>::None; + _2 = const Option::<Layout>::None; StorageLive(_10); - _10 = const 0_isize; - switchInt(const 0_isize) -> [0: bb1, 1: bb3, otherwise: bb2]; +- _10 = discriminant(_2); +- switchInt(move _10) -> [0: bb1, 1: bb3, otherwise: bb2]; ++ _10 = const 0_isize; ++ switchInt(const 0_isize) -> [0: bb1, 1: bb3, otherwise: bb2]; } bb1: { diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff index 63db9553b37..a6658713a02 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff @@ -40,8 +40,10 @@ - _2 = Option::<Layout>::None; + _2 = const Option::<Layout>::None; StorageLive(_10); - _10 = const 0_isize; - switchInt(const 0_isize) -> [0: bb2, 1: bb4, otherwise: bb3]; +- _10 = discriminant(_2); +- switchInt(move _10) -> [0: bb2, 1: bb4, otherwise: bb3]; ++ _10 = const 0_isize; ++ switchInt(const 0_isize) -> [0: bb2, 1: bb4, otherwise: bb3]; } bb1: { diff --git a/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir index 73a3be7f301..42c7eb3c6aa 100644 --- a/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir @@ -72,7 +72,7 @@ fn int_range(_1: usize, _2: usize) -> () { bb2: { StorageDead(_7); StorageDead(_6); - _11 = Option::<usize>::None; + _11 = const Option::<usize>::None; goto -> bb5; } @@ -118,3 +118,7 @@ fn int_range(_1: usize, _2: usize) -> () { unreachable; } } + +ALLOC0 (size: 16, align: 8) { + 00 00 00 00 00 00 00 00 __ __ __ __ __ __ __ __ │ ........░░░░░░░░ +} diff --git a/tests/mir-opt/pre-codegen/loops.rs b/tests/mir-opt/pre-codegen/loops.rs index 7f9c26f4fff..9412c3f234e 100644 --- a/tests/mir-opt/pre-codegen/loops.rs +++ b/tests/mir-opt/pre-codegen/loops.rs @@ -1,6 +1,7 @@ // skip-filecheck // compile-flags: -O -Zmir-opt-level=2 -g // needs-unwind +// only-64bit #![crate_type = "lib"] diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-abort.diff index bddd961c933..4e34233a979 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-unwind.diff index 297ebd79fad..275f17e52ae 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-abort.diff index bddd961c933..4e34233a979 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-unwind.diff index 297ebd79fad..275f17e52ae 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.rs b/tests/mir-opt/pre-codegen/optimizes_into_variable.rs index bb089ea4455..fb634ca85ef 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.rs +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.rs @@ -9,7 +9,7 @@ struct Point { // EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR optimizes_into_variable.main.ScalarReplacementOfAggregates.diff -// EMIT_MIR optimizes_into_variable.main.ConstProp.diff +// EMIT_MIR optimizes_into_variable.main.GVN.diff // EMIT_MIR optimizes_into_variable.main.SimplifyLocals-final.after.mir // EMIT_MIR optimizes_into_variable.main.PreCodegen.after.mir fn main() { diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir index cd734b10fea..e5940bd8201 100644 --- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir @@ -75,7 +75,7 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb2: { StorageDead(_8); StorageDead(_7); - _12 = Option::<u32>::None; + _12 = const Option::<u32>::None; goto -> bb5; } @@ -131,3 +131,7 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { unreachable; } } + +ALLOC0 (size: 8, align: 4) { + 00 00 00 00 __ __ __ __ │ ....░░░░ +} diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir index 3342da545ae..87e7485cb36 100644 --- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir @@ -75,7 +75,7 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb2: { StorageDead(_8); StorageDead(_7); - _12 = Option::<u32>::None; + _12 = const Option::<u32>::None; goto -> bb5; } @@ -139,3 +139,7 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { resume; } } + +ALLOC0 (size: 8, align: 4) { + 00 00 00 00 __ __ __ __ │ ....░░░░ +} diff --git a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir index 6ed3d73b11d..f674f6a3009 100644 --- a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir @@ -46,7 +46,7 @@ fn range_iter_next(_1: &mut std::ops::Range<u32>) -> Option<u32> { bb1: { StorageDead(_3); StorageDead(_2); - _0 = Option::<u32>::None; + _0 = const Option::<u32>::None; goto -> bb4; } @@ -71,3 +71,7 @@ fn range_iter_next(_1: &mut std::ops::Range<u32>) -> Option<u32> { return; } } + +ALLOC0 (size: 8, align: 4) { + 00 00 00 00 __ __ __ __ │ ....░░░░ +} diff --git a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir index a030647deae..a5029dcad3a 100644 --- a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir @@ -46,7 +46,7 @@ fn range_iter_next(_1: &mut std::ops::Range<u32>) -> Option<u32> { bb1: { StorageDead(_3); StorageDead(_2); - _0 = Option::<u32>::None; + _0 = const Option::<u32>::None; goto -> bb4; } @@ -71,3 +71,7 @@ fn range_iter_next(_1: &mut std::ops::Range<u32>) -> Option<u32> { return; } } + +ALLOC0 (size: 8, align: 4) { + 00 00 00 00 __ __ __ __ │ ....░░░░ +} diff --git a/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir index af5d385a979..718dba21a95 100644 --- a/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir @@ -24,7 +24,7 @@ fn ezmap(_1: Option<i32>) -> Option<i32> { } bb1: { - _0 = Option::<i32>::None; + _0 = const Option::<i32>::None; goto -> bb3; } @@ -46,3 +46,7 @@ fn ezmap(_1: Option<i32>) -> Option<i32> { unreachable; } } + +ALLOC0 (size: 8, align: 4) { + 00 00 00 00 __ __ __ __ │ ....░░░░ +} diff --git a/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir index 05f16cdacce..cc009e45e7e 100644 --- a/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir @@ -4,239 +4,217 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:8:25: 8:39}, _2 let mut _0: bool; let mut _3: &(usize, usize, usize, usize); let _4: &usize; - let mut _5: &(usize, usize, usize, usize); + let _5: &usize; let _6: &usize; - let mut _7: &(usize, usize, usize, usize); - let _8: &usize; - let mut _9: &(usize, usize, usize, usize); - let _10: &usize; - let mut _11: &&usize; - let _12: &usize; - let mut _13: &&usize; - let mut _18: bool; - let mut _19: &&usize; - let _20: &usize; - let mut _21: &&usize; - let mut _26: bool; - let mut _27: &&usize; - let _28: &usize; - let mut _29: &&usize; - let mut _34: bool; - let mut _35: &&usize; - let _36: &usize; - let mut _37: &&usize; + let _7: &usize; + let mut _8: &&usize; + let _9: &usize; + let mut _10: &&usize; + let mut _15: bool; + let mut _16: &&usize; + let _17: &usize; + let mut _18: &&usize; + let mut _23: bool; + let mut _24: &&usize; + let _25: &usize; + let mut _26: &&usize; + let mut _31: bool; + let mut _32: &&usize; + let _33: &usize; + let mut _34: &&usize; scope 1 { debug a => _4; - debug b => _6; - debug c => _8; - debug d => _10; + debug b => _5; + debug c => _6; + debug d => _7; scope 2 (inlined std::cmp::impls::<impl PartialOrd for &usize>::le) { - debug self => _11; - debug other => _13; - let mut _14: &usize; - let mut _15: &usize; + debug self => _8; + debug other => _10; + let mut _11: &usize; + let mut _12: &usize; scope 3 (inlined std::cmp::impls::<impl PartialOrd for usize>::le) { - debug self => _14; - debug other => _15; - let mut _16: usize; - let mut _17: usize; + debug self => _11; + debug other => _12; + let mut _13: usize; + let mut _14: usize; } } scope 4 (inlined std::cmp::impls::<impl PartialOrd for &usize>::le) { - debug self => _19; - debug other => _21; - let mut _22: &usize; - let mut _23: &usize; + debug self => _16; + debug other => _18; + let mut _19: &usize; + let mut _20: &usize; scope 5 (inlined std::cmp::impls::<impl PartialOrd for usize>::le) { - debug self => _22; - debug other => _23; - let mut _24: usize; - let mut _25: usize; + debug self => _19; + debug other => _20; + let mut _21: usize; + let mut _22: usize; } } scope 6 (inlined std::cmp::impls::<impl PartialOrd for &usize>::le) { - debug self => _27; - debug other => _29; - let mut _30: &usize; - let mut _31: &usize; + debug self => _24; + debug other => _26; + let mut _27: &usize; + let mut _28: &usize; scope 7 (inlined std::cmp::impls::<impl PartialOrd for usize>::le) { - debug self => _30; - debug other => _31; - let mut _32: usize; - let mut _33: usize; + debug self => _27; + debug other => _28; + let mut _29: usize; + let mut _30: usize; } } scope 8 (inlined std::cmp::impls::<impl PartialOrd for &usize>::le) { - debug self => _35; - debug other => _37; - let mut _38: &usize; - let mut _39: &usize; + debug self => _32; + debug other => _34; + let mut _35: &usize; + let mut _36: &usize; scope 9 (inlined std::cmp::impls::<impl PartialOrd for usize>::le) { - debug self => _38; - debug other => _39; - let mut _40: usize; - let mut _41: usize; + debug self => _35; + debug other => _36; + let mut _37: usize; + let mut _38: usize; } } } bb0: { StorageLive(_4); - _3 = deref_copy (*_2); + _3 = (*_2); _4 = &((*_3).0: usize); + StorageLive(_5); + _5 = &((*_3).1: usize); StorageLive(_6); - _5 = deref_copy (*_2); - _6 = &((*_5).1: usize); + _6 = &((*_3).2: usize); + StorageLive(_7); + _7 = &((*_3).3: usize); + StorageLive(_15); StorageLive(_8); - _7 = deref_copy (*_2); - _8 = &((*_7).2: usize); + _8 = &_4; StorageLive(_10); - _9 = deref_copy (*_2); - _10 = &((*_9).3: usize); - StorageLive(_18); - StorageLive(_11); - _11 = &_4; + StorageLive(_9); + _9 = _6; + _10 = &_9; + _11 = _4; + _12 = _9; StorageLive(_13); - StorageLive(_12); - _12 = _8; - _13 = &_12; + _13 = (*_11); StorageLive(_14); - StorageLive(_15); - _14 = deref_copy _4; - _15 = deref_copy _12; - StorageLive(_16); - _16 = (*_14); - StorageLive(_17); - _17 = (*_15); - _18 = Le(move _16, move _17); - StorageDead(_17); - StorageDead(_16); - StorageDead(_15); + _14 = (*_12); + _15 = Le(move _13, move _14); StorageDead(_14); - switchInt(move _18) -> [0: bb1, otherwise: bb2]; + StorageDead(_13); + switchInt(move _15) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageDead(_12); - StorageDead(_13); - StorageDead(_11); + StorageDead(_9); + StorageDead(_10); + StorageDead(_8); goto -> bb4; } bb2: { - StorageDead(_12); - StorageDead(_13); - StorageDead(_11); - StorageLive(_26); - StorageLive(_19); - _19 = &_10; + StorageDead(_9); + StorageDead(_10); + StorageDead(_8); + StorageLive(_23); + StorageLive(_16); + _16 = &_7; + StorageLive(_18); + StorageLive(_17); + _17 = _5; + _18 = &_17; + _19 = _7; + _20 = _17; StorageLive(_21); - StorageLive(_20); - _20 = _6; - _21 = &_20; + _21 = (*_19); StorageLive(_22); - StorageLive(_23); - _22 = deref_copy _10; - _23 = deref_copy _20; - StorageLive(_24); - _24 = (*_22); - StorageLive(_25); - _25 = (*_23); - _26 = Le(move _24, move _25); - StorageDead(_25); - StorageDead(_24); - StorageDead(_23); + _22 = (*_20); + _23 = Le(move _21, move _22); StorageDead(_22); - switchInt(move _26) -> [0: bb3, otherwise: bb8]; + StorageDead(_21); + switchInt(move _23) -> [0: bb3, otherwise: bb8]; } bb3: { - StorageDead(_20); - StorageDead(_21); - StorageDead(_19); + StorageDead(_17); + StorageDead(_18); + StorageDead(_16); goto -> bb4; } bb4: { - StorageLive(_34); - StorageLive(_27); - _27 = &_8; + StorageLive(_31); + StorageLive(_24); + _24 = &_6; + StorageLive(_26); + StorageLive(_25); + _25 = _4; + _26 = &_25; + _27 = _6; + _28 = _25; StorageLive(_29); - StorageLive(_28); - _28 = _4; - _29 = &_28; + _29 = (*_27); StorageLive(_30); - StorageLive(_31); - _30 = deref_copy _8; - _31 = deref_copy _28; - StorageLive(_32); - _32 = (*_30); - StorageLive(_33); - _33 = (*_31); - _34 = Le(move _32, move _33); - StorageDead(_33); - StorageDead(_32); - StorageDead(_31); + _30 = (*_28); + _31 = Le(move _29, move _30); StorageDead(_30); - switchInt(move _34) -> [0: bb5, otherwise: bb6]; + StorageDead(_29); + switchInt(move _31) -> [0: bb5, otherwise: bb6]; } bb5: { - StorageDead(_28); - StorageDead(_29); - StorageDead(_27); + StorageDead(_25); + StorageDead(_26); + StorageDead(_24); _0 = const false; goto -> bb7; } bb6: { - StorageDead(_28); - StorageDead(_29); - StorageDead(_27); - StorageLive(_35); - _35 = &_6; + StorageDead(_25); + StorageDead(_26); + StorageDead(_24); + StorageLive(_32); + _32 = &_5; + StorageLive(_34); + StorageLive(_33); + _33 = _7; + _34 = &_33; + _35 = _5; + _36 = _33; StorageLive(_37); - StorageLive(_36); - _36 = _10; - _37 = &_36; + _37 = (*_35); StorageLive(_38); - StorageLive(_39); - _38 = deref_copy _6; - _39 = deref_copy _36; - StorageLive(_40); - _40 = (*_38); - StorageLive(_41); - _41 = (*_39); - _0 = Le(move _40, move _41); - StorageDead(_41); - StorageDead(_40); - StorageDead(_39); + _38 = (*_36); + _0 = Le(move _37, move _38); StorageDead(_38); - StorageDead(_36); StorageDead(_37); - StorageDead(_35); + StorageDead(_33); + StorageDead(_34); + StorageDead(_32); goto -> bb7; } bb7: { - StorageDead(_34); + StorageDead(_31); goto -> bb9; } bb8: { - StorageDead(_20); - StorageDead(_21); - StorageDead(_19); + StorageDead(_17); + StorageDead(_18); + StorageDead(_16); _0 = const true; goto -> bb9; } bb9: { - StorageDead(_26); - StorageDead(_18); - StorageDead(_10); - StorageDead(_8); + StorageDead(_23); + StorageDead(_15); + StorageDead(_7); StorageDead(_6); + StorageDead(_5); StorageDead(_4); return; } diff --git a/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir index e2ed1d101dc..5477796512c 100644 --- a/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir @@ -4,46 +4,40 @@ fn variant_b::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:12:25: 12:41}, let mut _0: bool; let mut _3: &(usize, usize, usize, usize); let _4: usize; - let mut _5: &(usize, usize, usize, usize); + let _5: usize; let _6: usize; - let mut _7: &(usize, usize, usize, usize); - let _8: usize; - let mut _9: &(usize, usize, usize, usize); - let _10: usize; - let mut _11: bool; - let mut _12: bool; - let mut _13: bool; + let _7: usize; + let mut _8: bool; + let mut _9: bool; + let mut _10: bool; scope 1 { debug a => _4; - debug b => _6; - debug c => _8; - debug d => _10; + debug b => _5; + debug c => _6; + debug d => _7; } bb0: { - _3 = deref_copy (*_2); + _3 = (*_2); _4 = ((*_3).0: usize); - _5 = deref_copy (*_2); - _6 = ((*_5).1: usize); - _7 = deref_copy (*_2); - _8 = ((*_7).2: usize); - _9 = deref_copy (*_2); - _10 = ((*_9).3: usize); - StorageLive(_11); - _11 = Le(_4, _8); - switchInt(move _11) -> [0: bb2, otherwise: bb1]; + _5 = ((*_3).1: usize); + _6 = ((*_3).2: usize); + _7 = ((*_3).3: usize); + StorageLive(_8); + _8 = Le(_4, _6); + switchInt(move _8) -> [0: bb2, otherwise: bb1]; } bb1: { - StorageLive(_12); - _12 = Le(_10, _6); - switchInt(move _12) -> [0: bb2, otherwise: bb6]; + StorageLive(_9); + _9 = Le(_7, _5); + switchInt(move _9) -> [0: bb2, otherwise: bb6]; } bb2: { - StorageLive(_13); - _13 = Le(_8, _4); - switchInt(move _13) -> [0: bb3, otherwise: bb4]; + StorageLive(_10); + _10 = Le(_6, _4); + switchInt(move _10) -> [0: bb3, otherwise: bb4]; } bb3: { @@ -52,12 +46,12 @@ fn variant_b::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:12:25: 12:41}, } bb4: { - _0 = Le(_6, _10); + _0 = Le(_5, _7); goto -> bb5; } bb5: { - StorageDead(_13); + StorageDead(_10); goto -> bb7; } @@ -67,8 +61,8 @@ fn variant_b::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:12:25: 12:41}, } bb7: { - StorageDead(_12); - StorageDead(_11); + StorageDead(_9); + StorageDead(_8); return; } } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir index e4d9060d4cf..a12411a0413 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir @@ -50,7 +50,6 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { } bb0: { - StorageLive(_7); StorageLive(_4); StorageLive(_3); _3 = Len((*_1)); @@ -86,7 +85,6 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { bb3: { StorageDead(_4); - StorageDead(_7); return; } } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir index e4d9060d4cf..a12411a0413 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir @@ -50,7 +50,6 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { } bb0: { - StorageLive(_7); StorageLive(_4); StorageLive(_3); _3 = Len((*_1)); @@ -86,7 +85,6 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { bb3: { StorageDead(_4); - StorageDead(_7); return; } } diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir index db6922968ae..6a99f15774f 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir @@ -84,7 +84,7 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { bb2: { StorageDead(_8); StorageDead(_7); - _12 = Option::<usize>::None; + _12 = const Option::<usize>::None; goto -> bb5; } @@ -147,3 +147,7 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { unreachable; } } + +ALLOC0 (size: 16, align: 8) { + 00 00 00 00 00 00 00 00 __ __ __ __ __ __ __ __ │ ........░░░░░░░░ +} diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir index 81d1832eebb..4f028fa0a64 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir @@ -84,7 +84,7 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { bb2: { StorageDead(_8); StorageDead(_7); - _12 = Option::<usize>::None; + _12 = const Option::<usize>::None; goto -> bb5; } @@ -155,3 +155,7 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { resume; } } + +ALLOC0 (size: 16, align: 8) { + 00 00 00 00 00 00 00 00 __ __ __ __ __ __ __ __ │ ........░░░░░░░░ +} diff --git a/tests/mir-opt/reference_prop.rs b/tests/mir-opt/reference_prop.rs index 1b9c8fe15c2..8adfbb4535b 100644 --- a/tests/mir-opt/reference_prop.rs +++ b/tests/mir-opt/reference_prop.rs @@ -1,3 +1,4 @@ +// compile-flags: -Zlint-mir=no // unit-test: ReferencePropagation // needs-unwind diff --git a/tests/mir-opt/simplify_match.main.ConstProp.panic-abort.diff b/tests/mir-opt/simplify_match.main.GVN.panic-abort.diff index 6025abb7382..825babe7994 100644 --- a/tests/mir-opt/simplify_match.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/simplify_match.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/simplify_match.main.ConstProp.panic-unwind.diff b/tests/mir-opt/simplify_match.main.GVN.panic-unwind.diff index c881dec28c7..24ab6c39788 100644 --- a/tests/mir-opt/simplify_match.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/simplify_match.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/simplify_match.rs b/tests/mir-opt/simplify_match.rs index eb385005cd9..2eac93edbb8 100644 --- a/tests/mir-opt/simplify_match.rs +++ b/tests/mir-opt/simplify_match.rs @@ -3,7 +3,7 @@ #[inline(never)] fn noop() {} -// EMIT_MIR simplify_match.main.ConstProp.diff +// EMIT_MIR simplify_match.main.GVN.diff fn main() { match { let x = false; x } { true => noop(), diff --git a/tests/pretty/issue-4264.pp b/tests/pretty/issue-4264.pp index 4020a433d62..2d713832dcd 100644 --- a/tests/pretty/issue-4264.pp +++ b/tests/pretty/issue-4264.pp @@ -32,7 +32,7 @@ fn bar() ({ ({ let res = ((::alloc::fmt::format as - for<'a> fn(Arguments<'a>) -> String {format})(((<#[lang = "format_arguments"]>::new_const + for<'a> fn(Arguments<'a>) -> String {format})(((format_arguments::new_const as fn(&[&'static str]) -> Arguments<'_> {Arguments::<'_>::new_const})((&([("test" as &str)] as [&str; 1]) as &[&str; 1])) as Arguments<'_>)) diff --git a/tests/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs b/tests/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs index 086ca0bdf37..9e0a7ba63d0 100644 --- a/tests/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs +++ b/tests/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs @@ -67,7 +67,7 @@ impl CodegenBackend for TheBackend { let crate_name = codegen_results.crate_info.local_crate_name; for &crate_type in sess.opts.crate_types.iter() { if crate_type != CrateType::Rlib { - sess.fatal(format!("Crate type is {:?}", crate_type)); + sess.dcx().fatal(format!("Crate type is {:?}", crate_type)); } let output_name = out_filename(sess, crate_type, &outputs, crate_name); match output_name { diff --git a/tests/run-make-fulldeps/obtain-borrowck/driver.rs b/tests/run-make-fulldeps/obtain-borrowck/driver.rs index 9cbe9e5900a..2e3bf70e144 100644 --- a/tests/run-make-fulldeps/obtain-borrowck/driver.rs +++ b/tests/run-make-fulldeps/obtain-borrowck/driver.rs @@ -61,7 +61,7 @@ impl rustc_driver::Callbacks for CompilerCalls { compiler: &Compiler, queries: &'tcx Queries<'tcx>, ) -> Compilation { - compiler.sess.abort_if_errors(); + compiler.sess.dcx().abort_if_errors(); queries.global_ctxt().unwrap().enter(|tcx| { // Collect definition ids of MIR bodies. let hir = tcx.hir(); diff --git a/tests/rustdoc-gui/globals.goml b/tests/rustdoc-gui/globals.goml new file mode 100644 index 00000000000..53f96ff086e --- /dev/null +++ b/tests/rustdoc-gui/globals.goml @@ -0,0 +1,24 @@ +// Make sure search stores its data in `window` +// It needs to use a global to avoid racing on search-index.js and search.js +// https://github.com/rust-lang/rust/pull/118961 + +// URL query +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=sa'%3Bda'%3Bds" +wait-for: "#search-tabs" +assert-window-property-false: {"searchIndex": null} +assert-window-property: {"srcIndex": null} + +// Form input +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +write: (".search-input", "Foo") +press-key: 'Enter' +wait-for: "#search-tabs" +assert-window-property-false: {"searchIndex": null} +assert-window-property: {"srcIndex": null} + +// source sidebar +go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" +click: "#src-sidebar-toggle" +wait-for: "#src-sidebar details" +assert-window-property-false: {"srcIndex": null} +assert-window-property: {"searchIndex": null} diff --git a/tests/rustdoc-gui/hide-mobile-topbar.goml b/tests/rustdoc-gui/hide-mobile-topbar.goml new file mode 100644 index 00000000000..46eb8acfe8c --- /dev/null +++ b/tests/rustdoc-gui/hide-mobile-topbar.goml @@ -0,0 +1,20 @@ +// Checks sidebar resizing stays synced with the setting +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +set-window-size: (400, 600) + +// Verify that the "hide" option is unchecked +click: "#settings-menu" +wait-for: "#settings" +assert-css: ("#settings", {"display": "block"}) +assert-property: ("#hide-sidebar", {"checked": "false"}) +assert-css: (".mobile-topbar", {"display": "flex"}) + +// Toggle it +click: "#hide-sidebar" +assert-property: ("#hide-sidebar", {"checked": "true"}) +assert-css: (".mobile-topbar", {"display": "none"}) + +// Toggle it again +click: "#hide-sidebar" +assert-property: ("#hide-sidebar", {"checked": "false"}) +assert-css: (".mobile-topbar", {"display": "flex"}) diff --git a/tests/rustdoc-gui/links-color.goml b/tests/rustdoc-gui/links-color.goml index 0789d785f58..d88ebfb40d7 100644 --- a/tests/rustdoc-gui/links-color.goml +++ b/tests/rustdoc-gui/links-color.goml @@ -26,12 +26,12 @@ define-function: ( assert-css: (".item-table .keyword", {"color": |keyword|}, ALL) // Checking sidebar elements. assert-css: ( - ".sidebar-elems a:not(.current)", + ".sidebar-elems li:not(.current) a", {"color": |sidebar|, "background-color": "rgba(0, 0, 0, 0)", "font-weight": "400"}, ALL, ) assert-css: ( - ".sidebar-elems a.current", + ".sidebar-elems li.current a", { "color": |sidebar_current|, "background-color": |sidebar_current_background|, diff --git a/tests/rustdoc-gui/search-form-elements.goml b/tests/rustdoc-gui/search-form-elements.goml index a4e22364859..0ea61a4f0eb 100644 --- a/tests/rustdoc-gui/search-form-elements.goml +++ b/tests/rustdoc-gui/search-form-elements.goml @@ -137,3 +137,12 @@ call-function: ( "menu_a_color": "#3873ad", } ) + +// Check that search input correctly decodes form encoding. +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=a+b" +wait-for: "#search-tabs" // Waiting for the search.js to load. +assert-property: (".search-input", { "value": "a b" }) +// Check that literal + is not treated as space. +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=a%2Bb" +wait-for: "#search-tabs" // Waiting for the search.js to load. +assert-property: (".search-input", { "value": "a+b" }) diff --git a/tests/rustdoc-gui/sidebar-links-color.goml b/tests/rustdoc-gui/sidebar-links-color.goml index 079d582a567..774fbcac1e2 100644 --- a/tests/rustdoc-gui/sidebar-links-color.goml +++ b/tests/rustdoc-gui/sidebar-links-color.goml @@ -17,10 +17,10 @@ define-function: ( reload: // Struct assert-css: ( - ".sidebar .block.struct a:not(.current)", + ".sidebar .block.struct li:not(.current) a", {"color": |struct|, "background-color": "rgba(0, 0, 0, 0)"}, ) - move-cursor-to: ".sidebar .block.struct a:not(.current)" + move-cursor-to: ".sidebar .block.struct li:not(.current) a" assert-css: ( ".sidebar .block.struct a:hover", {"color": |struct_hover|, "background-color": |struct_hover_background|}, diff --git a/tests/rustdoc-gui/sidebar-resize-setting.goml b/tests/rustdoc-gui/sidebar-resize-setting.goml new file mode 100644 index 00000000000..2fdb2faa864 --- /dev/null +++ b/tests/rustdoc-gui/sidebar-resize-setting.goml @@ -0,0 +1,23 @@ +// Checks sidebar resizing stays synced with the setting +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +assert-property: (".sidebar", {"clientWidth": "200"}) +show-text: true + +// Verify that the "hide" option is unchecked +click: "#settings-menu" +wait-for: "#settings" +assert-css: ("#settings", {"display": "block"}) +assert-property: ("#hide-sidebar", {"checked": "false"}) +press-key: "Escape" +wait-for-css: ("#settings", {"display": "none"}) + +drag-and-drop: ((205, 100), (5, 100)) +assert-css: (".sidebar", {"display": "none"}) + +// Verify that the "hide" option is checked +focus: "#settings-menu a" +press-key: "Enter" +wait-for-css: ("#settings", {"display": "block"}) +assert-property: ("#hide-sidebar", {"checked": "true"}) +click: "#hide-sidebar" +wait-for-css: (".sidebar", {"display": "block"}) diff --git a/tests/rustdoc-gui/sidebar-resize-window.goml b/tests/rustdoc-gui/sidebar-resize-window.goml new file mode 100644 index 00000000000..fb6baafda71 --- /dev/null +++ b/tests/rustdoc-gui/sidebar-resize-window.goml @@ -0,0 +1,37 @@ +// Checks sidebar resizing +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +set-window-size: (1280, 600) +wait-for-property: (".sidebar", {"clientWidth": 200}, [NEAR]) + +// resize past maximum (don't grow past 500) +drag-and-drop: ((205, 100), (600, 100)) +wait-for-property: (".sidebar", {"clientWidth": 500}, [NEAR]) + +// make the window small enough that the sidebar has to shrink +set-window-size: (750, 600) +wait-for-property: (".sidebar", {"clientWidth": 350}, [NEAR]) + +// grow the window again to make the sidebar bigger +set-window-size: (1280, 600) +wait-for-property: (".sidebar", {"clientWidth": 500}, [NEAR]) + +// make the window small enough that the sidebar has to shrink +set-window-size: (750, 600) +wait-for-property: (".sidebar", {"clientWidth": 350}, [NEAR]) +assert-local-storage: {"rustdoc-desktop-sidebar-width": "350"} +set-window-size: (400, 600) +wait-for-css: (".sidebar", {"display": "block", "left": "-1000px"}) +assert-local-storage: {"rustdoc-desktop-sidebar-width": "350"} + +// grow the window again to make the sidebar bigger +set-window-size: (1280, 600) +wait-for-property: (".sidebar", {"clientWidth": 500}, [NEAR]) + +// shrink back down again, then reload the page +// the "desired size" is a bit of remembered implicit state, +// and rustdoc tries to minimize things like this +set-window-size: (800, 600) +wait-for-property: (".sidebar", {"clientWidth": 400}, [NEAR]) +reload: +set-window-size: (1280, 600) +wait-for-property: (".sidebar", {"clientWidth": 400}, [NEAR]) diff --git a/tests/rustdoc-gui/sidebar-resize.goml b/tests/rustdoc-gui/sidebar-resize.goml new file mode 100644 index 00000000000..543d5d390c7 --- /dev/null +++ b/tests/rustdoc-gui/sidebar-resize.goml @@ -0,0 +1,28 @@ +// Checks sidebar resizing +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +assert-property: (".sidebar", {"clientWidth": "200"}) +show-text: true +// normal resizing +drag-and-drop: ((205, 100), (185, 100)) +assert-property: (".sidebar", {"clientWidth": "182"}) +// resize past maximum (don't grow past 500) +drag-and-drop: ((185, 100), (600, 100)) +assert-property: (".sidebar", {"clientWidth": "500"}) +// resize past minimum (hide sidebar) +drag-and-drop: ((501, 100), (5, 100)) +assert-property: (".sidebar", {"clientWidth": "0"}) +assert-css: (".sidebar", {"display": "none"}) +assert-local-storage: {"rustdoc-hide-sidebar": "true"} +set-local-storage: {"rustdoc-hide-sidebar": "false"} + +// Now same thing, but for source code +go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" +assert-property: (".sidebar", {"clientWidth": "49"}) +drag-and-drop: ((52, 100), (185, 100)) +assert-property: (".sidebar", {"clientWidth": "181"}) +drag-and-drop: ((185, 100), (600, 100)) +assert-property: (".sidebar", {"clientWidth": "499"}) +drag-and-drop: ((500, 100), (5, 100)) +// instead of hiding the sidebar entirely, this +// will switch to the toggle mode +assert-property: (".sidebar", {"clientWidth": "49"}) diff --git a/tests/rustdoc-gui/sidebar-source-code.goml b/tests/rustdoc-gui/sidebar-source-code.goml index 0d72e670cf4..9fc1409e86f 100644 --- a/tests/rustdoc-gui/sidebar-source-code.goml +++ b/tests/rustdoc-gui/sidebar-source-code.goml @@ -48,6 +48,7 @@ call-function: ( // Next, desktop mode layout. set-window-size: (1100, 800) +wait-for: "#src-sidebar-toggle" // We check that the sidebar isn't expanded and has the expected width. assert-css: ("nav.sidebar", {"width": "50px"}) // We now click on the button to expand the sidebar. @@ -58,7 +59,7 @@ assert-css: (".src-sidebar-expanded nav.sidebar a", {"font-size": "14px"}) // We collapse the sidebar. click: (10, 10) // We ensure that the class has been removed. -wait-for: "html:not(.expanded)" +wait-for: "html:not(.src-sidebar-expanded)" assert: "nav.sidebar" // Checking that only the path to the current file is "open". diff --git a/tests/rustdoc-gui/sidebar.goml b/tests/rustdoc-gui/sidebar.goml index eff66d803d2..82b4f2e9429 100644 --- a/tests/rustdoc-gui/sidebar.goml +++ b/tests/rustdoc-gui/sidebar.goml @@ -57,7 +57,7 @@ assert-count: (".sidebar h2", 1) assert-text: ("#all-types", "All Items") assert-css: ("#all-types", {"color": "#356da4"}) // We check that we have the crates list and that the "current" on is "test_docs". -assert-text: (".sidebar-elems ul.crate > li > a.current", "test_docs") +assert-text: (".sidebar-elems ul.crate > li.current > a", "test_docs") // And we're also supposed to have the list of items in the current module. assert-text: (".sidebar-elems section ul > li:nth-child(1)", "Re-exports") assert-text: (".sidebar-elems section ul > li:nth-child(2)", "Modules") @@ -98,7 +98,7 @@ assert-property: (".sidebar", {"clientWidth": "200"}) assert-text: (".sidebar > .sidebar-crate > h2 > a", "lib2") assert-count: (".sidebar .location", 0) // We check that we have the crates list and that the "current" on is now "lib2". -assert-text: (".sidebar-elems ul.crate > li > a.current", "lib2") +assert-text: (".sidebar-elems ul.crate > li.current > a", "lib2") // We now go to the "foobar" function page. assert-text: (".sidebar-elems > section ul.block > li:nth-child(1)", "Modules") assert-text: (".sidebar-elems > section ul.block > li:nth-child(2)", "Structs") diff --git a/tests/rustdoc-gui/src/test_docs/lib.rs b/tests/rustdoc-gui/src/test_docs/lib.rs index 0bc777230bf..7e34178e56f 100644 --- a/tests/rustdoc-gui/src/test_docs/lib.rs +++ b/tests/rustdoc-gui/src/test_docs/lib.rs @@ -85,6 +85,9 @@ impl AsRef<str> for Foo { } } +/// <div id="doc-warning-0" class="warning">I have warnings!</div> +pub struct WarningStruct; + /// Just a normal enum. /// /// # title! diff --git a/tests/rustdoc-gui/src/theme_css/custom-theme.css b/tests/rustdoc-gui/src/theme_css/custom-theme.css index 260ef87f6ea..49227d9ea11 100644 --- a/tests/rustdoc-gui/src/theme_css/custom-theme.css +++ b/tests/rustdoc-gui/src/theme_css/custom-theme.css @@ -96,4 +96,6 @@ --scrape-example-help-hover-color: #000; --scrape-example-code-wrapper-background-start: rgba(255, 255, 255, 1); --scrape-example-code-wrapper-background-end: rgba(255, 255, 255, 0); + --sidebar-resizer-hover: hsl(207, 90%, 66%); + --sidebar-resizer-active: hsl(207, 90%, 54%); } diff --git a/tests/rustdoc-gui/warning-block.goml b/tests/rustdoc-gui/warning-block.goml index 8832b65c4d8..10e206049f5 100644 --- a/tests/rustdoc-gui/warning-block.goml +++ b/tests/rustdoc-gui/warning-block.goml @@ -2,6 +2,7 @@ go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" show-text: true +store-value: (default_y_pos, 5) define-function: ( "check-warning", (theme, color, border_color), @@ -16,12 +17,18 @@ define-function: ( "border-left": "2px solid " + |border_color|, "background-color": "transparent", }) + store-position: ("#doc-warning-1", {"y": warn_div_y}) + store-position: ("#doc-warning-1::before", {"y": warn_y}) + assert: |warn_y| == |warn_div_y| + |default_y_pos| assert-css: ("#doc-warning-2", { "margin-bottom": "0px", "color": |color|, "border-left": "2px solid " + |border_color|, "background-color": "transparent", }) + store-position: ("#doc-warning-2", {"y": warn_div_y}) + store-position: ("#doc-warning-2::before", {"y": warn_y}) + assert: |warn_y| == |warn_div_y| + |default_y_pos| }, ) @@ -40,3 +47,9 @@ call-function: ("check-warning", { "color": "black", "border_color": "#ff8e00", }) + +// We ensure that the warning element in the top doc is not overlaying the "[-]" button. +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.WarningStruct.html" +store-position: ("#doc-warning-0", {"y": warn_div_y}) +store-position: ("#doc-warning-0::before", {"y": warn_y}) +assert: |warn_y| == |warn_div_y| + |default_y_pos| + 15 diff --git a/tests/rustdoc-js-std/asrawfd.js b/tests/rustdoc-js-std/asrawfd.js index 5b3cfeabbcd..5dbc4ba95d9 100644 --- a/tests/rustdoc-js-std/asrawfd.js +++ b/tests/rustdoc-js-std/asrawfd.js @@ -7,7 +7,6 @@ const EXPECTED = { // Validate that type alias methods get the correct path. { 'path': 'std::os::fd::AsRawFd', 'name': 'as_raw_fd' }, { 'path': 'std::os::fd::AsRawFd', 'name': 'as_raw_fd' }, - { 'path': 'std::os::linux::process::PidFd', 'name': 'as_raw_fd' }, { 'path': 'std::os::fd::RawFd', 'name': 'as_raw_fd' }, ], }; diff --git a/tests/rustdoc-js-std/path-maxeditdistance.js b/tests/rustdoc-js-std/path-maxeditdistance.js new file mode 100644 index 00000000000..822389aaa4f --- /dev/null +++ b/tests/rustdoc-js-std/path-maxeditdistance.js @@ -0,0 +1,42 @@ +// exact-check +const FILTER_CRATE = "std"; +const EXPECTED = [ + { + query: 'vec::intoiterator', + others: [ + // trait std::iter::IntoIterator is not the first result + { 'path': 'std::vec', 'name': 'IntoIter' }, + { 'path': 'std::vec::Vec', 'name': 'into_iter' }, + { 'path': 'std::vec::Drain', 'name': 'into_iter' }, + { 'path': 'std::vec::IntoIter', 'name': 'into_iter' }, + { 'path': 'std::vec::ExtractIf', 'name': 'into_iter' }, + { 'path': 'std::vec::Splice', 'name': 'into_iter' }, + { 'path': 'std::collections::VecDeque', 'name': 'into_iter' }, + ], + }, + { + query: 'vec::iter', + others: [ + // std::net::ToSocketAttrs::iter should not show up here + { 'path': 'std::vec', 'name': 'IntoIter' }, + { 'path': 'std::vec::Vec', 'name': 'from_iter' }, + { 'path': 'std::vec::Vec', 'name': 'into_iter' }, + { 'path': 'std::vec::Drain', 'name': 'into_iter' }, + { 'path': 'std::vec::IntoIter', 'name': 'into_iter' }, + { 'path': 'std::vec::ExtractIf', 'name': 'into_iter' }, + { 'path': 'std::vec::Splice', 'name': 'into_iter' }, + { 'path': 'std::collections::VecDeque', 'name': 'iter' }, + { 'path': 'std::collections::VecDeque', 'name': 'iter_mut' }, + { 'path': 'std::collections::VecDeque', 'name': 'from_iter' }, + { 'path': 'std::collections::VecDeque', 'name': 'into_iter' }, + ], + }, + { + query: 'slice::itermut', + others: [ + // std::collections::btree_map::itermut should not show up here + { 'path': 'std::slice', 'name': 'IterMut' }, + { 'path': 'std::slice', 'name': 'iter_mut' }, + ], + }, +]; diff --git a/tests/rustdoc-js-std/path-ordering.js b/tests/rustdoc-js-std/path-ordering.js index c3d61d238cc..e6b7bfab1e5 100644 --- a/tests/rustdoc-js-std/path-ordering.js +++ b/tests/rustdoc-js-std/path-ordering.js @@ -1,11 +1,20 @@ -const EXPECTED = { - query: 'hashset::insert', - others: [ - // ensure hashset::insert comes first - { 'path': 'std::collections::hash_set::HashSet', 'name': 'insert' }, - { 'path': 'std::collections::hash_set::HashSet', 'name': 'get_or_insert' }, - { 'path': 'std::collections::hash_set::HashSet', 'name': 'get_or_insert_with' }, - { 'path': 'std::collections::hash_set::HashSet', 'name': 'get_or_insert_owned' }, - { 'path': 'std::collections::hash_map::HashMap', 'name': 'insert' }, - ], -}; +const EXPECTED = [ + { + query: 'hashset::insert', + others: [ + // ensure hashset::insert comes first + { 'path': 'std::collections::hash_set::HashSet', 'name': 'insert' }, + { 'path': 'std::collections::hash_set::HashSet', 'name': 'get_or_insert' }, + { 'path': 'std::collections::hash_set::HashSet', 'name': 'get_or_insert_with' }, + { 'path': 'std::collections::hash_set::HashSet', 'name': 'get_or_insert_owned' }, + ], + }, + { + query: 'hash::insert', + others: [ + // ensure hashset/hashmap::insert come first + { 'path': 'std::collections::hash_map::HashMap', 'name': 'insert' }, + { 'path': 'std::collections::hash_set::HashSet', 'name': 'insert' }, + ], + }, +]; diff --git a/tests/rustdoc-js/assoc-type.js b/tests/rustdoc-js/assoc-type.js index 47776656e32..eec4e7a8258 100644 --- a/tests/rustdoc-js/assoc-type.js +++ b/tests/rustdoc-js/assoc-type.js @@ -7,16 +7,16 @@ const EXPECTED = [ 'query': 'iterator<something> -> u32', 'correction': null, 'others': [ - { 'path': 'assoc_type', 'name': 'my_fn' }, { 'path': 'assoc_type::my', 'name': 'other_fn' }, + { 'path': 'assoc_type', 'name': 'my_fn' }, ], }, { 'query': 'iterator<something>', 'correction': null, 'in_args': [ - { 'path': 'assoc_type', 'name': 'my_fn' }, { 'path': 'assoc_type::my', 'name': 'other_fn' }, + { 'path': 'assoc_type', 'name': 'my_fn' }, ], }, { @@ -26,8 +26,8 @@ const EXPECTED = [ { 'path': 'assoc_type', 'name': 'Something' }, ], 'in_args': [ - { 'path': 'assoc_type', 'name': 'my_fn' }, { 'path': 'assoc_type::my', 'name': 'other_fn' }, + { 'path': 'assoc_type', 'name': 'my_fn' }, ], }, // if I write an explicit binding, only it shows up diff --git a/tests/rustdoc-js/big-result.js b/tests/rustdoc-js/big-result.js new file mode 100644 index 00000000000..07961d196f4 --- /dev/null +++ b/tests/rustdoc-js/big-result.js @@ -0,0 +1,39 @@ +// exact-check + +const EXPECTED = [ + { + 'query': 'First', + 'in_args': (function() { + // Generate the list of 200 items that should match. + const results = []; + function generate(lx, ly) { + for (const x of lx) { + for (const y of ly) { + results.push({ + 'path': `big_result::${y}`, + 'name': x, + }); + } + } + } + // Fewest parameters that still match go on top. + generate( + ['u', 'v', 'w', 'x', 'y'], + ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'] + ); + generate( + ['p', 'q', 'r', 's', 't'], + ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'] + ); + generate( + ['k', 'l', 'm', 'n', 'o'], + ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'] + ); + generate( + ['f', 'g', 'h', 'i', 'j'], + ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'] + ); + return results; + })(), + }, +]; diff --git a/tests/rustdoc-js/big-result.rs b/tests/rustdoc-js/big-result.rs new file mode 100644 index 00000000000..4dfecd6aaad --- /dev/null +++ b/tests/rustdoc-js/big-result.rs @@ -0,0 +1,61 @@ +#![feature(concat_idents)] +#![allow(nonstandard_style)] +/// Generate 250 items that all match the query, starting with the longest. +/// Those long items should be dropped from the result set, and the short ones +/// should be shown instead. +macro_rules! generate { + ([$($x:ident),+], $y:tt, $z:tt) => { + $( + generate!(@ $x, $y, $z); + )+ + }; + (@ $x:ident , [$($y:ident),+], $z:tt) => { + pub struct $x; + $( + generate!(@@ $x, $y, $z); + )+ + }; + (@@ $x:ident , $y:ident, [$($z:ident: $zt:ident),+]) => { + impl $y { + pub fn $x($($z: $zt,)+) {} + } + } +} + +pub struct First; +pub struct Second; +pub struct Third; +pub struct Fourth; +pub struct Fifth; + +generate!( + [a, b, c, d, e], + [a, b, c, d, e, f, g, h, i, j], + [a: First, b: Second, c: Third, d: Fourth, e: Fifth] +); + +generate!( + [f, g, h, i, j], + [a, b, c, d, e, f, g, h, i, j], + [a: First, b: Second, c: Third, d: Fourth] +); + +generate!( + [k, l, m, n, o], + [a, b, c, d, e, f, g, h, i, j], + [a: First, b: Second, c: Third] +); + +generate!( + // reverse it, just to make sure they're alphabetized + // in the result set when all else is equal + [t, s, r, q, p], + [a, b, c, d, e, f, g, h, i, j], + [a: First, b: Second] +); + +generate!( + [u, v, w, x, y], + [a, b, c, d, e, f, g, h, i, j], + [a: First] +); diff --git a/tests/rustdoc-js/exact-match.js b/tests/rustdoc-js/exact-match.js index ce3a76f9b7d..9e47d27490b 100644 --- a/tests/rustdoc-js/exact-match.js +++ b/tests/rustdoc-js/exact-match.js @@ -3,6 +3,5 @@ const EXPECTED = { 'others': [ { 'path': 'exact_match::Si', 'name': 'pc' }, { 'path': 'exact_match::Psi', 'name': 'pc' }, - { 'path': 'exact_match::Si', 'name': 'pa' }, ], }; diff --git a/tests/rustdoc-js/full-path-function.js b/tests/rustdoc-js/full-path-function.js index 48be51b156f..0464f792217 100644 --- a/tests/rustdoc-js/full-path-function.js +++ b/tests/rustdoc-js/full-path-function.js @@ -4,16 +4,16 @@ const EXPECTED = [ { 'query': 'sac -> usize', 'others': [ - { 'path': 'full_path_function::b::Sac', 'name': 'bar' }, { 'path': 'full_path_function::b::Sac', 'name': 'len' }, { 'path': 'full_path_function::sac::Sac', 'name': 'len' }, + { 'path': 'full_path_function::b::Sac', 'name': 'bar' }, ], }, { 'query': 'b::sac -> usize', 'others': [ - { 'path': 'full_path_function::b::Sac', 'name': 'bar' }, { 'path': 'full_path_function::b::Sac', 'name': 'len' }, + { 'path': 'full_path_function::b::Sac', 'name': 'bar' }, ], }, { diff --git a/tests/rustdoc-js/generics.js b/tests/rustdoc-js/generics.js index ebc92ccfc05..b3ca0af3056 100644 --- a/tests/rustdoc-js/generics.js +++ b/tests/rustdoc-js/generics.js @@ -1,4 +1,5 @@ // exact-check +// ignore-order const EXPECTED = [ { diff --git a/tests/rustdoc-js/impl-trait.js b/tests/rustdoc-js/impl-trait.js index 00d67d639bd..8bb3f2d3e99 100644 --- a/tests/rustdoc-js/impl-trait.js +++ b/tests/rustdoc-js/impl-trait.js @@ -39,8 +39,8 @@ const EXPECTED = [ { 'path': 'impl_trait', 'name': 'Aaaaaaa' }, ], 'in_args': [ - { 'path': 'impl_trait::Ccccccc', 'name': 'eeeeeee' }, { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' }, + { 'path': 'impl_trait::Ccccccc', 'name': 'eeeeeee' }, ], 'returned': [ { 'path': 'impl_trait', 'name': 'bbbbbbb' }, diff --git a/tests/rustdoc-js/module-substring.js b/tests/rustdoc-js/module-substring.js index 7a10397ebc6..74c421d7f0b 100644 --- a/tests/rustdoc-js/module-substring.js +++ b/tests/rustdoc-js/module-substring.js @@ -1,7 +1,15 @@ -const EXPECTED = { - 'query': 'ig::pc', - 'others': [ - { 'path': 'module_substring::Sig', 'name': 'pc' }, - { 'path': 'module_substring::Si', 'name': 'pc' }, - ], -}; +const EXPECTED = [ + { + 'query': 'ig::pc', + 'others': [ + { 'path': 'module_substring::Sig', 'name': 'pc' }, + ], + }, + { + 'query': 'si::pc', + 'others': [ + { 'path': 'module_substring::Si', 'name': 'pc' }, + { 'path': 'module_substring::Sig', 'name': 'pc' }, + ], + }, +]; diff --git a/tests/rustdoc-js/path-maxeditdistance.js b/tests/rustdoc-js/path-maxeditdistance.js new file mode 100644 index 00000000000..73b24a6dddf --- /dev/null +++ b/tests/rustdoc-js/path-maxeditdistance.js @@ -0,0 +1,35 @@ +// exact-check + +const EXPECTED = [ + { + 'query': 'xxxxxxxxxxx::hocuspocusprestidigitation', + // do not match abracadabra::hocuspocusprestidigitation + 'others': [], + }, + { + // exact match + 'query': 'abracadabra::hocuspocusprestidigitation', + 'others': [ + { 'path': 'abracadabra', 'name': 'HocusPocusPrestidigitation' }, + ], + }, + { + // swap br/rb; that's edit distance 2, where maxPathEditDistance = 3 (11 / 3) + 'query': 'arbacadarba::hocuspocusprestidigitation', + 'others': [ + { 'path': 'abracadabra', 'name': 'HocusPocusPrestidigitation' }, + ], + }, + { + // truncate 5 chars, where maxEditDistance = 7 (21 / 3) + 'query': 'abracadarba::hocusprestidigitation', + 'others': [ + { 'path': 'abracadabra', 'name': 'HocusPocusPrestidigitation' }, + ], + }, + { + // truncate 9 chars, where maxEditDistance = 5 (17 / 3) + 'query': 'abracadarba::hprestidigitation', + 'others': [], + }, +]; diff --git a/tests/rustdoc-js/path-maxeditdistance.rs b/tests/rustdoc-js/path-maxeditdistance.rs new file mode 100644 index 00000000000..3861280d59b --- /dev/null +++ b/tests/rustdoc-js/path-maxeditdistance.rs @@ -0,0 +1,3 @@ +#![crate_name="abracadabra"] + +pub struct HocusPocusPrestidigitation; diff --git a/tests/rustdoc-js/path-ordering.js b/tests/rustdoc-js/path-ordering.js index f2e6fe2fa61..73d3f4b2755 100644 --- a/tests/rustdoc-js/path-ordering.js +++ b/tests/rustdoc-js/path-ordering.js @@ -1,13 +1,13 @@ // exact-check const EXPECTED = { - 'query': 'b::ccccccc', + 'query': 'bbbbbb::ccccccc', 'others': [ // `ccccccc` is an exact match for all three of these. // However `b` is a closer match for `bb` than for any // of the others, so it ought to go first. - { 'path': 'path_ordering::bb', 'name': 'Ccccccc' }, - { 'path': 'path_ordering::aa', 'name': 'Ccccccc' }, - { 'path': 'path_ordering::dd', 'name': 'Ccccccc' }, + { 'path': 'path_ordering::bbbbbb', 'name': 'Ccccccc' }, + { 'path': 'path_ordering::abbbbb', 'name': 'Ccccccc' }, + { 'path': 'path_ordering::dbbbbb', 'name': 'Ccccccc' }, ], }; diff --git a/tests/rustdoc-js/path-ordering.rs b/tests/rustdoc-js/path-ordering.rs index 7843cf7f9dc..71e24923ed1 100644 --- a/tests/rustdoc-js/path-ordering.rs +++ b/tests/rustdoc-js/path-ordering.rs @@ -1,9 +1,9 @@ -pub mod dd { +pub mod dbbbbb { pub struct Ccccccc; } -pub mod aa { +pub mod abbbbb { pub struct Ccccccc; } -pub mod bb { +pub mod bbbbbb { pub struct Ccccccc; } diff --git a/tests/rustdoc-js/substring.js b/tests/rustdoc-js/substring.js index 96efa992bb6..b791ac4bfd1 100644 --- a/tests/rustdoc-js/substring.js +++ b/tests/rustdoc-js/substring.js @@ -1,7 +1,15 @@ -const EXPECTED = { - 'query': 'waker_from', - 'others': [ - { 'path': 'substring::SuperWaker', 'name': 'local_waker_from_nonlocal' }, - { 'path': 'substring::SuperWakerTask', 'name': 'local_waker_from_nonlocal' }, - ], -}; +const EXPECTED = [ + { + 'query': 'waker_from', + 'others': [ + { 'path': 'substring::SuperWaker', 'name': 'local_waker_from_nonlocal' }, + { 'path': 'substring::SuperWakerTask', 'name': 'local_waker_from_nonlocal' }, + ], + }, + { + 'query': 'my', + 'others': [ + { 'path': 'substring', 'name': 'm_y_substringmatching' }, + ], + }, +]; diff --git a/tests/rustdoc-js/substring.rs b/tests/rustdoc-js/substring.rs index e729c722c79..ea88894d03d 100644 --- a/tests/rustdoc-js/substring.rs +++ b/tests/rustdoc-js/substring.rs @@ -19,3 +19,5 @@ impl SuperWakerTask { pub fn waker_non_local() {} pub fn from_non_local() {} } + +pub fn m_y_substringmatching() {} diff --git a/tests/rustdoc-js/type-parameters.js b/tests/rustdoc-js/type-parameters.js index e695f189bb6..e045409e507 100644 --- a/tests/rustdoc-js/type-parameters.js +++ b/tests/rustdoc-js/type-parameters.js @@ -1,20 +1,19 @@ // exact-check -// ignore-order const EXPECTED = [ { query: '-> trait:Some', others: [ - { path: 'foo', name: 'alef' }, { path: 'foo', name: 'alpha' }, + { path: 'foo', name: 'alef' }, ], }, { query: '-> generic:T', others: [ + { path: 'foo', name: 'beta' }, { path: 'foo', name: 'bet' }, { path: 'foo', name: 'alef' }, - { path: 'foo', name: 'beta' }, ], }, { @@ -44,38 +43,40 @@ const EXPECTED = [ { query: 'Other, Other', others: [ - { path: 'foo', name: 'other' }, { path: 'foo', name: 'alternate' }, + { path: 'foo', name: 'other' }, ], }, { query: 'generic:T', in_args: [ - { path: 'foo', name: 'bet' }, { path: 'foo', name: 'beta' }, - { path: 'foo', name: 'other' }, + { path: 'foo', name: 'bet' }, { path: 'foo', name: 'alternate' }, + { path: 'foo', name: 'other' }, ], }, { query: 'generic:Other', in_args: [ - { path: 'foo', name: 'bet' }, { path: 'foo', name: 'beta' }, - { path: 'foo', name: 'other' }, + { path: 'foo', name: 'bet' }, { path: 'foo', name: 'alternate' }, + { path: 'foo', name: 'other' }, ], }, { query: 'trait:Other', in_args: [ - { path: 'foo', name: 'other' }, { path: 'foo', name: 'alternate' }, + { path: 'foo', name: 'other' }, ], }, { query: 'Other', in_args: [ + // because function is called "other", it's sorted first + // even though it has higher type distance { path: 'foo', name: 'other' }, { path: 'foo', name: 'alternate' }, ], diff --git a/tests/rustdoc-json/traits/is_object_safe.rs b/tests/rustdoc-json/traits/is_object_safe.rs new file mode 100644 index 00000000000..131c5fc57a5 --- /dev/null +++ b/tests/rustdoc-json/traits/is_object_safe.rs @@ -0,0 +1,19 @@ +#![no_std] + +// @has "$.index[*][?(@.name=='FooUnsafe')]" +// @is "$.index[*][?(@.name=='FooUnsafe')].inner.trait.is_object_safe" false +pub trait FooUnsafe { + fn foo() -> Self; +} + +// @has "$.index[*][?(@.name=='BarUnsafe')]" +// @is "$.index[*][?(@.name=='BarUnsafe')].inner.trait.is_object_safe" false +pub trait BarUnsafe<T> { + fn foo(i: T); +} + +// @has "$.index[*][?(@.name=='FooSafe')]" +// @is "$.index[*][?(@.name=='FooSafe')].inner.trait.is_object_safe" true +pub trait FooSafe { + fn foo(&self); +} diff --git a/tests/rustdoc-ui/bounded-hr-lifetime.rs b/tests/rustdoc-ui/bounded-hr-lifetime.rs index b2e000b9757..d6c90f552a2 100644 --- a/tests/rustdoc-ui/bounded-hr-lifetime.rs +++ b/tests/rustdoc-ui/bounded-hr-lifetime.rs @@ -4,6 +4,6 @@ pub fn hrlt<'b, 'c>() where for<'a: 'b + 'c> &'a (): std::fmt::Debug, - //~^ ERROR lifetime bounds cannot be used in this context + //~^ ERROR bounds cannot be used in this context { } diff --git a/tests/rustdoc-ui/bounded-hr-lifetime.stderr b/tests/rustdoc-ui/bounded-hr-lifetime.stderr index d7c4e8c380c..c936e4022ef 100644 --- a/tests/rustdoc-ui/bounded-hr-lifetime.stderr +++ b/tests/rustdoc-ui/bounded-hr-lifetime.stderr @@ -1,4 +1,4 @@ -error: lifetime bounds cannot be used in this context +error: bounds cannot be used in this context --> $DIR/bounded-hr-lifetime.rs:6:13 | LL | for<'a: 'b + 'c> &'a (): std::fmt::Debug, diff --git a/tests/rustdoc-ui/check-cfg/check-cfg.stderr b/tests/rustdoc-ui/check-cfg/check-cfg.stderr index d010c1f7ec6..3bca5dd0834 100644 --- a/tests/rustdoc-ui/check-cfg/check-cfg.stderr +++ b/tests/rustdoc-ui/check-cfg/check-cfg.stderr @@ -4,6 +4,8 @@ warning: unexpected `cfg` condition name: `uniz` LL | #[cfg(uniz)] | ^^^^ help: there is a config with a similar name: `unix` | + = help: to expect this configuration use `--check-cfg=cfg(uniz)` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/rustdoc-ui/doctest/check-attr-test.stderr b/tests/rustdoc-ui/doctest/check-attr-test.stderr index 01beba1ffc4..10f763a6f9d 100644 --- a/tests/rustdoc-ui/doctest/check-attr-test.stderr +++ b/tests/rustdoc-ui/doctest/check-attr-test.stderr @@ -1,4 +1,4 @@ -error: unknown attribute `compile-fail`. Did you mean `compile_fail`? +error: unknown attribute `compile-fail` --> $DIR/check-attr-test.rs:5:1 | 5 | / /// foo @@ -8,6 +8,7 @@ error: unknown attribute `compile-fail`. Did you mean `compile_fail`? 9 | | /// ``` | |_______^ | + = help: there is an attribute with a similar name: `compile_fail` = help: the code block will either not be tested if not marked as a rust one or won't fail if it compiles successfully note: the lint level is defined here --> $DIR/check-attr-test.rs:3:9 @@ -15,7 +16,7 @@ note: the lint level is defined here 3 | #![deny(rustdoc::invalid_codeblock_attributes)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: unknown attribute `compilefail`. Did you mean `compile_fail`? +error: unknown attribute `compilefail` --> $DIR/check-attr-test.rs:5:1 | 5 | / /// foo @@ -25,9 +26,10 @@ error: unknown attribute `compilefail`. Did you mean `compile_fail`? 9 | | /// ``` | |_______^ | + = help: there is an attribute with a similar name: `compile_fail` = help: the code block will either not be tested if not marked as a rust one or won't fail if it compiles successfully -error: unknown attribute `comPile_fail`. Did you mean `compile_fail`? +error: unknown attribute `comPile_fail` --> $DIR/check-attr-test.rs:5:1 | 5 | / /// foo @@ -37,9 +39,10 @@ error: unknown attribute `comPile_fail`. Did you mean `compile_fail`? 9 | | /// ``` | |_______^ | + = help: there is an attribute with a similar name: `compile_fail` = help: the code block will either not be tested if not marked as a rust one or won't fail if it compiles successfully -error: unknown attribute `should-panic`. Did you mean `should_panic`? +error: unknown attribute `should-panic` --> $DIR/check-attr-test.rs:12:1 | 12 | / /// bar @@ -49,9 +52,10 @@ error: unknown attribute `should-panic`. Did you mean `should_panic`? 16 | | /// ``` | |_______^ | + = help: there is an attribute with a similar name: `should_panic` = help: the code block will either not be tested if not marked as a rust one or won't fail if it doesn't panic when running -error: unknown attribute `shouldpanic`. Did you mean `should_panic`? +error: unknown attribute `shouldpanic` --> $DIR/check-attr-test.rs:12:1 | 12 | / /// bar @@ -61,9 +65,10 @@ error: unknown attribute `shouldpanic`. Did you mean `should_panic`? 16 | | /// ``` | |_______^ | + = help: there is an attribute with a similar name: `should_panic` = help: the code block will either not be tested if not marked as a rust one or won't fail if it doesn't panic when running -error: unknown attribute `shOuld_panic`. Did you mean `should_panic`? +error: unknown attribute `shOuld_panic` --> $DIR/check-attr-test.rs:12:1 | 12 | / /// bar @@ -73,9 +78,10 @@ error: unknown attribute `shOuld_panic`. Did you mean `should_panic`? 16 | | /// ``` | |_______^ | + = help: there is an attribute with a similar name: `should_panic` = help: the code block will either not be tested if not marked as a rust one or won't fail if it doesn't panic when running -error: unknown attribute `no-run`. Did you mean `no_run`? +error: unknown attribute `no-run` --> $DIR/check-attr-test.rs:19:1 | 19 | / /// foobar @@ -85,9 +91,10 @@ error: unknown attribute `no-run`. Did you mean `no_run`? 23 | | /// ``` | |_______^ | + = help: there is an attribute with a similar name: `no_run` = help: the code block will either not be tested if not marked as a rust one or will be run (which you might not want) -error: unknown attribute `norun`. Did you mean `no_run`? +error: unknown attribute `norun` --> $DIR/check-attr-test.rs:19:1 | 19 | / /// foobar @@ -97,9 +104,10 @@ error: unknown attribute `norun`. Did you mean `no_run`? 23 | | /// ``` | |_______^ | + = help: there is an attribute with a similar name: `no_run` = help: the code block will either not be tested if not marked as a rust one or will be run (which you might not want) -error: unknown attribute `nO_run`. Did you mean `no_run`? +error: unknown attribute `nO_run` --> $DIR/check-attr-test.rs:19:1 | 19 | / /// foobar @@ -109,9 +117,10 @@ error: unknown attribute `nO_run`. Did you mean `no_run`? 23 | | /// ``` | |_______^ | + = help: there is an attribute with a similar name: `no_run` = help: the code block will either not be tested if not marked as a rust one or will be run (which you might not want) -error: unknown attribute `test-harness`. Did you mean `test_harness`? +error: unknown attribute `test-harness` --> $DIR/check-attr-test.rs:26:1 | 26 | / /// b @@ -121,9 +130,10 @@ error: unknown attribute `test-harness`. Did you mean `test_harness`? 30 | | /// ``` | |_______^ | + = help: there is an attribute with a similar name: `test_harness` = help: the code block will either not be tested if not marked as a rust one or the code will be wrapped inside a main function -error: unknown attribute `testharness`. Did you mean `test_harness`? +error: unknown attribute `testharness` --> $DIR/check-attr-test.rs:26:1 | 26 | / /// b @@ -133,9 +143,10 @@ error: unknown attribute `testharness`. Did you mean `test_harness`? 30 | | /// ``` | |_______^ | + = help: there is an attribute with a similar name: `test_harness` = help: the code block will either not be tested if not marked as a rust one or the code will be wrapped inside a main function -error: unknown attribute `tesT_harness`. Did you mean `test_harness`? +error: unknown attribute `tesT_harness` --> $DIR/check-attr-test.rs:26:1 | 26 | / /// b @@ -145,6 +156,7 @@ error: unknown attribute `tesT_harness`. Did you mean `test_harness`? 30 | | /// ``` | |_______^ | + = help: there is an attribute with a similar name: `test_harness` = help: the code block will either not be tested if not marked as a rust one or the code will be wrapped inside a main function error: aborting due to 12 previous errors diff --git a/tests/rustdoc-ui/doctest/check-cfg-test.stderr b/tests/rustdoc-ui/doctest/check-cfg-test.stderr index 0bfd569e381..5524f582d56 100644 --- a/tests/rustdoc-ui/doctest/check-cfg-test.stderr +++ b/tests/rustdoc-ui/doctest/check-cfg-test.stderr @@ -5,6 +5,8 @@ LL | #[cfg(feature = "invalid")] | ^^^^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `test` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("invalid"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/rustdoc-ui/lints/check-attr.rs b/tests/rustdoc-ui/lints/check-attr.rs index 0b3f7bedda5..3c06e6c076b 100644 --- a/tests/rustdoc-ui/lints/check-attr.rs +++ b/tests/rustdoc-ui/lints/check-attr.rs @@ -39,3 +39,20 @@ pub fn foobar() {} /// boo /// ``` pub fn b() {} + +/// b +//~^ ERROR +/// +/// ```rust2018 +/// boo +/// ``` +pub fn c() {} + +/// b +//~^ ERROR +//~| ERROR +/// +/// ```rust2018 shouldpanic +/// boo +/// ``` +pub fn d() {} diff --git a/tests/rustdoc-ui/lints/check-attr.stderr b/tests/rustdoc-ui/lints/check-attr.stderr index f66e63ab727..d640125ab51 100644 --- a/tests/rustdoc-ui/lints/check-attr.stderr +++ b/tests/rustdoc-ui/lints/check-attr.stderr @@ -1,4 +1,4 @@ -error: unknown attribute `compile-fail`. Did you mean `compile_fail`? +error: unknown attribute `compile-fail` --> $DIR/check-attr.rs:3:1 | LL | / /// foo @@ -10,6 +10,7 @@ LL | | /// boo LL | | /// ``` | |_______^ | + = help: there is an attribute with a similar name: `compile_fail` = help: the code block will either not be tested if not marked as a rust one or won't fail if it compiles successfully note: the lint level is defined here --> $DIR/check-attr.rs:1:9 @@ -17,7 +18,7 @@ note: the lint level is defined here LL | #![deny(rustdoc::invalid_codeblock_attributes)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: unknown attribute `compilefail`. Did you mean `compile_fail`? +error: unknown attribute `compilefail` --> $DIR/check-attr.rs:3:1 | LL | / /// foo @@ -29,9 +30,10 @@ LL | | /// boo LL | | /// ``` | |_______^ | + = help: there is an attribute with a similar name: `compile_fail` = help: the code block will either not be tested if not marked as a rust one or won't fail if it compiles successfully -error: unknown attribute `comPile_fail`. Did you mean `compile_fail`? +error: unknown attribute `comPile_fail` --> $DIR/check-attr.rs:3:1 | LL | / /// foo @@ -43,9 +45,10 @@ LL | | /// boo LL | | /// ``` | |_______^ | + = help: there is an attribute with a similar name: `compile_fail` = help: the code block will either not be tested if not marked as a rust one or won't fail if it compiles successfully -error: unknown attribute `should-panic`. Did you mean `should_panic`? +error: unknown attribute `should-panic` --> $DIR/check-attr.rs:13:1 | LL | / /// bar @@ -57,9 +60,10 @@ LL | | /// boo LL | | /// ``` | |_______^ | + = help: there is an attribute with a similar name: `should_panic` = help: the code block will either not be tested if not marked as a rust one or won't fail if it doesn't panic when running -error: unknown attribute `shouldpanic`. Did you mean `should_panic`? +error: unknown attribute `shouldpanic` --> $DIR/check-attr.rs:13:1 | LL | / /// bar @@ -71,9 +75,10 @@ LL | | /// boo LL | | /// ``` | |_______^ | + = help: there is an attribute with a similar name: `should_panic` = help: the code block will either not be tested if not marked as a rust one or won't fail if it doesn't panic when running -error: unknown attribute `sHould_panic`. Did you mean `should_panic`? +error: unknown attribute `sHould_panic` --> $DIR/check-attr.rs:13:1 | LL | / /// bar @@ -85,9 +90,10 @@ LL | | /// boo LL | | /// ``` | |_______^ | + = help: there is an attribute with a similar name: `should_panic` = help: the code block will either not be tested if not marked as a rust one or won't fail if it doesn't panic when running -error: unknown attribute `no-run`. Did you mean `no_run`? +error: unknown attribute `no-run` --> $DIR/check-attr.rs:23:1 | LL | / /// foobar @@ -99,9 +105,10 @@ LL | | /// boo LL | | /// ``` | |_______^ | + = help: there is an attribute with a similar name: `no_run` = help: the code block will either not be tested if not marked as a rust one or will be run (which you might not want) -error: unknown attribute `norun`. Did you mean `no_run`? +error: unknown attribute `norun` --> $DIR/check-attr.rs:23:1 | LL | / /// foobar @@ -113,9 +120,10 @@ LL | | /// boo LL | | /// ``` | |_______^ | + = help: there is an attribute with a similar name: `no_run` = help: the code block will either not be tested if not marked as a rust one or will be run (which you might not want) -error: unknown attribute `no_Run`. Did you mean `no_run`? +error: unknown attribute `no_Run` --> $DIR/check-attr.rs:23:1 | LL | / /// foobar @@ -127,9 +135,10 @@ LL | | /// boo LL | | /// ``` | |_______^ | + = help: there is an attribute with a similar name: `no_run` = help: the code block will either not be tested if not marked as a rust one or will be run (which you might not want) -error: unknown attribute `test-harness`. Did you mean `test_harness`? +error: unknown attribute `test-harness` --> $DIR/check-attr.rs:33:1 | LL | / /// b @@ -141,9 +150,10 @@ LL | | /// boo LL | | /// ``` | |_______^ | + = help: there is an attribute with a similar name: `test_harness` = help: the code block will either not be tested if not marked as a rust one or the code will be wrapped inside a main function -error: unknown attribute `testharness`. Did you mean `test_harness`? +error: unknown attribute `testharness` --> $DIR/check-attr.rs:33:1 | LL | / /// b @@ -155,9 +165,10 @@ LL | | /// boo LL | | /// ``` | |_______^ | + = help: there is an attribute with a similar name: `test_harness` = help: the code block will either not be tested if not marked as a rust one or the code will be wrapped inside a main function -error: unknown attribute `teSt_harness`. Did you mean `test_harness`? +error: unknown attribute `teSt_harness` --> $DIR/check-attr.rs:33:1 | LL | / /// b @@ -169,7 +180,50 @@ LL | | /// boo LL | | /// ``` | |_______^ | + = help: there is an attribute with a similar name: `test_harness` = help: the code block will either not be tested if not marked as a rust one or the code will be wrapped inside a main function -error: aborting due to 12 previous errors +error: unknown attribute `rust2018` + --> $DIR/check-attr.rs:43:1 + | +LL | / /// b +LL | | +LL | | /// +LL | | /// ```rust2018 +LL | | /// boo +LL | | /// ``` + | |_______^ + | + = help: there is an attribute with a similar name: `edition2018` + +error: unknown attribute `rust2018` + --> $DIR/check-attr.rs:51:1 + | +LL | / /// b +LL | | +LL | | +LL | | /// +LL | | /// ```rust2018 shouldpanic +LL | | /// boo +LL | | /// ``` + | |_______^ + | + = help: there is an attribute with a similar name: `edition2018` + +error: unknown attribute `shouldpanic` + --> $DIR/check-attr.rs:51:1 + | +LL | / /// b +LL | | +LL | | +LL | | /// +LL | | /// ```rust2018 shouldpanic +LL | | /// boo +LL | | /// ``` + | |_______^ + | + = help: there is an attribute with a similar name: `should_panic` + = help: the code block will either not be tested if not marked as a rust one or won't fail if it doesn't panic when running + +error: aborting due to 15 previous errors diff --git a/tests/rustdoc-ui/lints/check-fail.stderr b/tests/rustdoc-ui/lints/check-fail.stderr index f05e457af64..99b01bac598 100644 --- a/tests/rustdoc-ui/lints/check-fail.stderr +++ b/tests/rustdoc-ui/lints/check-fail.stderr @@ -22,7 +22,7 @@ note: the lint level is defined here LL | #![deny(rustdoc::missing_doc_code_examples)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: unknown attribute `testharness`. Did you mean `test_harness`? +error: unknown attribute `testharness` --> $DIR/check-fail.rs:8:1 | LL | / //! ```rust,testharness @@ -31,6 +31,7 @@ LL | | //! let x = 12; LL | | //! ``` | |_______^ | + = help: there is an attribute with a similar name: `test_harness` = help: the code block will either not be tested if not marked as a rust one or the code will be wrapped inside a main function note: the lint level is defined here --> $DIR/check-fail.rs:6:9 @@ -39,7 +40,7 @@ LL | #![deny(rustdoc::all)] | ^^^^^^^^^^^^ = note: `#[deny(rustdoc::invalid_codeblock_attributes)]` implied by `#[deny(rustdoc::all)]` -error: unknown attribute `testharness`. Did you mean `test_harness`? +error: unknown attribute `testharness` --> $DIR/check-fail.rs:17:1 | LL | / /// hello @@ -50,6 +51,7 @@ LL | | /// let x = 12; LL | | /// ``` | |_______^ | + = help: there is an attribute with a similar name: `test_harness` = help: the code block will either not be tested if not marked as a rust one or the code will be wrapped inside a main function error: aborting due to 4 previous errors diff --git a/tests/rustdoc/reexport-cfg.rs b/tests/rustdoc/reexport-cfg.rs new file mode 100644 index 00000000000..a6179fad873 --- /dev/null +++ b/tests/rustdoc/reexport-cfg.rs @@ -0,0 +1,30 @@ +// This test ensures that only the re-export `cfg` will be displayed and that it won't +// include `cfg`s from the previous chained items. + +#![crate_name = "foo"] +#![feature(doc_auto_cfg, doc_cfg)] + +mod foo { + #[cfg(not(feature = "foo"))] + pub struct Bar; + + #[doc(cfg(not(feature = "bar")))] + pub struct Bar2; +} + +// @has 'foo/index.html' +// @has - '//*[@class="item-name"]' 'BabarNon-lie' +#[cfg(not(feature = "lie"))] +pub use crate::foo::Bar as Babar; + +// @has - '//*[@class="item-name"]' 'Babar2Non-cake' +#[doc(cfg(not(feature = "cake")))] +pub use crate::foo::Bar2 as Babar2; + +// @has - '//*[@class="item-table"]/li' 'pub use crate::Babar as Elephant;Non-robot' +#[cfg(not(feature = "robot"))] +pub use crate::Babar as Elephant; + +// @has - '//*[@class="item-table"]/li' 'pub use crate::Babar2 as Elephant2;Non-cat' +#[doc(cfg(not(feature = "cat")))] +pub use crate::Babar2 as Elephant2; diff --git a/tests/rustdoc/reexport-stability-tags-deprecated-and-portability.rs b/tests/rustdoc/reexport-stability-tags-deprecated-and-portability.rs index a79d05904e3..c81c654a20e 100644 --- a/tests/rustdoc/reexport-stability-tags-deprecated-and-portability.rs +++ b/tests/rustdoc/reexport-stability-tags-deprecated-and-portability.rs @@ -27,7 +27,7 @@ pub mod mod1 { pub mod mod2 { // @has - '//code' 'pub use tag::Portability;' // @!has - '//span' 'Deprecated' - // @has - '//span' 'sync' + // @!has - '//span' 'sync' pub use tag::Portability; } @@ -35,7 +35,7 @@ pub mod mod2 { pub mod mod3 { // @has - '//code' 'pub use tag::Both;' // @has - '//span' 'Deprecated' - // @has - '//span' 'sync' + // @!has - '//span' 'sync' pub use tag::Both; } diff --git a/tests/rustdoc/reexport-stability-tags-unstable-and-portability.rs b/tests/rustdoc/reexport-stability-tags-unstable-and-portability.rs index ff8a910f59f..423838e251b 100644 --- a/tests/rustdoc/reexport-stability-tags-unstable-and-portability.rs +++ b/tests/rustdoc/reexport-stability-tags-unstable-and-portability.rs @@ -35,7 +35,7 @@ pub mod mod1 { pub mod mod2 { // @has - '//code' 'pub use tag::Portability;' // @!has - '//span' 'Experimental' - // @has - '//span' 'sync' + // @!has - '//span' 'sync' #[stable(feature = "rust1", since = "1.0.0")] pub use tag::Portability; } @@ -45,7 +45,7 @@ pub mod mod2 { pub mod mod3 { // @has - '//code' 'pub use tag::Both;' // @has - '//span' 'Experimental' - // @has - '//span' 'sync' + // @!has - '//span' 'sync' #[stable(feature = "rust1", since = "1.0.0")] pub use tag::Both; } diff --git a/tests/rustdoc/trait-object-safe.rs b/tests/rustdoc/trait-object-safe.rs index 818843f7558..8b028ad2e13 100644 --- a/tests/rustdoc/trait-object-safe.rs +++ b/tests/rustdoc/trait-object-safe.rs @@ -22,6 +22,6 @@ pub trait Safe { } // @has 'foo/struct.Foo.html' -// @!has - '//*[@class="object-safety-info"]' '' -// @!has - '//*[@id="object-safety"]' '' +// @count - '//*[@class="object-safety-info"]' 0 +// @count - '//*[@id="object-safety"]' 0 pub struct Foo; diff --git a/tests/ui-fulldeps/internal-lints/diagnostics.rs b/tests/ui-fulldeps/internal-lints/diagnostics.rs index 7f545ead152..ab42d3b8c1e 100644 --- a/tests/ui-fulldeps/internal-lints/diagnostics.rs +++ b/tests/ui-fulldeps/internal-lints/diagnostics.rs @@ -13,8 +13,8 @@ extern crate rustc_session; extern crate rustc_span; use rustc_errors::{ - AddToDiagnostic, Diagnostic, DiagnosticBuilder, DiagnosticMessage, ErrorGuaranteed, Handler, - IntoDiagnostic, SubdiagnosticMessage, + AddToDiagnostic, Diagnostic, DiagnosticBuilder, DiagnosticMessage, EmissionGuarantee, DiagCtxt, + IntoDiagnostic, Level, SubdiagnosticMessage, }; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::Span; @@ -37,18 +37,18 @@ struct Note { pub struct UntranslatableInIntoDiagnostic; -impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for UntranslatableInIntoDiagnostic { - fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> { - handler.struct_err("untranslatable diagnostic") +impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for UntranslatableInIntoDiagnostic { + fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> { + DiagnosticBuilder::new(dcx, level, "untranslatable diagnostic") //~^ ERROR diagnostics should be created using translatable messages } } pub struct TranslatableInIntoDiagnostic; -impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for TranslatableInIntoDiagnostic { - fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> { - handler.struct_err(crate::fluent_generated::no_crate_example) +impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for TranslatableInIntoDiagnostic { + fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> { + DiagnosticBuilder::new(dcx, level, crate::fluent_generated::no_crate_example) } } @@ -75,11 +75,11 @@ impl AddToDiagnostic for TranslatableInAddToDiagnostic { } } -pub fn make_diagnostics<'a>(handler: &'a Handler) { - let _diag = handler.struct_err(crate::fluent_generated::no_crate_example); +pub fn make_diagnostics<'a>(dcx: &'a DiagCtxt) { + let _diag = dcx.struct_err(crate::fluent_generated::no_crate_example); //~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls - let _diag = handler.struct_err("untranslatable diagnostic"); + let _diag = dcx.struct_err("untranslatable diagnostic"); //~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls //~^^ ERROR diagnostics should be created using translatable messages } @@ -87,6 +87,6 @@ pub fn make_diagnostics<'a>(handler: &'a Handler) { // Check that `rustc_lint_diagnostics`-annotated functions aren't themselves linted. #[rustc_lint_diagnostics] -pub fn skipped_because_of_annotation<'a>(handler: &'a Handler) { - let _diag = handler.struct_err("untranslatable diagnostic"); // okay! +pub fn skipped_because_of_annotation<'a>(dcx: &'a DiagCtxt) { + let _diag = dcx.struct_err("untranslatable diagnostic"); // okay! } diff --git a/tests/ui-fulldeps/internal-lints/diagnostics.stderr b/tests/ui-fulldeps/internal-lints/diagnostics.stderr index 8e0535e021b..f70240ecf17 100644 --- a/tests/ui-fulldeps/internal-lints/diagnostics.stderr +++ b/tests/ui-fulldeps/internal-lints/diagnostics.stderr @@ -1,8 +1,8 @@ error: diagnostics should be created using translatable messages - --> $DIR/diagnostics.rs:42:17 + --> $DIR/diagnostics.rs:42:9 | -LL | handler.struct_err("untranslatable diagnostic") - | ^^^^^^^^^^ +LL | DiagnosticBuilder::new(dcx, level, "untranslatable diagnostic") + | ^^^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here --> $DIR/diagnostics.rs:6:9 @@ -17,10 +17,10 @@ LL | diag.note("untranslatable diagnostic"); | ^^^^ error: diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls - --> $DIR/diagnostics.rs:79:25 + --> $DIR/diagnostics.rs:79:21 | -LL | let _diag = handler.struct_err(crate::fluent_generated::no_crate_example); - | ^^^^^^^^^^ +LL | let _diag = dcx.struct_err(crate::fluent_generated::no_crate_example); + | ^^^^^^^^^^ | note: the lint level is defined here --> $DIR/diagnostics.rs:7:9 @@ -29,16 +29,16 @@ LL | #![deny(rustc::diagnostic_outside_of_impl)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls - --> $DIR/diagnostics.rs:82:25 + --> $DIR/diagnostics.rs:82:21 | -LL | let _diag = handler.struct_err("untranslatable diagnostic"); - | ^^^^^^^^^^ +LL | let _diag = dcx.struct_err("untranslatable diagnostic"); + | ^^^^^^^^^^ error: diagnostics should be created using translatable messages - --> $DIR/diagnostics.rs:82:25 + --> $DIR/diagnostics.rs:82:21 | -LL | let _diag = handler.struct_err("untranslatable diagnostic"); - | ^^^^^^^^^^ +LL | let _diag = dcx.struct_err("untranslatable diagnostic"); + | ^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui-fulldeps/stable-mir/check_abi.rs b/tests/ui-fulldeps/stable-mir/check_abi.rs new file mode 100644 index 00000000000..30b42bc3bfa --- /dev/null +++ b/tests/ui-fulldeps/stable-mir/check_abi.rs @@ -0,0 +1,143 @@ +// run-pass +//! Test information regarding type layout. + +// ignore-stage1 +// ignore-cross-compile +// ignore-remote +// ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 + +#![feature(rustc_private)] +#![feature(assert_matches)] +#![feature(control_flow_enum)] +#![feature(ascii_char, ascii_char_variants)] + +extern crate rustc_hir; +extern crate rustc_middle; +#[macro_use] +extern crate rustc_smir; +extern crate rustc_driver; +extern crate rustc_interface; +extern crate stable_mir; + +use rustc_middle::ty::TyCtxt; +use rustc_smir::rustc_internal; +use stable_mir::abi::{ArgAbi, CallConvention, FieldsShape, PassMode, VariantsShape}; +use stable_mir::mir::mono::Instance; +use stable_mir::{CrateDef, CrateItem, CrateItems, ItemKind}; +use std::assert_matches::assert_matches; +use std::convert::TryFrom; +use std::io::Write; +use std::ops::ControlFlow; + +const CRATE_NAME: &str = "input"; + +/// This function uses the Stable MIR APIs to get information about the test crate. +fn test_stable_mir(_tcx: TyCtxt<'_>) -> ControlFlow<()> { + // Find items in the local crate. + let items = stable_mir::all_local_items(); + + // Test fn_abi + let target_fn = *get_item(&items, (ItemKind::Fn, "fn_abi")).unwrap(); + let instance = Instance::try_from(target_fn).unwrap(); + let fn_abi = instance.fn_abi().unwrap(); + assert_eq!(fn_abi.conv, CallConvention::Rust); + assert_eq!(fn_abi.args.len(), 2); + + check_ignore(&fn_abi.args[0]); + check_primitive(&fn_abi.args[1]); + check_result(fn_abi.ret); + + // Test variadic function. + let variadic_fn = *get_item(&items, (ItemKind::Fn, "variadic_fn")).unwrap(); + check_variadic(variadic_fn); + + ControlFlow::Continue(()) +} + +/// Check the variadic function ABI: +/// ```no_run +/// pub unsafe extern "C" fn variadic_fn(n: usize, mut args: ...) -> usize { +/// 0 +/// } +/// ``` +fn check_variadic(variadic_fn: CrateItem) { + let instance = Instance::try_from(variadic_fn).unwrap(); + let abi = instance.fn_abi().unwrap(); + assert!(abi.c_variadic); + assert_eq!(abi.args.len(), 1); +} + +/// Check the argument to be ignored: `ignore: [u8; 0]`. +fn check_ignore(abi: &ArgAbi) { + assert!(abi.ty.kind().is_array()); + assert_eq!(abi.mode, PassMode::Ignore); + let layout = abi.layout.shape(); + assert!(layout.is_sized()); + assert!(layout.is_1zst()); +} + +/// Check the primitive argument: `primitive: char`. +fn check_primitive(abi: &ArgAbi) { + assert!(abi.ty.kind().is_char()); + assert_matches!(abi.mode, PassMode::Direct(_)); + let layout = abi.layout.shape(); + assert!(layout.is_sized()); + assert!(!layout.is_1zst()); + assert_matches!(layout.fields, FieldsShape::Primitive); +} + +/// Check the return value: `Result<usize, &str>`. +fn check_result(abi: ArgAbi) { + assert!(abi.ty.kind().is_enum()); + assert_matches!(abi.mode, PassMode::Indirect { .. }); + let layout = abi.layout.shape(); + assert!(layout.is_sized()); + assert_matches!(layout.fields, FieldsShape::Arbitrary { .. }); + assert_matches!(layout.variants, VariantsShape::Multiple { .. }) +} + +fn get_item<'a>( + items: &'a CrateItems, + item: (ItemKind, &str), +) -> Option<&'a stable_mir::CrateItem> { + items.iter().find(|crate_item| (item.0 == crate_item.kind()) && crate_item.name() == item.1) +} + +/// This test will generate and analyze a dummy crate using the stable mir. +/// For that, it will first write the dummy crate into a file. +/// Then it will create a `StableMir` using custom arguments and then +/// it will run the compiler. +fn main() { + let path = "alloc_input.rs"; + generate_input(&path).unwrap(); + let args = vec![ + "rustc".to_string(), + "--crate-type=lib".to_string(), + "--crate-name".to_string(), + CRATE_NAME.to_string(), + path.to_string(), + ]; + run!(args, tcx, test_stable_mir(tcx)).unwrap(); +} + +fn generate_input(path: &str) -> std::io::Result<()> { + let mut file = std::fs::File::create(path)?; + write!( + file, + r#" + #![feature(c_variadic)] + #![allow(unused_variables)] + + pub fn fn_abi(ignore: [u8; 0], primitive: char) -> Result<usize, &'static str> {{ + // We only care about the signature. + todo!() + }} + + + pub unsafe extern "C" fn variadic_fn(n: usize, mut args: ...) -> usize {{ + 0 + }} + "# + )?; + Ok(()) +} diff --git a/tests/ui-fulldeps/stable-mir/check_allocation.rs b/tests/ui-fulldeps/stable-mir/check_allocation.rs index 88c41537d9f..7ce3597206b 100644 --- a/tests/ui-fulldeps/stable-mir/check_allocation.rs +++ b/tests/ui-fulldeps/stable-mir/check_allocation.rs @@ -33,6 +33,7 @@ use std::ascii::Char; use std::assert_matches::assert_matches; use std::cmp::{max, min}; use std::collections::HashMap; +use std::ffi::CStr; use std::io::Write; use std::ops::ControlFlow; @@ -45,6 +46,7 @@ fn test_stable_mir(_tcx: TyCtxt<'_>) -> ControlFlow<()> { check_foo(*get_item(&items, (ItemKind::Static, "FOO")).unwrap()); check_bar(*get_item(&items, (ItemKind::Static, "BAR")).unwrap()); check_len(*get_item(&items, (ItemKind::Static, "LEN")).unwrap()); + check_cstr(*get_item(&items, (ItemKind::Static, "C_STR")).unwrap()); check_other_consts(*get_item(&items, (ItemKind::Fn, "other_consts")).unwrap()); check_type_id(*get_item(&items, (ItemKind::Fn, "check_type_id")).unwrap()); ControlFlow::Continue(()) @@ -86,6 +88,24 @@ fn check_bar(item: CrateItem) { assert_eq!(std::str::from_utf8(&allocation.raw_bytes().unwrap()), Ok("Bar")); } +/// Check the allocation data for static `C_STR`. +/// +/// ```no_run +/// static C_STR: &core::ffi::cstr = c"cstr"; +/// ``` +fn check_cstr(item: CrateItem) { + let def = StaticDef::try_from(item).unwrap(); + let alloc = def.eval_initializer().unwrap(); + assert_eq!(alloc.provenance.ptrs.len(), 1); + let deref = item.ty().kind().builtin_deref(true).unwrap(); + assert!(deref.ty.kind().is_cstr(), "Expected CStr, but got: {:?}", item.ty()); + + let alloc_id_0 = alloc.provenance.ptrs[0].1.0; + let GlobalAlloc::Memory(allocation) = GlobalAlloc::from(alloc_id_0) else { unreachable!() }; + assert_eq!(allocation.bytes.len(), 5); + assert_eq!(CStr::from_bytes_until_nul(&allocation.raw_bytes().unwrap()), Ok(c"cstr")); +} + /// Check the allocation data for constants used in `other_consts` function. fn check_other_consts(item: CrateItem) { // Instance body will force constant evaluation. @@ -189,7 +209,6 @@ fn check_len(item: CrateItem) { assert_eq!(alloc.read_uint(), Ok(2)); } -// Use internal API to find a function in a crate. fn get_item<'a>( items: &'a CrateItems, item: (ItemKind, &str), @@ -206,6 +225,7 @@ fn main() { generate_input(&path).unwrap(); let args = vec![ "rustc".to_string(), + "--edition=2021".to_string(), "--crate-name".to_string(), CRATE_NAME.to_string(), path.to_string(), @@ -224,6 +244,7 @@ fn generate_input(path: &str) -> std::io::Result<()> { static LEN: usize = 2; static FOO: [&str; 2] = ["hi", "there"]; static BAR: &str = "Bar"; + static C_STR: &std::ffi::CStr = c"cstr"; const NULL: *const u8 = std::ptr::null(); const TUPLE: (u32, u32) = (10, u32::MAX); diff --git a/tests/ui-fulldeps/stable-mir/check_defs.rs b/tests/ui-fulldeps/stable-mir/check_defs.rs index d311be5982d..e9a2599d873 100644 --- a/tests/ui-fulldeps/stable-mir/check_defs.rs +++ b/tests/ui-fulldeps/stable-mir/check_defs.rs @@ -69,9 +69,9 @@ fn extract_elem_ty(ty: Ty) -> Ty { /// Check signature and type of `Vec::<u8>::new` and its generic version. fn test_vec_new(instance: mir::mono::Instance) { - let sig = instance.fn_sig(); - assert_matches!(sig.inputs(), &[]); - let elem_ty = extract_elem_ty(sig.output()); + let sig = instance.fn_abi().unwrap(); + assert_eq!(&sig.args, &[]); + let elem_ty = extract_elem_ty(sig.ret.ty); assert_matches!(elem_ty.kind(), TyKind::RigidTy(RigidTy::Uint(UintTy::U8))); // Get the signature for Vec::<T>::new. diff --git a/tests/ui-fulldeps/stable-mir/check_item_kind.rs b/tests/ui-fulldeps/stable-mir/check_item_kind.rs new file mode 100644 index 00000000000..72e0e09e6e3 --- /dev/null +++ b/tests/ui-fulldeps/stable-mir/check_item_kind.rs @@ -0,0 +1,84 @@ +// run-pass +//! Test that item kind works as expected. + +// ignore-stage1 +// ignore-cross-compile +// ignore-remote +// ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 +// edition: 2021 + +#![feature(rustc_private)] +#![feature(assert_matches)] +#![feature(control_flow_enum)] + +extern crate rustc_middle; +#[macro_use] +extern crate rustc_smir; +extern crate rustc_driver; +extern crate rustc_interface; +extern crate stable_mir; + +use rustc_middle::ty::TyCtxt; +use rustc_smir::rustc_internal; +use stable_mir::*; +use std::io::Write; +use std::ops::ControlFlow; + +const CRATE_NAME: &str = "input"; + +/// This function uses the Stable MIR APIs to get information about the test crate. +fn test_item_kind(_tcx: TyCtxt<'_>) -> ControlFlow<()> { + let items = stable_mir::all_local_items(); + assert_eq!(items.len(), 4); + // Constructor item. + for item in items { + let expected_kind = match item.name().as_str() { + "Dummy" => ItemKind::Ctor(CtorKind::Fn), + "dummy" => ItemKind::Fn, + "unit" => ItemKind::Fn, + "DUMMY_CONST" => ItemKind::Const, + name => unreachable!("Unexpected item {name}"), + }; + assert_eq!(item.kind(), expected_kind, "Mismatched type for {}", item.name()); + } + ControlFlow::Continue(()) +} + +/// This test will generate and analyze a dummy crate using the stable mir. +/// For that, it will first write the dummy crate into a file. +/// Then it will create a `StableMir` using custom arguments and then +/// it will run the compiler. +fn main() { + let path = "item_kind_input.rs"; + generate_input(&path).unwrap(); + let args = vec![ + "rustc".to_string(), + "-Cpanic=abort".to_string(), + "--crate-type=lib".to_string(), + "--crate-name".to_string(), + CRATE_NAME.to_string(), + path.to_string(), + ]; + run!(args, tcx, test_item_kind(tcx)).unwrap(); +} + +fn generate_input(path: &str) -> std::io::Result<()> { + let mut file = std::fs::File::create(path)?; + write!( + file, + r#" + pub struct Dummy(u32); + pub const DUMMY_CONST: Dummy = Dummy(0); + pub struct DummyUnit; + + pub fn dummy() -> Dummy {{ + Dummy(5) + }} + + pub fn unit() -> DummyUnit {{ + DummyUnit + }} + "# + )?; + Ok(()) +} diff --git a/tests/ui/abi/stack-probes-lto.rs b/tests/ui/abi/stack-probes-lto.rs index 7282d09706c..fb478671754 100644 --- a/tests/ui/abi/stack-probes-lto.rs +++ b/tests/ui/abi/stack-probes-lto.rs @@ -1,5 +1,7 @@ -// revisions: x32 x64 +// revisions: aarch64 x32 x64 // run-pass +//[aarch64] only-aarch64 +//[aarch64] min-llvm-version: 18 //[x32] only-x86 //[x64] only-x86_64 // ignore-sgx no processes diff --git a/tests/ui/abi/stack-probes.rs b/tests/ui/abi/stack-probes.rs index 4b8a79a4b68..e5c7a1a6804 100644 --- a/tests/ui/abi/stack-probes.rs +++ b/tests/ui/abi/stack-probes.rs @@ -1,5 +1,7 @@ -// revisions: x32 x64 +// revisions: aarch64 x32 x64 // run-pass +//[aarch64] only-aarch64 +//[aarch64] min-llvm-version: 18 //[x32] only-x86 //[x64] only-x86_64 // ignore-emscripten no processes diff --git a/tests/ui/associated-inherent-types/inference.rs b/tests/ui/associated-inherent-types/inference.rs index 66f879c5a71..054034b4c28 100644 --- a/tests/ui/associated-inherent-types/inference.rs +++ b/tests/ui/associated-inherent-types/inference.rs @@ -1,7 +1,7 @@ // Testing inference capabilities. // check-pass // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver #![feature(inherent_associated_types)] #![allow(incomplete_features)] diff --git a/tests/ui/associated-inherent-types/issue-109071.no_gate.stderr b/tests/ui/associated-inherent-types/issue-109071.no_gate.stderr index 866a53f57fc..2fceeb15ea9 100644 --- a/tests/ui/associated-inherent-types/issue-109071.no_gate.stderr +++ b/tests/ui/associated-inherent-types/issue-109071.no_gate.stderr @@ -33,7 +33,14 @@ error[E0223]: ambiguous associated type --> $DIR/issue-109071.rs:15:22 | LL | fn T() -> Option<Self::Item> {} - | ^^^^^^^^^^ help: use fully-qualified syntax: `<Windows<T> as IntoIterator>::Item` + | ^^^^^^^^^^ + | +help: use fully-qualified syntax + | +LL | fn T() -> Option<<Windows<T> as IntoAsyncIterator>::Item> {} + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +LL | fn T() -> Option<<Windows<T> as IntoIterator>::Item> {} + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: aborting due to 4 previous errors diff --git a/tests/ui/associated-types/bound-lifetime-in-binding-only.elision.stderr b/tests/ui/associated-types/bound-lifetime-in-binding-only.elision.stderr index 8ccfb212216..24fd38f31ad 100644 --- a/tests/ui/associated-types/bound-lifetime-in-binding-only.elision.stderr +++ b/tests/ui/associated-types/bound-lifetime-in-binding-only.elision.stderr @@ -5,10 +5,15 @@ LL | fn elision<T: Fn() -> &i32>() { | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | fn elision<T: Fn() -> &'static i32>() { | +++++++ +help: instead, you are more likely to want to return an owned value + | +LL - fn elision<T: Fn() -> &i32>() { +LL + fn elision<T: Fn() -> i32>() { + | error: aborting due to 1 previous error diff --git a/tests/ui/associated-types/bound-lifetime-in-return-only.elision.stderr b/tests/ui/associated-types/bound-lifetime-in-return-only.elision.stderr index 0593a62a750..d24378487e7 100644 --- a/tests/ui/associated-types/bound-lifetime-in-return-only.elision.stderr +++ b/tests/ui/associated-types/bound-lifetime-in-return-only.elision.stderr @@ -5,10 +5,15 @@ LL | fn elision(_: fn() -> &i32) { | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | fn elision(_: fn() -> &'static i32) { | +++++++ +help: instead, you are more likely to want to return an owned value + | +LL - fn elision(_: fn() -> &i32) { +LL + fn elision(_: fn() -> i32) { + | error: aborting due to 1 previous error diff --git a/tests/ui/associated-types/substs-ppaux.rs b/tests/ui/associated-types/substs-ppaux.rs index 66cd94d7a1b..db6e7a4cf05 100644 --- a/tests/ui/associated-types/substs-ppaux.rs +++ b/tests/ui/associated-types/substs-ppaux.rs @@ -1,7 +1,7 @@ // // revisions: verbose normal // -//[verbose] compile-flags: -Z verbose +//[verbose] compile-flags: -Z verbose-internals trait Foo<'b, 'c, S=u32> { fn bar<'a, T>() where T: 'a {} diff --git a/tests/ui/async-await/feature-async-for-loop.rs b/tests/ui/async-await/feature-async-for-loop.rs new file mode 100644 index 00000000000..42247dd14b0 --- /dev/null +++ b/tests/ui/async-await/feature-async-for-loop.rs @@ -0,0 +1,23 @@ +// edition:2021 +// gate-test-async_for_loop + +#![feature(async_iter_from_iter, async_iterator)] + +fn f() { + let _ = async { + for await _i in core::async_iter::from_iter(0..3) { + //~^ ERROR `for await` loops are experimental + } + }; +} + +#[cfg(FALSE)] +fn g() { + let _ = async { + for await _i in core::async_iter::from_iter(0..3) { + //~^ ERROR `for await` loops are experimental + } + }; +} + +fn main() {} diff --git a/tests/ui/async-await/feature-async-for-loop.stderr b/tests/ui/async-await/feature-async-for-loop.stderr new file mode 100644 index 00000000000..38f75821772 --- /dev/null +++ b/tests/ui/async-await/feature-async-for-loop.stderr @@ -0,0 +1,21 @@ +error[E0658]: `for await` loops are experimental + --> $DIR/feature-async-for-loop.rs:8:13 + | +LL | for await _i in core::async_iter::from_iter(0..3) { + | ^^^^^ + | + = note: see issue #118898 <https://github.com/rust-lang/rust/issues/118898> for more information + = help: add `#![feature(async_for_loop)]` to the crate attributes to enable + +error[E0658]: `for await` loops are experimental + --> $DIR/feature-async-for-loop.rs:17:13 + | +LL | for await _i in core::async_iter::from_iter(0..3) { + | ^^^^^ + | + = note: see issue #118898 <https://github.com/rust-lang/rust/issues/118898> for more information + = help: add `#![feature(async_for_loop)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/async-await/for-await-2015.rs b/tests/ui/async-await/for-await-2015.rs new file mode 100644 index 00000000000..c1b7c016d1f --- /dev/null +++ b/tests/ui/async-await/for-await-2015.rs @@ -0,0 +1,10 @@ +// check-pass + +#![feature(async_for_loop)] + +// Make sure we don't break `for await` loops in the 2015 edition, where `await` was allowed as an +// identifier. + +fn main() { + for await in 0..3 {} +} diff --git a/tests/ui/async-await/for-await-consumes-iter.rs b/tests/ui/async-await/for-await-consumes-iter.rs new file mode 100644 index 00000000000..65bb9e88448 --- /dev/null +++ b/tests/ui/async-await/for-await-consumes-iter.rs @@ -0,0 +1,20 @@ +// edition: 2021 +#![feature(async_iterator, async_iter_from_iter, const_waker, async_for_loop, noop_waker)] + +use std::future::Future; + +// a test to make sure `for await` consumes the iterator + +async fn real_main() { + let iter = core::async_iter::from_iter(0..3); + let mut count = 0; + for await i in iter { + } + // make sure iter has been moved and we can't iterate over it again. + for await i in iter { + //~^ ERROR: use of moved value: `iter` + } +} + +fn main() { +} diff --git a/tests/ui/async-await/for-await-consumes-iter.stderr b/tests/ui/async-await/for-await-consumes-iter.stderr new file mode 100644 index 00000000000..a3e5bbcabf5 --- /dev/null +++ b/tests/ui/async-await/for-await-consumes-iter.stderr @@ -0,0 +1,22 @@ +error[E0382]: use of moved value: `iter` + --> $DIR/for-await-consumes-iter.rs:14:20 + | +LL | let iter = core::async_iter::from_iter(0..3); + | ---- move occurs because `iter` has type `FromIter<std::ops::Range<i32>>`, which does not implement the `Copy` trait +LL | let mut count = 0; +LL | for await i in iter { + | ---- `iter` moved due to this method call +... +LL | for await i in iter { + | ^^^^ value used here after move + | +note: `into_async_iter` takes ownership of the receiver `self`, which moves `iter` + --> $SRC_DIR/core/src/async_iter/async_iter.rs:LL:COL +help: you can `clone` the value and consume it, but this might not be your desired behavior + | +LL | for await i in iter.clone() { + | ++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/tests/ui/async-await/for-await-passthrough.rs b/tests/ui/async-await/for-await-passthrough.rs new file mode 100644 index 00000000000..7fa133aaedc --- /dev/null +++ b/tests/ui/async-await/for-await-passthrough.rs @@ -0,0 +1,32 @@ +// run-pass +// edition: 2024 +// compile-flags: -Zunstable-options +#![feature(async_iterator, async_iter_from_iter, const_waker, async_for_loop, noop_waker, + gen_blocks)] + +use std::future::Future; + +async gen fn async_iter() -> i32 { + let iter = core::async_iter::from_iter(0..3); + for await i in iter { + yield i + 1; + } +} + +// make sure a simple for await loop works +async fn real_main() { + let mut count = 1; + for await i in async_iter() { + assert_eq!(i, count); + count += 1; + } + assert_eq!(count, 4); +} + +fn main() { + let future = real_main(); + let waker = std::task::Waker::noop(); + let mut cx = &mut core::task::Context::from_waker(&waker); + let mut future = core::pin::pin!(future); + while let core::task::Poll::Pending = future.as_mut().poll(&mut cx) {} +} diff --git a/tests/ui/async-await/for-await.rs b/tests/ui/async-await/for-await.rs new file mode 100644 index 00000000000..6345ceb0c27 --- /dev/null +++ b/tests/ui/async-await/for-await.rs @@ -0,0 +1,24 @@ +// run-pass +// edition: 2021 +#![feature(async_iterator, async_iter_from_iter, const_waker, async_for_loop, noop_waker)] + +use std::future::Future; + +// make sure a simple for await loop works +async fn real_main() { + let iter = core::async_iter::from_iter(0..3); + let mut count = 0; + for await i in iter { + assert_eq!(i, count); + count += 1; + } + assert_eq!(count, 3); +} + +fn main() { + let future = real_main(); + let waker = std::task::Waker::noop(); + let mut cx = &mut core::task::Context::from_waker(&waker); + let mut future = core::pin::pin!(future); + while let core::task::Poll::Pending = future.as_mut().poll(&mut cx) {} +} diff --git a/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout b/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout index b0447a58261..47b39e5246d 100644 --- a/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout +++ b/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout @@ -52,10 +52,16 @@ print-type-size variant `Panicked`: 1024 bytes print-type-size upvar `.arg`: 1024 bytes print-type-size type: `std::mem::ManuallyDrop<bool>`: 1 bytes, alignment: 1 bytes print-type-size field `.value`: 1 bytes +print-type-size type: `std::mem::ManuallyDrop<{async fn body@$DIR/async-awaiting-fut.rs:6:17: 6:19}>`: 1 bytes, alignment: 1 bytes +print-type-size field `.value`: 1 bytes print-type-size type: `std::mem::MaybeUninit<bool>`: 1 bytes, alignment: 1 bytes print-type-size variant `MaybeUninit`: 1 bytes print-type-size field `.uninit`: 0 bytes print-type-size field `.value`: 1 bytes +print-type-size type: `std::mem::MaybeUninit<{async fn body@$DIR/async-awaiting-fut.rs:6:17: 6:19}>`: 1 bytes, alignment: 1 bytes +print-type-size variant `MaybeUninit`: 1 bytes +print-type-size field `.uninit`: 0 bytes +print-type-size field `.value`: 1 bytes print-type-size type: `std::task::Poll<()>`: 1 bytes, alignment: 1 bytes print-type-size discriminant: 1 bytes print-type-size variant `Ready`: 0 bytes diff --git a/tests/ui/async-await/in-trait/async-default-fn-overridden.rs b/tests/ui/async-await/in-trait/async-default-fn-overridden.rs index c8fd2d8f6c2..491dfcc6ae0 100644 --- a/tests/ui/async-await/in-trait/async-default-fn-overridden.rs +++ b/tests/ui/async-await/in-trait/async-default-fn-overridden.rs @@ -1,6 +1,7 @@ // run-pass // edition:2021 +#![feature(noop_waker)] use std::future::Future; @@ -32,33 +33,18 @@ async fn async_main() { // ------------------------------------------------------------------------- // // Implementation Details Below... -use std::pin::Pin; +use std::pin::pin; use std::task::*; -pub fn noop_waker() -> Waker { - let raw = RawWaker::new(std::ptr::null(), &NOOP_WAKER_VTABLE); - - // SAFETY: the contracts for RawWaker and RawWakerVTable are upheld - unsafe { Waker::from_raw(raw) } -} - -const NOOP_WAKER_VTABLE: RawWakerVTable = RawWakerVTable::new(noop_clone, noop, noop, noop); - -unsafe fn noop_clone(_p: *const ()) -> RawWaker { - RawWaker::new(std::ptr::null(), &NOOP_WAKER_VTABLE) -} - -unsafe fn noop(_p: *const ()) {} - fn main() { - let mut fut = async_main(); + let mut fut = pin!(async_main()); // Poll loop, just to test the future... - let waker = noop_waker(); + let waker = Waker::noop(); let ctx = &mut Context::from_waker(&waker); loop { - match unsafe { Pin::new_unchecked(&mut fut).poll(ctx) } { + match fut.as_mut().poll(ctx) { Poll::Pending => {} Poll::Ready(()) => break, } diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs index 18b0fa4856d..f21abf012ba 100644 --- a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs +++ b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs @@ -2,6 +2,7 @@ // known-bug: #108309 #![feature(min_specialization)] +#![feature(noop_waker)] struct MyStruct; @@ -35,34 +36,18 @@ async fn indirection<T>(x: T) -> &'static str { // ------------------------------------------------------------------------- // // Implementation Details Below... -use std::future::Future; -use std::pin::Pin; +use std::pin::{pin, Pin}; use std::task::*; -pub fn noop_waker() -> Waker { - let raw = RawWaker::new(std::ptr::null(), &NOOP_WAKER_VTABLE); - - // SAFETY: the contracts for RawWaker and RawWakerVTable are upheld - unsafe { Waker::from_raw(raw) } -} - -const NOOP_WAKER_VTABLE: RawWakerVTable = RawWakerVTable::new(noop_clone, noop, noop, noop); - -unsafe fn noop_clone(_p: *const ()) -> RawWaker { - RawWaker::new(std::ptr::null(), &NOOP_WAKER_VTABLE) -} - -unsafe fn noop(_p: *const ()) {} - fn main() { - let mut fut = async_main(); + let mut fut = pin!(async_main()); // Poll loop, just to test the future... - let waker = noop_waker(); + let waker = Waker::noop(); let ctx = &mut Context::from_waker(&waker); loop { - match unsafe { Pin::new_unchecked(&mut fut).poll(ctx) } { + match fut.as_mut().poll(ctx) { Poll::Pending => {} Poll::Ready(()) => break, } diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr index 5e2be08623b..0560cd9c5fe 100644 --- a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr +++ b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr @@ -1,11 +1,11 @@ error[E0053]: method `foo` has an incompatible type for trait - --> $DIR/dont-project-to-specializable-projection.rs:13:5 + --> $DIR/dont-project-to-specializable-projection.rs:14:5 | LL | default async fn foo(_: T) -> &'static str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected associated type, found future | note: type in trait - --> $DIR/dont-project-to-specializable-projection.rs:9:5 + --> $DIR/dont-project-to-specializable-projection.rs:10:5 | LL | async fn foo(_: T) -> &'static str; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,13 +13,29 @@ LL | async fn foo(_: T) -> &'static str; found signature `fn(_) -> impl Future<Output = &'static str>` error: async associated function in trait cannot be specialized - --> $DIR/dont-project-to-specializable-projection.rs:13:5 + --> $DIR/dont-project-to-specializable-projection.rs:14:5 | LL | default async fn foo(_: T) -> &'static str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: specialization behaves in inconsistent and surprising ways with async functions in traits, and for now is disallowed -error: aborting due to 2 previous errors +error[E0599]: no method named `poll` found for struct `Pin<&mut impl Future<Output = ()>>` in the current scope + --> $DIR/dont-project-to-specializable-projection.rs:50:28 + | +LL | match fut.as_mut().poll(ctx) { + | ^^^^ method not found in `Pin<&mut impl Future<Output = ()>>` + --> $SRC_DIR/core/src/future/future.rs:LL:COL + | + = note: the method is available for `Pin<&mut impl Future<Output = ()>>` here + | + = help: items from traits can only be used if the trait is in scope +help: the following trait is implemented but not in scope; perhaps add a `use` for it: + | +LL + use std::future::Future; + | + +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0053`. +Some errors have detailed explanations: E0053, E0599. +For more information about an error, try `rustc --explain E0053`. diff --git a/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr b/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr index 95731b67ccf..8e573b512ad 100644 --- a/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr +++ b/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr @@ -1,7 +1,9 @@ -error[E0391]: cycle detected when computing layout of `{async fn body@$DIR/indirect-recursion-issue-112047.rs:33:27: 35:6}` +error[E0391]: cycle detected when computing layout of `core::mem::maybe_uninit::MaybeUninit<{async fn body@$DIR/indirect-recursion-issue-112047.rs:33:27: 35:6}>` | - = note: ...which requires computing layout of `<<A as First>::Second as Second>::{opaque#0}`... - = note: ...which again requires computing layout of `{async fn body@$DIR/indirect-recursion-issue-112047.rs:33:27: 35:6}`, completing the cycle + = note: ...which requires computing layout of `core::mem::manually_drop::ManuallyDrop<{async fn body@$DIR/indirect-recursion-issue-112047.rs:33:27: 35:6}>`... + = note: ...which requires computing layout of `{async fn body@$DIR/indirect-recursion-issue-112047.rs:33:27: 35:6}`... + = note: ...which requires computing layout of `core::mem::maybe_uninit::MaybeUninit<<<A as First>::Second as Second>::{opaque#0}>`... + = note: ...which again requires computing layout of `core::mem::maybe_uninit::MaybeUninit<{async fn body@$DIR/indirect-recursion-issue-112047.rs:33:27: 35:6}>`, completing the cycle = note: cycle used when computing layout of `{async block@$DIR/indirect-recursion-issue-112047.rs:6:13: 8:6}` = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information diff --git a/tests/ui/async-await/normalize-output-in-signature-deduction.rs b/tests/ui/async-await/normalize-output-in-signature-deduction.rs index 960065a83a4..e07fe9e98ec 100644 --- a/tests/ui/async-await/normalize-output-in-signature-deduction.rs +++ b/tests/ui/async-await/normalize-output-in-signature-deduction.rs @@ -1,6 +1,6 @@ // edition:2021 // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver // check-pass #![feature(type_alias_impl_trait)] diff --git a/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.rs b/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.rs index e581e5ffda7..6097c7f1073 100644 --- a/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.rs +++ b/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.rs @@ -1,7 +1,7 @@ // revisions: current next //[current] known-bug: #109924 //[next] check-pass -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver // edition:2021 #![feature(return_type_notation)] diff --git a/tests/ui/attributes/issue-90873.rs b/tests/ui/attributes/issue-90873.rs index 1411f61744d..53339ce7e28 100644 --- a/tests/ui/attributes/issue-90873.rs +++ b/tests/ui/attributes/issue-90873.rs @@ -1,9 +1,9 @@ #![u=||{static d=||1;}] -//~^ unexpected expression +//~^ attribute value must be a literal //~| cannot find attribute `u` in this scope //~| missing type for `static` item #![a={impl std::ops::Neg for i8 {}}] -//~^ ERROR unexpected expression +//~^ ERROR attribute value must be a literal //~| ERROR cannot find attribute `a` in this scope //~| ERROR `main` function not found in crate `issue_90873` diff --git a/tests/ui/attributes/issue-90873.stderr b/tests/ui/attributes/issue-90873.stderr index 894ec8341f8..5a8bbaf8ec1 100644 --- a/tests/ui/attributes/issue-90873.stderr +++ b/tests/ui/attributes/issue-90873.stderr @@ -1,15 +1,10 @@ -error: unexpected expression: `|| - { - static d: _ = || 1; - }` +error: attribute value must be a literal --> $DIR/issue-90873.rs:1:6 | LL | #![u=||{static d=||1;}] | ^^^^^^^^^^^^^^^^^ -error: unexpected expression: `{ - impl std::ops::Neg for i8 {} - }` +error: attribute value must be a literal --> $DIR/issue-90873.rs:6:6 | LL | #![a={impl std::ops::Neg for i8 {}}] diff --git a/tests/ui/attributes/key-value-expansion-on-mac.rs b/tests/ui/attributes/key-value-expansion-on-mac.rs index c1d68d8cda9..ea7cf7c4f64 100644 --- a/tests/ui/attributes/key-value-expansion-on-mac.rs +++ b/tests/ui/attributes/key-value-expansion-on-mac.rs @@ -7,8 +7,8 @@ macro_rules! bar { // FIXME?: `bar` here expands before `stringify` has a chance to expand. // `#[rustc_dummy = ...]` is validated and dropped during expansion of `bar`, -// the "unexpected expression" errors comes from the validation. -#[rustc_dummy = stringify!(b)] //~ ERROR unexpected expression: `stringify!(b)` +// the "attribute value must be a literal" error comes from the validation. +#[rustc_dummy = stringify!(b)] //~ ERROR attribute value must be a literal bar!(); fn main() {} diff --git a/tests/ui/attributes/key-value-expansion-on-mac.stderr b/tests/ui/attributes/key-value-expansion-on-mac.stderr index 7d817da1362..260462cfeef 100644 --- a/tests/ui/attributes/key-value-expansion-on-mac.stderr +++ b/tests/ui/attributes/key-value-expansion-on-mac.stderr @@ -1,4 +1,4 @@ -error: unexpected expression: `stringify!(b)` +error: attribute value must be a literal --> $DIR/key-value-expansion-on-mac.rs:11:17 | LL | #[rustc_dummy = stringify!(b)] diff --git a/tests/ui/attributes/key-value-expansion.rs b/tests/ui/attributes/key-value-expansion.rs index 83d601e5e3a..3065c12749c 100644 --- a/tests/ui/attributes/key-value-expansion.rs +++ b/tests/ui/attributes/key-value-expansion.rs @@ -18,13 +18,13 @@ macro_rules! bug { // Any expressions containing macro call `X` that's more complex than `X` itself. // Parentheses will work. -bug!((column!())); //~ ERROR unexpected expression: `(7u32)` +bug!((column!())); //~ ERROR attribute value must be a literal // Original test case. macro_rules! bug { () => { - bug!("bug" + stringify!(found)); //~ ERROR unexpected expression: `"bug" + "found"` + bug!("bug" + stringify!(found)); //~ ERROR attribute value must be a literal }; ($test:expr) => { #[doc = $test] @@ -46,7 +46,7 @@ macro_rules! doc_comment { macro_rules! some_macro { ($t1: ty) => { doc_comment! {format!("{coor}", coor = stringify!($t1)).as_str()} - //~^ ERROR unexpected expression: `{ + //~^ ERROR attribute value must be a literal }; } diff --git a/tests/ui/attributes/key-value-expansion.stderr b/tests/ui/attributes/key-value-expansion.stderr index aaa8b169583..54d79c5bebb 100644 --- a/tests/ui/attributes/key-value-expansion.stderr +++ b/tests/ui/attributes/key-value-expansion.stderr @@ -1,10 +1,10 @@ -error: unexpected expression: `(7u32)` +error: attribute value must be a literal --> $DIR/key-value-expansion.rs:21:6 | LL | bug!((column!())); | ^^^^^^^^^^^ -error: unexpected expression: `"bug" + "found"` +error: attribute value must be a literal --> $DIR/key-value-expansion.rs:27:14 | LL | bug!("bug" + stringify!(found)); @@ -15,7 +15,7 @@ LL | bug!(); | = note: this error originates in the macro `bug` (in Nightly builds, run with -Z macro-backtrace for more info) -error: unexpected expression: `{ let res = ::alloc::fmt::format(format_args!("{0}", "u8")); res }.as_str()` +error: attribute value must be a literal --> $DIR/key-value-expansion.rs:48:23 | LL | doc_comment! {format!("{coor}", coor = stringify!($t1)).as_str()} diff --git a/tests/ui/attributes/unused-item-in-attr.rs b/tests/ui/attributes/unused-item-in-attr.rs index 70dcd5413f1..fda0a5d6a3f 100644 --- a/tests/ui/attributes/unused-item-in-attr.rs +++ b/tests/ui/attributes/unused-item-in-attr.rs @@ -1,5 +1,5 @@ #[w = { extern crate alloc; }] -//~^ ERROR unexpected expression: `{ +//~^ ERROR attribute value must be a literal //~| ERROR cannot find attribute `w` in this scope fn f() {} diff --git a/tests/ui/attributes/unused-item-in-attr.stderr b/tests/ui/attributes/unused-item-in-attr.stderr index 92a8f585821..84130965d31 100644 --- a/tests/ui/attributes/unused-item-in-attr.stderr +++ b/tests/ui/attributes/unused-item-in-attr.stderr @@ -1,6 +1,4 @@ -error: unexpected expression: `{ - extern crate alloc; - }` +error: attribute value must be a literal --> $DIR/unused-item-in-attr.rs:1:7 | LL | #[w = { extern crate alloc; }] diff --git a/tests/ui/auto-traits/issue-23080-2.rs b/tests/ui/auto-traits/issue-23080-2.rs index 882b8f39384..d63cd9d5dd6 100644 --- a/tests/ui/auto-traits/issue-23080-2.rs +++ b/tests/ui/auto-traits/issue-23080-2.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver #![feature(auto_traits)] #![feature(negative_impls)] diff --git a/tests/ui/binop/binary-op-suggest-deref.fixed b/tests/ui/binop/binary-op-suggest-deref.fixed deleted file mode 100644 index 1ff3599137b..00000000000 --- a/tests/ui/binop/binary-op-suggest-deref.fixed +++ /dev/null @@ -1,8 +0,0 @@ -// Issue #52544 -// run-rustfix - -fn main() { - let i: &i64 = &1; - if *i < 0 {} - //~^ ERROR mismatched types [E0308] -} diff --git a/tests/ui/binop/binary-op-suggest-deref.rs b/tests/ui/binop/binary-op-suggest-deref.rs index 12505a9ac27..57f24a4c28e 100644 --- a/tests/ui/binop/binary-op-suggest-deref.rs +++ b/tests/ui/binop/binary-op-suggest-deref.rs @@ -1,8 +1,75 @@ -// Issue #52544 -// run-rustfix +#![allow(dead_code)] -fn main() { +fn foo() { + // Issue #52544 let i: &i64 = &1; if i < 0 {} //~^ ERROR mismatched types [E0308] } + +fn bar() { + // Issue #40660 + let foo = &&0; + + // Dereference LHS + _ = foo == 0; + //~^ERROR can't compare `&&{integer}` with `{integer}` [E0277] + _ = foo == &0; + //~^ERROR can't compare `&{integer}` with `{integer}` [E0277] + _ = &&&&foo == 0; + //~^ERROR can't compare `&&&&&&{integer}` with `{integer}` [E0277] + _ = *foo == 0; + //~^ERROR can't compare `&{integer}` with `{integer}` [E0277] + _ = &&foo == &&0; + //~^ERROR can't compare `&&{integer}` with `{integer}` [E0277] + _ = &Box::new(42) == 42; + //~^ERROR can't compare `&Box<{integer}>` with `{integer}` [E0277] + _ = &Box::new(&Box::new(&42)) == 42; + //~^ERROR can't compare `&Box<&Box<&{integer}>>` with `{integer}` [E0277] + + // Dereference RHS + _ = 0 == foo; + //~^ERROR can't compare `{integer}` with `&&{integer}` [E0277] + _ = &0 == foo; + //~^ERROR can't compare `{integer}` with `&{integer}` [E0277] + _ = 0 == &&&&foo; + //~^ERROR can't compare `{integer}` with `&&&&&&{integer}` [E0277] + _ = 0 == *foo; + //~^ERROR can't compare `{integer}` with `&{integer}` [E0277] + _ = &&0 == &&foo; + //~^ERROR can't compare `{integer}` with `&&{integer}` [E0277] + + // Dereference both sides + _ = &Box::new(Box::new(42)) == &foo; + //~^ERROR can't compare `Box<Box<{integer}>>` with `&&{integer}` [E0277] + _ = &Box::new(42) == &foo; + //~^ERROR can't compare `Box<{integer}>` with `&&{integer}` [E0277] + _ = &Box::new(Box::new(Box::new(Box::new(42)))) == &foo; + //~^ERROR can't compare `Box<Box<Box<Box<{integer}>>>>` with `&&{integer}` [E0277] + _ = &foo == &Box::new(Box::new(Box::new(Box::new(42)))); + //~^ERROR can't compare `&&{integer}` with `Box<Box<Box<Box<{integer}>>>>` [E0277] + + // Don't suggest dereferencing the LHS; suggest boxing the RHS instead + _ = Box::new(42) == 42; + //~^ERROR mismatched types [E0308] + + // Don't suggest dereferencing with types that can't be compared + struct Foo; + _ = &&0 == Foo; + //~^ERROR can't compare `&&{integer}` with `Foo` [E0277] + _ = Foo == &&0; + //~^ERROR binary operation `==` cannot be applied to type `Foo` [E0369] +} + +fn baz() { + // Issue #44695 + let owned = "foo".to_owned(); + let string_ref = &owned; + let partial = "foobar"; + _ = string_ref == partial[..3]; + //~^ERROR can't compare `&String` with `str` [E0277] + _ = partial[..3] == string_ref; + //~^ERROR can't compare `str` with `&String` [E0277] +} + +fn main() {} diff --git a/tests/ui/binop/binary-op-suggest-deref.stderr b/tests/ui/binop/binary-op-suggest-deref.stderr index d1d0089ece7..f5de64e3ab1 100644 --- a/tests/ui/binop/binary-op-suggest-deref.stderr +++ b/tests/ui/binop/binary-op-suggest-deref.stderr @@ -9,6 +9,298 @@ help: consider dereferencing the borrow LL | if *i < 0 {} | + -error: aborting due to 1 previous error +error[E0277]: can't compare `&&{integer}` with `{integer}` + --> $DIR/binary-op-suggest-deref.rs:15:13 + | +LL | _ = foo == 0; + | ^^ no implementation for `&&{integer} == {integer}` + | + = help: the trait `PartialEq<{integer}>` is not implemented for `&&{integer}` +help: consider dereferencing here + | +LL | _ = **foo == 0; + | ++ + +error[E0277]: can't compare `&{integer}` with `{integer}` + --> $DIR/binary-op-suggest-deref.rs:17:13 + | +LL | _ = foo == &0; + | ^^ no implementation for `&{integer} == {integer}` + | + = help: the trait `PartialEq<{integer}>` is not implemented for `&{integer}` + = note: required for `&&{integer}` to implement `PartialEq<&{integer}>` +help: consider dereferencing here + | +LL | _ = *foo == &0; + | + + +error[E0277]: can't compare `&&&&&&{integer}` with `{integer}` + --> $DIR/binary-op-suggest-deref.rs:19:17 + | +LL | _ = &&&&foo == 0; + | ^^ no implementation for `&&&&&&{integer} == {integer}` + | + = help: the trait `PartialEq<{integer}>` is not implemented for `&&&&&&{integer}` +help: consider removing the borrows and dereferencing instead + | +LL - _ = &&&&foo == 0; +LL + _ = **foo == 0; + | + +error[E0277]: can't compare `&{integer}` with `{integer}` + --> $DIR/binary-op-suggest-deref.rs:21:14 + | +LL | _ = *foo == 0; + | ^^ no implementation for `&{integer} == {integer}` + | + = help: the trait `PartialEq<{integer}>` is not implemented for `&{integer}` +help: consider dereferencing here + | +LL | _ = **foo == 0; + | + + +error[E0277]: can't compare `&&{integer}` with `{integer}` + --> $DIR/binary-op-suggest-deref.rs:23:15 + | +LL | _ = &&foo == &&0; + | ^^ no implementation for `&&{integer} == {integer}` + | + = help: the trait `PartialEq<{integer}>` is not implemented for `&&{integer}` + = note: required for `&&&{integer}` to implement `PartialEq<&{integer}>` + = note: 1 redundant requirement hidden + = note: required for `&&&&{integer}` to implement `PartialEq<&&{integer}>` +help: consider removing the borrows + | +LL - _ = &&foo == &&0; +LL + _ = foo == &&0; + | + +error[E0277]: can't compare `&Box<{integer}>` with `{integer}` + --> $DIR/binary-op-suggest-deref.rs:25:23 + | +LL | _ = &Box::new(42) == 42; + | ^^ no implementation for `&Box<{integer}> == {integer}` + | + = help: the trait `PartialEq<{integer}>` is not implemented for `&Box<{integer}>` +help: consider removing the borrow and dereferencing instead + | +LL - _ = &Box::new(42) == 42; +LL + _ = *Box::new(42) == 42; + | + +error[E0277]: can't compare `&Box<&Box<&{integer}>>` with `{integer}` + --> $DIR/binary-op-suggest-deref.rs:27:35 + | +LL | _ = &Box::new(&Box::new(&42)) == 42; + | ^^ no implementation for `&Box<&Box<&{integer}>> == {integer}` + | + = help: the trait `PartialEq<{integer}>` is not implemented for `&Box<&Box<&{integer}>>` +help: consider removing the borrow and dereferencing instead + | +LL - _ = &Box::new(&Box::new(&42)) == 42; +LL + _ = ****Box::new(&Box::new(&42)) == 42; + | + +error[E0277]: can't compare `{integer}` with `&&{integer}` + --> $DIR/binary-op-suggest-deref.rs:31:11 + | +LL | _ = 0 == foo; + | ^^ no implementation for `{integer} == &&{integer}` + | + = help: the trait `PartialEq<&&{integer}>` is not implemented for `{integer}` +help: consider dereferencing here + | +LL | _ = 0 == **foo; + | ++ + +error[E0277]: can't compare `{integer}` with `&{integer}` + --> $DIR/binary-op-suggest-deref.rs:33:12 + | +LL | _ = &0 == foo; + | ^^ no implementation for `{integer} == &{integer}` + | + = help: the trait `PartialEq<&{integer}>` is not implemented for `{integer}` + = note: required for `&{integer}` to implement `PartialEq<&&{integer}>` +help: consider dereferencing here + | +LL | _ = &0 == *foo; + | + + +error[E0277]: can't compare `{integer}` with `&&&&&&{integer}` + --> $DIR/binary-op-suggest-deref.rs:35:11 + | +LL | _ = 0 == &&&&foo; + | ^^ no implementation for `{integer} == &&&&&&{integer}` + | + = help: the trait `PartialEq<&&&&&&{integer}>` is not implemented for `{integer}` +help: consider removing the borrows and dereferencing instead + | +LL - _ = 0 == &&&&foo; +LL + _ = 0 == **foo; + | + +error[E0277]: can't compare `{integer}` with `&{integer}` + --> $DIR/binary-op-suggest-deref.rs:37:11 + | +LL | _ = 0 == *foo; + | ^^ no implementation for `{integer} == &{integer}` + | + = help: the trait `PartialEq<&{integer}>` is not implemented for `{integer}` +help: consider dereferencing here + | +LL | _ = 0 == **foo; + | + + +error[E0277]: can't compare `{integer}` with `&&{integer}` + --> $DIR/binary-op-suggest-deref.rs:39:13 + | +LL | _ = &&0 == &&foo; + | ^^ no implementation for `{integer} == &&{integer}` + | + = help: the trait `PartialEq<&&{integer}>` is not implemented for `{integer}` + = note: required for `&{integer}` to implement `PartialEq<&&&{integer}>` + = note: 1 redundant requirement hidden + = note: required for `&&{integer}` to implement `PartialEq<&&&&{integer}>` +help: consider removing the borrows + | +LL - _ = &&0 == &&foo; +LL + _ = &&0 == foo; + | + +error[E0277]: can't compare `Box<Box<{integer}>>` with `&&{integer}` + --> $DIR/binary-op-suggest-deref.rs:43:33 + | +LL | _ = &Box::new(Box::new(42)) == &foo; + | ^^ no implementation for `Box<Box<{integer}>> == &&{integer}` + | + = help: the trait `PartialEq<&&{integer}>` is not implemented for `Box<Box<{integer}>>` + = note: required for `&Box<Box<{integer}>>` to implement `PartialEq<&&&{integer}>` +help: consider dereferencing both sides of the expression + | +LL - _ = &Box::new(Box::new(42)) == &foo; +LL + _ = **Box::new(Box::new(42)) == **foo; + | + +error[E0277]: can't compare `Box<{integer}>` with `&&{integer}` + --> $DIR/binary-op-suggest-deref.rs:45:23 + | +LL | _ = &Box::new(42) == &foo; + | ^^ no implementation for `Box<{integer}> == &&{integer}` + | + = help: the trait `PartialEq<&&{integer}>` is not implemented for `Box<{integer}>` + = note: required for `&Box<{integer}>` to implement `PartialEq<&&&{integer}>` +help: consider dereferencing both sides of the expression + | +LL - _ = &Box::new(42) == &foo; +LL + _ = *Box::new(42) == **foo; + | + +error[E0277]: can't compare `Box<Box<Box<Box<{integer}>>>>` with `&&{integer}` + --> $DIR/binary-op-suggest-deref.rs:47:53 + | +LL | _ = &Box::new(Box::new(Box::new(Box::new(42)))) == &foo; + | ^^ no implementation for `Box<Box<Box<Box<{integer}>>>> == &&{integer}` + | + = help: the trait `PartialEq<&&{integer}>` is not implemented for `Box<Box<Box<Box<{integer}>>>>` + = note: required for `&Box<Box<Box<Box<{integer}>>>>` to implement `PartialEq<&&&{integer}>` +help: consider dereferencing both sides of the expression + | +LL - _ = &Box::new(Box::new(Box::new(Box::new(42)))) == &foo; +LL + _ = ****Box::new(Box::new(Box::new(Box::new(42)))) == **foo; + | + +error[E0277]: can't compare `&&{integer}` with `Box<Box<Box<Box<{integer}>>>>` + --> $DIR/binary-op-suggest-deref.rs:49:14 + | +LL | _ = &foo == &Box::new(Box::new(Box::new(Box::new(42)))); + | ^^ no implementation for `&&{integer} == Box<Box<Box<Box<{integer}>>>>` + | + = help: the trait `PartialEq<Box<Box<Box<Box<{integer}>>>>>` is not implemented for `&&{integer}` + = note: required for `&&&{integer}` to implement `PartialEq<&Box<Box<Box<Box<{integer}>>>>>` +help: consider dereferencing both sides of the expression + | +LL - _ = &foo == &Box::new(Box::new(Box::new(Box::new(42)))); +LL + _ = **foo == ****Box::new(Box::new(Box::new(Box::new(42)))); + | + +error[E0308]: mismatched types + --> $DIR/binary-op-suggest-deref.rs:53:25 + | +LL | _ = Box::new(42) == 42; + | ------------ ^^ expected `Box<{integer}>`, found integer + | | + | expected because this is `Box<{integer}>` + | + = note: expected struct `Box<{integer}>` + found type `{integer}` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +help: store this in the heap by calling `Box::new` + | +LL | _ = Box::new(42) == Box::new(42); + | +++++++++ + + +error[E0277]: can't compare `&&{integer}` with `Foo` + --> $DIR/binary-op-suggest-deref.rs:58:13 + | +LL | _ = &&0 == Foo; + | ^^ no implementation for `&&{integer} == Foo` + | + = help: the trait `PartialEq<Foo>` is not implemented for `&&{integer}` + = help: the following other types implement trait `PartialEq<Rhs>`: + isize + i8 + i16 + i32 + i64 + i128 + usize + u8 + and 6 others + +error[E0369]: binary operation `==` cannot be applied to type `Foo` + --> $DIR/binary-op-suggest-deref.rs:60:13 + | +LL | _ = Foo == &&0; + | --- ^^ --- &&{integer} + | | + | Foo + | +note: an implementation of `PartialEq<&&{integer}>` might be missing for `Foo` + --> $DIR/binary-op-suggest-deref.rs:57:5 + | +LL | struct Foo; + | ^^^^^^^^^^ must implement `PartialEq<&&{integer}>` +help: consider annotating `Foo` with `#[derive(PartialEq)]` + | +LL + #[derive(PartialEq)] +LL | struct Foo; + | + +error[E0277]: can't compare `&String` with `str` + --> $DIR/binary-op-suggest-deref.rs:69:20 + | +LL | _ = string_ref == partial[..3]; + | ^^ no implementation for `&String == str` + | + = help: the trait `PartialEq<str>` is not implemented for `&String` +help: consider dereferencing here + | +LL | _ = *string_ref == partial[..3]; + | + + +error[E0277]: can't compare `str` with `&String` + --> $DIR/binary-op-suggest-deref.rs:71:22 + | +LL | _ = partial[..3] == string_ref; + | ^^ no implementation for `str == &String` + | + = help: the trait `PartialEq<&String>` is not implemented for `str` +help: consider dereferencing here + | +LL | _ = partial[..3] == *string_ref; + | + + +error: aborting due to 22 previous errors -For more information about this error, try `rustc --explain E0308`. +Some errors have detailed explanations: E0277, E0308, E0369. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/bounds-lifetime.rs b/tests/ui/bounds-lifetime.rs index e3e635a4e84..f26976066ac 100644 --- a/tests/ui/bounds-lifetime.rs +++ b/tests/ui/bounds-lifetime.rs @@ -1,6 +1,6 @@ -type A = for<'b, 'a: 'b> fn(); //~ ERROR lifetime bounds cannot be used in this context -type B = for<'b, 'a: 'b,> fn(); //~ ERROR lifetime bounds cannot be used in this context -type C = for<'b, 'a: 'b +> fn(); //~ ERROR lifetime bounds cannot be used in this context +type A = for<'b, 'a: 'b> fn(); //~ ERROR bounds cannot be used in this context +type B = for<'b, 'a: 'b,> fn(); //~ ERROR bounds cannot be used in this context +type C = for<'b, 'a: 'b +> fn(); //~ ERROR bounds cannot be used in this context type D = for<'a, T> fn(); //~ ERROR only lifetime parameters can be used in this context type E = dyn for<T, U> Fn(); //~ ERROR only lifetime parameters can be used in this context diff --git a/tests/ui/bounds-lifetime.stderr b/tests/ui/bounds-lifetime.stderr index bbae835d875..de9b9e01242 100644 --- a/tests/ui/bounds-lifetime.stderr +++ b/tests/ui/bounds-lifetime.stderr @@ -1,16 +1,16 @@ -error: lifetime bounds cannot be used in this context +error: bounds cannot be used in this context --> $DIR/bounds-lifetime.rs:1:22 | LL | type A = for<'b, 'a: 'b> fn(); | ^^ -error: lifetime bounds cannot be used in this context +error: bounds cannot be used in this context --> $DIR/bounds-lifetime.rs:2:22 | LL | type B = for<'b, 'a: 'b,> fn(); | ^^ -error: lifetime bounds cannot be used in this context +error: bounds cannot be used in this context --> $DIR/bounds-lifetime.rs:3:22 | LL | type C = for<'b, 'a: 'b +> fn(); diff --git a/tests/ui/c-variadic/variadic-ffi-6.stderr b/tests/ui/c-variadic/variadic-ffi-6.stderr index 1ceff570478..344bfed4b42 100644 --- a/tests/ui/c-variadic/variadic-ffi-6.stderr +++ b/tests/ui/c-variadic/variadic-ffi-6.stderr @@ -5,10 +5,19 @@ LL | ) -> &usize { | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | ) -> &'static usize { | +++++++ +help: instead, you are more likely to want to change one of the arguments to be borrowed... + | +LL | x: &usize, + | + +help: ...or alternatively, you might want to return an owned value + | +LL - ) -> &usize { +LL + ) -> usize { + | error: aborting due to 1 previous error diff --git a/tests/ui/cast/cast-to-slice.rs b/tests/ui/cast/cast-to-slice.rs new file mode 100644 index 00000000000..a6c784a3d47 --- /dev/null +++ b/tests/ui/cast/cast-to-slice.rs @@ -0,0 +1,8 @@ +fn main() { + "example".as_bytes() as [char]; + //~^ ERROR cast to unsized type + + let arr: &[u8] = &[0, 2, 3]; + arr as [char]; + //~^ ERROR cast to unsized type +} diff --git a/tests/ui/cast/cast-to-slice.stderr b/tests/ui/cast/cast-to-slice.stderr new file mode 100644 index 00000000000..8f862c00014 --- /dev/null +++ b/tests/ui/cast/cast-to-slice.stderr @@ -0,0 +1,19 @@ +error[E0620]: cast to unsized type: `&[u8]` as `[char]` + --> $DIR/cast-to-slice.rs:2:5 + | +LL | "example".as_bytes() as [char]; + | ^^^^^^^^^^^^^^^^^^^^^^^^------ + | | + | help: try casting to a reference instead: `&[char]` + +error[E0620]: cast to unsized type: `&[u8]` as `[char]` + --> $DIR/cast-to-slice.rs:6:5 + | +LL | arr as [char]; + | ^^^^^^^------ + | | + | help: try casting to a reference instead: `&[char]` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0620`. diff --git a/tests/ui/check-cfg/allow-same-level.stderr b/tests/ui/check-cfg/allow-same-level.stderr index 652efc3f591..7f0faa0700d 100644 --- a/tests/ui/check-cfg/allow-same-level.stderr +++ b/tests/ui/check-cfg/allow-same-level.stderr @@ -5,6 +5,8 @@ LL | #[cfg(FALSE)] | ^^^^^ | = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = help: to expect this configuration use `--check-cfg=cfg(FALSE)` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/cargo-feature.none.stderr b/tests/ui/check-cfg/cargo-feature.none.stderr new file mode 100644 index 00000000000..44c8f7e3072 --- /dev/null +++ b/tests/ui/check-cfg/cargo-feature.none.stderr @@ -0,0 +1,31 @@ +warning: unexpected `cfg` condition name: `feature` + --> $DIR/cargo-feature.rs:13:7 + | +LL | #[cfg(feature = "serde")] + | ^^^^^^^^^^^^^^^^^ + | + = help: consider defining some features in `Cargo.toml` + = note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: unexpected `cfg` condition name: `tokio_unstable` + --> $DIR/cargo-feature.rs:18:7 + | +LL | #[cfg(tokio_unstable)] + | ^^^^^^^^^^^^^^ + | + = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = help: consider using a Cargo feature instead or adding `println!("cargo:rustc-check-cfg=cfg(tokio_unstable)");` to the top of a `build.rs` + = note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration + +warning: unexpected `cfg` condition name: `CONFIG_NVME` + --> $DIR/cargo-feature.rs:22:7 + | +LL | #[cfg(CONFIG_NVME = "m")] + | ^^^^^^^^^^^^^^^^^ + | + = help: consider using a Cargo feature instead or adding `println!("cargo:rustc-check-cfg=cfg(CONFIG_NVME, values(\"m\"))");` to the top of a `build.rs` + = note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration + +warning: 3 warnings emitted + diff --git a/tests/ui/check-cfg/cargo-feature.rs b/tests/ui/check-cfg/cargo-feature.rs index ea48c6ea201..fe343d0a678 100644 --- a/tests/ui/check-cfg/cargo-feature.rs +++ b/tests/ui/check-cfg/cargo-feature.rs @@ -3,12 +3,25 @@ // list of all the expected names // // check-pass +// revisions: some none // rustc-env:CARGO=/usr/bin/cargo // compile-flags: --check-cfg=cfg() -Z unstable-options -// error-pattern:Cargo.toml +// [some]compile-flags: --check-cfg=cfg(feature,values("bitcode")) +// [some]compile-flags: --check-cfg=cfg(CONFIG_NVME,values("y")) +// [none]error-pattern:Cargo.toml #[cfg(feature = "serde")] -//~^ WARNING unexpected `cfg` condition name +//[none]~^ WARNING unexpected `cfg` condition name +//[some]~^^ WARNING unexpected `cfg` condition value fn ser() {} +#[cfg(tokio_unstable)] +//~^ WARNING unexpected `cfg` condition name +fn tokio() {} + +#[cfg(CONFIG_NVME = "m")] +//[none]~^ WARNING unexpected `cfg` condition name +//[some]~^^ WARNING unexpected `cfg` condition value +fn tokio() {} + fn main() {} diff --git a/tests/ui/check-cfg/cargo-feature.some.stderr b/tests/ui/check-cfg/cargo-feature.some.stderr new file mode 100644 index 00000000000..92d63d01534 --- /dev/null +++ b/tests/ui/check-cfg/cargo-feature.some.stderr @@ -0,0 +1,35 @@ +warning: unexpected `cfg` condition value: `serde` + --> $DIR/cargo-feature.rs:13:7 + | +LL | #[cfg(feature = "serde")] + | ^^^^^^^^^^^^^^^^^ + | + = note: expected values for `feature` are: `bitcode` + = help: consider adding `serde` as a feature in `Cargo.toml` + = note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: unexpected `cfg` condition name: `tokio_unstable` + --> $DIR/cargo-feature.rs:18:7 + | +LL | #[cfg(tokio_unstable)] + | ^^^^^^^^^^^^^^ + | + = help: expected names are: `CONFIG_NVME`, `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = help: consider using a Cargo feature instead or adding `println!("cargo:rustc-check-cfg=cfg(tokio_unstable)");` to the top of a `build.rs` + = note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration + +warning: unexpected `cfg` condition value: `m` + --> $DIR/cargo-feature.rs:22:7 + | +LL | #[cfg(CONFIG_NVME = "m")] + | ^^^^^^^^^^^^^^--- + | | + | help: there is a expected value with a similar name: `"y"` + | + = note: expected values for `CONFIG_NVME` are: `y` + = help: consider using a Cargo feature instead or adding `println!("cargo:rustc-check-cfg=cfg(CONFIG_NVME, values(\"m\"))");` to the top of a `build.rs` + = note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration + +warning: 3 warnings emitted + diff --git a/tests/ui/check-cfg/cargo-feature.stderr b/tests/ui/check-cfg/cargo-feature.stderr deleted file mode 100644 index 619410a28f3..00000000000 --- a/tests/ui/check-cfg/cargo-feature.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: unexpected `cfg` condition name: `feature` - --> $DIR/cargo-feature.rs:10:7 - | -LL | #[cfg(feature = "serde")] - | ^^^^^^^^^^^^^^^^^ - | - = help: consider defining some features in `Cargo.toml` - = note: `#[warn(unexpected_cfgs)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/check-cfg/compact-names.stderr b/tests/ui/check-cfg/compact-names.stderr index d3bfb9f7100..dfa26f5dde0 100644 --- a/tests/ui/check-cfg/compact-names.stderr +++ b/tests/ui/check-cfg/compact-names.stderr @@ -5,6 +5,8 @@ LL | #[cfg(target(os = "linux", architecture = "arm"))] | ^^^^^^^^^^^^^^^^^^^^ | = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = help: to expect this configuration use `--check-cfg=cfg(target_architecture, values("arm"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/compact-values.stderr b/tests/ui/check-cfg/compact-values.stderr index 819b789c3e5..10276af4d8f 100644 --- a/tests/ui/check-cfg/compact-values.stderr +++ b/tests/ui/check-cfg/compact-values.stderr @@ -5,6 +5,8 @@ LL | #[cfg(target(os = "linux", pointer_width = "X"))] | ^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_pointer_width` are: `16`, `32`, `64` + = help: to expect this configuration use `--check-cfg=cfg(target_pointer_width, values("X"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/concat-values.stderr b/tests/ui/check-cfg/concat-values.stderr index da2bd7d6ad9..dec43f5bda3 100644 --- a/tests/ui/check-cfg/concat-values.stderr +++ b/tests/ui/check-cfg/concat-values.stderr @@ -5,6 +5,8 @@ LL | #[cfg(my_cfg)] | ^^^^^^ | = note: expected values for `my_cfg` are: `bar`, `foo` + = help: to expect this configuration use `--check-cfg=cfg(my_cfg)` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `unk` @@ -14,6 +16,8 @@ LL | #[cfg(my_cfg = "unk")] | ^^^^^^^^^^^^^^ | = note: expected values for `my_cfg` are: `bar`, `foo` + = help: to expect this configuration use `--check-cfg=cfg(my_cfg, values("unk"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: 2 warnings emitted diff --git a/tests/ui/check-cfg/diagnotics.cargo.stderr b/tests/ui/check-cfg/diagnotics.cargo.stderr new file mode 100644 index 00000000000..05c52bf59fa --- /dev/null +++ b/tests/ui/check-cfg/diagnotics.cargo.stderr @@ -0,0 +1,71 @@ +warning: unexpected `cfg` condition name: `featur` + --> $DIR/diagnotics.rs:7:7 + | +LL | #[cfg(featur)] + | ^^^^^^ help: there is a config with a similar name: `feature` + | + = help: expected values for `feature` are: `foo` + = note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: unexpected `cfg` condition name: `featur` + --> $DIR/diagnotics.rs:11:7 + | +LL | #[cfg(featur = "foo")] + | ^^^^^^^^^^^^^^ + | + = note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration +help: there is a config with a similar name and value + | +LL | #[cfg(feature = "foo")] + | ~~~~~~~ + +warning: unexpected `cfg` condition name: `featur` + --> $DIR/diagnotics.rs:15:7 + | +LL | #[cfg(featur = "fo")] + | ^^^^^^^^^^^^^ + | + = help: expected values for `feature` are: `foo` + = note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration +help: there is a config with a similar name and different values + | +LL | #[cfg(feature = "foo")] + | ~~~~~~~~~~~~~~~ + +warning: unexpected `cfg` condition name: `no_value` + --> $DIR/diagnotics.rs:22:7 + | +LL | #[cfg(no_value)] + | ^^^^^^^^ help: there is a config with a similar name: `no_values` + | + = help: consider using a Cargo feature instead or adding `println!("cargo:rustc-check-cfg=cfg(no_value)");` to the top of a `build.rs` + = note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration + +warning: unexpected `cfg` condition name: `no_value` + --> $DIR/diagnotics.rs:26:7 + | +LL | #[cfg(no_value = "foo")] + | ^^^^^^^^^^^^^^^^ + | + = help: consider using a Cargo feature instead or adding `println!("cargo:rustc-check-cfg=cfg(no_value, values(\"foo\"))");` to the top of a `build.rs` + = note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration +help: there is a config with a similar name and no value + | +LL | #[cfg(no_values)] + | ~~~~~~~~~ + +warning: unexpected `cfg` condition value: `bar` + --> $DIR/diagnotics.rs:30:7 + | +LL | #[cfg(no_values = "bar")] + | ^^^^^^^^^-------- + | | + | help: remove the value + | + = note: no expected value for `no_values` + = help: consider using a Cargo feature instead or adding `println!("cargo:rustc-check-cfg=cfg(no_values, values(\"bar\"))");` to the top of a `build.rs` + = note: see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration + +warning: 6 warnings emitted + diff --git a/tests/ui/check-cfg/diagnotics.rs b/tests/ui/check-cfg/diagnotics.rs index 45875bddc17..33073f05f69 100644 --- a/tests/ui/check-cfg/diagnotics.rs +++ b/tests/ui/check-cfg/diagnotics.rs @@ -1,4 +1,7 @@ // check-pass +// revisions: cargo rustc +// [rustc]unset-rustc-env:CARGO +// [cargo]rustc-env:CARGO=/usr/bin/cargo // compile-flags: --check-cfg=cfg(feature,values("foo")) --check-cfg=cfg(no_values) -Z unstable-options #[cfg(featur)] diff --git a/tests/ui/check-cfg/diagnotics.rustc.stderr b/tests/ui/check-cfg/diagnotics.rustc.stderr new file mode 100644 index 00000000000..2b1129a3920 --- /dev/null +++ b/tests/ui/check-cfg/diagnotics.rustc.stderr @@ -0,0 +1,74 @@ +warning: unexpected `cfg` condition name: `featur` + --> $DIR/diagnotics.rs:7:7 + | +LL | #[cfg(featur)] + | ^^^^^^ help: there is a config with a similar name: `feature` + | + = help: expected values for `feature` are: `foo` + = help: to expect this configuration use `--check-cfg=cfg(featur)` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: unexpected `cfg` condition name: `featur` + --> $DIR/diagnotics.rs:11:7 + | +LL | #[cfg(featur = "foo")] + | ^^^^^^^^^^^^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(featur, values("foo"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration +help: there is a config with a similar name and value + | +LL | #[cfg(feature = "foo")] + | ~~~~~~~ + +warning: unexpected `cfg` condition name: `featur` + --> $DIR/diagnotics.rs:15:7 + | +LL | #[cfg(featur = "fo")] + | ^^^^^^^^^^^^^ + | + = help: expected values for `feature` are: `foo` + = help: to expect this configuration use `--check-cfg=cfg(featur, values("fo"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration +help: there is a config with a similar name and different values + | +LL | #[cfg(feature = "foo")] + | ~~~~~~~~~~~~~~~ + +warning: unexpected `cfg` condition name: `no_value` + --> $DIR/diagnotics.rs:22:7 + | +LL | #[cfg(no_value)] + | ^^^^^^^^ help: there is a config with a similar name: `no_values` + | + = help: to expect this configuration use `--check-cfg=cfg(no_value)` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration + +warning: unexpected `cfg` condition name: `no_value` + --> $DIR/diagnotics.rs:26:7 + | +LL | #[cfg(no_value = "foo")] + | ^^^^^^^^^^^^^^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(no_value, values("foo"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration +help: there is a config with a similar name and no value + | +LL | #[cfg(no_values)] + | ~~~~~~~~~ + +warning: unexpected `cfg` condition value: `bar` + --> $DIR/diagnotics.rs:30:7 + | +LL | #[cfg(no_values = "bar")] + | ^^^^^^^^^-------- + | | + | help: remove the value + | + = note: no expected value for `no_values` + = help: to expect this configuration use `--check-cfg=cfg(no_values, values("bar"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration + +warning: 6 warnings emitted + diff --git a/tests/ui/check-cfg/diagnotics.stderr b/tests/ui/check-cfg/diagnotics.stderr deleted file mode 100644 index 31c0db03a7e..00000000000 --- a/tests/ui/check-cfg/diagnotics.stderr +++ /dev/null @@ -1,61 +0,0 @@ -warning: unexpected `cfg` condition name: `featur` - --> $DIR/diagnotics.rs:4:7 - | -LL | #[cfg(featur)] - | ^^^^^^ help: there is a config with a similar name: `feature` - | - = help: expected values for `feature` are: `foo` - = note: `#[warn(unexpected_cfgs)]` on by default - -warning: unexpected `cfg` condition name: `featur` - --> $DIR/diagnotics.rs:8:7 - | -LL | #[cfg(featur = "foo")] - | ^^^^^^^^^^^^^^ - | -help: there is a config with a similar name and value - | -LL | #[cfg(feature = "foo")] - | ~~~~~~~ - -warning: unexpected `cfg` condition name: `featur` - --> $DIR/diagnotics.rs:12:7 - | -LL | #[cfg(featur = "fo")] - | ^^^^^^^^^^^^^ - | - = help: expected values for `feature` are: `foo` -help: there is a config with a similar name and different values - | -LL | #[cfg(feature = "foo")] - | ~~~~~~~~~~~~~~~ - -warning: unexpected `cfg` condition name: `no_value` - --> $DIR/diagnotics.rs:19:7 - | -LL | #[cfg(no_value)] - | ^^^^^^^^ help: there is a config with a similar name: `no_values` - -warning: unexpected `cfg` condition name: `no_value` - --> $DIR/diagnotics.rs:23:7 - | -LL | #[cfg(no_value = "foo")] - | ^^^^^^^^^^^^^^^^ - | -help: there is a config with a similar name and no value - | -LL | #[cfg(no_values)] - | ~~~~~~~~~ - -warning: unexpected `cfg` condition value: `bar` - --> $DIR/diagnotics.rs:27:7 - | -LL | #[cfg(no_values = "bar")] - | ^^^^^^^^^-------- - | | - | help: remove the value - | - = note: no expected value for `no_values` - -warning: 6 warnings emitted - diff --git a/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr b/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr index 9501c134bac..27af8212026 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr @@ -5,6 +5,8 @@ LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ | = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = help: to expect this configuration use `--check-cfg=cfg(unknown_key, values("value"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `value` @@ -16,18 +18,26 @@ LL | #[cfg(test = "value")] | help: remove the value | = note: no expected value for `test` + = help: to expect this configuration use `--check-cfg=cfg(test, values("value"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `feature` --> $DIR/exhaustive-names-values.rs:18:7 | LL | #[cfg(feature = "unk")] | ^^^^^^^^^^^^^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(feature, values("unk"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `feature` --> $DIR/exhaustive-names-values.rs:25:7 | LL | #[cfg(feature = "std")] | ^^^^^^^^^^^^^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(feature, values("std"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: 4 warnings emitted diff --git a/tests/ui/check-cfg/exhaustive-names-values.empty_names_values.stderr b/tests/ui/check-cfg/exhaustive-names-values.empty_names_values.stderr deleted file mode 100644 index e37a222f52a..00000000000 --- a/tests/ui/check-cfg/exhaustive-names-values.empty_names_values.stderr +++ /dev/null @@ -1,33 +0,0 @@ -warning: unexpected `cfg` condition name: `unknown_key` - --> $DIR/exhaustive-names-values.rs:11:7 - | -LL | #[cfg(unknown_key = "value")] - | ^^^^^^^^^^^^^^^^^^^^^ - | - = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` - = note: `#[warn(unexpected_cfgs)]` on by default - -warning: unexpected `cfg` condition value: `value` - --> $DIR/exhaustive-names-values.rs:15:7 - | -LL | #[cfg(test = "value")] - | ^^^^---------- - | | - | help: remove the value - | - = note: no expected value for `test` - -warning: unexpected `cfg` condition name: `feature` - --> $DIR/exhaustive-names-values.rs:19:7 - | -LL | #[cfg(feature = "unk")] - | ^^^^^^^^^^^^^^^ - -warning: unexpected `cfg` condition name: `feature` - --> $DIR/exhaustive-names-values.rs:26:7 - | -LL | #[cfg(feature = "std")] - | ^^^^^^^^^^^^^^^ - -warning: 4 warnings emitted - diff --git a/tests/ui/check-cfg/exhaustive-names-values.feature.stderr b/tests/ui/check-cfg/exhaustive-names-values.feature.stderr index ea204eaff1b..a5aa80ef8e5 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.feature.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.feature.stderr @@ -5,6 +5,8 @@ LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ | = help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = help: to expect this configuration use `--check-cfg=cfg(unknown_key, values("value"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `value` @@ -16,6 +18,8 @@ LL | #[cfg(test = "value")] | help: remove the value | = note: no expected value for `test` + = help: to expect this configuration use `--check-cfg=cfg(test, values("value"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `unk` --> $DIR/exhaustive-names-values.rs:18:7 @@ -24,6 +28,8 @@ LL | #[cfg(feature = "unk")] | ^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `std` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("unk"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: 3 warnings emitted diff --git a/tests/ui/check-cfg/exhaustive-names-values.full.stderr b/tests/ui/check-cfg/exhaustive-names-values.full.stderr index ea204eaff1b..a5aa80ef8e5 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.full.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.full.stderr @@ -5,6 +5,8 @@ LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ | = help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = help: to expect this configuration use `--check-cfg=cfg(unknown_key, values("value"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `value` @@ -16,6 +18,8 @@ LL | #[cfg(test = "value")] | help: remove the value | = note: no expected value for `test` + = help: to expect this configuration use `--check-cfg=cfg(test, values("value"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `unk` --> $DIR/exhaustive-names-values.rs:18:7 @@ -24,6 +28,8 @@ LL | #[cfg(feature = "unk")] | ^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `std` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("unk"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: 3 warnings emitted diff --git a/tests/ui/check-cfg/exhaustive-names.exhaustive_names.stderr b/tests/ui/check-cfg/exhaustive-names.exhaustive_names.stderr deleted file mode 100644 index b5c8cad275f..00000000000 --- a/tests/ui/check-cfg/exhaustive-names.exhaustive_names.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: unexpected `cfg` condition name: `unknown_key` - --> $DIR/exhaustive-names.rs:8:7 - | -LL | #[cfg(unknown_key = "value")] - | ^^^^^^^^^^^^^^^^^^^^^ - | - = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` - = note: `#[warn(unexpected_cfgs)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/check-cfg/exhaustive-names.stderr b/tests/ui/check-cfg/exhaustive-names.stderr index c5f6d537c5e..cfac28cd9b9 100644 --- a/tests/ui/check-cfg/exhaustive-names.stderr +++ b/tests/ui/check-cfg/exhaustive-names.stderr @@ -5,6 +5,8 @@ LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ | = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = help: to expect this configuration use `--check-cfg=cfg(unknown_key, values("value"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/exhaustive-values.empty_cfg.stderr b/tests/ui/check-cfg/exhaustive-values.empty_cfg.stderr index 745646bda1c..0a7bd81b8aa 100644 --- a/tests/ui/check-cfg/exhaustive-values.empty_cfg.stderr +++ b/tests/ui/check-cfg/exhaustive-values.empty_cfg.stderr @@ -7,6 +7,8 @@ LL | #[cfg(test = "value")] | help: remove the value | = note: no expected value for `test` + = help: to expect this configuration use `--check-cfg=cfg(test, values("value"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/exhaustive-values.without_names.stderr b/tests/ui/check-cfg/exhaustive-values.without_names.stderr index 745646bda1c..0a7bd81b8aa 100644 --- a/tests/ui/check-cfg/exhaustive-values.without_names.stderr +++ b/tests/ui/check-cfg/exhaustive-values.without_names.stderr @@ -7,6 +7,8 @@ LL | #[cfg(test = "value")] | help: remove the value | = note: no expected value for `test` + = help: to expect this configuration use `--check-cfg=cfg(test, values("value"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/mix.cfg.stderr b/tests/ui/check-cfg/mix.cfg.stderr deleted file mode 100644 index 046d40f36b0..00000000000 --- a/tests/ui/check-cfg/mix.cfg.stderr +++ /dev/null @@ -1,184 +0,0 @@ -warning: unexpected `cfg` condition name: `widnows` - --> $DIR/mix.rs:15:7 - | -LL | #[cfg(widnows)] - | ^^^^^^^ help: there is a config with a similar name: `windows` - | - = note: `#[warn(unexpected_cfgs)]` on by default - -warning: unexpected `cfg` condition value: (none) - --> $DIR/mix.rs:19:7 - | -LL | #[cfg(feature)] - | ^^^^^^^- help: specify a config value: `= "foo"` - | - = note: expected values for `feature` are: `foo` - -warning: unexpected `cfg` condition value: `bar` - --> $DIR/mix.rs:26:7 - | -LL | #[cfg(feature = "bar")] - | ^^^^^^^^^^^^^^^ - | - = note: expected values for `feature` are: `foo` - -warning: unexpected `cfg` condition value: `zebra` - --> $DIR/mix.rs:30:7 - | -LL | #[cfg(feature = "zebra")] - | ^^^^^^^^^^^^^^^^^ - | - = note: expected values for `feature` are: `foo` - -warning: unexpected `cfg` condition name: `uu` - --> $DIR/mix.rs:34:12 - | -LL | #[cfg_attr(uu, test)] - | ^^ - | - = help: expected names are: `cfg`, `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `names_values`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` - -warning: unexpected `cfg` condition name: `widnows` - --> $DIR/mix.rs:43:10 - | -LL | cfg!(widnows); - | ^^^^^^^ help: there is a config with a similar name: `windows` - -warning: unexpected `cfg` condition value: `bar` - --> $DIR/mix.rs:46:10 - | -LL | cfg!(feature = "bar"); - | ^^^^^^^^^^^^^^^ - | - = note: expected values for `feature` are: `foo` - -warning: unexpected `cfg` condition value: `zebra` - --> $DIR/mix.rs:48:10 - | -LL | cfg!(feature = "zebra"); - | ^^^^^^^^^^^^^^^^^ - | - = note: expected values for `feature` are: `foo` - -warning: unexpected `cfg` condition name: `xxx` - --> $DIR/mix.rs:50:10 - | -LL | cfg!(xxx = "foo"); - | ^^^^^^^^^^^ - -warning: unexpected `cfg` condition name: `xxx` - --> $DIR/mix.rs:52:10 - | -LL | cfg!(xxx); - | ^^^ - -warning: unexpected `cfg` condition name: `xxx` - --> $DIR/mix.rs:54:14 - | -LL | cfg!(any(xxx, windows)); - | ^^^ - -warning: unexpected `cfg` condition value: `bad` - --> $DIR/mix.rs:56:14 - | -LL | cfg!(any(feature = "bad", windows)); - | ^^^^^^^^^^^^^^^ - | - = note: expected values for `feature` are: `foo` - -warning: unexpected `cfg` condition name: `xxx` - --> $DIR/mix.rs:58:23 - | -LL | cfg!(any(windows, xxx)); - | ^^^ - -warning: unexpected `cfg` condition name: `xxx` - --> $DIR/mix.rs:60:20 - | -LL | cfg!(all(unix, xxx)); - | ^^^ - -warning: unexpected `cfg` condition name: `aa` - --> $DIR/mix.rs:62:14 - | -LL | cfg!(all(aa, bb)); - | ^^ - -warning: unexpected `cfg` condition name: `bb` - --> $DIR/mix.rs:62:18 - | -LL | cfg!(all(aa, bb)); - | ^^ - -warning: unexpected `cfg` condition name: `aa` - --> $DIR/mix.rs:65:14 - | -LL | cfg!(any(aa, bb)); - | ^^ - -warning: unexpected `cfg` condition name: `bb` - --> $DIR/mix.rs:65:18 - | -LL | cfg!(any(aa, bb)); - | ^^ - -warning: unexpected `cfg` condition value: `zebra` - --> $DIR/mix.rs:68:20 - | -LL | cfg!(any(unix, feature = "zebra")); - | ^^^^^^^^^^^^^^^^^ - | - = note: expected values for `feature` are: `foo` - -warning: unexpected `cfg` condition name: `xxx` - --> $DIR/mix.rs:70:14 - | -LL | cfg!(any(xxx, feature = "zebra")); - | ^^^ - -warning: unexpected `cfg` condition value: `zebra` - --> $DIR/mix.rs:70:19 - | -LL | cfg!(any(xxx, feature = "zebra")); - | ^^^^^^^^^^^^^^^^^ - | - = note: expected values for `feature` are: `foo` - -warning: unexpected `cfg` condition name: `xxx` - --> $DIR/mix.rs:73:14 - | -LL | cfg!(any(xxx, unix, xxx)); - | ^^^ - -warning: unexpected `cfg` condition name: `xxx` - --> $DIR/mix.rs:73:25 - | -LL | cfg!(any(xxx, unix, xxx)); - | ^^^ - -warning: unexpected `cfg` condition value: `zebra` - --> $DIR/mix.rs:76:14 - | -LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); - | ^^^^^^^^^^^^^^^^^ - | - = note: expected values for `feature` are: `foo` - -warning: unexpected `cfg` condition value: `zebra` - --> $DIR/mix.rs:76:33 - | -LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); - | ^^^^^^^^^^^^^^^^^ - | - = note: expected values for `feature` are: `foo` - -warning: unexpected `cfg` condition value: `zebra` - --> $DIR/mix.rs:76:52 - | -LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); - | ^^^^^^^^^^^^^^^^^ - | - = note: expected values for `feature` are: `foo` - -warning: 26 warnings emitted - diff --git a/tests/ui/check-cfg/mix.stderr b/tests/ui/check-cfg/mix.stderr index 25b8f95ae2f..39660a2fd6e 100644 --- a/tests/ui/check-cfg/mix.stderr +++ b/tests/ui/check-cfg/mix.stderr @@ -4,6 +4,8 @@ warning: unexpected `cfg` condition name: `widnows` LL | #[cfg(widnows)] | ^^^^^^^ help: there is a config with a similar name: `windows` | + = help: to expect this configuration use `--check-cfg=cfg(widnows)` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: (none) @@ -13,6 +15,8 @@ LL | #[cfg(feature)] | ^^^^^^^- help: specify a config value: `= "foo"` | = note: expected values for `feature` are: `foo` + = help: to expect this configuration use `--check-cfg=cfg(feature)` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `bar` --> $DIR/mix.rs:23:7 @@ -21,6 +25,8 @@ LL | #[cfg(feature = "bar")] | ^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("bar"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` --> $DIR/mix.rs:27:7 @@ -29,6 +35,8 @@ LL | #[cfg(feature = "zebra")] | ^^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("zebra"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `uu` --> $DIR/mix.rs:31:12 @@ -37,12 +45,17 @@ LL | #[cfg_attr(uu, test)] | ^^ | = help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = help: to expect this configuration use `--check-cfg=cfg(uu)` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `widnows` --> $DIR/mix.rs:40:10 | LL | cfg!(widnows); | ^^^^^^^ help: there is a config with a similar name: `windows` + | + = help: to expect this configuration use `--check-cfg=cfg(widnows)` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `bar` --> $DIR/mix.rs:43:10 @@ -51,6 +64,8 @@ LL | cfg!(feature = "bar"); | ^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("bar"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` --> $DIR/mix.rs:45:10 @@ -59,24 +74,35 @@ LL | cfg!(feature = "zebra"); | ^^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("zebra"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` --> $DIR/mix.rs:47:10 | LL | cfg!(xxx = "foo"); | ^^^^^^^^^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(xxx, values("foo"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` --> $DIR/mix.rs:49:10 | LL | cfg!(xxx); | ^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(xxx)` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` --> $DIR/mix.rs:51:14 | LL | cfg!(any(xxx, windows)); | ^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(xxx)` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `bad` --> $DIR/mix.rs:53:14 @@ -85,42 +111,62 @@ LL | cfg!(any(feature = "bad", windows)); | ^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("bad"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` --> $DIR/mix.rs:55:23 | LL | cfg!(any(windows, xxx)); | ^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(xxx)` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` --> $DIR/mix.rs:57:20 | LL | cfg!(all(unix, xxx)); | ^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(xxx)` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `aa` --> $DIR/mix.rs:59:14 | LL | cfg!(all(aa, bb)); | ^^ + | + = help: to expect this configuration use `--check-cfg=cfg(aa)` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `bb` --> $DIR/mix.rs:59:18 | LL | cfg!(all(aa, bb)); | ^^ + | + = help: to expect this configuration use `--check-cfg=cfg(bb)` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `aa` --> $DIR/mix.rs:62:14 | LL | cfg!(any(aa, bb)); | ^^ + | + = help: to expect this configuration use `--check-cfg=cfg(aa)` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `bb` --> $DIR/mix.rs:62:18 | LL | cfg!(any(aa, bb)); | ^^ + | + = help: to expect this configuration use `--check-cfg=cfg(bb)` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` --> $DIR/mix.rs:65:20 @@ -129,12 +175,17 @@ LL | cfg!(any(unix, feature = "zebra")); | ^^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("zebra"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` --> $DIR/mix.rs:67:14 | LL | cfg!(any(xxx, feature = "zebra")); | ^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(xxx)` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` --> $DIR/mix.rs:67:19 @@ -143,18 +194,26 @@ LL | cfg!(any(xxx, feature = "zebra")); | ^^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("zebra"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` --> $DIR/mix.rs:70:14 | LL | cfg!(any(xxx, unix, xxx)); | ^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(xxx)` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` --> $DIR/mix.rs:70:25 | LL | cfg!(any(xxx, unix, xxx)); | ^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(xxx)` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` --> $DIR/mix.rs:73:14 @@ -163,6 +222,8 @@ LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); | ^^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("zebra"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` --> $DIR/mix.rs:73:33 @@ -171,6 +232,8 @@ LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); | ^^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("zebra"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` --> $DIR/mix.rs:73:52 @@ -179,6 +242,8 @@ LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); | ^^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("zebra"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: 26 warnings emitted diff --git a/tests/ui/check-cfg/no-expected-values.empty.stderr b/tests/ui/check-cfg/no-expected-values.empty.stderr index 0969d61dd40..ae55c95c0b1 100644 --- a/tests/ui/check-cfg/no-expected-values.empty.stderr +++ b/tests/ui/check-cfg/no-expected-values.empty.stderr @@ -7,6 +7,8 @@ LL | #[cfg(feature = "foo")] | help: remove the value | = note: no expected value for `feature` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("foo"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `foo` @@ -18,6 +20,8 @@ LL | #[cfg(test = "foo")] | help: remove the value | = note: no expected value for `test` + = help: to expect this configuration use `--check-cfg=cfg(test, values("foo"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: 2 warnings emitted diff --git a/tests/ui/check-cfg/no-expected-values.mixed.stderr b/tests/ui/check-cfg/no-expected-values.mixed.stderr index 0969d61dd40..ae55c95c0b1 100644 --- a/tests/ui/check-cfg/no-expected-values.mixed.stderr +++ b/tests/ui/check-cfg/no-expected-values.mixed.stderr @@ -7,6 +7,8 @@ LL | #[cfg(feature = "foo")] | help: remove the value | = note: no expected value for `feature` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("foo"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `foo` @@ -18,6 +20,8 @@ LL | #[cfg(test = "foo")] | help: remove the value | = note: no expected value for `test` + = help: to expect this configuration use `--check-cfg=cfg(test, values("foo"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: 2 warnings emitted diff --git a/tests/ui/check-cfg/no-expected-values.simple.stderr b/tests/ui/check-cfg/no-expected-values.simple.stderr index 0969d61dd40..ae55c95c0b1 100644 --- a/tests/ui/check-cfg/no-expected-values.simple.stderr +++ b/tests/ui/check-cfg/no-expected-values.simple.stderr @@ -7,6 +7,8 @@ LL | #[cfg(feature = "foo")] | help: remove the value | = note: no expected value for `feature` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("foo"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `foo` @@ -18,6 +20,8 @@ LL | #[cfg(test = "foo")] | help: remove the value | = note: no expected value for `test` + = help: to expect this configuration use `--check-cfg=cfg(test, values("foo"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: 2 warnings emitted diff --git a/tests/ui/check-cfg/order-independant.values_after.stderr b/tests/ui/check-cfg/order-independant.values_after.stderr index ed162fb5489..d1de26ba303 100644 --- a/tests/ui/check-cfg/order-independant.values_after.stderr +++ b/tests/ui/check-cfg/order-independant.values_after.stderr @@ -5,6 +5,8 @@ LL | #[cfg(a = "unk")] | ^^^^^^^^^ | = note: expected values for `a` are: (none), `b` + = help: to expect this configuration use `--check-cfg=cfg(a, values("unk"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/order-independant.values_before.stderr b/tests/ui/check-cfg/order-independant.values_before.stderr index ed162fb5489..d1de26ba303 100644 --- a/tests/ui/check-cfg/order-independant.values_before.stderr +++ b/tests/ui/check-cfg/order-independant.values_before.stderr @@ -5,6 +5,8 @@ LL | #[cfg(a = "unk")] | ^^^^^^^^^ | = note: expected values for `a` are: (none), `b` + = help: to expect this configuration use `--check-cfg=cfg(a, values("unk"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/stmt-no-ice.stderr b/tests/ui/check-cfg/stmt-no-ice.stderr index c2483fe4a06..112367606dc 100644 --- a/tests/ui/check-cfg/stmt-no-ice.stderr +++ b/tests/ui/check-cfg/stmt-no-ice.stderr @@ -5,6 +5,8 @@ LL | #[cfg(crossbeam_loom)] | ^^^^^^^^^^^^^^ | = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = help: to expect this configuration use `--check-cfg=cfg(crossbeam_loom)` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/unexpected-cfg-name.stderr b/tests/ui/check-cfg/unexpected-cfg-name.stderr index 0874ccfc461..8748b324fb6 100644 --- a/tests/ui/check-cfg/unexpected-cfg-name.stderr +++ b/tests/ui/check-cfg/unexpected-cfg-name.stderr @@ -4,6 +4,8 @@ warning: unexpected `cfg` condition name: `widnows` LL | #[cfg(widnows)] | ^^^^^^^ help: there is a config with a similar name: `windows` | + = help: to expect this configuration use `--check-cfg=cfg(widnows)` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/unexpected-cfg-value.cfg.stderr b/tests/ui/check-cfg/unexpected-cfg-value.cfg.stderr deleted file mode 100644 index 2855aa75966..00000000000 --- a/tests/ui/check-cfg/unexpected-cfg-value.cfg.stderr +++ /dev/null @@ -1,21 +0,0 @@ -warning: unexpected `cfg` condition value: `sedre` - --> $DIR/unexpected-cfg-value.rs:9:7 - | -LL | #[cfg(feature = "sedre")] - | ^^^^^^^^^^------- - | | - | help: there is a expected value with a similar name: `"serde"` - | - = note: expected values for `feature` are: `full`, `serde` - = note: `#[warn(unexpected_cfgs)]` on by default - -warning: unexpected `cfg` condition value: `rand` - --> $DIR/unexpected-cfg-value.rs:16:7 - | -LL | #[cfg(feature = "rand")] - | ^^^^^^^^^^^^^^^^ - | - = note: expected values for `feature` are: `full`, `serde` - -warning: 2 warnings emitted - diff --git a/tests/ui/check-cfg/unexpected-cfg-value.stderr b/tests/ui/check-cfg/unexpected-cfg-value.stderr index 31c473a08cb..e5435d37670 100644 --- a/tests/ui/check-cfg/unexpected-cfg-value.stderr +++ b/tests/ui/check-cfg/unexpected-cfg-value.stderr @@ -7,6 +7,8 @@ LL | #[cfg(feature = "sedre")] | help: there is a expected value with a similar name: `"serde"` | = note: expected values for `feature` are: `full`, `serde` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("sedre"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `rand` @@ -16,6 +18,8 @@ LL | #[cfg(feature = "rand")] | ^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `full`, `serde` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("rand"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: 2 warnings emitted diff --git a/tests/ui/check-cfg/well-known-names.stderr b/tests/ui/check-cfg/well-known-names.stderr index 6040663074d..763ba4646c3 100644 --- a/tests/ui/check-cfg/well-known-names.stderr +++ b/tests/ui/check-cfg/well-known-names.stderr @@ -4,6 +4,8 @@ warning: unexpected `cfg` condition name: `target_oz` LL | #[cfg(target_oz = "linux")] | ^^^^^^^^^^^^^^^^^^^ | + = help: to expect this configuration use `--check-cfg=cfg(target_oz, values("linux"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default help: there is a config with a similar name and value | @@ -17,18 +19,26 @@ LL | #[cfg(features = "foo")] | ^^^^^^^^^^^^^^^^ | = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows` + = help: to expect this configuration use `--check-cfg=cfg(features, values("foo"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `feature` --> $DIR/well-known-names.rs:17:7 | LL | #[cfg(feature = "foo")] | ^^^^^^^^^^^^^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(feature, values("foo"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `uniw` --> $DIR/well-known-names.rs:21:7 | LL | #[cfg(uniw)] | ^^^^ help: there is a config with a similar name: `unix` + | + = help: to expect this configuration use `--check-cfg=cfg(uniw)` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: 4 warnings emitted diff --git a/tests/ui/check-cfg/well-known-values.rs b/tests/ui/check-cfg/well-known-values.rs index 39a470c202f..21268bf10d5 100644 --- a/tests/ui/check-cfg/well-known-values.rs +++ b/tests/ui/check-cfg/well-known-values.rs @@ -51,7 +51,8 @@ //~^ WARN unexpected `cfg` condition value target_family = "_UNEXPECTED_VALUE", //~^ WARN unexpected `cfg` condition value - target_feature = "_UNEXPECTED_VALUE", // currently *any* values are "expected" + target_feature = "_UNEXPECTED_VALUE", + //~^ WARN unexpected `cfg` condition value target_has_atomic = "_UNEXPECTED_VALUE", //~^ WARN unexpected `cfg` condition value target_has_atomic_equal_alignment = "_UNEXPECTED_VALUE", @@ -90,6 +91,9 @@ fn target_os_linux_misspell() {} #[cfg(target_os = "linux")] fn target_os_linux() {} +#[cfg(target_feature = "crt-static")] // pure rustc feature +fn target_feature() {} + #[cfg(target_has_atomic = "8")] fn target_has_atomic_8() {} diff --git a/tests/ui/check-cfg/well-known-values.stderr b/tests/ui/check-cfg/well-known-values.stderr index a6b9c75a142..4f708e62cd3 100644 --- a/tests/ui/check-cfg/well-known-values.stderr +++ b/tests/ui/check-cfg/well-known-values.stderr @@ -7,6 +7,8 @@ LL | debug_assertions = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `debug_assertions` + = help: to expect this configuration use `--check-cfg=cfg(debug_assertions, values("_UNEXPECTED_VALUE"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` @@ -18,6 +20,8 @@ LL | doc = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `doc` + = help: to expect this configuration use `--check-cfg=cfg(doc, values("_UNEXPECTED_VALUE"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:30:5 @@ -28,6 +32,8 @@ LL | doctest = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `doctest` + = help: to expect this configuration use `--check-cfg=cfg(doctest, values("_UNEXPECTED_VALUE"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:32:5 @@ -38,6 +44,8 @@ LL | miri = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `miri` + = help: to expect this configuration use `--check-cfg=cfg(miri, values("_UNEXPECTED_VALUE"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:34:5 @@ -48,6 +56,8 @@ LL | overflow_checks = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `overflow_checks` + = help: to expect this configuration use `--check-cfg=cfg(overflow_checks, values("_UNEXPECTED_VALUE"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:36:5 @@ -56,6 +66,8 @@ LL | panic = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `panic` are: `abort`, `unwind` + = help: to expect this configuration use `--check-cfg=cfg(panic, values("_UNEXPECTED_VALUE"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:38:5 @@ -66,6 +78,8 @@ LL | proc_macro = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `proc_macro` + = help: to expect this configuration use `--check-cfg=cfg(proc_macro, values("_UNEXPECTED_VALUE"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:40:5 @@ -74,6 +88,8 @@ LL | relocation_model = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `relocation_model` are: `dynamic-no-pic`, `pic`, `pie`, `ropi`, `ropi-rwpi`, `rwpi`, `static` + = help: to expect this configuration use `--check-cfg=cfg(relocation_model, values("_UNEXPECTED_VALUE"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:42:5 @@ -82,6 +98,8 @@ LL | sanitize = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `sanitize` are: `address`, `cfi`, `hwaddress`, `kcfi`, `kernel-address`, `leak`, `memory`, `memtag`, `safestack`, `shadow-call-stack`, `thread` + = help: to expect this configuration use `--check-cfg=cfg(sanitize, values("_UNEXPECTED_VALUE"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:44:5 @@ -90,6 +108,8 @@ LL | target_abi = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_abi` are: ``, `abi64`, `abiv2`, `abiv2hf`, `eabi`, `eabihf`, `elf`, `fortanix`, `ilp32`, `llvm`, `macabi`, `sim`, `softfloat`, `spe`, `uwp`, `vec-extabi`, `x32` + = help: to expect this configuration use `--check-cfg=cfg(target_abi, values("_UNEXPECTED_VALUE"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:46:5 @@ -98,6 +118,8 @@ LL | target_arch = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_arch` are: `aarch64`, `arm`, `avr`, `bpf`, `csky`, `hexagon`, `loongarch64`, `m68k`, `mips`, `mips32r6`, `mips64`, `mips64r6`, `msp430`, `nvptx64`, `powerpc`, `powerpc64`, `riscv32`, `riscv64`, `s390x`, `sparc`, `sparc64`, `wasm32`, `wasm64`, `x86`, `x86_64` + = help: to expect this configuration use `--check-cfg=cfg(target_arch, values("_UNEXPECTED_VALUE"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:48:5 @@ -106,6 +128,8 @@ LL | target_endian = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_endian` are: `big`, `little` + = help: to expect this configuration use `--check-cfg=cfg(target_endian, values("_UNEXPECTED_VALUE"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:50:5 @@ -114,6 +138,8 @@ LL | target_env = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_env` are: ``, `eabihf`, `gnu`, `gnueabihf`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `psx`, `relibc`, `sgx`, `uclibc` + = help: to expect this configuration use `--check-cfg=cfg(target_env, values("_UNEXPECTED_VALUE"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:52:5 @@ -122,49 +148,71 @@ LL | target_family = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_family` are: `unix`, `wasm`, `windows` + = help: to expect this configuration use `--check-cfg=cfg(target_family, values("_UNEXPECTED_VALUE"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:55:5 + --> $DIR/well-known-values.rs:54:5 + | +LL | target_feature = "_UNEXPECTED_VALUE", + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512er`, `avx512f`, `avx512ifma`, `avx512pf`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, `avx512vpopcntdq`, `bf16`, `bmi1`, `bmi2`, `bti`, `bulk-memory`, `c`, `cache`, `cmpxchg16b`, `crc`, `crt-static`, `d`, `d32`, `dit`, `doloop`, `dotprod`, `dpb`, `dpb2`, `dsp`, `dsp1e2`, `dspe60`, `e`, `e1`, `e2`, `edsp`, `elrw`, `ermsb`, `exception-handling`, `f`, `f16c`, `f32mm`, `f64mm`, `fast-unaligned-access`, `fcma`, `fdivdu`, `fhm`, `flagm`, `float1e2`, `float1e3`, `float3e4`, `float7e60`, `floate1`, `fma`, `fp-armv8`, `fp16`, `fp64`, `fpuv2_df`, `fpuv2_sf`, `fpuv3_df`, `fpuv3_hf`, `fpuv3_hi`, `fpuv3_sf`, `frintts`, `fxsr`, `gfni`, `hard-float`, `hard-float-abi`, `hard-tp`, `high-registers`, `hvx`, `hvx-length128b`, `hwdiv`, `i8mm`, `jsconv`, `lasx`, `lbt`, `lor`, `lse`, `lsx`, `lvz`, `lzcnt`, `m`, `mclass`, `movbe`, `mp`, `mp1e2`, `msa`, `mte`, `multivalue`, `mutable-globals`, `neon`, `nontrapping-fptoint`, `nvic`, `paca`, `pacg`, `pan`, `pclmulqdq`, `pmuv3`, `popcnt`, `power10-vector`, `power8-altivec`, `power8-vector`, `power9-altivec`, `power9-vector`, `rand`, `ras`, `rclass`, `rcpc`, `rcpc2`, `rdm`, `rdrand`, `rdseed`, `reference-types`, `relax`, `relaxed-simd`, `rtm`, `sb`, `sha`, `sha2`, `sha3`, `sign-ext`, `simd128`, `sm4`, `spe`, `ssbs`, `sse`, `sse2`, `sse3`, `sse4.1`, `sse4.2`, `sse4a`, `ssse3`, `sve`, `sve2`, `sve2-aes`, `sve2-bitperm`, `sve2-sha3`, `sve2-sm4`, `tbm`, `thumb-mode`, `thumb2`, `tme`, `trust`, `trustzone`, `ual`, `v`, `v5te`, `v6`, `v6k`, `v6t2`, `v7`, `v8`, `v8.1a`, `v8.2a`, `v8.3a`, `v8.4a`, `v8.5a`, `v8.6a`, `v8.7a`, `vaes`, `vdsp2e60f`, `vdspv1`, `vdspv2`, `vfp2`, `vfp3`, `vfp4`, `vh`, `virt`, `virtualization`, `vpclmulqdq`, `vsx`, `xsave`, `xsavec`, `xsaveopt`, `xsaves`, `zba`, `zbb`, `zbc`, `zbkb`, `zbkc`, `zbkx`, `zbs`, `zdinx`, `zfh`, `zfhmin`, `zfinx`, `zhinx`, `zhinxmin`, `zk`, `zkn`, `zknd`, `zkne`, `zknh`, `zkr`, `zks`, `zksed`, `zksh`, `zkt` + = help: to expect this configuration use `--check-cfg=cfg(target_feature, values("_UNEXPECTED_VALUE"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration + +warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` + --> $DIR/well-known-values.rs:56:5 | LL | target_has_atomic = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_has_atomic` are: (none), `128`, `16`, `32`, `64`, `8`, `ptr` + = help: to expect this configuration use `--check-cfg=cfg(target_has_atomic, values("_UNEXPECTED_VALUE"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:57:5 + --> $DIR/well-known-values.rs:58:5 | LL | target_has_atomic_equal_alignment = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_has_atomic_equal_alignment` are: (none), `128`, `16`, `32`, `64`, `8`, `ptr` + = help: to expect this configuration use `--check-cfg=cfg(target_has_atomic_equal_alignment, values("_UNEXPECTED_VALUE"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:59:5 + --> $DIR/well-known-values.rs:60:5 | LL | target_has_atomic_load_store = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_has_atomic_load_store` are: (none), `128`, `16`, `32`, `64`, `8`, `ptr` + = help: to expect this configuration use `--check-cfg=cfg(target_has_atomic_load_store, values("_UNEXPECTED_VALUE"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:61:5 + --> $DIR/well-known-values.rs:62:5 | LL | target_os = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous` + = help: to expect this configuration use `--check-cfg=cfg(target_os, values("_UNEXPECTED_VALUE"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:63:5 + --> $DIR/well-known-values.rs:64:5 | LL | target_pointer_width = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_pointer_width` are: `16`, `32`, `64` + = help: to expect this configuration use `--check-cfg=cfg(target_pointer_width, values("_UNEXPECTED_VALUE"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:65:5 + --> $DIR/well-known-values.rs:66:5 | LL | target_thread_local = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^---------------------- @@ -172,17 +220,21 @@ LL | target_thread_local = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `target_thread_local` + = help: to expect this configuration use `--check-cfg=cfg(target_thread_local, values("_UNEXPECTED_VALUE"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:67:5 + --> $DIR/well-known-values.rs:68:5 | LL | target_vendor = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_vendor` are: `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `nintendo`, `nvidia`, `pc`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, `wrs` + = help: to expect this configuration use `--check-cfg=cfg(target_vendor, values("_UNEXPECTED_VALUE"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:69:5 + --> $DIR/well-known-values.rs:70:5 | LL | test = "_UNEXPECTED_VALUE", | ^^^^---------------------- @@ -190,9 +242,11 @@ LL | test = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `test` + = help: to expect this configuration use `--check-cfg=cfg(test, values("_UNEXPECTED_VALUE"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:71:5 + --> $DIR/well-known-values.rs:72:5 | LL | unix = "_UNEXPECTED_VALUE", | ^^^^---------------------- @@ -200,9 +254,11 @@ LL | unix = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `unix` + = help: to expect this configuration use `--check-cfg=cfg(unix, values("_UNEXPECTED_VALUE"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:73:5 + --> $DIR/well-known-values.rs:74:5 | LL | windows = "_UNEXPECTED_VALUE", | ^^^^^^^---------------------- @@ -210,9 +266,11 @@ LL | windows = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `windows` + = help: to expect this configuration use `--check-cfg=cfg(windows, values("_UNEXPECTED_VALUE"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `linuz` - --> $DIR/well-known-values.rs:79:7 + --> $DIR/well-known-values.rs:80:7 | LL | #[cfg(target_os = "linuz")] // testing that we suggest `linux` | ^^^^^^^^^^^^------- @@ -220,6 +278,8 @@ LL | #[cfg(target_os = "linuz")] // testing that we suggest `linux` | help: there is a expected value with a similar name: `"linux"` | = note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous` + = help: to expect this configuration use `--check-cfg=cfg(target_os, values("linuz"))` + = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration -warning: 25 warnings emitted +warning: 26 warnings emitted diff --git a/tests/ui/closures/2229_closure_analysis/issue-118144.rs b/tests/ui/closures/2229_closure_analysis/issue-118144.rs new file mode 100644 index 00000000000..3e5d9f9739a --- /dev/null +++ b/tests/ui/closures/2229_closure_analysis/issue-118144.rs @@ -0,0 +1,16 @@ +// Regression test for ICE #118144 + +struct V(i32); + +fn func(func_arg: &mut V) { + || { + // Declaring `x` separately instead of using + // a destructuring binding like `let V(x) = ...` + // becaue only `V(x) = ...` triggers the ICE + let x; + V(x) = func_arg; //~ ERROR: mismatched types + func_arg.0 = 0; + }; +} + +fn main() {} diff --git a/tests/ui/closures/2229_closure_analysis/issue-118144.stderr b/tests/ui/closures/2229_closure_analysis/issue-118144.stderr new file mode 100644 index 00000000000..85cb5adc07e --- /dev/null +++ b/tests/ui/closures/2229_closure_analysis/issue-118144.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/issue-118144.rs:11:9 + | +LL | V(x) = func_arg; + | ^^^^ -------- this expression has type `&mut V` + | | + | expected `&mut V`, found `V` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/closures/binder/bounds-on-closure-type-binders.rs b/tests/ui/closures/binder/bounds-on-closure-type-binders.rs new file mode 100644 index 00000000000..099047251ca --- /dev/null +++ b/tests/ui/closures/binder/bounds-on-closure-type-binders.rs @@ -0,0 +1,14 @@ +// check-fail + +#![allow(incomplete_features)] +#![feature(non_lifetime_binders)] +#![feature(closure_lifetime_binder)] + +trait Trait {} + +fn main() { + // Regression test for issue #119067 + let _ = for<T: Trait> || -> () {}; + //~^ ERROR bounds cannot be used in this context + //~| ERROR late-bound type parameter not allowed on closures +} diff --git a/tests/ui/closures/binder/bounds-on-closure-type-binders.stderr b/tests/ui/closures/binder/bounds-on-closure-type-binders.stderr new file mode 100644 index 00000000000..9cb921f6631 --- /dev/null +++ b/tests/ui/closures/binder/bounds-on-closure-type-binders.stderr @@ -0,0 +1,14 @@ +error: bounds cannot be used in this context + --> $DIR/bounds-on-closure-type-binders.rs:11:20 + | +LL | let _ = for<T: Trait> || -> () {}; + | ^^^^^ + +error: late-bound type parameter not allowed on closures + --> $DIR/bounds-on-closure-type-binders.rs:11:17 + | +LL | let _ = for<T: Trait> || -> () {}; + | ^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/closures/infer-signature-from-impl.rs b/tests/ui/closures/infer-signature-from-impl.rs index 6e8c94177bf..8b18e4ef9e7 100644 --- a/tests/ui/closures/infer-signature-from-impl.rs +++ b/tests/ui/closures/infer-signature-from-impl.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver //[next] known-bug: trait-system-refactor-initiative#71 //[current] check-pass diff --git a/tests/ui/closures/print/closure-print-generic-trim-off-verbose-2.rs b/tests/ui/closures/print/closure-print-generic-trim-off-verbose-2.rs index 07bf8fe4c00..b6c7659bc72 100644 --- a/tests/ui/closures/print/closure-print-generic-trim-off-verbose-2.rs +++ b/tests/ui/closures/print/closure-print-generic-trim-off-verbose-2.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrim-diagnostic-paths=off -Zverbose +// compile-flags: -Ztrim-diagnostic-paths=off -Zverbose-internals mod mod1 { pub fn f<T: std::fmt::Display>(t: T) diff --git a/tests/ui/closures/print/closure-print-generic-verbose-1.rs b/tests/ui/closures/print/closure-print-generic-verbose-1.rs index 67d37f1c59b..6c631fabaa2 100644 --- a/tests/ui/closures/print/closure-print-generic-verbose-1.rs +++ b/tests/ui/closures/print/closure-print-generic-verbose-1.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zverbose +// compile-flags: -Zverbose-internals fn to_fn_once<F:FnOnce()>(f: F) -> F { f } diff --git a/tests/ui/closures/print/closure-print-generic-verbose-2.rs b/tests/ui/closures/print/closure-print-generic-verbose-2.rs index f460fedffb7..dcf7fb2865c 100644 --- a/tests/ui/closures/print/closure-print-generic-verbose-2.rs +++ b/tests/ui/closures/print/closure-print-generic-verbose-2.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zverbose +// compile-flags: -Zverbose-internals mod mod1 { pub fn f<T: std::fmt::Display>(t: T) diff --git a/tests/ui/closures/print/closure-print-verbose.rs b/tests/ui/closures/print/closure-print-verbose.rs index 4b0438a91ed..76fe5471a60 100644 --- a/tests/ui/closures/print/closure-print-verbose.rs +++ b/tests/ui/closures/print/closure-print-verbose.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zverbose +// compile-flags: -Zverbose-internals // Same as closure-coerce-fn-1.rs diff --git a/tests/ui/coherence/coherence-overlap-downstream-inherent.rs b/tests/ui/coherence/coherence-overlap-downstream-inherent.rs index 2c3ef4fd3f7..94a7ecbe11f 100644 --- a/tests/ui/coherence/coherence-overlap-downstream-inherent.rs +++ b/tests/ui/coherence/coherence-overlap-downstream-inherent.rs @@ -1,5 +1,5 @@ // revisions: old next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver // Tests that we consider `T: Sugar + Fruit` to be ambiguous, even // though no impls are found. diff --git a/tests/ui/coherence/coherence-overlap-downstream.rs b/tests/ui/coherence/coherence-overlap-downstream.rs index a4e559604a0..171b2a32fc5 100644 --- a/tests/ui/coherence/coherence-overlap-downstream.rs +++ b/tests/ui/coherence/coherence-overlap-downstream.rs @@ -1,5 +1,5 @@ // revisions: old next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver // Tests that we consider `T: Sugar + Fruit` to be ambiguous, even // though no impls are found. diff --git a/tests/ui/coherence/coherence-overlap-issue-23516-inherent.rs b/tests/ui/coherence/coherence-overlap-issue-23516-inherent.rs index a7c90a6b8c8..6f5cc980491 100644 --- a/tests/ui/coherence/coherence-overlap-issue-23516-inherent.rs +++ b/tests/ui/coherence/coherence-overlap-issue-23516-inherent.rs @@ -1,5 +1,5 @@ // revisions: old next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver // Tests that we consider `Box<U>: !Sugar` to be ambiguous, even // though we see no impl of `Sugar` for `Box`. Therefore, an overlap diff --git a/tests/ui/coherence/coherence-overlap-issue-23516.rs b/tests/ui/coherence/coherence-overlap-issue-23516.rs index c846d39716b..4daaed4366f 100644 --- a/tests/ui/coherence/coherence-overlap-issue-23516.rs +++ b/tests/ui/coherence/coherence-overlap-issue-23516.rs @@ -1,5 +1,5 @@ // revisions: old next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver // Tests that we consider `Box<U>: !Sugar` to be ambiguous, even // though we see no impl of `Sugar` for `Box`. Therefore, an overlap diff --git a/tests/ui/coherence/inter-crate-ambiguity-causes-notes.rs b/tests/ui/coherence/inter-crate-ambiguity-causes-notes.rs index 743e80d3f18..0f785b4e5f6 100644 --- a/tests/ui/coherence/inter-crate-ambiguity-causes-notes.rs +++ b/tests/ui/coherence/inter-crate-ambiguity-causes-notes.rs @@ -1,5 +1,5 @@ // revisions: old next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver struct S; diff --git a/tests/ui/coherence/normalize-for-errors.rs b/tests/ui/coherence/normalize-for-errors.rs index 367d34251ae..30723518bce 100644 --- a/tests/ui/coherence/normalize-for-errors.rs +++ b/tests/ui/coherence/normalize-for-errors.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver struct MyType; trait MyTrait<S> {} diff --git a/tests/ui/coherence/occurs-check/associated-type.next.stderr b/tests/ui/coherence/occurs-check/associated-type.next.stderr index 69f541cba05..f64e8b39798 100644 --- a/tests/ui/coherence/occurs-check/associated-type.next.stderr +++ b/tests/ui/coherence/occurs-check/associated-type.next.stderr @@ -1,11 +1,11 @@ -WARN rustc_infer::infer::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) -WARN rustc_infer::infer::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!2_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) -WARN rustc_infer::infer::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) -WARN rustc_infer::infer::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!2_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) -WARN rustc_infer::infer::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) -WARN rustc_infer::infer::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!2_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) -WARN rustc_infer::infer::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) -WARN rustc_infer::infer::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!2_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) +WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) +WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!2_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) +WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) +WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!2_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) +WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) +WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!2_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) +WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) +WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!2_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) error[E0119]: conflicting implementations of trait `Overlap<for<'a> fn(&'a (), ())>` for type `for<'a> fn(&'a (), ())` --> $DIR/associated-type.rs:31:1 | diff --git a/tests/ui/coherence/occurs-check/associated-type.old.stderr b/tests/ui/coherence/occurs-check/associated-type.old.stderr index c2c951af0db..8e852ec796e 100644 --- a/tests/ui/coherence/occurs-check/associated-type.old.stderr +++ b/tests/ui/coherence/occurs-check/associated-type.old.stderr @@ -1,11 +1,11 @@ -WARN rustc_infer::infer::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) -WARN rustc_infer::infer::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!3_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) -WARN rustc_infer::infer::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) -WARN rustc_infer::infer::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!3_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) -WARN rustc_infer::infer::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) -WARN rustc_infer::infer::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!3_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) -WARN rustc_infer::infer::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) -WARN rustc_infer::infer::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!3_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) +WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) +WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!3_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) +WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) +WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!3_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) +WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) +WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!3_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) +WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) +WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!3_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }) error[E0119]: conflicting implementations of trait `Overlap<for<'a> fn(&'a (), _)>` for type `for<'a> fn(&'a (), _)` --> $DIR/associated-type.rs:31:1 | diff --git a/tests/ui/coherence/occurs-check/associated-type.rs b/tests/ui/coherence/occurs-check/associated-type.rs index 909551f65be..227b6684785 100644 --- a/tests/ui/coherence/occurs-check/associated-type.rs +++ b/tests/ui/coherence/occurs-check/associated-type.rs @@ -1,5 +1,5 @@ // revisions: old next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver // A regression test for #105787 diff --git a/tests/ui/coherence/occurs-check/opaques.rs b/tests/ui/coherence/occurs-check/opaques.rs index 9d31a3dc82d..2fa9dcebfde 100644 --- a/tests/ui/coherence/occurs-check/opaques.rs +++ b/tests/ui/coherence/occurs-check/opaques.rs @@ -1,5 +1,5 @@ //revisions: old next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver // A regression test for #105787 diff --git a/tests/ui/coinduction/canonicalization-rerun.rs b/tests/ui/coinduction/canonicalization-rerun.rs index c68895fc4e6..bbd8d802630 100644 --- a/tests/ui/coinduction/canonicalization-rerun.rs +++ b/tests/ui/coinduction/canonicalization-rerun.rs @@ -1,6 +1,6 @@ // check-pass // revisions: old next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver // If we use canonical goals during trait solving we have to reevaluate // the root goal of a cycle until we hit a fixpoint. diff --git a/tests/ui/const-generics/default-ty-closure.rs b/tests/ui/const-generics/default-ty-closure.rs new file mode 100644 index 00000000000..36128505dda --- /dev/null +++ b/tests/ui/const-generics/default-ty-closure.rs @@ -0,0 +1,6 @@ +// https://github.com/rust-lang/rust/issues/116796 + +struct X<const FN: fn() = { || {} }>; +//~^ ERROR using function pointers as const generic parameters is forbidden + +fn main() {} diff --git a/tests/ui/const-generics/default-ty-closure.stderr b/tests/ui/const-generics/default-ty-closure.stderr new file mode 100644 index 00000000000..9c737c1a19d --- /dev/null +++ b/tests/ui/const-generics/default-ty-closure.stderr @@ -0,0 +1,10 @@ +error: using function pointers as const generic parameters is forbidden + --> $DIR/default-ty-closure.rs:3:20 + | +LL | struct X<const FN: fn() = { || {} }>; + | ^^^^ + | + = note: the only supported types are integers, `bool` and `char` + +error: aborting due to 1 previous error + diff --git a/tests/ui/const-generics/defaults/default-param-wf-concrete.rs b/tests/ui/const-generics/defaults/default-param-wf-concrete.rs index 09a00dd8e70..aa3307b92e4 100644 --- a/tests/ui/const-generics/defaults/default-param-wf-concrete.rs +++ b/tests/ui/const-generics/defaults/default-param-wf-concrete.rs @@ -1,5 +1,5 @@ // revisions: old next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver struct Foo<const N: u8 = { 255 + 1 }>; //~^ ERROR evaluation of constant value failed diff --git a/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.rs b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.rs new file mode 100644 index 00000000000..6256000b491 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.rs @@ -0,0 +1,25 @@ +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +fn foo<const N: usize>( + _: [u8; { + { + N + } + }], +) { +} + +fn ice<const L: usize>() +where + [(); (L - 1) + 1 + L]:, +{ + foo::<_, L>([(); L + 1 + L]); + //~^ ERROR: mismatched types + //~^^ ERROR: unconstrained generic constant + //~^^^ ERROR: function takes 1 generic argument but 2 generic arguments were supplied + //~^^^^ ERROR: unconstrained generic constant + //~^^^^^ ERROR: unconstrained generic constant `{const expr}` +} + +fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.stderr b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.stderr new file mode 100644 index 00000000000..6001d824787 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.stderr @@ -0,0 +1,64 @@ +error[E0107]: function takes 1 generic argument but 2 generic arguments were supplied + --> $DIR/issue_114151.rs:17:5 + | +LL | foo::<_, L>([(); L + 1 + L]); + | ^^^ - help: remove this generic argument + | | + | expected 1 generic argument + | +note: function defined here, with 1 generic parameter: `N` + --> $DIR/issue_114151.rs:4:4 + | +LL | fn foo<const N: usize>( + | ^^^ -------------- + +error[E0308]: mismatched types + --> $DIR/issue_114151.rs:17:18 + | +LL | foo::<_, L>([(); L + 1 + L]); + | ^^ expected `u8`, found `()` + +error: unconstrained generic constant + --> $DIR/issue_114151.rs:17:22 + | +LL | foo::<_, L>([(); L + 1 + L]); + | ^^^^^^^^^ + | + = help: try adding a `where` bound using this expression: `where [(); L + 1 + L]:` + +error: unconstrained generic constant + --> $DIR/issue_114151.rs:17:17 + | +LL | foo::<_, L>([(); L + 1 + L]); + | ----------- ^^^^^^^^^^^^^^^ + | | + | required by a bound introduced by this call + | + = help: try adding a `where` bound using this expression: `where [(); { + { + N + } + }]:` +note: required by a bound in `foo` + --> $DIR/issue_114151.rs:5:13 + | +LL | fn foo<const N: usize>( + | --- required by a bound in this function +LL | _: [u8; { + | _____________^ +LL | | { +LL | | N +LL | | } +LL | | }], + | |_____^ required by this bound in `foo` + +error: unconstrained generic constant `{const expr}` + --> $DIR/issue_114151.rs:17:5 + | +LL | foo::<_, L>([(); L + 1 + L]); + | ^^^^^^^^^^^ + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0107, E0308. +For more information about an error, try `rustc --explain E0107`. diff --git a/tests/ui/consts/auxiliary/closure-in-foreign-crate.rs b/tests/ui/consts/auxiliary/closure-in-foreign-crate.rs index edc7fa81abb..411707133a8 100644 --- a/tests/ui/consts/auxiliary/closure-in-foreign-crate.rs +++ b/tests/ui/consts/auxiliary/closure-in-foreign-crate.rs @@ -1,5 +1,5 @@ #![crate_type = "lib"] -#![feature(const_closures, const_trait_impl)] +#![feature(const_closures, const_trait_impl, effects)] #![allow(incomplete_features)] pub const fn test() { diff --git a/tests/ui/consts/const-assert-unchecked-ub.rs b/tests/ui/consts/const-assert-unchecked-ub.rs new file mode 100644 index 00000000000..5c05b813048 --- /dev/null +++ b/tests/ui/consts/const-assert-unchecked-ub.rs @@ -0,0 +1,10 @@ +#![feature(hint_assert_unchecked)] +#![feature(const_hint_assert_unchecked)] + +const _: () = unsafe { + let n = u32::MAX.count_ones(); + std::hint::assert_unchecked(n < 32); //~ ERROR evaluation of constant value failed +}; + +fn main() { +} diff --git a/tests/ui/consts/const-assert-unchecked-ub.stderr b/tests/ui/consts/const-assert-unchecked-ub.stderr new file mode 100644 index 00000000000..3957a3b1c24 --- /dev/null +++ b/tests/ui/consts/const-assert-unchecked-ub.stderr @@ -0,0 +1,9 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/const-assert-unchecked-ub.rs:6:5 + | +LL | std::hint::assert_unchecked(n < 32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `assume` called with `false` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr b/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr index f3ec3200f94..7e764ca7239 100644 --- a/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr +++ b/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr @@ -10,12 +10,6 @@ note: erroneous constant encountered LL | &<A<T> as Foo<T>>::BAR | ^^^^^^^^^^^^^^^^^^^^^ -note: erroneous constant encountered - --> $DIR/issue-50814-2.rs:20:5 - | -LL | &<A<T> as Foo<T>>::BAR - | ^^^^^^^^^^^^^^^^^^^^^^ - error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.rs b/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.rs new file mode 100644 index 00000000000..c6960fa7259 --- /dev/null +++ b/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.rs @@ -0,0 +1,43 @@ +// Test that we can handle unsized types with an extern type tail part. +// Regression test for issue #91827. + +#![feature(extern_types)] + +use std::ptr::addr_of; + +extern "C" { + type Opaque; +} + +struct Newtype(Opaque); + +struct S { + i: i32, + j: i32, + a: Newtype, +} + +const NEWTYPE: () = unsafe { + let buf = [0i32; 4]; + let x: &Newtype = &*(&buf as *const _ as *const Newtype); + + // Projecting to the newtype works, because it is always at offset 0. + let field = &x.0; +}; + +const OFFSET: () = unsafe { + let buf = [0i32; 4]; + let x: &S = &*(&buf as *const _ as *const S); + + // Accessing sized fields is perfectly fine, even at non-zero offsets. + let field = &x.i; + let field = &x.j; + + // This needs to compute the field offset, but we don't know the type's alignment, so this + // fails. + let field = &x.a; + //~^ ERROR: evaluation of constant value failed + //~| does not have a known offset +}; + +fn main() {} diff --git a/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.stderr b/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.stderr new file mode 100644 index 00000000000..99f37fedd3d --- /dev/null +++ b/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.stderr @@ -0,0 +1,9 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/issue-91827-extern-types-field-offset.rs:38:17 + | +LL | let field = &x.a; + | ^^^^ `extern type` does not have a known offset + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/issue-91827-extern-types.rs b/tests/ui/consts/const-eval/issue-91827-extern-types.rs deleted file mode 100644 index c9aaa6e5587..00000000000 --- a/tests/ui/consts/const-eval/issue-91827-extern-types.rs +++ /dev/null @@ -1,59 +0,0 @@ -// run-pass -// -// Test that we can handle unsized types with an extern type tail part. -// Regression test for issue #91827. - -#![feature(extern_types)] - -use std::ptr::addr_of; - -extern "C" { - type Opaque; -} - -unsafe impl Sync for Opaque {} - -#[repr(C)] -pub struct List<T> { - len: usize, - data: [T; 0], - tail: Opaque, -} - -#[repr(C)] -pub struct ListImpl<T, const N: usize> { - len: usize, - data: [T; N], -} - -impl<T> List<T> { - const fn as_slice(&self) -> &[T] { - unsafe { - let ptr = addr_of!(self.tail) as *const T; - std::slice::from_raw_parts(ptr, self.len) - } - } -} - -impl<T, const N: usize> ListImpl<T, N> { - const fn as_list(&self) -> &List<T> { - unsafe { std::mem::transmute(self) } - } -} - -pub static A: ListImpl<u128, 3> = ListImpl { - len: 3, - data: [5, 6, 7], -}; -pub static A_REF: &'static List<u128> = A.as_list(); -pub static A_TAIL_OFFSET: isize = tail_offset(A.as_list()); - -const fn tail_offset<T>(list: &List<T>) -> isize { - unsafe { (addr_of!(list.tail) as *const u8).offset_from(list as *const List<T> as *const u8) } -} - -fn main() { - assert_eq!(A_REF.as_slice(), &[5, 6, 7]); - // Check that interpreter and code generation agree about the position of the tail field. - assert_eq!(A_TAIL_OFFSET, tail_offset(A_REF)); -} diff --git a/tests/ui/consts/const-float-classify.rs b/tests/ui/consts/const-float-classify.rs index 877ce02193c..e8bd095ed25 100644 --- a/tests/ui/consts/const-float-classify.rs +++ b/tests/ui/consts/const-float-classify.rs @@ -1,41 +1,24 @@ // compile-flags: -Zmir-opt-level=0 -// known-bug: #110395 -// FIXME run-pass +// run-pass #![feature(const_float_bits_conv)] #![feature(const_float_classify)] -#![feature(const_trait_impl)] +#![feature(const_trait_impl, effects)] // Don't promote const fn nop<T>(x: T) -> T { x } -// FIXME(const-hack): replace with PartialEq -#[const_trait] -trait MyEq<T> { - fn eq(self, b: T) -> bool; -} - -impl const MyEq<bool> for bool { - fn eq(self, b: bool) -> bool { - self == b - } -} - -impl const MyEq<NonDet> for bool { - fn eq(self, _: NonDet) -> bool { +impl const PartialEq<NonDet> for bool { + fn eq(&self, _: &NonDet) -> bool { true } } -const fn eq<A: ~const MyEq<B>, B>(x: A, y: B) -> bool { - x.eq(y) -} - macro_rules! const_assert { ($a:expr, $b:expr) => { { - const _: () = assert!(eq($a, $b)); - assert!(eq(nop($a), nop($b))); + const _: () = assert!($a == $b); + assert!(nop($a) == nop($b)); } }; } diff --git a/tests/ui/consts/const-float-classify.stderr b/tests/ui/consts/const-float-classify.stderr deleted file mode 100644 index f0c6c69eac4..00000000000 --- a/tests/ui/consts/const-float-classify.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0015]: cannot call non-const fn `<A as MyEq<B>>::eq` in constant functions - --> $DIR/const-float-classify.rs:31:7 - | -LL | x.eq(y) - | ^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/const-len-underflow-separate-spans.rs b/tests/ui/consts/const-len-underflow-separate-spans.rs index 55704b64154..bd37be21576 100644 --- a/tests/ui/consts/const-len-underflow-separate-spans.rs +++ b/tests/ui/consts/const-len-underflow-separate-spans.rs @@ -3,7 +3,7 @@ // overall context for what caused the evaluation. // revisions: old next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver const ONE: usize = 1; const TWO: usize = 2; diff --git a/tests/ui/consts/const-try.stderr b/tests/ui/consts/const-try.stderr index 94f4153a29e..37a6598af9e 100644 --- a/tests/ui/consts/const-try.stderr +++ b/tests/ui/consts/const-try.stderr @@ -10,6 +10,7 @@ note: impl defined here, but it is not `const` LL | impl const Try for TryMe { | ^^^^^^^^^^^^^^^^^^^^^^^^ = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = help: add `#![feature(effects)]` to the crate attributes to enable error[E0015]: `?` cannot convert from residual of `TryMe` in constant functions --> $DIR/const-try.rs:33:5 @@ -23,6 +24,7 @@ note: impl defined here, but it is not `const` LL | impl const FromResidual<Error> for TryMe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = help: add `#![feature(effects)]` to the crate attributes to enable error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const_cmp_type_id.rs b/tests/ui/consts/const_cmp_type_id.rs index 19cee2022ac..cda811144c7 100644 --- a/tests/ui/consts/const_cmp_type_id.rs +++ b/tests/ui/consts/const_cmp_type_id.rs @@ -1,6 +1,6 @@ // known-bug: #110395 #![feature(const_type_id)] -#![feature(const_trait_impl)] +#![feature(const_trait_impl, effects)] use std::any::TypeId; diff --git a/tests/ui/consts/const_cmp_type_id.stderr b/tests/ui/consts/const_cmp_type_id.stderr index 0d915cec07d..84be0b67307 100644 --- a/tests/ui/consts/const_cmp_type_id.stderr +++ b/tests/ui/consts/const_cmp_type_id.stderr @@ -1,34 +1,28 @@ -error[E0015]: cannot call non-const operator in constant functions +error[E0131]: `main` function is not allowed to have generic parameters + --> $DIR/const_cmp_type_id.rs:7:14 + | +LL | const fn main() { + | ^ `main` cannot have generic parameters + +error[E0308]: mismatched types --> $DIR/const_cmp_type_id.rs:8:13 | LL | assert!(TypeId::of::<u8>() == TypeId::of::<u8>()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `host`, found `true` | -note: impl defined here, but it is not `const` - --> $SRC_DIR/core/src/any.rs:LL:COL - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = note: expected constant `host` + found constant `true` -error[E0015]: cannot call non-const operator in constant functions +error[E0308]: mismatched types --> $DIR/const_cmp_type_id.rs:9:13 | LL | assert!(TypeId::of::<()>() != TypeId::of::<u8>()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: impl defined here, but it is not `const` - --> $SRC_DIR/core/src/any.rs:LL:COL - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error[E0015]: cannot call non-const operator in constants - --> $DIR/const_cmp_type_id.rs:10:22 - | -LL | const _A: bool = TypeId::of::<u8>() < TypeId::of::<u16>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `host`, found `true` | -note: impl defined here, but it is not `const` - --> $SRC_DIR/core/src/any.rs:LL:COL - = note: calls in constants are limited to constant functions, tuple structs and tuple variants - = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: expected constant `host` + found constant `true` error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0015`. +Some errors have detailed explanations: E0131, E0308. +For more information about an error, try `rustc --explain E0131`. diff --git a/tests/ui/consts/const_in_pattern/null-raw-ptr-issue-119270.rs b/tests/ui/consts/const_in_pattern/null-raw-ptr-issue-119270.rs new file mode 100644 index 00000000000..03e91f2b3b1 --- /dev/null +++ b/tests/ui/consts/const_in_pattern/null-raw-ptr-issue-119270.rs @@ -0,0 +1,19 @@ +// run-pass +// Eventually this will be rejected (when the future-compat lints are turned into hard errors), and +// then this test can be removed. But meanwhile we should ensure that this works and does not ICE. +struct NoDerive(i32); + +#[derive(PartialEq)] +struct WrapEmbedded(*const NoDerive); + +const WRAP_UNSAFE_EMBEDDED: &&WrapEmbedded = &&WrapEmbedded(std::ptr::null()); + +fn main() { + let b = match WRAP_UNSAFE_EMBEDDED { + WRAP_UNSAFE_EMBEDDED => true, + //~^ WARN: must be annotated with `#[derive(PartialEq, Eq)]` + //~| previously accepted + _ => false, + }; + assert!(b); +} diff --git a/tests/ui/consts/const_in_pattern/null-raw-ptr-issue-119270.stderr b/tests/ui/consts/const_in_pattern/null-raw-ptr-issue-119270.stderr new file mode 100644 index 00000000000..c186d349e72 --- /dev/null +++ b/tests/ui/consts/const_in_pattern/null-raw-ptr-issue-119270.stderr @@ -0,0 +1,14 @@ +warning: to use a constant of type `WrapEmbedded` in a pattern, `WrapEmbedded` must be annotated with `#[derive(PartialEq, Eq)]` + --> $DIR/null-raw-ptr-issue-119270.rs:13:9 + | +LL | WRAP_UNSAFE_EMBEDDED => true, + | ^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411> + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details + = note: `#[warn(indirect_structural_match)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/consts/constifconst-call-in-const-position.stderr b/tests/ui/consts/constifconst-call-in-const-position.stderr index 6eee466611c..42ad4125824 100644 --- a/tests/ui/consts/constifconst-call-in-const-position.stderr +++ b/tests/ui/consts/constifconst-call-in-const-position.stderr @@ -14,6 +14,7 @@ LL | [0; T::a()] | ^^^^^^ | = note: calls in constants are limited to constant functions, tuple structs and tuple variants + = help: add `#![feature(effects)]` to the crate attributes to enable error[E0015]: cannot call non-const fn `<T as Tr>::a` in constants --> $DIR/constifconst-call-in-const-position.rs:16:38 @@ -22,6 +23,7 @@ LL | const fn foo<T: ~const Tr>() -> [u8; T::a()] { | ^^^^^^ | = note: calls in constants are limited to constant functions, tuple structs and tuple variants + = help: add `#![feature(effects)]` to the crate attributes to enable error: aborting due to 2 previous errors; 1 warning emitted diff --git a/tests/ui/consts/fn_trait_refs.stderr b/tests/ui/consts/fn_trait_refs.stderr index e5ebe1d8528..e6ea4108f40 100644 --- a/tests/ui/consts/fn_trait_refs.stderr +++ b/tests/ui/consts/fn_trait_refs.stderr @@ -4,13 +4,13 @@ error[E0635]: unknown feature `const_fn_trait_ref_impls` LL | #![feature(const_fn_trait_ref_impls)] | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: ~const can only be applied to `#[const_trait]` traits +error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:15:15 | LL | T: ~const Fn<()> + ~const Destruct, | ^^^^^^ -error: ~const can only be applied to `#[const_trait]` traits +error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:15:15 | LL | T: ~const Fn<()> + ~const Destruct, @@ -18,13 +18,13 @@ LL | T: ~const Fn<()> + ~const Destruct, | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: ~const can only be applied to `#[const_trait]` traits +error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:22:15 | LL | T: ~const FnMut<()> + ~const Destruct, | ^^^^^^^^^ -error: ~const can only be applied to `#[const_trait]` traits +error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:22:15 | LL | T: ~const FnMut<()> + ~const Destruct, @@ -32,13 +32,13 @@ LL | T: ~const FnMut<()> + ~const Destruct, | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: ~const can only be applied to `#[const_trait]` traits +error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:29:15 | LL | T: ~const FnOnce<()>, | ^^^^^^^^^^ -error: ~const can only be applied to `#[const_trait]` traits +error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:29:15 | LL | T: ~const FnOnce<()>, @@ -46,13 +46,13 @@ LL | T: ~const FnOnce<()>, | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: ~const can only be applied to `#[const_trait]` traits +error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:36:15 | LL | T: ~const Fn<()> + ~const Destruct, | ^^^^^^ -error: ~const can only be applied to `#[const_trait]` traits +error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:36:15 | LL | T: ~const Fn<()> + ~const Destruct, @@ -60,13 +60,13 @@ LL | T: ~const Fn<()> + ~const Destruct, | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: ~const can only be applied to `#[const_trait]` traits +error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:50:15 | LL | T: ~const FnMut<()> + ~const Destruct, | ^^^^^^^^^ -error: ~const can only be applied to `#[const_trait]` traits +error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:50:15 | LL | T: ~const FnMut<()> + ~const Destruct, diff --git a/tests/ui/consts/issue-73976-monomorphic.stderr b/tests/ui/consts/issue-73976-monomorphic.stderr index ef754b23ff0..465efc7bfc2 100644 --- a/tests/ui/consts/issue-73976-monomorphic.stderr +++ b/tests/ui/consts/issue-73976-monomorphic.stderr @@ -7,6 +7,7 @@ LL | GetTypeId::<T>::VALUE == GetTypeId::<usize>::VALUE note: impl defined here, but it is not `const` --> $SRC_DIR/core/src/any.rs:LL:COL = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = help: add `#![feature(effects)]` to the crate attributes to enable error: aborting due to 1 previous error diff --git a/tests/ui/consts/issue-90878-2.rs b/tests/ui/consts/issue-90878-2.rs index e5bcecce6ee..0e61c65305f 100644 --- a/tests/ui/consts/issue-90878-2.rs +++ b/tests/ui/consts/issue-90878-2.rs @@ -1,4 +1,4 @@ - #![l=|x|[b;x ]] //~ ERROR unexpected expression: `|x| [b; x]` + #![l=|x|[b;x ]] //~ ERROR attribute value must be a literal //~^ ERROR cannot find attribute `l` in this scope // notice the space at the start, diff --git a/tests/ui/consts/issue-90878-2.stderr b/tests/ui/consts/issue-90878-2.stderr index 71b8d21fb4d..0b332840042 100644 --- a/tests/ui/consts/issue-90878-2.stderr +++ b/tests/ui/consts/issue-90878-2.stderr @@ -1,4 +1,4 @@ -error: unexpected expression: `|x| [b; x]` +error: attribute value must be a literal --> $DIR/issue-90878-2.rs:1:7 | LL | #![l=|x|[b;x ]] diff --git a/tests/ui/consts/issue-94675.stderr b/tests/ui/consts/issue-94675.stderr index f51f305ac38..60a56f85c11 100644 --- a/tests/ui/consts/issue-94675.stderr +++ b/tests/ui/consts/issue-94675.stderr @@ -15,6 +15,7 @@ LL | self.bar[0] = baz.len(); note: impl defined here, but it is not `const` --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = help: add `#![feature(effects)]` to the crate attributes to enable error: aborting due to 2 previous errors diff --git a/tests/ui/consts/unstable-const-fn-in-libcore.stderr b/tests/ui/consts/unstable-const-fn-in-libcore.stderr index 4b649bf43ed..08147a4afaf 100644 --- a/tests/ui/consts/unstable-const-fn-in-libcore.stderr +++ b/tests/ui/consts/unstable-const-fn-in-libcore.stderr @@ -1,4 +1,4 @@ -error: ~const can only be applied to `#[const_trait]` traits +error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/unstable-const-fn-in-libcore.rs:19:39 | LL | const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T { diff --git a/tests/ui/coroutine/async-gen-deduce-yield.rs b/tests/ui/coroutine/async-gen-deduce-yield.rs new file mode 100644 index 00000000000..9ccc8ee41f6 --- /dev/null +++ b/tests/ui/coroutine/async-gen-deduce-yield.rs @@ -0,0 +1,14 @@ +// compile-flags: --edition 2024 -Zunstable-options +// check-pass + +#![feature(async_iterator, gen_blocks)] + +use std::async_iter::AsyncIterator; + +fn deduce() -> impl AsyncIterator<Item = ()> { + async gen { + yield Default::default(); + } +} + +fn main() {} diff --git a/tests/ui/coroutine/async-gen-yield-ty-is-unit.rs b/tests/ui/coroutine/async-gen-yield-ty-is-unit.rs new file mode 100644 index 00000000000..aac74d3eacb --- /dev/null +++ b/tests/ui/coroutine/async-gen-yield-ty-is-unit.rs @@ -0,0 +1,17 @@ +// compile-flags: --edition 2024 -Zunstable-options +// check-pass + +#![feature(async_iterator, gen_blocks, noop_waker)] + +use std::{async_iter::AsyncIterator, pin::pin, task::{Context, Waker}}; + +async gen fn gen_fn() -> &'static str { + yield "hello" +} + +pub fn main() { + let async_iterator = pin!(gen_fn()); + let waker = Waker::noop(); + let ctx = &mut Context::from_waker(&waker); + async_iterator.poll_next(ctx); +} diff --git a/tests/ui/coroutine/async_gen_fn_iter.rs b/tests/ui/coroutine/async_gen_fn_iter.rs index 4fa29e1095a..ec6464d0048 100644 --- a/tests/ui/coroutine/async_gen_fn_iter.rs +++ b/tests/ui/coroutine/async_gen_fn_iter.rs @@ -3,6 +3,7 @@ // run-pass #![feature(gen_blocks, async_iterator)] +#![feature(noop_waker)] // make sure that a ridiculously simple async gen fn works as an iterator. @@ -42,7 +43,7 @@ async fn async_main() { // ------------------------------------------------------------------------- // // Implementation Details Below... -use std::pin::Pin; +use std::pin::{Pin, pin}; use std::task::*; use std::async_iter::AsyncIterator; use std::future::Future; @@ -69,30 +70,15 @@ impl<'s, S: AsyncIterator> Future for Next<'s, S> where S: Unpin { } } -pub fn noop_waker() -> Waker { - let raw = RawWaker::new(std::ptr::null(), &NOOP_WAKER_VTABLE); - - // SAFETY: the contracts for RawWaker and RawWakerVTable are upheld - unsafe { Waker::from_raw(raw) } -} - -const NOOP_WAKER_VTABLE: RawWakerVTable = RawWakerVTable::new(noop_clone, noop, noop, noop); - -unsafe fn noop_clone(_p: *const ()) -> RawWaker { - RawWaker::new(std::ptr::null(), &NOOP_WAKER_VTABLE) -} - -unsafe fn noop(_p: *const ()) {} - fn main() { - let mut fut = async_main(); + let mut fut = pin!(async_main()); // Poll loop, just to test the future... - let waker = noop_waker(); + let waker = Waker::noop(); let ctx = &mut Context::from_waker(&waker); loop { - match unsafe { Pin::new_unchecked(&mut fut).poll(ctx) } { + match fut.as_mut().poll(ctx) { Poll::Pending => {} Poll::Ready(()) => break, } diff --git a/tests/ui/coroutine/clone-rpit.rs b/tests/ui/coroutine/clone-rpit.rs index e0061e1c6bb..cbd28f88fcb 100644 --- a/tests/ui/coroutine/clone-rpit.rs +++ b/tests/ui/coroutine/clone-rpit.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver // check-pass #![feature(coroutines, coroutine_trait, coroutine_clone)] diff --git a/tests/ui/coroutine/gen_block_is_iter.rs b/tests/ui/coroutine/gen_block_is_iter.rs index 92625cf7c28..d43eef4a18d 100644 --- a/tests/ui/coroutine/gen_block_is_iter.rs +++ b/tests/ui/coroutine/gen_block_is_iter.rs @@ -1,6 +1,6 @@ // revisions: next old //compile-flags: --edition 2024 -Zunstable-options -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver // check-pass #![feature(gen_blocks)] diff --git a/tests/ui/coroutine/gen_block_iterate.rs b/tests/ui/coroutine/gen_block_iterate.rs index 18e1bb88772..8e72b00d99d 100644 --- a/tests/ui/coroutine/gen_block_iterate.rs +++ b/tests/ui/coroutine/gen_block_iterate.rs @@ -1,6 +1,6 @@ // revisions: next old //compile-flags: --edition 2024 -Zunstable-options -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver // run-pass #![feature(gen_blocks)] diff --git a/tests/ui/coroutine/non-static-is-unpin.rs b/tests/ui/coroutine/non-static-is-unpin.rs index d77fe659f08..238e49bbfdf 100644 --- a/tests/ui/coroutine/non-static-is-unpin.rs +++ b/tests/ui/coroutine/non-static-is-unpin.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver // run-pass #![feature(coroutines, coroutine_trait)] diff --git a/tests/ui/coroutine/print/coroutine-print-verbose-1.rs b/tests/ui/coroutine/print/coroutine-print-verbose-1.rs index c47d7572ca7..f0094aa694b 100644 --- a/tests/ui/coroutine/print/coroutine-print-verbose-1.rs +++ b/tests/ui/coroutine/print/coroutine-print-verbose-1.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zverbose +// compile-flags: -Zverbose-internals // Same as: tests/ui/coroutine/issue-68112.stderr diff --git a/tests/ui/coroutine/print/coroutine-print-verbose-2.rs b/tests/ui/coroutine/print/coroutine-print-verbose-2.rs index c65c33cb4ba..390bfc542b7 100644 --- a/tests/ui/coroutine/print/coroutine-print-verbose-2.rs +++ b/tests/ui/coroutine/print/coroutine-print-verbose-2.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zverbose +// compile-flags: -Zverbose-internals // Same as test/ui/coroutine/not-send-sync.rs #![feature(coroutines)] diff --git a/tests/ui/coroutine/print/coroutine-print-verbose-3.rs b/tests/ui/coroutine/print/coroutine-print-verbose-3.rs index 3e4bb628176..49b54a4cd5b 100644 --- a/tests/ui/coroutine/print/coroutine-print-verbose-3.rs +++ b/tests/ui/coroutine/print/coroutine-print-verbose-3.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zverbose +// compile-flags: -Zverbose-internals #![feature(coroutines, coroutine_trait)] diff --git a/tests/ui/coroutine/return-types-diverge.rs b/tests/ui/coroutine/return-types-diverge.rs new file mode 100644 index 00000000000..5f21c8cbf34 --- /dev/null +++ b/tests/ui/coroutine/return-types-diverge.rs @@ -0,0 +1,20 @@ +// compile-flags: --edition 2024 -Zunstable-options +// check-pass + +#![feature(gen_blocks)] + +fn diverge() -> ! { loop {} } + +async gen fn async_gen_fn() -> i32 { diverge() } + +gen fn gen_fn() -> i32 { diverge() } + +fn async_gen_block() { + async gen { yield (); diverge() }; +} + +fn gen_block() { + gen { yield (); diverge() }; +} + +fn main() {} diff --git a/tests/ui/coroutine/return-types.rs b/tests/ui/coroutine/return-types.rs new file mode 100644 index 00000000000..3543d6293f7 --- /dev/null +++ b/tests/ui/coroutine/return-types.rs @@ -0,0 +1,21 @@ +// compile-flags: --edition 2024 -Zunstable-options + +#![feature(gen_blocks)] + +async gen fn async_gen_fn() -> i32 { 0 } +//~^ ERROR mismatched types + +gen fn gen_fn() -> i32 { 0 } +//~^ ERROR mismatched types + +fn async_gen_block() { + async gen { yield (); 1 }; + //~^ ERROR mismatched types +} + +fn gen_block() { + gen { yield (); 1 }; + //~^ ERROR mismatched types +} + +fn main() {} diff --git a/tests/ui/coroutine/return-types.stderr b/tests/ui/coroutine/return-types.stderr new file mode 100644 index 00000000000..7be96e538d9 --- /dev/null +++ b/tests/ui/coroutine/return-types.stderr @@ -0,0 +1,31 @@ +error[E0308]: mismatched types + --> $DIR/return-types.rs:5:38 + | +LL | async gen fn async_gen_fn() -> i32 { 0 } + | --- ^ expected `()`, found integer + | | + | expected `()` because of return type + +error[E0308]: mismatched types + --> $DIR/return-types.rs:8:26 + | +LL | gen fn gen_fn() -> i32 { 0 } + | --- ^ expected `()`, found integer + | | + | expected `()` because of return type + +error[E0308]: mismatched types + --> $DIR/return-types.rs:12:27 + | +LL | async gen { yield (); 1 }; + | ^ expected `()`, found integer + +error[E0308]: mismatched types + --> $DIR/return-types.rs:17:21 + | +LL | gen { yield (); 1 }; + | ^ expected `()`, found integer + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/coroutine/static-not-unpin.rs b/tests/ui/coroutine/static-not-unpin.rs index 6ce78046dcc..f27183d11db 100644 --- a/tests/ui/coroutine/static-not-unpin.rs +++ b/tests/ui/coroutine/static-not-unpin.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver #![feature(coroutines)] diff --git a/tests/ui/coroutine/uninhabited-field.rs b/tests/ui/coroutine/uninhabited-field.rs new file mode 100644 index 00000000000..d9570c2fed8 --- /dev/null +++ b/tests/ui/coroutine/uninhabited-field.rs @@ -0,0 +1,37 @@ +// Test that uninhabited saved local doesn't make the entire variant uninhabited. +// run-pass +#![allow(unused)] +#![feature(assert_matches)] +#![feature(coroutine_trait)] +#![feature(coroutines)] +#![feature(never_type)] +use std::assert_matches::assert_matches; +use std::ops::Coroutine; +use std::ops::CoroutineState; +use std::pin::Pin; + +fn conjure<T>() -> T { loop {} } + +fn run<T>(x: bool, y: bool) { + let mut c = || { + if x { + let a : T; + if y { + a = conjure::<T>(); + } + yield (); + } else { + let a : T; + if y { + a = conjure::<T>(); + } + yield (); + } + }; + assert_matches!(Pin::new(&mut c).resume(()), CoroutineState::Yielded(())); + assert_matches!(Pin::new(&mut c).resume(()), CoroutineState::Complete(())); +} + +fn main() { + run::<!>(false, false); +} diff --git a/tests/ui/destructuring-assignment/bad-expr-lhs.rs b/tests/ui/destructuring-assignment/bad-expr-lhs.rs index 53794783a3c..90e1ac19943 100644 --- a/tests/ui/destructuring-assignment/bad-expr-lhs.rs +++ b/tests/ui/destructuring-assignment/bad-expr-lhs.rs @@ -4,6 +4,4 @@ fn main() { (1, 2) = (3, 4); //~^ ERROR invalid left-hand side of assignment //~| ERROR invalid left-hand side of assignment - - None = Some(3); //~ ERROR invalid left-hand side of assignment } diff --git a/tests/ui/destructuring-assignment/bad-expr-lhs.stderr b/tests/ui/destructuring-assignment/bad-expr-lhs.stderr index d2986747480..2916d6d9f11 100644 --- a/tests/ui/destructuring-assignment/bad-expr-lhs.stderr +++ b/tests/ui/destructuring-assignment/bad-expr-lhs.stderr @@ -30,15 +30,7 @@ LL | (1, 2) = (3, 4); | | | cannot assign to this expression -error[E0070]: invalid left-hand side of assignment - --> $DIR/bad-expr-lhs.rs:8:10 - | -LL | None = Some(3); - | ---- ^ - | | - | cannot assign to this expression - -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0067, E0070. For more information about an error, try `rustc --explain E0067`. diff --git a/tests/ui/destructuring-assignment/non-exhaustive-destructure.rs b/tests/ui/destructuring-assignment/non-exhaustive-destructure.rs new file mode 100644 index 00000000000..39939f2bad6 --- /dev/null +++ b/tests/ui/destructuring-assignment/non-exhaustive-destructure.rs @@ -0,0 +1,4 @@ +fn main() { + None = Some(3); + //~^ ERROR refutable pattern in local binding +} diff --git a/tests/ui/destructuring-assignment/non-exhaustive-destructure.stderr b/tests/ui/destructuring-assignment/non-exhaustive-destructure.stderr new file mode 100644 index 00000000000..b9ceaa4af7b --- /dev/null +++ b/tests/ui/destructuring-assignment/non-exhaustive-destructure.stderr @@ -0,0 +1,17 @@ +error[E0005]: refutable pattern in local binding + --> $DIR/non-exhaustive-destructure.rs:2:5 + | +LL | None = Some(3); + | ^^^^ pattern `Some(_)` not covered + | + = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant + = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html + = note: the matched value is of type `Option<i32>` +help: you might want to use `if let` to ignore the variant that isn't matched + | +LL | if None = Some(3) { todo!() }; + | ++ +++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0005`. diff --git a/tests/ui/destructuring-assignment/struct-or-enum-variant-path.rs b/tests/ui/destructuring-assignment/struct-or-enum-variant-path.rs index 8da7f90c524..f82e029983b 100644 --- a/tests/ui/destructuring-assignment/struct-or-enum-variant-path.rs +++ b/tests/ui/destructuring-assignment/struct-or-enum-variant-path.rs @@ -11,17 +11,22 @@ type A = E; fn main() { let mut a; + S = S; (S, a) = (S, ()); + E::V = E::V; (E::V, a) = (E::V, ()); + <E>::V = E::V; (<E>::V, a) = (E::V, ()); + A::V = A::V; (A::V, a) = (E::V, ()); } impl S { fn check() { let a; + Self = S; (Self, a) = (S, ()); } } @@ -29,6 +34,7 @@ impl S { impl E { fn check() { let a; + Self::V = E::V; (Self::V, a) = (E::V, ()); } } diff --git a/tests/ui/diagnostic-width/long-E0308.stderr b/tests/ui/diagnostic-width/long-E0308.stderr index 20b018b9f77..1e5966a1c5d 100644 --- a/tests/ui/diagnostic-width/long-E0308.stderr +++ b/tests/ui/diagnostic-width/long-E0308.stderr @@ -19,9 +19,8 @@ LL | | )))))))))))))))))))))))))))))); | |__________________________________^ expected `Atype<Btype<..., ...>, ...>`, found `Result<Result<..., ...>, ...>` | = note: expected struct `Atype<Btype<..., ...>, ...>` - the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt' found enum `Result<Result<..., ...>, ...>` - the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt' + = note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt' error[E0308]: mismatched types --> $DIR/long-E0308.rs:57:26 @@ -35,9 +34,8 @@ LL | | )))))))))))))))))))))))); | |____________________________^ expected `Option<Result<..., ...>>`, found `Result<Result<..., ...>, ...>` | = note: expected enum `Option<Result<..., ...>>` - the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt' found enum `Result<Result<..., ...>, ...>` - the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt' + = note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt' error[E0308]: mismatched types --> $DIR/long-E0308.rs:88:9 @@ -55,8 +53,8 @@ LL | | > = (); | expected due to this | = note: expected struct `Atype<Btype<..., ...>, ...>` - the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt' found unit type `()` + = note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt' error[E0308]: mismatched types --> $DIR/long-E0308.rs:91:17 @@ -73,7 +71,7 @@ LL | | )))))))))))))))))))))))); | = note: expected unit type `()` found enum `Result<Result<..., ...>, ...>` - the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt' + = note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt' error: aborting due to 4 previous errors diff --git a/tests/ui/drop/dynamic-drop.rs b/tests/ui/drop/dynamic-drop.rs index 5bf2cc30e7f..d35913ed641 100644 --- a/tests/ui/drop/dynamic-drop.rs +++ b/tests/ui/drop/dynamic-drop.rs @@ -343,6 +343,17 @@ fn if_let_guard(a: &Allocator, c: bool, d: i32) { } } +fn if_let_guard_2(a: &Allocator, num: i32) { + let d = a.alloc(); + match num { + #[allow(irrefutable_let_patterns)] + 1 | 2 if let Ptr(ref _idx, _) = a.alloc() => { + a.alloc(); + } + _ => {} + } +} + fn panic_after_return(a: &Allocator) -> Ptr<'_> { // Panic in the drop of `p` or `q` can leak let exceptions = vec![8, 9]; @@ -514,6 +525,9 @@ fn main() { run_test(|a| if_let_guard(a, false, 0)); run_test(|a| if_let_guard(a, false, 1)); run_test(|a| if_let_guard(a, false, 2)); + run_test(|a| if_let_guard_2(a, 0)); + run_test(|a| if_let_guard_2(a, 1)); + run_test(|a| if_let_guard_2(a, 2)); run_test(|a| { panic_after_return(a); diff --git a/tests/ui/dst/issue-113447.fixed b/tests/ui/dst/issue-113447.fixed deleted file mode 100644 index 536f680f697..00000000000 --- a/tests/ui/dst/issue-113447.fixed +++ /dev/null @@ -1,25 +0,0 @@ -// run-rustfix - -pub struct Bytes; - -impl Bytes { - pub fn as_slice(&self) -> &[u8] { - todo!() - } -} - -impl PartialEq<[u8]> for Bytes { - fn eq(&self, other: &[u8]) -> bool { - self.as_slice() == other - } -} - -impl PartialEq<Bytes> for &[u8] { - fn eq(&self, other: &Bytes) -> bool { - *other == **self - } -} - -fn main() { - let _ = &[0u8] == &[0xAA][..]; //~ ERROR can't compare `&[u8; 1]` with `[{integer}; 1]` -} diff --git a/tests/ui/dst/issue-113447.rs b/tests/ui/dst/issue-113447.rs index c10a4f2ff8e..75156a117e9 100644 --- a/tests/ui/dst/issue-113447.rs +++ b/tests/ui/dst/issue-113447.rs @@ -1,5 +1,3 @@ -// run-rustfix - pub struct Bytes; impl Bytes { diff --git a/tests/ui/dst/issue-113447.stderr b/tests/ui/dst/issue-113447.stderr index 266eb228046..4d0ed33a643 100644 --- a/tests/ui/dst/issue-113447.stderr +++ b/tests/ui/dst/issue-113447.stderr @@ -1,24 +1,15 @@ error[E0277]: can't compare `&[u8; 1]` with `[{integer}; 1]` - --> $DIR/issue-113447.rs:24:20 + --> $DIR/issue-113447.rs:22:20 | LL | let _ = &[0u8] == [0xAA]; | ^^ no implementation for `&[u8; 1] == [{integer}; 1]` | = help: the trait `PartialEq<[{integer}; 1]>` is not implemented for `&[u8; 1]` - = help: the following other types implement trait `PartialEq<Rhs>`: - <[A; N] as PartialEq<[B; N]>> - <[A; N] as PartialEq<[B]>> - <[A; N] as PartialEq<&[B]>> - <[A; N] as PartialEq<&mut [B]>> - <[T] as PartialEq<Vec<U, A>>> - <[A] as PartialEq<[B]>> - <[B] as PartialEq<[A; N]>> - <&[u8] as PartialEq<Bytes>> - and 4 others -help: convert the array to a `&[u8]` slice instead +help: consider removing the borrow + | +LL - let _ = &[0u8] == [0xAA]; +LL + let _ = [0u8] == [0xAA]; | -LL | let _ = &[0u8] == &[0xAA][..]; - | + ++++ error: aborting due to 1 previous error diff --git a/tests/ui/duplicate_entry_error.stderr b/tests/ui/duplicate_entry_error.stderr index 592640a884c..3b5998df353 100644 --- a/tests/ui/duplicate_entry_error.stderr +++ b/tests/ui/duplicate_entry_error.stderr @@ -1,8 +1,11 @@ error[E0152]: found duplicate lang item `panic_impl` --> $DIR/duplicate_entry_error.rs:11:1 | -LL | fn panic_impl(info: &PanicInfo) -> ! { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | / fn panic_impl(info: &PanicInfo) -> ! { +LL | | +LL | | loop {} +LL | | } + | |_^ | = note: the lang item is first defined in crate `std` (which `duplicate_entry_error` depends on) = note: first definition in `std` loaded from SYSROOT/libstd-*.rlib diff --git a/tests/ui/dyn-star/box.rs b/tests/ui/dyn-star/box.rs index 87c8356a174..8b2f46bd1b2 100644 --- a/tests/ui/dyn-star/box.rs +++ b/tests/ui/dyn-star/box.rs @@ -1,7 +1,7 @@ // run-pass // revisions: current next //[current] compile-flags: -C opt-level=0 -//[next] compile-flags: -Ztrait-solver=next -C opt-level=0 +//[next] compile-flags: -Znext-solver -C opt-level=0 #![feature(dyn_star)] #![allow(incomplete_features)] diff --git a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs index 9846f871424..dffe6ae8a36 100644 --- a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs +++ b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver #![feature(dyn_star)] #![allow(incomplete_features)] diff --git a/tests/ui/dyn-star/dispatch-on-pin-mut.rs b/tests/ui/dyn-star/dispatch-on-pin-mut.rs index 5774c8b2a67..c4ae279e6c1 100644 --- a/tests/ui/dyn-star/dispatch-on-pin-mut.rs +++ b/tests/ui/dyn-star/dispatch-on-pin-mut.rs @@ -4,6 +4,7 @@ #![feature(dyn_star)] //~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes +#![feature(noop_waker)] use std::future::Future; @@ -18,33 +19,18 @@ async fn async_main() { // ------------------------------------------------------------------------- // // Implementation Details Below... -use std::pin::Pin; use std::task::*; - -pub fn noop_waker() -> Waker { - let raw = RawWaker::new(std::ptr::null(), &NOOP_WAKER_VTABLE); - - // SAFETY: the contracts for RawWaker and RawWakerVTable are upheld - unsafe { Waker::from_raw(raw) } -} - -const NOOP_WAKER_VTABLE: RawWakerVTable = RawWakerVTable::new(noop_clone, noop, noop, noop); - -unsafe fn noop_clone(_p: *const ()) -> RawWaker { - RawWaker::new(std::ptr::null(), &NOOP_WAKER_VTABLE) -} - -unsafe fn noop(_p: *const ()) {} +use std::pin::pin; fn main() { - let mut fut = async_main(); + let mut fut = pin!(async_main()); // Poll loop, just to test the future... - let waker = noop_waker(); + let waker = Waker::noop(); let ctx = &mut Context::from_waker(&waker); loop { - match unsafe { Pin::new_unchecked(&mut fut).poll(ctx) } { + match fut.as_mut().poll(ctx) { Poll::Pending => {} Poll::Ready(()) => break, } diff --git a/tests/ui/dyn-star/param-env-region-infer.rs b/tests/ui/dyn-star/param-env-region-infer.rs index 50dec94d25b..1e331777765 100644 --- a/tests/ui/dyn-star/param-env-region-infer.rs +++ b/tests/ui/dyn-star/param-env-region-infer.rs @@ -1,7 +1,7 @@ // revisions: current // incremental -// FIXME(-Ztrait-solver=next): THis currently results in unstable query results: +// FIXME(-Znext-solver): THis currently results in unstable query results: // `normalizes-to(opaque, opaque)` changes from `Maybe(Ambiguous)` to `Maybe(Overflow)` // once the hidden type of the opaque is already defined to be itself. diff --git a/tests/ui/editions/edition-cstr-2015-2018.rs b/tests/ui/editions/edition-cstr-2015-2018.rs new file mode 100644 index 00000000000..4c35c48646a --- /dev/null +++ b/tests/ui/editions/edition-cstr-2015-2018.rs @@ -0,0 +1,62 @@ +macro_rules! construct { ($x:ident) => { $x"str" } } + //~^ ERROR expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `"str"` + //~| NOTE expected one of 8 possible tokens + +macro_rules! contain { () => { c"str" } } + //~^ ERROR expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `"str"` + //~| NOTE expected one of 8 possible tokens + //~| NOTE you may be trying to write a c-string literal + //~| NOTE c-string literals require Rust 2021 or later + //~| HELP pass `--edition 2021` to `rustc` + //~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide + +fn check_macro_construct() { + construct!(c); //~ NOTE in this expansion of construct! +} + +fn check_macro_contain() { + contain!(); + //~^ NOTE in this expansion of contain! + //~| NOTE in this expansion of contain! + //~| NOTE in this expansion of contain! + //~| NOTE in this expansion of contain! + //~| NOTE in this expansion of contain! +} + +fn check_basic() { + c"str"; + //~^ ERROR expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `"str"` + //~| NOTE expected one of 8 possible tokens + //~| NOTE you may be trying to write a c-string literal + //~| NOTE c-string literals require Rust 2021 or later + //~| HELP pass `--edition 2021` to `rustc` + //~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide +} + +fn check_craw() { + cr"str"; + //~^ ERROR expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `"str"` + //~| NOTE expected one of 8 possible tokens + //~| NOTE you may be trying to write a c-string literal + //~| NOTE c-string literals require Rust 2021 or later + //~| HELP pass `--edition 2021` to `rustc` + //~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide +} + +fn check_craw_hash() { + cr##"str"##; + //~^ ERROR expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `#` + //~| NOTE expected one of 8 possible tokens + //~| NOTE you may be trying to write a c-string literal + //~| NOTE c-string literals require Rust 2021 or later + //~| HELP pass `--edition 2021` to `rustc` + //~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide +} + +fn check_cstr_space() { + c "str"; + //~^ ERROR expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `"str"` + //~| NOTE expected one of 8 possible tokens +} + +fn main() {} diff --git a/tests/ui/editions/edition-cstr-2015-2018.stderr b/tests/ui/editions/edition-cstr-2015-2018.stderr new file mode 100644 index 00000000000..b864df308ef --- /dev/null +++ b/tests/ui/editions/edition-cstr-2015-2018.stderr @@ -0,0 +1,67 @@ +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `"str"` + --> $DIR/edition-cstr-2015-2018.rs:27:6 + | +LL | c"str"; + | ^^^^^ expected one of 8 possible tokens + | + = note: you may be trying to write a c-string literal + = note: c-string literals require Rust 2021 or later + = help: pass `--edition 2021` to `rustc` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `"str"` + --> $DIR/edition-cstr-2015-2018.rs:37:7 + | +LL | cr"str"; + | ^^^^^ expected one of 8 possible tokens + | + = note: you may be trying to write a c-string literal + = note: c-string literals require Rust 2021 or later + = help: pass `--edition 2021` to `rustc` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `#` + --> $DIR/edition-cstr-2015-2018.rs:47:7 + | +LL | cr##"str"##; + | ^ expected one of 8 possible tokens + | + = note: you may be trying to write a c-string literal + = note: c-string literals require Rust 2021 or later + = help: pass `--edition 2021` to `rustc` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `"str"` + --> $DIR/edition-cstr-2015-2018.rs:57:7 + | +LL | c "str"; + | ^^^^^ expected one of 8 possible tokens + +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `"str"` + --> $DIR/edition-cstr-2015-2018.rs:1:44 + | +LL | macro_rules! construct { ($x:ident) => { $x"str" } } + | ^^^^^ expected one of 8 possible tokens +... +LL | construct!(c); + | ------------- in this macro invocation + | + = note: this error originates in the macro `construct` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `"str"` + --> $DIR/edition-cstr-2015-2018.rs:5:33 + | +LL | macro_rules! contain { () => { c"str" } } + | ^^^^^ expected one of 8 possible tokens +... +LL | contain!(); + | ---------- in this macro invocation + | + = note: you may be trying to write a c-string literal + = note: c-string literals require Rust 2021 or later + = help: pass `--edition 2021` to `rustc` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + = note: this error originates in the macro `contain` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 6 previous errors + diff --git a/tests/ui/entry-point/issue-118772.rs b/tests/ui/entry-point/issue-118772.rs new file mode 100644 index 00000000000..1a4173e1252 --- /dev/null +++ b/tests/ui/entry-point/issue-118772.rs @@ -0,0 +1,3 @@ +fn main(_: &i32) { //~ ERROR `main` function has wrong type + println!("Hello, world!"); +} diff --git a/tests/ui/entry-point/issue-118772.stderr b/tests/ui/entry-point/issue-118772.stderr new file mode 100644 index 00000000000..cc33427f59d --- /dev/null +++ b/tests/ui/entry-point/issue-118772.stderr @@ -0,0 +1,12 @@ +error[E0580]: `main` function has wrong type + --> $DIR/issue-118772.rs:1:1 + | +LL | fn main(_: &i32) { + | ^^^^^^^^^^^^^^^^ incorrect number of function parameters + | + = note: expected signature `fn()` + found signature `for<'a> fn(&'a i32)` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0580`. diff --git a/tests/ui/entry-point/return-ty-has-bound-vars.rs b/tests/ui/entry-point/return-ty-has-bound-vars.rs new file mode 100644 index 00000000000..0995ce06160 --- /dev/null +++ b/tests/ui/entry-point/return-ty-has-bound-vars.rs @@ -0,0 +1,3 @@ +// issue-119209 + +fn main<'a>(_: &'a i32) -> &'a () { &() } //~ERROR `main` function return type is not allowed to have generic parameters diff --git a/tests/ui/entry-point/return-ty-has-bound-vars.stderr b/tests/ui/entry-point/return-ty-has-bound-vars.stderr new file mode 100644 index 00000000000..e7aab839f31 --- /dev/null +++ b/tests/ui/entry-point/return-ty-has-bound-vars.stderr @@ -0,0 +1,9 @@ +error[E0131]: `main` function return type is not allowed to have generic parameters + --> $DIR/return-ty-has-bound-vars.rs:3:28 + | +LL | fn main<'a>(_: &'a i32) -> &'a () { &() } + | ^^^^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0131`. diff --git a/tests/ui/error-codes/E0152.stderr b/tests/ui/error-codes/E0152.stderr index 816ba2d569b..dbea7e6d27f 100644 --- a/tests/ui/error-codes/E0152.stderr +++ b/tests/ui/error-codes/E0152.stderr @@ -2,7 +2,7 @@ error[E0152]: found duplicate lang item `owned_box` --> $DIR/E0152.rs:5:1 | LL | struct Foo<T>(T); - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^ | = note: the lang item is first defined in crate `alloc` (which `std` depends on) = note: first definition in `alloc` loaded from SYSROOT/liballoc-*.rlib diff --git a/tests/ui/error-codes/E0264.stderr b/tests/ui/error-codes/E0264.stderr index 14a4ffbe316..3503fb229e4 100644 --- a/tests/ui/error-codes/E0264.stderr +++ b/tests/ui/error-codes/E0264.stderr @@ -2,7 +2,7 @@ error[E0264]: unknown external lang item: `cake` --> $DIR/E0264.rs:5:5 | LL | fn cake(); - | ^^^^^^^^^ + | ^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0453.rs b/tests/ui/error-codes/E0453.rs index ca9573c5b46..8ed724dd3fc 100644 --- a/tests/ui/error-codes/E0453.rs +++ b/tests/ui/error-codes/E0453.rs @@ -2,6 +2,5 @@ #[allow(non_snake_case)] //~^ ERROR allow(non_snake_case) incompatible -//~| ERROR allow(non_snake_case) incompatible fn main() { } diff --git a/tests/ui/error-codes/E0453.stderr b/tests/ui/error-codes/E0453.stderr index bb2c39298c0..9a89f0d41e4 100644 --- a/tests/ui/error-codes/E0453.stderr +++ b/tests/ui/error-codes/E0453.stderr @@ -7,17 +7,6 @@ LL | LL | #[allow(non_snake_case)] | ^^^^^^^^^^^^^^ overruled by previous forbid -error[E0453]: allow(non_snake_case) incompatible with previous forbid - --> $DIR/E0453.rs:3:9 - | -LL | #![forbid(non_snake_case)] - | -------------- `forbid` level set here -LL | -LL | #[allow(non_snake_case)] - | ^^^^^^^^^^^^^^ overruled by previous forbid - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0453`. diff --git a/tests/ui/error-codes/E0476.rs b/tests/ui/error-codes/E0476.rs index e9afc756726..d87916198c5 100644 --- a/tests/ui/error-codes/E0476.rs +++ b/tests/ui/error-codes/E0476.rs @@ -1,5 +1,5 @@ // revisions: old next -//[next] compile-flags: -Ztrait-solver=next-coherence +//[next] compile-flags: -Znext-solver=coherence #![feature(coerce_unsized)] #![feature(unsize)] diff --git a/tests/ui/error-codes/E0620.stderr b/tests/ui/error-codes/E0620.stderr index 5bc8903624c..644ba813c96 100644 --- a/tests/ui/error-codes/E0620.stderr +++ b/tests/ui/error-codes/E0620.stderr @@ -2,13 +2,9 @@ error[E0620]: cast to unsized type: `&[usize; 2]` as `[usize]` --> $DIR/E0620.rs:2:16 | LL | let _foo = &[1_usize, 2] as [usize]; - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: consider using an implicit coercion to `&[usize]` instead - --> $DIR/E0620.rs:2:16 - | -LL | let _foo = &[1_usize, 2] as [usize]; - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^------- + | | + | help: try casting to a reference instead: `&[usize]` error: aborting due to 1 previous error diff --git a/tests/ui/extern/extern-types-field-offset.rs b/tests/ui/extern/extern-types-field-offset.rs new file mode 100644 index 00000000000..bfbc1e9bffa --- /dev/null +++ b/tests/ui/extern/extern-types-field-offset.rs @@ -0,0 +1,33 @@ +// run-fail +// check-run-results +// exec-env:RUST_BACKTRACE=0 +// normalize-stderr-test: "(core/src/panicking\.rs):[0-9]+:[0-9]+" -> "$1:$$LINE:$$COL" +#![feature(extern_types)] + +extern "C" { + type Opaque; +} + +struct Newtype(Opaque); + +struct S { + i: i32, + j: i32, + a: Newtype, +} + +fn main() { + let buf = [0i32; 4]; + + let x: &Newtype = unsafe { &*(&buf as *const _ as *const Newtype) }; + // Projecting to the newtype works, because it is always at offset 0. + let field = &x.0; + + let x: &S = unsafe { &*(&buf as *const _ as *const S) }; + // Accessing sized fields is perfectly fine, even at non-zero offsets. + let field = &x.i; + let field = &x.j; + // This needs to compute the field offset, but we don't know the type's alignment, + // so this panics. + let field = &x.a; +} diff --git a/tests/ui/extern/extern-types-field-offset.run.stderr b/tests/ui/extern/extern-types-field-offset.run.stderr new file mode 100644 index 00000000000..1b04b860db5 --- /dev/null +++ b/tests/ui/extern/extern-types-field-offset.run.stderr @@ -0,0 +1,4 @@ +thread 'main' panicked at library/core/src/panicking.rs:$LINE:$COL: +attempted to compute the size or alignment of extern type `Opaque` +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +thread caused non-unwinding panic. aborting. diff --git a/tests/ui/extern/extern-types-size_of_val.align.run.stderr b/tests/ui/extern/extern-types-size_of_val.align.run.stderr new file mode 100644 index 00000000000..20c4d8785e8 --- /dev/null +++ b/tests/ui/extern/extern-types-size_of_val.align.run.stderr @@ -0,0 +1,4 @@ +thread 'main' panicked at library/core/src/panicking.rs:$LINE:$COL: +attempted to compute the size or alignment of extern type `A` +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +thread caused non-unwinding panic. aborting. diff --git a/tests/ui/extern/extern-types-size_of_val.rs b/tests/ui/extern/extern-types-size_of_val.rs index 3b02ea28eaa..4c4de873b7f 100644 --- a/tests/ui/extern/extern-types-size_of_val.rs +++ b/tests/ui/extern/extern-types-size_of_val.rs @@ -1,4 +1,8 @@ -// run-pass +// run-fail +// check-run-results +// exec-env:RUST_BACKTRACE=0 +// normalize-stderr-test: "(core/src/panicking\.rs):[0-9]+:[0-9]+" -> "$1:$$LINE:$$COL" +// revisions: size align #![feature(extern_types)] use std::mem::{align_of_val, size_of_val}; @@ -10,6 +14,10 @@ extern "C" { fn main() { let x: &A = unsafe { &*(1usize as *const A) }; - assert_eq!(size_of_val(x), 0); - assert_eq!(align_of_val(x), 1); + // These don't have a dynamic size, so this should panic. + if cfg!(size) { + assert_eq!(size_of_val(x), 0); + } else { + assert_eq!(align_of_val(x), 1); + } } diff --git a/tests/ui/extern/extern-types-size_of_val.size.run.stderr b/tests/ui/extern/extern-types-size_of_val.size.run.stderr new file mode 100644 index 00000000000..20c4d8785e8 --- /dev/null +++ b/tests/ui/extern/extern-types-size_of_val.size.run.stderr @@ -0,0 +1,4 @@ +thread 'main' panicked at library/core/src/panicking.rs:$LINE:$COL: +attempted to compute the size or alignment of extern type `A` +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +thread caused non-unwinding panic. aborting. diff --git a/tests/ui/feature-gates/bench.stderr b/tests/ui/feature-gates/bench.stderr index 5f0aaf9251f..df935560fd6 100644 --- a/tests/ui/feature-gates/bench.stderr +++ b/tests/ui/feature-gates/bench.stderr @@ -19,3 +19,25 @@ LL | use bench as _; error: aborting due to 2 previous errors +Future incompatibility report: Future breakage diagnostic: +error: use of unstable library feature 'test': `bench` is a part of custom test frameworks which are unstable + --> $DIR/bench.rs:3:3 + | +LL | #[bench] + | ^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266> + = note: `#[deny(soft_unstable)]` on by default + +Future breakage diagnostic: +error: use of unstable library feature 'test': `bench` is a part of custom test frameworks which are unstable + --> $DIR/bench.rs:7:5 + | +LL | use bench as _; + | ^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266> + = note: `#[deny(soft_unstable)]` on by default + diff --git a/tests/ui/feature-gates/feature-gate-cfg-sanitizer_cfi.rs b/tests/ui/feature-gates/feature-gate-cfg-sanitizer_cfi.rs new file mode 100644 index 00000000000..76d96de750a --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg-sanitizer_cfi.rs @@ -0,0 +1,9 @@ +#[cfg(sanitizer_cfi_generalize_pointers)] +//~^ `cfg(sanitizer_cfi_generalize_pointers)` is experimental +fn foo() {} + +#[cfg(sanitizer_cfi_normalize_integers)] +//~^ `cfg(sanitizer_cfi_normalize_integers)` is experimental +fn bar() {} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-cfg-sanitizer_cfi.stderr b/tests/ui/feature-gates/feature-gate-cfg-sanitizer_cfi.stderr new file mode 100644 index 00000000000..8c2a8411c7b --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg-sanitizer_cfi.stderr @@ -0,0 +1,21 @@ +error[E0658]: `cfg(sanitizer_cfi_generalize_pointers)` is experimental and subject to change + --> $DIR/feature-gate-cfg-sanitizer_cfi.rs:1:7 + | +LL | #[cfg(sanitizer_cfi_generalize_pointers)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #89653 <https://github.com/rust-lang/rust/issues/89653> for more information + = help: add `#![feature(cfg_sanitizer_cfi)]` to the crate attributes to enable + +error[E0658]: `cfg(sanitizer_cfi_normalize_integers)` is experimental and subject to change + --> $DIR/feature-gate-cfg-sanitizer_cfi.rs:5:7 + | +LL | #[cfg(sanitizer_cfi_normalize_integers)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #89653 <https://github.com/rust-lang/rust/issues/89653> for more information + = help: add `#![feature(cfg_sanitizer_cfi)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-gen_blocks.e2024.stderr b/tests/ui/feature-gates/feature-gate-gen_blocks.e2024.stderr index 1462c41e957..c582ca7ba3d 100644 --- a/tests/ui/feature-gates/feature-gate-gen_blocks.e2024.stderr +++ b/tests/ui/feature-gates/feature-gate-gen_blocks.e2024.stderr @@ -2,16 +2,34 @@ error[E0658]: gen blocks are experimental --> $DIR/feature-gate-gen_blocks.rs:5:5 | LL | gen {}; - | ^^^^^ + | ^^^ | = note: see issue #117078 <https://github.com/rust-lang/rust/issues/117078> for more information = help: add `#![feature(gen_blocks)]` to the crate attributes to enable error[E0658]: gen blocks are experimental - --> $DIR/feature-gate-gen_blocks.rs:13:5 + --> $DIR/feature-gate-gen_blocks.rs:12:5 + | +LL | async gen {}; + | ^^^^^^^^^ + | + = note: see issue #117078 <https://github.com/rust-lang/rust/issues/117078> for more information + = help: add `#![feature(gen_blocks)]` to the crate attributes to enable + +error[E0658]: gen blocks are experimental + --> $DIR/feature-gate-gen_blocks.rs:22:5 | LL | gen {}; - | ^^^^^ + | ^^^ + | + = note: see issue #117078 <https://github.com/rust-lang/rust/issues/117078> for more information + = help: add `#![feature(gen_blocks)]` to the crate attributes to enable + +error[E0658]: gen blocks are experimental + --> $DIR/feature-gate-gen_blocks.rs:25:5 + | +LL | async gen {}; + | ^^^^^^^^^ | = note: see issue #117078 <https://github.com/rust-lang/rust/issues/117078> for more information = help: add `#![feature(gen_blocks)]` to the crate attributes to enable @@ -22,7 +40,13 @@ error[E0282]: type annotations needed LL | gen {}; | ^^ cannot infer type -error: aborting due to 3 previous errors +error[E0282]: type annotations needed + --> $DIR/feature-gate-gen_blocks.rs:12:15 + | +LL | async gen {}; + | ^^ cannot infer type + +error: aborting due to 6 previous errors Some errors have detailed explanations: E0282, E0658. For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/feature-gates/feature-gate-gen_blocks.none.stderr b/tests/ui/feature-gates/feature-gate-gen_blocks.none.stderr index 56f8309a69f..b4b37f0e638 100644 --- a/tests/ui/feature-gates/feature-gate-gen_blocks.none.stderr +++ b/tests/ui/feature-gates/feature-gate-gen_blocks.none.stderr @@ -1,9 +1,21 @@ +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `gen` + --> $DIR/feature-gate-gen_blocks.rs:12:11 + | +LL | async gen {}; + | ^^^ expected one of 8 possible tokens + +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `gen` + --> $DIR/feature-gate-gen_blocks.rs:25:11 + | +LL | async gen {}; + | ^^^ expected one of 8 possible tokens + error[E0422]: cannot find struct, variant or union type `gen` in this scope --> $DIR/feature-gate-gen_blocks.rs:5:5 | LL | gen {}; | ^^^ not found in this scope -error: aborting due to 1 previous error +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0422`. diff --git a/tests/ui/feature-gates/feature-gate-gen_blocks.rs b/tests/ui/feature-gates/feature-gate-gen_blocks.rs index e2e1574a36a..ff9a0b139c0 100644 --- a/tests/ui/feature-gates/feature-gate-gen_blocks.rs +++ b/tests/ui/feature-gates/feature-gate-gen_blocks.rs @@ -1,15 +1,28 @@ // revisions: e2024 none //[e2024] compile-flags: --edition 2024 -Zunstable-options -fn main() { +fn test_gen() { gen {}; //[none]~^ ERROR: cannot find struct, variant or union type `gen` //[e2024]~^^ ERROR: gen blocks are experimental //[e2024]~| ERROR: type annotations needed } +fn test_async_gen() { + async gen {}; + //[none]~^ ERROR expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `gen` + //[e2024]~^^ ERROR: gen blocks are experimental + //[e2024]~| ERROR: type annotations needed +} + +fn main() {} + #[cfg(FALSE)] fn foo() { gen {}; //[e2024]~^ ERROR: gen blocks are experimental + + async gen {}; + //[e2024]~^ ERROR: gen blocks are experimental + //[none]~^^ ERROR expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `gen` } diff --git a/tests/ui/feature-gates/feature-gate-multiple_supertrait_upcastable.rs b/tests/ui/feature-gates/feature-gate-multiple_supertrait_upcastable.rs index 0467dea621b..4e296b96ca9 100644 --- a/tests/ui/feature-gates/feature-gate-multiple_supertrait_upcastable.rs +++ b/tests/ui/feature-gates/feature-gate-multiple_supertrait_upcastable.rs @@ -2,11 +2,7 @@ #![deny(multiple_supertrait_upcastable)] //~^ WARNING unknown lint: `multiple_supertrait_upcastable` -//~| WARNING unknown lint: `multiple_supertrait_upcastable` -//~| WARNING unknown lint: `multiple_supertrait_upcastable` #![warn(multiple_supertrait_upcastable)] //~^ WARNING unknown lint: `multiple_supertrait_upcastable` -//~| WARNING unknown lint: `multiple_supertrait_upcastable` -//~| WARNING unknown lint: `multiple_supertrait_upcastable` fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-multiple_supertrait_upcastable.stderr b/tests/ui/feature-gates/feature-gate-multiple_supertrait_upcastable.stderr index 5e14bf6397f..f6fcf4ee3ed 100644 --- a/tests/ui/feature-gates/feature-gate-multiple_supertrait_upcastable.stderr +++ b/tests/ui/feature-gates/feature-gate-multiple_supertrait_upcastable.stderr @@ -9,7 +9,7 @@ LL | #![deny(multiple_supertrait_upcastable)] = note: `#[warn(unknown_lints)]` on by default warning: unknown lint: `multiple_supertrait_upcastable` - --> $DIR/feature-gate-multiple_supertrait_upcastable.rs:7:1 + --> $DIR/feature-gate-multiple_supertrait_upcastable.rs:5:1 | LL | #![warn(multiple_supertrait_upcastable)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,45 +17,5 @@ LL | #![warn(multiple_supertrait_upcastable)] = note: the `multiple_supertrait_upcastable` lint is unstable = help: add `#![feature(multiple_supertrait_upcastable)]` to the crate attributes to enable -warning: unknown lint: `multiple_supertrait_upcastable` - --> $DIR/feature-gate-multiple_supertrait_upcastable.rs:3:1 - | -LL | #![deny(multiple_supertrait_upcastable)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `multiple_supertrait_upcastable` lint is unstable - = help: add `#![feature(multiple_supertrait_upcastable)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: unknown lint: `multiple_supertrait_upcastable` - --> $DIR/feature-gate-multiple_supertrait_upcastable.rs:7:1 - | -LL | #![warn(multiple_supertrait_upcastable)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `multiple_supertrait_upcastable` lint is unstable - = help: add `#![feature(multiple_supertrait_upcastable)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: unknown lint: `multiple_supertrait_upcastable` - --> $DIR/feature-gate-multiple_supertrait_upcastable.rs:3:1 - | -LL | #![deny(multiple_supertrait_upcastable)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `multiple_supertrait_upcastable` lint is unstable - = help: add `#![feature(multiple_supertrait_upcastable)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: unknown lint: `multiple_supertrait_upcastable` - --> $DIR/feature-gate-multiple_supertrait_upcastable.rs:7:1 - | -LL | #![warn(multiple_supertrait_upcastable)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `multiple_supertrait_upcastable` lint is unstable - = help: add `#![feature(multiple_supertrait_upcastable)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: 6 warnings emitted +warning: 2 warnings emitted diff --git a/tests/ui/feature-gates/feature-gate-never_patterns.rs b/tests/ui/feature-gates/feature-gate-never_patterns.rs index ca5ce3b9489..f3910622313 100644 --- a/tests/ui/feature-gates/feature-gate-never_patterns.rs +++ b/tests/ui/feature-gates/feature-gate-never_patterns.rs @@ -12,16 +12,63 @@ fn main() { unsafe { let ptr: *const Void = NonNull::dangling().as_ptr(); match *ptr { - ! //~ ERROR `!` patterns are experimental + ! + //~^ ERROR `!` patterns are experimental + } + // Check that the gate operates even behind `cfg`. + #[cfg(FALSE)] + match *ptr { + ! + //~^ ERROR `!` patterns are experimental + } + #[cfg(FALSE)] + match *ptr { + ! => {} + //~^ ERROR `!` patterns are experimental } } + // Correctly gate match arms with no body. + match Some(0) { + None => {} + Some(_), + //~^ ERROR unexpected `,` in pattern + } + match Some(0) { + None => {} + Some(_) + //~^ ERROR `match` arm with no body + } + match Some(0) { + _ => {} + Some(_) if false, + //~^ ERROR `match` arm with no body + Some(_) if false + //~^ ERROR `match` arm with no body + } + match res { + Ok(_) => {} + Err(!), + //~^ ERROR `!` patterns are experimental + } + match res { + Err(!) if false, + //~^ ERROR `!` patterns are experimental + //~| ERROR a guard on a never pattern will never be run + _ => {} + } + // Check that the gate operates even behind `cfg`. - #[cfg(FALSE)] - unsafe { - let ptr: *const Void = NonNull::dangling().as_ptr(); - match *ptr { - ! => {} //~ ERROR `!` patterns are experimental - } + match Some(0) { + None => {} + #[cfg(FALSE)] + Some(_) + //~^ ERROR `match` arm with no body + } + match Some(0) { + _ => {} + #[cfg(FALSE)] + Some(_) if false + //~^ ERROR `match` arm with no body } } diff --git a/tests/ui/feature-gates/feature-gate-never_patterns.stderr b/tests/ui/feature-gates/feature-gate-never_patterns.stderr index 2354a3b0476..dd10829d495 100644 --- a/tests/ui/feature-gates/feature-gate-never_patterns.stderr +++ b/tests/ui/feature-gates/feature-gate-never_patterns.stderr @@ -1,3 +1,18 @@ +error: unexpected `,` in pattern + --> $DIR/feature-gate-never_patterns.rs:34:16 + | +LL | Some(_), + | ^ + | +help: try adding parentheses to match on a tuple... + | +LL | (Some(_),) + | + + +help: ...or a vertical bar to match on multiple alternatives + | +LL | Some(_) | + | + error[E0408]: variable `_x` is not bound in all patterns --> $DIR/feature-gate-never_patterns.rs:8:19 | @@ -25,7 +40,16 @@ LL | ! = help: add `#![feature(never_patterns)]` to the crate attributes to enable error[E0658]: `!` patterns are experimental - --> $DIR/feature-gate-never_patterns.rs:24:13 + --> $DIR/feature-gate-never_patterns.rs:21:13 + | +LL | ! + | ^ + | + = note: see issue #118155 <https://github.com/rust-lang/rust/issues/118155> for more information + = help: add `#![feature(never_patterns)]` to the crate attributes to enable + +error[E0658]: `!` patterns are experimental + --> $DIR/feature-gate-never_patterns.rs:26:13 | LL | ! => {} | ^ @@ -33,7 +57,61 @@ LL | ! => {} = note: see issue #118155 <https://github.com/rust-lang/rust/issues/118155> for more information = help: add `#![feature(never_patterns)]` to the crate attributes to enable -error: aborting due to 4 previous errors +error: `match` arm with no body + --> $DIR/feature-gate-never_patterns.rs:39:9 + | +LL | Some(_) + | ^^^^^^^- help: add a body after the pattern: `=> todo!(),` + +error: `match` arm with no body + --> $DIR/feature-gate-never_patterns.rs:44:9 + | +LL | Some(_) if false, + | ^^^^^^^- help: add a body after the pattern: `=> todo!(),` + +error: `match` arm with no body + --> $DIR/feature-gate-never_patterns.rs:46:9 + | +LL | Some(_) if false + | ^^^^^^^- help: add a body after the pattern: `=> todo!(),` + +error[E0658]: `!` patterns are experimental + --> $DIR/feature-gate-never_patterns.rs:51:13 + | +LL | Err(!), + | ^ + | + = note: see issue #118155 <https://github.com/rust-lang/rust/issues/118155> for more information + = help: add `#![feature(never_patterns)]` to the crate attributes to enable + +error[E0658]: `!` patterns are experimental + --> $DIR/feature-gate-never_patterns.rs:55:13 + | +LL | Err(!) if false, + | ^ + | + = note: see issue #118155 <https://github.com/rust-lang/rust/issues/118155> for more information + = help: add `#![feature(never_patterns)]` to the crate attributes to enable + +error: `match` arm with no body + --> $DIR/feature-gate-never_patterns.rs:65:9 + | +LL | Some(_) + | ^^^^^^^- help: add a body after the pattern: `=> todo!(),` + +error: `match` arm with no body + --> $DIR/feature-gate-never_patterns.rs:71:9 + | +LL | Some(_) if false + | ^^^^^^^- help: add a body after the pattern: `=> todo!(),` + +error: a guard on a never pattern will never be run + --> $DIR/feature-gate-never_patterns.rs:55:19 + | +LL | Err(!) if false, + | ^^^^^ help: remove this guard + +error: aborting due to 14 previous errors Some errors have detailed explanations: E0408, E0658. For more information about an error, try `rustc --explain E0408`. diff --git a/tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.rs b/tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.rs index 1922bfb4913..1db3c2ccdde 100644 --- a/tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.rs +++ b/tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.rs @@ -2,12 +2,8 @@ #![deny(non_exhaustive_omitted_patterns)] //~^ WARNING unknown lint: `non_exhaustive_omitted_patterns` -//~| WARNING unknown lint: `non_exhaustive_omitted_patterns` -//~| WARNING unknown lint: `non_exhaustive_omitted_patterns` #![allow(non_exhaustive_omitted_patterns)] //~^ WARNING unknown lint: `non_exhaustive_omitted_patterns` -//~| WARNING unknown lint: `non_exhaustive_omitted_patterns` -//~| WARNING unknown lint: `non_exhaustive_omitted_patterns` fn main() { enum Foo { @@ -19,9 +15,6 @@ fn main() { #[allow(non_exhaustive_omitted_patterns)] //~^ WARNING unknown lint: `non_exhaustive_omitted_patterns` //~| WARNING unknown lint: `non_exhaustive_omitted_patterns` - //~| WARNING unknown lint: `non_exhaustive_omitted_patterns` - //~| WARNING unknown lint: `non_exhaustive_omitted_patterns` - //~| WARNING unknown lint: `non_exhaustive_omitted_patterns` match Foo::A { //~^ ERROR non-exhaustive patterns: `Foo::C` not covered Foo::A => {} @@ -31,9 +24,6 @@ fn main() { #[warn(non_exhaustive_omitted_patterns)] //~^ WARNING unknown lint: `non_exhaustive_omitted_patterns` //~| WARNING unknown lint: `non_exhaustive_omitted_patterns` - //~| WARNING unknown lint: `non_exhaustive_omitted_patterns` - //~| WARNING unknown lint: `non_exhaustive_omitted_patterns` - //~| WARNING unknown lint: `non_exhaustive_omitted_patterns` match Foo::A { Foo::A => {} Foo::B => {} diff --git a/tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.stderr b/tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.stderr index a5333713977..955d7fe3f3e 100644 --- a/tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.stderr +++ b/tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.stderr @@ -10,7 +10,7 @@ LL | #![deny(non_exhaustive_omitted_patterns)] = note: `#[warn(unknown_lints)]` on by default warning: unknown lint: `non_exhaustive_omitted_patterns` - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:7:1 + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:5:1 | LL | #![allow(non_exhaustive_omitted_patterns)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -20,7 +20,7 @@ LL | #![allow(non_exhaustive_omitted_patterns)] = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable warning: unknown lint: `non_exhaustive_omitted_patterns` - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:19:5 + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:15:5 | LL | #[allow(non_exhaustive_omitted_patterns)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -30,7 +30,7 @@ LL | #[allow(non_exhaustive_omitted_patterns)] = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable warning: unknown lint: `non_exhaustive_omitted_patterns` - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:19:5 + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:15:5 | LL | #[allow(non_exhaustive_omitted_patterns)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | #[allow(non_exhaustive_omitted_patterns)] = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` warning: unknown lint: `non_exhaustive_omitted_patterns` - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:31:5 + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:24:5 | LL | #[warn(non_exhaustive_omitted_patterns)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -51,73 +51,7 @@ LL | #[warn(non_exhaustive_omitted_patterns)] = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable warning: unknown lint: `non_exhaustive_omitted_patterns` - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:31:5 - | -LL | #[warn(non_exhaustive_omitted_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `non_exhaustive_omitted_patterns` lint is unstable - = note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information - = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: unknown lint: `non_exhaustive_omitted_patterns` - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:3:1 - | -LL | #![deny(non_exhaustive_omitted_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `non_exhaustive_omitted_patterns` lint is unstable - = note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information - = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: unknown lint: `non_exhaustive_omitted_patterns` - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:7:1 - | -LL | #![allow(non_exhaustive_omitted_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `non_exhaustive_omitted_patterns` lint is unstable - = note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information - = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: unknown lint: `non_exhaustive_omitted_patterns` - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:19:5 - | -LL | #[allow(non_exhaustive_omitted_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `non_exhaustive_omitted_patterns` lint is unstable - = note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information - = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: unknown lint: `non_exhaustive_omitted_patterns` - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:19:5 - | -LL | #[allow(non_exhaustive_omitted_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `non_exhaustive_omitted_patterns` lint is unstable - = note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information - = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: unknown lint: `non_exhaustive_omitted_patterns` - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:31:5 - | -LL | #[warn(non_exhaustive_omitted_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `non_exhaustive_omitted_patterns` lint is unstable - = note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information - = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: unknown lint: `non_exhaustive_omitted_patterns` - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:31:5 + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:24:5 | LL | #[warn(non_exhaustive_omitted_patterns)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -128,13 +62,13 @@ LL | #[warn(non_exhaustive_omitted_patterns)] = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0004]: non-exhaustive patterns: `Foo::C` not covered - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:25:11 + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:18:11 | LL | match Foo::A { | ^^^^^^ pattern `Foo::C` not covered | note: `Foo` defined here - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:13:10 + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:9:10 | LL | enum Foo { | ^^^ @@ -148,50 +82,6 @@ LL ~ Foo::B => {}, LL + Foo::C => todo!() | -warning: unknown lint: `non_exhaustive_omitted_patterns` - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:3:1 - | -LL | #![deny(non_exhaustive_omitted_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `non_exhaustive_omitted_patterns` lint is unstable - = note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information - = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: unknown lint: `non_exhaustive_omitted_patterns` - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:7:1 - | -LL | #![allow(non_exhaustive_omitted_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `non_exhaustive_omitted_patterns` lint is unstable - = note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information - = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: unknown lint: `non_exhaustive_omitted_patterns` - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:19:5 - | -LL | #[allow(non_exhaustive_omitted_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `non_exhaustive_omitted_patterns` lint is unstable - = note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information - = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: unknown lint: `non_exhaustive_omitted_patterns` - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:31:5 - | -LL | #[warn(non_exhaustive_omitted_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `non_exhaustive_omitted_patterns` lint is unstable - = note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information - = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: aborting due to 1 previous error; 16 warnings emitted +error: aborting due to 1 previous error; 6 warnings emitted For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/feature-gates/feature-gate-strict_provenance.rs b/tests/ui/feature-gates/feature-gate-strict_provenance.rs index 75d0ee5700d..24b8369b3d8 100644 --- a/tests/ui/feature-gates/feature-gate-strict_provenance.rs +++ b/tests/ui/feature-gates/feature-gate-strict_provenance.rs @@ -2,12 +2,8 @@ #![deny(fuzzy_provenance_casts)] //~^ WARNING unknown lint: `fuzzy_provenance_casts` -//~| WARNING unknown lint: `fuzzy_provenance_casts` -//~| WARNING unknown lint: `fuzzy_provenance_casts` #![deny(lossy_provenance_casts)] //~^ WARNING unknown lint: `lossy_provenance_casts` -//~| WARNING unknown lint: `lossy_provenance_casts` -//~| WARNING unknown lint: `lossy_provenance_casts` fn main() { // no warnings emitted since the lints are not activated diff --git a/tests/ui/feature-gates/feature-gate-strict_provenance.stderr b/tests/ui/feature-gates/feature-gate-strict_provenance.stderr index 1e6d762a540..36224ee864b 100644 --- a/tests/ui/feature-gates/feature-gate-strict_provenance.stderr +++ b/tests/ui/feature-gates/feature-gate-strict_provenance.stderr @@ -10,7 +10,7 @@ LL | #![deny(fuzzy_provenance_casts)] = note: `#[warn(unknown_lints)]` on by default warning: unknown lint: `lossy_provenance_casts` - --> $DIR/feature-gate-strict_provenance.rs:7:1 + --> $DIR/feature-gate-strict_provenance.rs:5:1 | LL | #![deny(lossy_provenance_casts)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -19,49 +19,5 @@ LL | #![deny(lossy_provenance_casts)] = note: see issue #95228 <https://github.com/rust-lang/rust/issues/95228> for more information = help: add `#![feature(strict_provenance)]` to the crate attributes to enable -warning: unknown lint: `fuzzy_provenance_casts` - --> $DIR/feature-gate-strict_provenance.rs:3:1 - | -LL | #![deny(fuzzy_provenance_casts)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `fuzzy_provenance_casts` lint is unstable - = note: see issue #95228 <https://github.com/rust-lang/rust/issues/95228> for more information - = help: add `#![feature(strict_provenance)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: unknown lint: `lossy_provenance_casts` - --> $DIR/feature-gate-strict_provenance.rs:7:1 - | -LL | #![deny(lossy_provenance_casts)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `lossy_provenance_casts` lint is unstable - = note: see issue #95228 <https://github.com/rust-lang/rust/issues/95228> for more information - = help: add `#![feature(strict_provenance)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: unknown lint: `fuzzy_provenance_casts` - --> $DIR/feature-gate-strict_provenance.rs:3:1 - | -LL | #![deny(fuzzy_provenance_casts)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `fuzzy_provenance_casts` lint is unstable - = note: see issue #95228 <https://github.com/rust-lang/rust/issues/95228> for more information - = help: add `#![feature(strict_provenance)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: unknown lint: `lossy_provenance_casts` - --> $DIR/feature-gate-strict_provenance.rs:7:1 - | -LL | #![deny(lossy_provenance_casts)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `lossy_provenance_casts` lint is unstable - = note: see issue #95228 <https://github.com/rust-lang/rust/issues/95228> for more information - = help: add `#![feature(strict_provenance)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: 6 warnings emitted +warning: 2 warnings emitted diff --git a/tests/ui/feature-gates/feature-gate-test_unstable_lint.rs b/tests/ui/feature-gates/feature-gate-test_unstable_lint.rs index c398394cbe1..3882ba9a227 100644 --- a/tests/ui/feature-gates/feature-gate-test_unstable_lint.rs +++ b/tests/ui/feature-gates/feature-gate-test_unstable_lint.rs @@ -3,7 +3,5 @@ // `test_unstable_lint` is for testing and should never be stabilized. #![allow(test_unstable_lint)] //~^ WARNING unknown lint: `test_unstable_lint` -//~| WARNING unknown lint: `test_unstable_lint` -//~| WARNING unknown lint: `test_unstable_lint` fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-test_unstable_lint.stderr b/tests/ui/feature-gates/feature-gate-test_unstable_lint.stderr index 562aa478a93..aec32ac4abb 100644 --- a/tests/ui/feature-gates/feature-gate-test_unstable_lint.stderr +++ b/tests/ui/feature-gates/feature-gate-test_unstable_lint.stderr @@ -8,25 +8,5 @@ LL | #![allow(test_unstable_lint)] = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable = note: `#[warn(unknown_lints)]` on by default -warning: unknown lint: `test_unstable_lint` - --> $DIR/feature-gate-test_unstable_lint.rs:4:1 - | -LL | #![allow(test_unstable_lint)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `test_unstable_lint` lint is unstable - = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: unknown lint: `test_unstable_lint` - --> $DIR/feature-gate-test_unstable_lint.rs:4:1 - | -LL | #![allow(test_unstable_lint)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `test_unstable_lint` lint is unstable - = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: 3 warnings emitted +warning: 1 warning emitted diff --git a/tests/ui/feature-gates/feature-gate-trivial_bounds.stderr b/tests/ui/feature-gates/feature-gate-trivial_bounds.stderr index d2ad372dfbc..1b87ebd9f20 100644 --- a/tests/ui/feature-gates/feature-gate-trivial_bounds.stderr +++ b/tests/ui/feature-gates/feature-gate-trivial_bounds.stderr @@ -95,7 +95,7 @@ LL | fn unsized_local() where Dst<dyn A>: Sized { | ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `Dst<(dyn A + 'static)>`, the trait `Sized` is not implemented for `(dyn A + 'static)` -note: required because it appears within the type `Dst<dyn A>` +note: required because it appears within the type `Dst<(dyn A + 'static)>` --> $DIR/feature-gate-trivial_bounds.rs:48:8 | LL | struct Dst<X: ?Sized> { diff --git a/tests/ui/feature-gates/feature-gate-type_privacy_lints.rs b/tests/ui/feature-gates/feature-gate-type_privacy_lints.rs index 8bb9736f1b4..80e51b265db 100644 --- a/tests/ui/feature-gates/feature-gate-type_privacy_lints.rs +++ b/tests/ui/feature-gates/feature-gate-type_privacy_lints.rs @@ -1,6 +1,4 @@ // check-pass #![warn(unnameable_types)] //~ WARN unknown lint - //~| WARN unknown lint - //~| WARN unknown lint fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-type_privacy_lints.stderr b/tests/ui/feature-gates/feature-gate-type_privacy_lints.stderr index 2614f2b3c35..5cc30de9c57 100644 --- a/tests/ui/feature-gates/feature-gate-type_privacy_lints.stderr +++ b/tests/ui/feature-gates/feature-gate-type_privacy_lints.stderr @@ -9,27 +9,5 @@ LL | #![warn(unnameable_types)] = help: add `#![feature(type_privacy_lints)]` to the crate attributes to enable = note: `#[warn(unknown_lints)]` on by default -warning: unknown lint: `unnameable_types` - --> $DIR/feature-gate-type_privacy_lints.rs:3:1 - | -LL | #![warn(unnameable_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `unnameable_types` lint is unstable - = note: see issue #48054 <https://github.com/rust-lang/rust/issues/48054> for more information - = help: add `#![feature(type_privacy_lints)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: unknown lint: `unnameable_types` - --> $DIR/feature-gate-type_privacy_lints.rs:3:1 - | -LL | #![warn(unnameable_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `unnameable_types` lint is unstable - = note: see issue #48054 <https://github.com/rust-lang/rust/issues/48054> for more information - = help: add `#![feature(type_privacy_lints)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: 3 warnings emitted +warning: 1 warning emitted diff --git a/tests/ui/fmt/send-sync.stderr b/tests/ui/fmt/send-sync.stderr index e3ebe6cdcb8..6c9c7941eb3 100644 --- a/tests/ui/fmt/send-sync.stderr +++ b/tests/ui/fmt/send-sync.stderr @@ -8,9 +8,9 @@ LL | send(format_args!("{:?}", c)); | = help: within `[core::fmt::rt::Argument<'_>]`, the trait `Sync` is not implemented for `core::fmt::rt::Opaque` = note: required because it appears within the type `&core::fmt::rt::Opaque` -note: required because it appears within the type `Argument<'_>` +note: required because it appears within the type `core::fmt::rt::Argument<'_>` --> $SRC_DIR/core/src/fmt/rt.rs:LL:COL - = note: required because it appears within the type `[Argument<'_>]` + = note: required because it appears within the type `[core::fmt::rt::Argument<'_>]` = note: required for `&[core::fmt::rt::Argument<'_>]` to implement `Send` note: required because it appears within the type `Arguments<'_>` --> $SRC_DIR/core/src/fmt/mod.rs:LL:COL @@ -30,10 +30,10 @@ LL | sync(format_args!("{:?}", c)); | = help: within `Arguments<'_>`, the trait `Sync` is not implemented for `core::fmt::rt::Opaque` = note: required because it appears within the type `&core::fmt::rt::Opaque` -note: required because it appears within the type `Argument<'_>` +note: required because it appears within the type `core::fmt::rt::Argument<'_>` --> $SRC_DIR/core/src/fmt/rt.rs:LL:COL - = note: required because it appears within the type `[Argument<'_>]` - = note: required because it appears within the type `&[Argument<'_>]` + = note: required because it appears within the type `[core::fmt::rt::Argument<'_>]` + = note: required because it appears within the type `&[core::fmt::rt::Argument<'_>]` note: required because it appears within the type `Arguments<'_>` --> $SRC_DIR/core/src/fmt/mod.rs:LL:COL note: required by a bound in `sync` diff --git a/tests/ui/fn/signature-error-reporting-under-verbose.rs b/tests/ui/fn/signature-error-reporting-under-verbose.rs index d00cbd8a0f2..d28c8530d58 100644 --- a/tests/ui/fn/signature-error-reporting-under-verbose.rs +++ b/tests/ui/fn/signature-error-reporting-under-verbose.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zverbose +// compile-flags: -Zverbose-internals fn foo(_: i32, _: i32) {} diff --git a/tests/ui/for/issue-20605.rs b/tests/ui/for/issue-20605.rs index 50d4c3fddb5..8ae9494faf8 100644 --- a/tests/ui/for/issue-20605.rs +++ b/tests/ui/for/issue-20605.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver fn changer<'a>(mut things: Box<dyn Iterator<Item=&'a mut u8>>) { for item in *things { *item = 0 } @@ -13,7 +13,7 @@ fn changer<'a>(mut things: Box<dyn Iterator<Item=&'a mut u8>>) { //[next]~| ERROR the type `Option<<<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter as Iterator>::Item>` is not well-formed //[next]~| ERROR the size for values of type `<<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter as Iterator>::Item` cannot be known at compilation time //[next]~| ERROR type `<<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter as Iterator>::Item` cannot be dereferenced - // FIXME(-Ztrait-solver=next): these error messages are horrible and have to be + // FIXME(-Znext-solver): these error messages are horrible and have to be // improved before we stabilize the new solver. } diff --git a/tests/ui/foreign-fn-return-lifetime.fixed b/tests/ui/foreign-fn-return-lifetime.fixed deleted file mode 100644 index 143d6343d26..00000000000 --- a/tests/ui/foreign-fn-return-lifetime.fixed +++ /dev/null @@ -1,8 +0,0 @@ -// run-rustfix - -extern "C" { - pub fn g(_: &u8) -> &u8; // OK - pub fn f() -> &'static u8; //~ ERROR missing lifetime specifier -} - -fn main() {} diff --git a/tests/ui/foreign-fn-return-lifetime.rs b/tests/ui/foreign-fn-return-lifetime.rs index 76fe50a340a..35595bab36d 100644 --- a/tests/ui/foreign-fn-return-lifetime.rs +++ b/tests/ui/foreign-fn-return-lifetime.rs @@ -1,5 +1,3 @@ -// run-rustfix - extern "C" { pub fn g(_: &u8) -> &u8; // OK pub fn f() -> &u8; //~ ERROR missing lifetime specifier diff --git a/tests/ui/foreign-fn-return-lifetime.stderr b/tests/ui/foreign-fn-return-lifetime.stderr index 43edcbde35c..e24c0f23c35 100644 --- a/tests/ui/foreign-fn-return-lifetime.stderr +++ b/tests/ui/foreign-fn-return-lifetime.stderr @@ -1,14 +1,19 @@ error[E0106]: missing lifetime specifier - --> $DIR/foreign-fn-return-lifetime.rs:5:19 + --> $DIR/foreign-fn-return-lifetime.rs:3:19 | LL | pub fn f() -> &u8; | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | pub fn f() -> &'static u8; | +++++++ +help: instead, you are more likely to want to return an owned value + | +LL - pub fn f() -> &u8; +LL + pub fn f() -> u8; + | error: aborting due to 1 previous error diff --git a/tests/ui/function-pointer/unsized-ret.stderr b/tests/ui/function-pointer/unsized-ret.stderr index dcfec53eeb9..66116273ff4 100644 --- a/tests/ui/function-pointer/unsized-ret.stderr +++ b/tests/ui/function-pointer/unsized-ret.stderr @@ -19,7 +19,7 @@ LL | foo::<for<'a> fn(&'a ()) -> (dyn std::fmt::Display + 'a), _>(None, (&() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `for<'a> fn(&'a ()) -> (dyn std::fmt::Display + 'a)`, the trait `for<'a> Sized` is not implemented for `(dyn std::fmt::Display + 'a)` - = note: required because it appears within the type `fn(&()) -> dyn Display` + = note: required because it appears within the type `for<'a> fn(&'a ()) -> (dyn std::fmt::Display + 'a)` note: required by a bound in `foo` --> $DIR/unsized-ret.rs:5:11 | diff --git a/tests/ui/generic-associated-types/issue-102114.rs b/tests/ui/generic-associated-types/issue-102114.rs index bb6622c0a5f..bb6369d7f8f 100644 --- a/tests/ui/generic-associated-types/issue-102114.rs +++ b/tests/ui/generic-associated-types/issue-102114.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver trait A { type B<'b>; diff --git a/tests/ui/generic-associated-types/issue-70304.stderr b/tests/ui/generic-associated-types/issue-70304.stderr index 99339e96859..9b02c1b0768 100644 --- a/tests/ui/generic-associated-types/issue-70304.stderr +++ b/tests/ui/generic-associated-types/issue-70304.stderr @@ -11,7 +11,7 @@ LL | fn create_doc() -> impl Document<Cursor<'_> = DocCursorImpl<'_>> { | ^^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`, or if you will only have owned values | LL | fn create_doc() -> impl Document<Cursor<'_> = DocCursorImpl<'static>> { | ~~~~~~~ diff --git a/tests/ui/generic-const-items/const-trait-impl.rs b/tests/ui/generic-const-items/const-trait-impl.rs index 43cdf818c46..04c3f3eb434 100644 --- a/tests/ui/generic-const-items/const-trait-impl.rs +++ b/tests/ui/generic-const-items/const-trait-impl.rs @@ -1,14 +1,12 @@ -// known-bug: #110395 -// FIXME check-pass +// check-pass // Test that we can call methods from const trait impls inside of generic const items. -#![feature(generic_const_items, const_trait_impl)] +#![feature(generic_const_items, const_trait_impl, effects)] #![allow(incomplete_features)] #![crate_type = "lib"] -// FIXME(generic_const_items, effects): Introduce `const` bounds to make this work. -const CREATE<T: Create>: T = T::create(); +const CREATE<T: const Create>: T = T::create(); pub const K0: i32 = CREATE::<i32>; pub const K1: i32 = CREATE; // arg inferred @@ -23,3 +21,13 @@ impl const Create for i32 { 4096 } } + +trait Mod { // doesn't need to be a `#[const_trait]` + const CREATE<T: const Create>: T; +} + +impl Mod for () { + const CREATE<T: const Create>: T = T::create(); +} + +pub const K2: i32 = <() as Mod>::CREATE::<i32>; diff --git a/tests/ui/generic-const-items/const-trait-impl.stderr b/tests/ui/generic-const-items/const-trait-impl.stderr deleted file mode 100644 index e7e90542796..00000000000 --- a/tests/ui/generic-const-items/const-trait-impl.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0015]: cannot call non-const fn `<T as Create>::create` in constants - --> $DIR/const-trait-impl.rs:11:30 - | -LL | const CREATE<T: Create>: T = T::create(); - | ^^^^^^^^^^^ - | - = note: calls in constants are limited to constant functions, tuple structs and tuple variants - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/half-open-range-patterns/range_pat_interactions1.rs b/tests/ui/half-open-range-patterns/range_pat_interactions1.rs index 9ffc2190d20..55353999b67 100644 --- a/tests/ui/half-open-range-patterns/range_pat_interactions1.rs +++ b/tests/ui/half-open-range-patterns/range_pat_interactions1.rs @@ -17,7 +17,7 @@ fn main() { } match x as i32 { 0..5+1 => errors_only.push(x), - //~^ error: expected one of `,`, `=>`, `if`, `|`, or `}`, found `+` + //~^ error: expected one of `=>`, `if`, or `|`, found `+` 1 | -3..0 => first_or.push(x), y @ (0..5 | 6) => or_two.push(y), y @ 0..const { 5 + 1 } => assert_eq!(y, 5), diff --git a/tests/ui/half-open-range-patterns/range_pat_interactions1.stderr b/tests/ui/half-open-range-patterns/range_pat_interactions1.stderr index 05235c9b922..19ebcaf0f36 100644 --- a/tests/ui/half-open-range-patterns/range_pat_interactions1.stderr +++ b/tests/ui/half-open-range-patterns/range_pat_interactions1.stderr @@ -1,8 +1,8 @@ -error: expected one of `,`, `=>`, `if`, `|`, or `}`, found `+` +error: expected one of `=>`, `if`, or `|`, found `+` --> $DIR/range_pat_interactions1.rs:19:17 | LL | 0..5+1 => errors_only.push(x), - | ^ expected one of `,`, `=>`, `if`, `|`, or `}` + | ^ expected one of `=>`, `if`, or `|` error[E0408]: variable `n` is not bound in all patterns --> $DIR/range_pat_interactions1.rs:10:25 diff --git a/tests/ui/half-open-range-patterns/range_pat_interactions2.rs b/tests/ui/half-open-range-patterns/range_pat_interactions2.rs index b212bfbe093..4615ebd688a 100644 --- a/tests/ui/half-open-range-patterns/range_pat_interactions2.rs +++ b/tests/ui/half-open-range-patterns/range_pat_interactions2.rs @@ -9,7 +9,7 @@ fn main() { match x as i32 { 0..=(5+1) => errors_only.push(x), //~^ error: inclusive range with no end - //~| error: expected one of `,`, `=>`, `if`, `|`, or `}`, found `(` + //~| error: expected one of `=>`, `if`, or `|`, found `(` 1 | -3..0 => first_or.push(x), y @ (0..5 | 6) => or_two.push(y), y @ 0..const { 5 + 1 } => assert_eq!(y, 5), diff --git a/tests/ui/half-open-range-patterns/range_pat_interactions2.stderr b/tests/ui/half-open-range-patterns/range_pat_interactions2.stderr index 0129f927e34..13a5542a474 100644 --- a/tests/ui/half-open-range-patterns/range_pat_interactions2.stderr +++ b/tests/ui/half-open-range-patterns/range_pat_interactions2.stderr @@ -6,11 +6,11 @@ LL | 0..=(5+1) => errors_only.push(x), | = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) -error: expected one of `,`, `=>`, `if`, `|`, or `}`, found `(` +error: expected one of `=>`, `if`, or `|`, found `(` --> $DIR/range_pat_interactions2.rs:10:17 | LL | 0..=(5+1) => errors_only.push(x), - | ^ expected one of `,`, `=>`, `if`, `|`, or `}` + | ^ expected one of `=>`, `if`, or `|` error: aborting due to 2 previous errors diff --git a/tests/ui/higher-ranked/higher-lifetime-bounds.rs b/tests/ui/higher-ranked/higher-lifetime-bounds.rs index f3393347d90..f1de1d1cf53 100644 --- a/tests/ui/higher-ranked/higher-lifetime-bounds.rs +++ b/tests/ui/higher-ranked/higher-lifetime-bounds.rs @@ -6,7 +6,7 @@ fn bar1<'a, 'b>( x: &'a i32, y: &'b i32, f: for<'xa, 'xb: 'xa+'xa> fn(&'xa i32, &'xb i32) -> &'xa i32) - //~^ ERROR lifetime bounds cannot be used in this context + //~^ ERROR bounds cannot be used in this context { // If the bound in f's type would matter, the call below would (have to) // be rejected. @@ -14,7 +14,7 @@ fn bar1<'a, 'b>( } fn bar2<'a, 'b, F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32>( - //~^ ERROR lifetime bounds cannot be used in this context + //~^ ERROR bounds cannot be used in this context x: &'a i32, y: &'b i32, f: F) @@ -29,7 +29,7 @@ fn bar3<'a, 'b, F>( y: &'b i32, f: F) where F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32 - //~^ ERROR lifetime bounds cannot be used in this context + //~^ ERROR bounds cannot be used in this context { // If the bound in f's type would matter, the call below would (have to) // be rejected. @@ -41,7 +41,7 @@ fn bar4<'a, 'b, F>( y: &'b i32, f: F) where for<'xa, 'xb: 'xa> F: Fn(&'xa i32, &'xb i32) -> &'xa i32 - //~^ ERROR lifetime bounds cannot be used in this context + //~^ ERROR bounds cannot be used in this context { // If the bound in f's type would matter, the call below would (have to) // be rejected. @@ -49,21 +49,21 @@ fn bar4<'a, 'b, F>( } struct S1<F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32>(F); -//~^ ERROR lifetime bounds cannot be used in this context +//~^ ERROR bounds cannot be used in this context struct S2<F>(F) where F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32; -//~^ ERROR lifetime bounds cannot be used in this context +//~^ ERROR bounds cannot be used in this context struct S3<F>(F) where for<'xa, 'xb: 'xa> F: Fn(&'xa i32, &'xb i32) -> &'xa i32; -//~^ ERROR lifetime bounds cannot be used in this context +//~^ ERROR bounds cannot be used in this context struct S_fnty(for<'xa, 'xb: 'xa> fn(&'xa i32, &'xb i32) -> &'xa i32); -//~^ ERROR lifetime bounds cannot be used in this context +//~^ ERROR bounds cannot be used in this context type T1 = Box<dyn for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32>; -//~^ ERROR lifetime bounds cannot be used in this context +//~^ ERROR bounds cannot be used in this context fn main() { let _ : Option<for<'xa, 'xb: 'xa> fn(&'xa i32, &'xb i32) -> &'xa i32> = None; - //~^ ERROR lifetime bounds cannot be used in this context + //~^ ERROR bounds cannot be used in this context let _ : Option<Box<dyn for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32>> = None; - //~^ ERROR lifetime bounds cannot be used in this context + //~^ ERROR bounds cannot be used in this context } diff --git a/tests/ui/higher-ranked/higher-lifetime-bounds.stderr b/tests/ui/higher-ranked/higher-lifetime-bounds.stderr index bc6d2288cdf..de83d8bccdb 100644 --- a/tests/ui/higher-ranked/higher-lifetime-bounds.stderr +++ b/tests/ui/higher-ranked/higher-lifetime-bounds.stderr @@ -1,64 +1,64 @@ -error: lifetime bounds cannot be used in this context +error: bounds cannot be used in this context --> $DIR/higher-lifetime-bounds.rs:8:22 | LL | f: for<'xa, 'xb: 'xa+'xa> fn(&'xa i32, &'xb i32) -> &'xa i32) | ^^^ ^^^ -error: lifetime bounds cannot be used in this context +error: bounds cannot be used in this context --> $DIR/higher-lifetime-bounds.rs:16:34 | LL | fn bar2<'a, 'b, F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32>( | ^^^ -error: lifetime bounds cannot be used in this context +error: bounds cannot be used in this context --> $DIR/higher-lifetime-bounds.rs:31:28 | LL | where F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32 | ^^^ -error: lifetime bounds cannot be used in this context +error: bounds cannot be used in this context --> $DIR/higher-lifetime-bounds.rs:43:25 | LL | where for<'xa, 'xb: 'xa> F: Fn(&'xa i32, &'xb i32) -> &'xa i32 | ^^^ -error: lifetime bounds cannot be used in this context +error: bounds cannot be used in this context --> $DIR/higher-lifetime-bounds.rs:51:28 | LL | struct S1<F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32>(F); | ^^^ -error: lifetime bounds cannot be used in this context +error: bounds cannot be used in this context --> $DIR/higher-lifetime-bounds.rs:53:40 | LL | struct S2<F>(F) where F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32; | ^^^ -error: lifetime bounds cannot be used in this context +error: bounds cannot be used in this context --> $DIR/higher-lifetime-bounds.rs:55:37 | LL | struct S3<F>(F) where for<'xa, 'xb: 'xa> F: Fn(&'xa i32, &'xb i32) -> &'xa i32; | ^^^ -error: lifetime bounds cannot be used in this context +error: bounds cannot be used in this context --> $DIR/higher-lifetime-bounds.rs:58:29 | LL | struct S_fnty(for<'xa, 'xb: 'xa> fn(&'xa i32, &'xb i32) -> &'xa i32); | ^^^ -error: lifetime bounds cannot be used in this context +error: bounds cannot be used in this context --> $DIR/higher-lifetime-bounds.rs:61:33 | LL | type T1 = Box<dyn for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32>; | ^^^ -error: lifetime bounds cannot be used in this context +error: bounds cannot be used in this context --> $DIR/higher-lifetime-bounds.rs:65:34 | LL | let _ : Option<for<'xa, 'xb: 'xa> fn(&'xa i32, &'xb i32) -> &'xa i32> = None; | ^^^ -error: lifetime bounds cannot be used in this context +error: bounds cannot be used in this context --> $DIR/higher-lifetime-bounds.rs:67:42 | LL | let _ : Option<Box<dyn for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32>> = None; diff --git a/tests/ui/higher-ranked/higher-ranked-lifetime-error.stderr b/tests/ui/higher-ranked/higher-ranked-lifetime-error.stderr index d0892fd8b09..c25e731d962 100644 --- a/tests/ui/higher-ranked/higher-ranked-lifetime-error.stderr +++ b/tests/ui/higher-ranked/higher-ranked-lifetime-error.stderr @@ -4,8 +4,8 @@ error[E0308]: mismatched types LL | assert_all::<_, &String>(id); | ^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other | - = note: expected reference `&String` - found reference `&String` + = note: expected trait `for<'a> <for<'a> fn(&'a String) -> &'a String {id} as FnMut<(&'a String,)>>` + found trait `for<'a> <for<'a> fn(&'a String) -> &'a String {id} as FnMut<(&'a String,)>>` error: aborting due to 1 previous error diff --git a/tests/ui/higher-ranked/leak-check-in-selection.rs b/tests/ui/higher-ranked/leak-check-in-selection.rs index e8d6cff856c..5b36902ffdf 100644 --- a/tests/ui/higher-ranked/leak-check-in-selection.rs +++ b/tests/ui/higher-ranked/leak-check-in-selection.rs @@ -1,6 +1,6 @@ // run-pass // revisions: old next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver #![allow(coherence_leak_check)] trait Trait: Sized { diff --git a/tests/ui/higher-ranked/trait-bounds/fn-ptr.rs b/tests/ui/higher-ranked/trait-bounds/fn-ptr.rs index adb19c035bc..41f24dde01a 100644 --- a/tests/ui/higher-ranked/trait-bounds/fn-ptr.rs +++ b/tests/ui/higher-ranked/trait-bounds/fn-ptr.rs @@ -1,5 +1,5 @@ // revisions: classic next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver //[next] check-pass fn ice() diff --git a/tests/ui/higher-ranked/trait-bounds/future.rs b/tests/ui/higher-ranked/trait-bounds/future.rs index 61d86a9cb23..baeb56e5d78 100644 --- a/tests/ui/higher-ranked/trait-bounds/future.rs +++ b/tests/ui/higher-ranked/trait-bounds/future.rs @@ -1,7 +1,7 @@ // ignore-tidy-linelength // edition:2021 // revisions: classic next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver //[next] check-pass //[classic] known-bug: #112347 //[classic] build-fail diff --git a/tests/ui/higher-ranked/trait-bounds/issue-95230.rs b/tests/ui/higher-ranked/trait-bounds/issue-95230.rs index 49a1584d54e..027644a280b 100644 --- a/tests/ui/higher-ranked/trait-bounds/issue-95230.rs +++ b/tests/ui/higher-ranked/trait-bounds/issue-95230.rs @@ -1,5 +1,5 @@ // revisions: old next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver //[old] check-pass //[next] known-bug: #109764 diff --git a/tests/ui/hygiene/cross-crate-define-and-use.rs b/tests/ui/hygiene/cross-crate-define-and-use.rs index 94f1adff626..62b1820235c 100644 --- a/tests/ui/hygiene/cross-crate-define-and-use.rs +++ b/tests/ui/hygiene/cross-crate-define-and-use.rs @@ -6,7 +6,6 @@ // check-pass // aux-build:use_by_macro.rs -#![feature(type_name_of_val)] extern crate use_by_macro; use use_by_macro::*; diff --git a/tests/ui/hygiene/panic-location.run.stderr b/tests/ui/hygiene/panic-location.run.stderr index e0dc13c0c95..5c552411da7 100644 --- a/tests/ui/hygiene/panic-location.run.stderr +++ b/tests/ui/hygiene/panic-location.run.stderr @@ -1,3 +1,3 @@ -thread 'main' panicked at library/alloc/src/raw_vec.rs:545:5: +thread 'main' panicked at library/alloc/src/raw_vec.rs:571:5: capacity overflow note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/impl-trait/associated-impl-trait-type-issue-114325.rs b/tests/ui/impl-trait/associated-impl-trait-type-issue-114325.rs new file mode 100644 index 00000000000..8173f8df11b --- /dev/null +++ b/tests/ui/impl-trait/associated-impl-trait-type-issue-114325.rs @@ -0,0 +1,55 @@ +// This is a non-regression test for issue #114325: an "unexpected unsized tail" ICE happened during +// codegen, and was fixed by MIR drop tracking #107421. + +// edition: 2021 +// build-pass: ICEd during codegen. + +#![feature(impl_trait_in_assoc_type)] + +use std::future::Future; + +fn main() { + RuntimeRef::spawn_local(actor_fn(http_actor)); +} + +async fn http_actor() { + async fn respond(body: impl Body) { + body.write_message().await; + } + + respond(&()).await; +} + +trait Body { + type WriteFuture: Future; + + fn write_message(self) -> Self::WriteFuture; +} + +impl Body for &'static () { + type WriteFuture = impl Future<Output = ()>; + + fn write_message(self) -> Self::WriteFuture { + async {} + } +} + +trait NewActor { + type RuntimeAccess; +} + +fn actor_fn<T, A>(_d: T) -> (T, A) { + loop {} +} + +impl<F: FnMut() -> A, A> NewActor for (F, A) { + type RuntimeAccess = RuntimeRef; +} +struct RuntimeRef(Vec<()>); + +impl RuntimeRef { + fn spawn_local<NA: NewActor<RuntimeAccess = RuntimeRef>>(_f: NA) { + struct ActorFuture<NA: NewActor>(NA::RuntimeAccess); + (ActorFuture::<NA>(RuntimeRef(vec![])), _f); + } +} diff --git a/tests/ui/impl-trait/auto-trait-coherence.rs b/tests/ui/impl-trait/auto-trait-coherence.rs index a5cd01a87ff..e4226b20074 100644 --- a/tests/ui/impl-trait/auto-trait-coherence.rs +++ b/tests/ui/impl-trait/auto-trait-coherence.rs @@ -1,5 +1,5 @@ // revisions: old next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver // Tests that type alias impls traits do not leak auto-traits for // the purposes of coherence checking diff --git a/tests/ui/impl-trait/autoderef.rs b/tests/ui/impl-trait/autoderef.rs index cd2cdd9e3b3..48ff8be6549 100644 --- a/tests/ui/impl-trait/autoderef.rs +++ b/tests/ui/impl-trait/autoderef.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver // check-pass use std::path::Path; diff --git a/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr b/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr index ed9261d0de5..4a52f82540d 100644 --- a/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr +++ b/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr @@ -16,7 +16,7 @@ LL | fn fuz() -> (usize, Trait) { (42, Struct) } | doesn't have a size known at compile-time | = help: within `(usize, (dyn Trait + 'static))`, the trait `Sized` is not implemented for `(dyn Trait + 'static)` - = note: required because it appears within the type `(usize, dyn Trait)` + = note: required because it appears within the type `(usize, (dyn Trait + 'static))` = note: the return type of a function must have a statically known size error[E0308]: mismatched types @@ -37,7 +37,7 @@ LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } | doesn't have a size known at compile-time | = help: within `(usize, (dyn Trait + 'static))`, the trait `Sized` is not implemented for `(dyn Trait + 'static)` - = note: required because it appears within the type `(usize, dyn Trait)` + = note: required because it appears within the type `(usize, (dyn Trait + 'static))` = note: the return type of a function must have a statically known size error[E0746]: return type cannot have an unboxed trait object diff --git a/tests/ui/impl-trait/erased-regions-in-hidden-ty.rs b/tests/ui/impl-trait/erased-regions-in-hidden-ty.rs index 698123a932d..0458b56f95f 100644 --- a/tests/ui/impl-trait/erased-regions-in-hidden-ty.rs +++ b/tests/ui/impl-trait/erased-regions-in-hidden-ty.rs @@ -1,6 +1,6 @@ // revisions: current next -// compile-flags: -Zverbose -//[next] compile-flags: -Ztrait-solver=next +// compile-flags: -Zverbose-internals +//[next] compile-flags: -Znext-solver // normalize-stderr-test "DefId\([^\)]+\)" -> "DefId(..)" #![feature(rustc_attrs)] diff --git a/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr b/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr index 443ffeb55cd..a5982a5542a 100644 --- a/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr +++ b/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr @@ -5,7 +5,7 @@ LL | fn d() -> impl Fn() -> (impl Debug + '_) { | ^^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`, or if you will only have owned values | LL | fn d() -> impl Fn() -> (impl Debug + 'static) { | ~~~~~~~ diff --git a/tests/ui/impl-trait/in-trait/object-safety-sized.rs b/tests/ui/impl-trait/in-trait/object-safety-sized.rs index 35afe80c97f..1a23493a94d 100644 --- a/tests/ui/impl-trait/in-trait/object-safety-sized.rs +++ b/tests/ui/impl-trait/in-trait/object-safety-sized.rs @@ -1,6 +1,6 @@ // check-pass // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver fn main() { diff --git a/tests/ui/impl-trait/in-trait/opaque-variances.rs b/tests/ui/impl-trait/in-trait/opaque-variances.rs index 60bfab0deb5..63e56051d1a 100644 --- a/tests/ui/impl-trait/in-trait/opaque-variances.rs +++ b/tests/ui/impl-trait/in-trait/opaque-variances.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver fn foo<'a: 'a>(x: &'a Vec<i32>) -> impl Sized { () diff --git a/tests/ui/impl-trait/issue-103181-1.rs b/tests/ui/impl-trait/issue-103181-1.rs index 5154abcd690..14c813cf00f 100644 --- a/tests/ui/impl-trait/issue-103181-1.rs +++ b/tests/ui/impl-trait/issue-103181-1.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver // edition:2021 mod hyper { diff --git a/tests/ui/impl-trait/normalize-tait-in-const.stderr b/tests/ui/impl-trait/normalize-tait-in-const.stderr index e0513433b8e..7fd2ec57b14 100644 --- a/tests/ui/impl-trait/normalize-tait-in-const.stderr +++ b/tests/ui/impl-trait/normalize-tait-in-const.stderr @@ -1,4 +1,4 @@ -error: ~const can only be applied to `#[const_trait]` traits +error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/normalize-tait-in-const.rs:25:42 | LL | const fn with_positive<F: ~const for<'a> Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) { diff --git a/tests/ui/impl-trait/not_general_enough_regression_106630.rs b/tests/ui/impl-trait/not_general_enough_regression_106630.rs new file mode 100644 index 00000000000..439973950f3 --- /dev/null +++ b/tests/ui/impl-trait/not_general_enough_regression_106630.rs @@ -0,0 +1,33 @@ +// edition:2018 +// run-pass + +use std::future::Future; + +trait AsyncCallback<'a> { + type Out; +} + +impl<'a, Fut, T, F> AsyncCallback<'a> for F +where + F: FnOnce(&'a mut ()) -> Fut, + Fut: Future<Output = T> + Send + 'a, +{ + type Out = T; +} + +trait CallbackMarker {} + +impl<F, T> CallbackMarker for F +where + T: 'static, + for<'a> F: AsyncCallback<'a, Out = T> + Send, +{ +} + +fn do_sth<F: CallbackMarker>(_: F) {} + +async fn callback(_: &mut ()) -> impl Send {} + +fn main() { + do_sth(callback); +} diff --git a/tests/ui/impl-trait/recursive-coroutine.rs b/tests/ui/impl-trait/recursive-coroutine.rs index f0bee4f120f..b82fe134a40 100644 --- a/tests/ui/impl-trait/recursive-coroutine.rs +++ b/tests/ui/impl-trait/recursive-coroutine.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver #![feature(coroutines, coroutine_trait)] use std::ops::{Coroutine, CoroutineState}; diff --git a/tests/ui/impl-trait/reveal-during-codegen.rs b/tests/ui/impl-trait/reveal-during-codegen.rs index 11463772eb3..7b2ca9c33f6 100644 --- a/tests/ui/impl-trait/reveal-during-codegen.rs +++ b/tests/ui/impl-trait/reveal-during-codegen.rs @@ -1,6 +1,6 @@ // build-pass // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver fn test() -> Option<impl Sized> { Some("") diff --git a/tests/ui/impl-trait/two_tait_defining_each_other.rs b/tests/ui/impl-trait/two_tait_defining_each_other.rs index b43a7cabd05..6a9e33500e5 100644 --- a/tests/ui/impl-trait/two_tait_defining_each_other.rs +++ b/tests/ui/impl-trait/two_tait_defining_each_other.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver //[next] check-pass #![feature(type_alias_impl_trait)] diff --git a/tests/ui/impl-trait/two_tait_defining_each_other2.rs b/tests/ui/impl-trait/two_tait_defining_each_other2.rs index 817de109fbe..8a79af19776 100644 --- a/tests/ui/impl-trait/two_tait_defining_each_other2.rs +++ b/tests/ui/impl-trait/two_tait_defining_each_other2.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver #![feature(type_alias_impl_trait)] type A = impl Foo; //[current]~ ERROR unconstrained opaque type diff --git a/tests/ui/impl-trait/two_tait_defining_each_other3.rs b/tests/ui/impl-trait/two_tait_defining_each_other3.rs index 6fb9e6e7188..55def937f48 100644 --- a/tests/ui/impl-trait/two_tait_defining_each_other3.rs +++ b/tests/ui/impl-trait/two_tait_defining_each_other3.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver //[next] check-pass #![feature(type_alias_impl_trait)] diff --git a/tests/ui/implied-bounds/hrlt-implied-trait-bounds-guard.rs b/tests/ui/implied-bounds/hrlt-implied-trait-bounds-guard.rs index c177655c5ac..27c8f30ec32 100644 --- a/tests/ui/implied-bounds/hrlt-implied-trait-bounds-guard.rs +++ b/tests/ui/implied-bounds/hrlt-implied-trait-bounds-guard.rs @@ -1,5 +1,5 @@ // A test exploiting the bug behind #25860 except with -// implied trait bounds which currently don't exist without `-Ztrait-solver=chalk`. +// implied trait bounds which currently don't exist. use std::marker::PhantomData; struct Foo<'a, 'b, T>(PhantomData<(&'a (), &'b (), T)>) where diff --git a/tests/ui/implied-bounds/impl-implied-bounds-compatibility-unnormalized.rs b/tests/ui/implied-bounds/impl-implied-bounds-compatibility-unnormalized.rs index 6ccbb5bb266..280856805e5 100644 --- a/tests/ui/implied-bounds/impl-implied-bounds-compatibility-unnormalized.rs +++ b/tests/ui/implied-bounds/impl-implied-bounds-compatibility-unnormalized.rs @@ -1,5 +1,3 @@ -#![deny(implied_bounds_entailment)] - trait Project { type Ty; } @@ -11,8 +9,7 @@ trait Trait { } impl Trait for () { fn get<'s>(s: &'s str, _: <&'static &'s () as Project>::Ty) -> &'static str { - //~^ ERROR impl method assumes more implied bounds than the corresponding trait method - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~^ ERROR cannot infer an appropriate lifetime for lifetime parameter 's in generic type due to conflicting requirements s } } diff --git a/tests/ui/implied-bounds/impl-implied-bounds-compatibility-unnormalized.stderr b/tests/ui/implied-bounds/impl-implied-bounds-compatibility-unnormalized.stderr index 86b12cf8fa2..c8d1614a7f3 100644 --- a/tests/ui/implied-bounds/impl-implied-bounds-compatibility-unnormalized.stderr +++ b/tests/ui/implied-bounds/impl-implied-bounds-compatibility-unnormalized.stderr @@ -1,31 +1,28 @@ -error: impl method assumes more implied bounds than the corresponding trait method - --> $DIR/impl-implied-bounds-compatibility-unnormalized.rs:13:31 +error[E0495]: cannot infer an appropriate lifetime for lifetime parameter 's in generic type due to conflicting requirements + --> $DIR/impl-implied-bounds-compatibility-unnormalized.rs:11:5 | LL | fn get<'s>(s: &'s str, _: <&'static &'s () as Project>::Ty) -> &'static str { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this type to make the impl signature compatible: `()` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #105572 <https://github.com/rust-lang/rust/issues/105572> -note: the lint level is defined here - --> $DIR/impl-implied-bounds-compatibility-unnormalized.rs:1:9 - | -LL | #![deny(implied_bounds_entailment)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - -Future incompatibility report: Future breakage diagnostic: -error: impl method assumes more implied bounds than the corresponding trait method - --> $DIR/impl-implied-bounds-compatibility-unnormalized.rs:13:31 +note: first, the lifetime cannot outlive the lifetime `'s` as defined here... + --> $DIR/impl-implied-bounds-compatibility-unnormalized.rs:11:12 | LL | fn get<'s>(s: &'s str, _: <&'static &'s () as Project>::Ty) -> &'static str { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this type to make the impl signature compatible: `()` + | ^^ +note: ...so that the method type is compatible with trait + --> $DIR/impl-implied-bounds-compatibility-unnormalized.rs:11:5 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #105572 <https://github.com/rust-lang/rust/issues/105572> -note: the lint level is defined here - --> $DIR/impl-implied-bounds-compatibility-unnormalized.rs:1:9 +LL | fn get<'s>(s: &'s str, _: <&'static &'s () as Project>::Ty) -> &'static str { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: expected `fn(&'s _, ()) -> &'static _` + found `fn(&_, ()) -> &'static _` + = note: but, the lifetime must be valid for the static lifetime... +note: ...so that the reference type `&'static &()` does not outlive the data it points at + --> $DIR/impl-implied-bounds-compatibility-unnormalized.rs:11:5 | -LL | #![deny(implied_bounds_entailment)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn get<'s>(s: &'s str, _: <&'static &'s () as Project>::Ty) -> &'static str { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error +For more information about this error, try `rustc --explain E0495`. diff --git a/tests/ui/implied-bounds/impl-implied-bounds-compatibility.rs b/tests/ui/implied-bounds/impl-implied-bounds-compatibility.rs index d097bc16a22..7f3817b326a 100644 --- a/tests/ui/implied-bounds/impl-implied-bounds-compatibility.rs +++ b/tests/ui/implied-bounds/impl-implied-bounds-compatibility.rs @@ -1,5 +1,3 @@ -#![deny(implied_bounds_entailment)] - use std::cell::RefCell; pub struct MessageListeners<'a> { @@ -12,8 +10,7 @@ pub trait MessageListenersInterface { impl<'a> MessageListenersInterface for MessageListeners<'a> { fn listeners<'b>(&'b self) -> &'a MessageListeners<'b> { - //~^ ERROR impl method assumes more implied bounds than the corresponding trait method - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~^ ERROR cannot infer an appropriate lifetime for lifetime parameter 'b in generic type due to conflicting requirements self } } diff --git a/tests/ui/implied-bounds/impl-implied-bounds-compatibility.stderr b/tests/ui/implied-bounds/impl-implied-bounds-compatibility.stderr index a89645c128b..6a412eb5e4b 100644 --- a/tests/ui/implied-bounds/impl-implied-bounds-compatibility.stderr +++ b/tests/ui/implied-bounds/impl-implied-bounds-compatibility.stderr @@ -1,31 +1,32 @@ -error: impl method assumes more implied bounds than the corresponding trait method - --> $DIR/impl-implied-bounds-compatibility.rs:14:35 +error[E0495]: cannot infer an appropriate lifetime for lifetime parameter 'b in generic type due to conflicting requirements + --> $DIR/impl-implied-bounds-compatibility.rs:12:5 | LL | fn listeners<'b>(&'b self) -> &'a MessageListeners<'b> { - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this type to make the impl signature compatible: `&'b MessageListeners<'b>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #105572 <https://github.com/rust-lang/rust/issues/105572> -note: the lint level is defined here - --> $DIR/impl-implied-bounds-compatibility.rs:1:9 +note: first, the lifetime cannot outlive the lifetime `'c` as defined here... + --> $DIR/impl-implied-bounds-compatibility.rs:12:5 | -LL | #![deny(implied_bounds_entailment)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - -Future incompatibility report: Future breakage diagnostic: -error: impl method assumes more implied bounds than the corresponding trait method - --> $DIR/impl-implied-bounds-compatibility.rs:14:35 +LL | fn listeners<'b>(&'b self) -> &'a MessageListeners<'b> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...so that the method type is compatible with trait + --> $DIR/impl-implied-bounds-compatibility.rs:12:5 | LL | fn listeners<'b>(&'b self) -> &'a MessageListeners<'b> { - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this type to make the impl signature compatible: `&'b MessageListeners<'b>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: expected `fn(&'c MessageListeners<'_>) -> &'c MessageListeners<'c>` + found `fn(&MessageListeners<'_>) -> &'a MessageListeners<'_>` +note: but, the lifetime must be valid for the lifetime `'a` as defined here... + --> $DIR/impl-implied-bounds-compatibility.rs:11:6 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #105572 <https://github.com/rust-lang/rust/issues/105572> -note: the lint level is defined here - --> $DIR/impl-implied-bounds-compatibility.rs:1:9 +LL | impl<'a> MessageListenersInterface for MessageListeners<'a> { + | ^^ +note: ...so that the reference type `&'a MessageListeners<'_>` does not outlive the data it points at + --> $DIR/impl-implied-bounds-compatibility.rs:12:5 | -LL | #![deny(implied_bounds_entailment)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn listeners<'b>(&'b self) -> &'a MessageListeners<'b> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error +For more information about this error, try `rustc --explain E0495`. diff --git a/tests/ui/inference/issue-103587.stderr b/tests/ui/inference/issue-103587.stderr index b373fbfbb94..589cb7ea7b1 100644 --- a/tests/ui/inference/issue-103587.stderr +++ b/tests/ui/inference/issue-103587.stderr @@ -26,14 +26,10 @@ error[E0308]: mismatched types LL | if None = x { } | ^^^^^^^^ expected `bool`, found `()` | -help: you might have meant to use pattern matching +help: consider adding `let` | LL | if let None = x { } | +++ -help: you might have meant to compare for equality - | -LL | if None == x { } - | + error: aborting due to 3 previous errors diff --git a/tests/ui/inference/type-infer-generalize-ty-var.rs b/tests/ui/inference/type-infer-generalize-ty-var.rs index 8b4a8c32bb2..6bf3c61ada8 100644 --- a/tests/ui/inference/type-infer-generalize-ty-var.rs +++ b/tests/ui/inference/type-infer-generalize-ty-var.rs @@ -1,6 +1,6 @@ // check-pass // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver #![allow(non_upper_case_globals)] #![allow(dead_code)] diff --git a/tests/ui/intrinsics/const-eval-select-bad.stderr b/tests/ui/intrinsics/const-eval-select-bad.stderr index bf91dc72cc1..85e22178c4a 100644 --- a/tests/ui/intrinsics/const-eval-select-bad.stderr +++ b/tests/ui/intrinsics/const-eval-select-bad.stderr @@ -16,20 +16,24 @@ LL | const_eval_select((), || {}, || {}); = note: expected a function item, found {closure@$DIR/const-eval-select-bad.rs:7:34: 7:36} = help: consult the documentation on `const_eval_select` for more information -error: this argument must be a function item +error[E0277]: expected a `FnOnce()` closure, found `{integer}` --> $DIR/const-eval-select-bad.rs:10:27 | LL | const_eval_select((), 42, 0xDEADBEEF); - | ^^ + | ----------------- ^^ expected an `FnOnce()` closure, found `{integer}` + | | + | required by a bound introduced by this call | - = note: expected a function item, found {integer} - = help: consult the documentation on `const_eval_select` for more information + = help: the trait `FnOnce<()>` is not implemented for `{integer}` + = note: wrap the `{integer}` in a closure with no arguments: `|| { /* code */ }` +note: required by a bound in `const_eval_select` + --> $SRC_DIR/core/src/intrinsics.rs:LL:COL error[E0277]: expected a `FnOnce()` closure, found `{integer}` - --> $DIR/const-eval-select-bad.rs:10:27 + --> $DIR/const-eval-select-bad.rs:10:31 | LL | const_eval_select((), 42, 0xDEADBEEF); - | ----------------- ^^ expected an `FnOnce()` closure, found `{integer}` + | ----------------- ^^^^^^^^^^ expected an `FnOnce()` closure, found `{integer}` | | | required by a bound introduced by this call | @@ -39,26 +43,22 @@ note: required by a bound in `const_eval_select` --> $SRC_DIR/core/src/intrinsics.rs:LL:COL error: this argument must be a function item - --> $DIR/const-eval-select-bad.rs:10:31 + --> $DIR/const-eval-select-bad.rs:10:27 | LL | const_eval_select((), 42, 0xDEADBEEF); - | ^^^^^^^^^^ + | ^^ | = note: expected a function item, found {integer} = help: consult the documentation on `const_eval_select` for more information -error[E0277]: expected a `FnOnce()` closure, found `{integer}` +error: this argument must be a function item --> $DIR/const-eval-select-bad.rs:10:31 | LL | const_eval_select((), 42, 0xDEADBEEF); - | ----------------- ^^^^^^^^^^ expected an `FnOnce()` closure, found `{integer}` - | | - | required by a bound introduced by this call + | ^^^^^^^^^^ | - = help: the trait `FnOnce<()>` is not implemented for `{integer}` - = note: wrap the `{integer}` in a closure with no arguments: `|| { /* code */ }` -note: required by a bound in `const_eval_select` - --> $SRC_DIR/core/src/intrinsics.rs:LL:COL + = note: expected a function item, found {integer} + = help: consult the documentation on `const_eval_select` for more information error[E0271]: expected `bar` to be a fn item that returns `i32`, but it returns `bool` --> $DIR/const-eval-select-bad.rs:32:34 diff --git a/tests/ui/issues/issue-13167.rs b/tests/ui/issues/issue-13167.rs index 9a9f129ec3a..747f652d4af 100644 --- a/tests/ui/issues/issue-13167.rs +++ b/tests/ui/issues/issue-13167.rs @@ -1,7 +1,7 @@ // check-pass // pretty-expanded FIXME #23616 // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver use std::slice; diff --git a/tests/ui/issues/issue-13407.rs b/tests/ui/issues/issue-13407.rs index 7ea81ffb59e..7794be37b85 100644 --- a/tests/ui/issues/issue-13407.rs +++ b/tests/ui/issues/issue-13407.rs @@ -4,6 +4,6 @@ mod A { fn main() { A::C = 1; - //~^ ERROR: invalid left-hand side of assignment - //~| ERROR: struct `C` is private + //~^ ERROR: mismatched types + //~| ERROR: unit struct `C` is private } diff --git a/tests/ui/issues/issue-13407.stderr b/tests/ui/issues/issue-13407.stderr index 54b6c640d9d..ac2eb6581fe 100644 --- a/tests/ui/issues/issue-13407.stderr +++ b/tests/ui/issues/issue-13407.stderr @@ -10,15 +10,18 @@ note: the unit struct `C` is defined here LL | struct C; | ^^^^^^^^^ -error[E0070]: invalid left-hand side of assignment - --> $DIR/issue-13407.rs:6:10 +error[E0308]: mismatched types + --> $DIR/issue-13407.rs:6:5 | +LL | struct C; + | -------- unit struct defined here +... LL | A::C = 1; - | ---- ^ + | ^^^^ - this expression has type `{integer}` | | - | cannot assign to this expression + | expected integer, found `C` error: aborting due to 2 previous errors -Some errors have detailed explanations: E0070, E0603. -For more information about an error, try `rustc --explain E0070`. +Some errors have detailed explanations: E0308, E0603. +For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/issues/issue-13482-2.rs b/tests/ui/issues/issue-13482-2.rs index bbcb954afcc..b5b81dea73e 100644 --- a/tests/ui/issues/issue-13482-2.rs +++ b/tests/ui/issues/issue-13482-2.rs @@ -1,4 +1,4 @@ -// compile-flags:-Z verbose +// compile-flags:-Z verbose-internals fn main() { let x = [1,2]; diff --git a/tests/ui/issues/issue-13497.stderr b/tests/ui/issues/issue-13497.stderr index 236e6b48607..fb3de637a79 100644 --- a/tests/ui/issues/issue-13497.stderr +++ b/tests/ui/issues/issue-13497.stderr @@ -5,10 +5,14 @@ LL | &str | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | &'static str | +++++++ +help: instead, you are more likely to want to return an owned value + | +LL | String + | ~~~~~~ error: aborting due to 1 previous error diff --git a/tests/ui/issues/issue-15734.rs b/tests/ui/issues/issue-15734.rs index 27410d4c3b0..77517f61813 100644 --- a/tests/ui/issues/issue-15734.rs +++ b/tests/ui/issues/issue-15734.rs @@ -1,6 +1,6 @@ // run-pass // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver use std::ops::Index; diff --git a/tests/ui/issues/issue-17441.stderr b/tests/ui/issues/issue-17441.stderr index 4dbe50178cf..29e50b91c7c 100644 --- a/tests/ui/issues/issue-17441.stderr +++ b/tests/ui/issues/issue-17441.stderr @@ -2,13 +2,9 @@ error[E0620]: cast to unsized type: `&[usize; 2]` as `[usize]` --> $DIR/issue-17441.rs:2:16 | LL | let _foo = &[1_usize, 2] as [usize]; - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: consider using an implicit coercion to `&[usize]` instead - --> $DIR/issue-17441.rs:2:16 - | -LL | let _foo = &[1_usize, 2] as [usize]; - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^------- + | | + | help: try casting to a reference instead: `&[usize]` error[E0620]: cast to unsized type: `Box<usize>` as `dyn Debug` --> $DIR/issue-17441.rs:5:16 diff --git a/tests/ui/issues/issue-21763.stderr b/tests/ui/issues/issue-21763.stderr index 3d623985cbb..135b705eeef 100644 --- a/tests/ui/issues/issue-21763.stderr +++ b/tests/ui/issues/issue-21763.stderr @@ -7,7 +7,7 @@ LL | foo::<HashMap<Rc<()>, Rc<()>>>(); = help: within `(Rc<()>, Rc<()>)`, the trait `Send` is not implemented for `Rc<()>` = note: required because it appears within the type `(Rc<()>, Rc<()>)` = note: required for `hashbrown::raw::RawTable<(Rc<()>, Rc<()>)>` to implement `Send` -note: required because it appears within the type `HashMap<Rc<()>, Rc<()>, RandomState>` +note: required because it appears within the type `hashbrown::map::HashMap<Rc<()>, Rc<()>, RandomState>` --> $HASHBROWN_SRC_LOCATION note: required because it appears within the type `HashMap<Rc<()>, Rc<()>>` --> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL diff --git a/tests/ui/issues/issue-22638.rs b/tests/ui/issues/issue-22638.rs index c2407227c2b..67fd147ae23 100644 --- a/tests/ui/issues/issue-22638.rs +++ b/tests/ui/issues/issue-22638.rs @@ -1,6 +1,7 @@ // build-fail // normalize-stderr-test: "<\{closure@.+`" -> "$$CLOSURE`" // normalize-stderr-test: ".nll/" -> "/" +// ignore-compare-mode-next-solver (hangs) #![allow(unused)] diff --git a/tests/ui/issues/issue-22638.stderr b/tests/ui/issues/issue-22638.stderr index a372078abd8..45290f6afe9 100644 --- a/tests/ui/issues/issue-22638.stderr +++ b/tests/ui/issues/issue-22638.stderr @@ -1,11 +1,11 @@ error: reached the recursion limit while instantiating `A::matches::$CLOSURE` - --> $DIR/issue-22638.rs:56:9 + --> $DIR/issue-22638.rs:57:9 | LL | a.matches(f) | ^^^^^^^^^^^^ | note: `A::matches` defined here - --> $DIR/issue-22638.rs:15:5 + --> $DIR/issue-22638.rs:16:5 | LL | pub fn matches<F: Fn()>(&self, f: &F) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/issues/issue-67552.rs b/tests/ui/issues/issue-67552.rs index 7336b873dd6..ec1997ccd5d 100644 --- a/tests/ui/issues/issue-67552.rs +++ b/tests/ui/issues/issue-67552.rs @@ -1,7 +1,6 @@ // build-fail // compile-flags: -Copt-level=0 // normalize-stderr-test: ".nll/" -> "/" -// ignore-compare-mode-next-solver (hangs) fn main() { rec(Empty); diff --git a/tests/ui/issues/issue-67552.stderr b/tests/ui/issues/issue-67552.stderr index 539bd45dbf1..1a8d7248b45 100644 --- a/tests/ui/issues/issue-67552.stderr +++ b/tests/ui/issues/issue-67552.stderr @@ -1,11 +1,11 @@ error: reached the recursion limit while instantiating `rec::<&mut &mut &mut &mut &mut ...>` - --> $DIR/issue-67552.rs:30:9 + --> $DIR/issue-67552.rs:29:9 | LL | rec(identity(&mut it)) | ^^^^^^^^^^^^^^^^^^^^^^ | note: `rec` defined here - --> $DIR/issue-67552.rs:23:1 + --> $DIR/issue-67552.rs:22:1 | LL | / fn rec<T>(mut it: T) LL | | where diff --git a/tests/ui/kindck/kindck-send-object1.stderr b/tests/ui/kindck/kindck-send-object1.stderr index 269193f73b4..c0d516e3f62 100644 --- a/tests/ui/kindck/kindck-send-object1.stderr +++ b/tests/ui/kindck/kindck-send-object1.stderr @@ -20,7 +20,7 @@ LL | assert_send::<Box<dyn Dummy + 'a>>(); | = help: the trait `Send` is not implemented for `(dyn Dummy + 'a)` = note: required for `Unique<(dyn Dummy + 'a)>` to implement `Send` -note: required because it appears within the type `Box<dyn Dummy>` +note: required because it appears within the type `Box<(dyn Dummy + 'a)>` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL note: required by a bound in `assert_send` --> $DIR/kindck-send-object1.rs:5:18 diff --git a/tests/ui/lang-items/lang-item-generic-requirements.rs b/tests/ui/lang-items/lang-item-generic-requirements.rs index 3d33adf6831..21bd7187e15 100644 --- a/tests/ui/lang-items/lang-item-generic-requirements.rs +++ b/tests/ui/lang-items/lang-item-generic-requirements.rs @@ -22,6 +22,8 @@ trait MyIndex<'a, T> {} #[lang = "phantom_data"] //~^ ERROR `phantom_data` language item must be applied to a struct with 1 generic argument struct MyPhantomData<T, U>; +//~^ ERROR parameter `T` is never used +//~| ERROR parameter `U` is never used #[lang = "owned_box"] //~^ ERROR `owned_box` language item must be applied to a struct with at least 1 generic argument @@ -40,6 +42,7 @@ fn ice() { let r = 5; let a = 6; r + a; + //~^ ERROR cannot add `{integer}` to `{integer}` // Use drop in place my_ptr_drop(); diff --git a/tests/ui/lang-items/lang-item-generic-requirements.stderr b/tests/ui/lang-items/lang-item-generic-requirements.stderr index 4d349a25f9c..8072e6797e4 100644 --- a/tests/ui/lang-items/lang-item-generic-requirements.stderr +++ b/tests/ui/lang-items/lang-item-generic-requirements.stderr @@ -33,7 +33,7 @@ LL | struct MyPhantomData<T, U>; | ------ this struct has 2 generic arguments error[E0718]: `owned_box` language item must be applied to a struct with at least 1 generic argument - --> $DIR/lang-item-generic-requirements.rs:26:1 + --> $DIR/lang-item-generic-requirements.rs:28:1 | LL | #[lang = "owned_box"] | ^^^^^^^^^^^^^^^^^^^^^ @@ -42,7 +42,7 @@ LL | struct Foo; | - this struct has 0 generic arguments error[E0718]: `start` language item must be applied to a function with 1 generic argument - --> $DIR/lang-item-generic-requirements.rs:32:1 + --> $DIR/lang-item-generic-requirements.rs:34:1 | LL | #[lang = "start"] | ^^^^^^^^^^^^^^^^^ @@ -50,6 +50,35 @@ LL | LL | fn start(_: *const u8, _: isize, _: *const *const u8) -> isize { | - this function has 0 generic arguments -error: aborting due to 6 previous errors +error[E0392]: parameter `T` is never used + --> $DIR/lang-item-generic-requirements.rs:24:22 + | +LL | struct MyPhantomData<T, U>; + | ^ unused parameter + | + = help: consider removing `T` or referring to it in a field + = help: if you intended `T` to be a const parameter, use `const T: usize` instead + +error[E0392]: parameter `U` is never used + --> $DIR/lang-item-generic-requirements.rs:24:25 + | +LL | struct MyPhantomData<T, U>; + | ^ unused parameter + | + = help: consider removing `U` or referring to it in a field + = help: if you intended `U` to be a const parameter, use `const U: usize` instead + +error[E0369]: cannot add `{integer}` to `{integer}` + --> $DIR/lang-item-generic-requirements.rs:44:7 + | +LL | r + a; + | - ^ - {integer} + | | + | {integer} + +error: requires `copy` lang_item + +error: aborting due to 10 previous errors -For more information about this error, try `rustc --explain E0718`. +Some errors have detailed explanations: E0369, E0392, E0718. +For more information about an error, try `rustc --explain E0369`. diff --git a/tests/ui/lazy-type-alias/coerce-behind-lazy.rs b/tests/ui/lazy-type-alias/coerce-behind-lazy.rs index 745eadb9625..ec9a6739975 100644 --- a/tests/ui/lazy-type-alias/coerce-behind-lazy.rs +++ b/tests/ui/lazy-type-alias/coerce-behind-lazy.rs @@ -1,6 +1,6 @@ // check-pass // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver #![feature(lazy_type_alias)] //~^ WARN the feature `lazy_type_alias` is incomplete diff --git a/tests/ui/lifetimes/issue-26638.stderr b/tests/ui/lifetimes/issue-26638.stderr index e61158a5d4d..ee958686259 100644 --- a/tests/ui/lifetimes/issue-26638.stderr +++ b/tests/ui/lifetimes/issue-26638.stderr @@ -17,10 +17,18 @@ LL | fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() } | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | fn parse_type_2(iter: fn(&u8)->&u8) -> &'static str { iter() } | +++++++ +help: instead, you are more likely to want to change the argument to be borrowed... + | +LL | fn parse_type_2(iter: &fn(&u8)->&u8) -> &str { iter() } + | + +help: ...or alternatively, you might want to return an owned value + | +LL | fn parse_type_2(iter: fn(&u8)->&u8) -> String { iter() } + | ~~~~~~ error[E0106]: missing lifetime specifier --> $DIR/issue-26638.rs:10:22 @@ -29,10 +37,14 @@ LL | fn parse_type_3() -> &str { unimplemented!() } | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | fn parse_type_3() -> &'static str { unimplemented!() } | +++++++ +help: instead, you are more likely to want to return an owned value + | +LL | fn parse_type_3() -> String { unimplemented!() } + | ~~~~~~ error[E0308]: mismatched types --> $DIR/issue-26638.rs:1:69 diff --git a/tests/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr b/tests/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr index 5eee953ef18..23ef36888f0 100644 --- a/tests/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr +++ b/tests/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr @@ -5,10 +5,15 @@ LL | fn f() -> &isize { | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | fn f() -> &'static isize { | +++++++ +help: instead, you are more likely to want to return an owned value + | +LL - fn f() -> &isize { +LL + fn f() -> isize { + | error[E0106]: missing lifetime specifier --> $DIR/lifetime-elision-return-type-requires-explicit-lifetime.rs:7:33 @@ -41,10 +46,19 @@ LL | fn i(_x: isize) -> &isize { | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | fn i(_x: isize) -> &'static isize { | +++++++ +help: instead, you are more likely to want to change the argument to be borrowed... + | +LL | fn i(_x: &isize) -> &isize { + | + +help: ...or alternatively, you might want to return an owned value + | +LL - fn i(_x: isize) -> &isize { +LL + fn i(_x: isize) -> isize { + | error[E0106]: missing lifetime specifier --> $DIR/lifetime-elision-return-type-requires-explicit-lifetime.rs:34:24 @@ -53,10 +67,19 @@ LL | fn j(_x: StaticStr) -> &isize { | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | fn j(_x: StaticStr) -> &'static isize { | +++++++ +help: instead, you are more likely to want to change the argument to be borrowed... + | +LL | fn j(_x: &StaticStr) -> &isize { + | + +help: ...or alternatively, you might want to return an owned value + | +LL - fn j(_x: StaticStr) -> &isize { +LL + fn j(_x: StaticStr) -> isize { + | error[E0106]: missing lifetime specifier --> $DIR/lifetime-elision-return-type-requires-explicit-lifetime.rs:40:49 diff --git a/tests/ui/lint/crate_level_only_lint.rs b/tests/ui/lint/crate_level_only_lint.rs index d9673faa214..6679cc0862f 100644 --- a/tests/ui/lint/crate_level_only_lint.rs +++ b/tests/ui/lint/crate_level_only_lint.rs @@ -3,20 +3,14 @@ mod foo { #![allow(uncommon_codepoints)] //~^ ERROR allow(uncommon_codepoints) is ignored unless specified at crate level [unused_attributes] -//~| ERROR allow(uncommon_codepoints) is ignored unless specified at crate level [unused_attributes] -//~| ERROR allow(uncommon_codepoints) is ignored unless specified at crate level [unused_attributes] #[allow(uncommon_codepoints)] //~^ ERROR allow(uncommon_codepoints) is ignored unless specified at crate level [unused_attributes] -//~| ERROR allow(uncommon_codepoints) is ignored unless specified at crate level [unused_attributes] -//~| ERROR allow(uncommon_codepoints) is ignored unless specified at crate level [unused_attributes] const BAR: f64 = 0.000001; } #[allow(uncommon_codepoints)] //~^ ERROR allow(uncommon_codepoints) is ignored unless specified at crate level [unused_attributes] -//~| ERROR allow(uncommon_codepoints) is ignored unless specified at crate level [unused_attributes] -//~| ERROR allow(uncommon_codepoints) is ignored unless specified at crate level [unused_attributes] fn main() { } diff --git a/tests/ui/lint/crate_level_only_lint.stderr b/tests/ui/lint/crate_level_only_lint.stderr index fbb1ec381c8..34d27f873f6 100644 --- a/tests/ui/lint/crate_level_only_lint.stderr +++ b/tests/ui/lint/crate_level_only_lint.stderr @@ -11,64 +11,16 @@ LL | #![deny(uncommon_codepoints, unused_attributes)] | ^^^^^^^^^^^^^^^^^ error: allow(uncommon_codepoints) is ignored unless specified at crate level - --> $DIR/crate_level_only_lint.rs:9:9 + --> $DIR/crate_level_only_lint.rs:7:9 | LL | #[allow(uncommon_codepoints)] | ^^^^^^^^^^^^^^^^^^^ error: allow(uncommon_codepoints) is ignored unless specified at crate level - --> $DIR/crate_level_only_lint.rs:17:9 + --> $DIR/crate_level_only_lint.rs:13:9 | LL | #[allow(uncommon_codepoints)] | ^^^^^^^^^^^^^^^^^^^ -error: allow(uncommon_codepoints) is ignored unless specified at crate level - --> $DIR/crate_level_only_lint.rs:4:10 - | -LL | #![allow(uncommon_codepoints)] - | ^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: allow(uncommon_codepoints) is ignored unless specified at crate level - --> $DIR/crate_level_only_lint.rs:9:9 - | -LL | #[allow(uncommon_codepoints)] - | ^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: allow(uncommon_codepoints) is ignored unless specified at crate level - --> $DIR/crate_level_only_lint.rs:17:9 - | -LL | #[allow(uncommon_codepoints)] - | ^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: allow(uncommon_codepoints) is ignored unless specified at crate level - --> $DIR/crate_level_only_lint.rs:4:10 - | -LL | #![allow(uncommon_codepoints)] - | ^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: allow(uncommon_codepoints) is ignored unless specified at crate level - --> $DIR/crate_level_only_lint.rs:9:9 - | -LL | #[allow(uncommon_codepoints)] - | ^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: allow(uncommon_codepoints) is ignored unless specified at crate level - --> $DIR/crate_level_only_lint.rs:17:9 - | -LL | #[allow(uncommon_codepoints)] - | ^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: aborting due to 9 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.rs b/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.rs index 2003e1e293a..a478153b3f4 100644 --- a/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.rs +++ b/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.rs @@ -15,6 +15,10 @@ struct Bar { _h: usize, } +// Issue 119267: this should not ICE. +#[derive(Debug)] +struct Foo(usize, #[allow(unused)] usize); + fn main() { Bar { a: 1, diff --git a/tests/ui/lint/expansion-time.stderr b/tests/ui/lint/expansion-time.stderr index 064ee5fadb1..626e51dd00c 100644 --- a/tests/ui/lint/expansion-time.stderr +++ b/tests/ui/lint/expansion-time.stderr @@ -54,3 +54,18 @@ LL | #[warn(incomplete_include)] warning: 4 warnings emitted +Future incompatibility report: Future breakage diagnostic: +warning: use of unstable library feature 'test': `bench` is a part of custom test frameworks which are unstable + --> $DIR/expansion-time.rs:14:7 + | +LL | #[bench] + | ^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266> +note: the lint level is defined here + --> $DIR/expansion-time.rs:12:8 + | +LL | #[warn(soft_unstable)] + | ^^^^^^^^^^^^^ + diff --git a/tests/ui/lint/forbid-group-group-2.rs b/tests/ui/lint/forbid-group-group-2.rs index b12fd72da74..b3d3e30fb8d 100644 --- a/tests/ui/lint/forbid-group-group-2.rs +++ b/tests/ui/lint/forbid-group-group-2.rs @@ -11,16 +11,4 @@ //~| WARNING previously accepted by the compiler //~| ERROR incompatible with previous //~| WARNING previously accepted by the compiler -//~| ERROR incompatible with previous -//~| WARNING previously accepted by the compiler -//~| ERROR incompatible with previous -//~| WARNING previously accepted by the compiler -//~| ERROR incompatible with previous -//~| WARNING previously accepted by the compiler -//~| ERROR incompatible with previous -//~| WARNING previously accepted by the compiler -//~| ERROR incompatible with previous -//~| WARNING previously accepted by the compiler -//~| ERROR incompatible with previous -//~| WARNING previously accepted by the compiler fn main() {} diff --git a/tests/ui/lint/forbid-group-group-2.stderr b/tests/ui/lint/forbid-group-group-2.stderr index 4a2c8fbd68a..80e2f566eb8 100644 --- a/tests/ui/lint/forbid-group-group-2.stderr +++ b/tests/ui/lint/forbid-group-group-2.stderr @@ -41,83 +41,5 @@ LL | #[allow(nonstandard_style)] = note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670> = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: allow(nonstandard_style) incompatible with previous forbid - --> $DIR/forbid-group-group-2.rs:7:9 - | -LL | #![forbid(warnings)] - | -------- `forbid` level set here -... -LL | #[allow(nonstandard_style)] - | ^^^^^^^^^^^^^^^^^ overruled by previous forbid - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670> - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: allow(nonstandard_style) incompatible with previous forbid - --> $DIR/forbid-group-group-2.rs:7:9 - | -LL | #![forbid(warnings)] - | -------- `forbid` level set here -... -LL | #[allow(nonstandard_style)] - | ^^^^^^^^^^^^^^^^^ overruled by previous forbid - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670> - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: allow(nonstandard_style) incompatible with previous forbid - --> $DIR/forbid-group-group-2.rs:7:9 - | -LL | #![forbid(warnings)] - | -------- `forbid` level set here -... -LL | #[allow(nonstandard_style)] - | ^^^^^^^^^^^^^^^^^ overruled by previous forbid - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670> - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: allow(nonstandard_style) incompatible with previous forbid - --> $DIR/forbid-group-group-2.rs:7:9 - | -LL | #![forbid(warnings)] - | -------- `forbid` level set here -... -LL | #[allow(nonstandard_style)] - | ^^^^^^^^^^^^^^^^^ overruled by previous forbid - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670> - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: allow(nonstandard_style) incompatible with previous forbid - --> $DIR/forbid-group-group-2.rs:7:9 - | -LL | #![forbid(warnings)] - | -------- `forbid` level set here -... -LL | #[allow(nonstandard_style)] - | ^^^^^^^^^^^^^^^^^ overruled by previous forbid - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670> - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: allow(nonstandard_style) incompatible with previous forbid - --> $DIR/forbid-group-group-2.rs:7:9 - | -LL | #![forbid(warnings)] - | -------- `forbid` level set here -... -LL | #[allow(nonstandard_style)] - | ^^^^^^^^^^^^^^^^^ overruled by previous forbid - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670> - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: aborting due to 9 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/lint/forbid-group-member.rs b/tests/ui/lint/forbid-group-member.rs index 664edeaa8b4..d03e858438b 100644 --- a/tests/ui/lint/forbid-group-member.rs +++ b/tests/ui/lint/forbid-group-member.rs @@ -8,10 +8,6 @@ #[allow(unused_variables)] //~^ WARNING incompatible with previous forbid //~| WARNING previously accepted -//~| WARNING incompatible with previous forbid -//~| WARNING previously accepted -//~| WARNING incompatible with previous forbid -//~| WARNING previously accepted fn main() { let a: (); } diff --git a/tests/ui/lint/forbid-group-member.stderr b/tests/ui/lint/forbid-group-member.stderr index ddaaafa12ec..8794591bd31 100644 --- a/tests/ui/lint/forbid-group-member.stderr +++ b/tests/ui/lint/forbid-group-member.stderr @@ -11,31 +11,5 @@ LL | #[allow(unused_variables)] = note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670> = note: `#[warn(forbidden_lint_groups)]` on by default -warning: allow(unused_variables) incompatible with previous forbid - --> $DIR/forbid-group-member.rs:8:9 - | -LL | #![forbid(unused)] - | ------ `forbid` level set here -LL | -LL | #[allow(unused_variables)] - | ^^^^^^^^^^^^^^^^ overruled by previous forbid - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670> - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: allow(unused_variables) incompatible with previous forbid - --> $DIR/forbid-group-member.rs:8:9 - | -LL | #![forbid(unused)] - | ------ `forbid` level set here -LL | -LL | #[allow(unused_variables)] - | ^^^^^^^^^^^^^^^^ overruled by previous forbid - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670> - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: 3 warnings emitted +warning: 1 warning emitted diff --git a/tests/ui/lint/forbid-member-group.rs b/tests/ui/lint/forbid-member-group.rs index e2f76825a2d..d1874aa81a5 100644 --- a/tests/ui/lint/forbid-member-group.rs +++ b/tests/ui/lint/forbid-member-group.rs @@ -5,7 +5,6 @@ #[allow(unused)] //~^ ERROR incompatible with previous forbid -//~| ERROR incompatible with previous forbid fn main() { let a: (); } diff --git a/tests/ui/lint/forbid-member-group.stderr b/tests/ui/lint/forbid-member-group.stderr index 612dccd8d6c..9b32c00a3c3 100644 --- a/tests/ui/lint/forbid-member-group.stderr +++ b/tests/ui/lint/forbid-member-group.stderr @@ -7,17 +7,6 @@ LL | LL | #[allow(unused)] | ^^^^^^ overruled by previous forbid -error[E0453]: allow(unused) incompatible with previous forbid - --> $DIR/forbid-member-group.rs:6:9 - | -LL | #![forbid(unused_variables)] - | ---------------- `forbid` level set here -LL | -LL | #[allow(unused)] - | ^^^^^^ overruled by previous forbid - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0453`. diff --git a/tests/ui/lint/issue-80988.rs b/tests/ui/lint/issue-80988.rs index 1e116206f7b..5b910f1d8df 100644 --- a/tests/ui/lint/issue-80988.rs +++ b/tests/ui/lint/issue-80988.rs @@ -7,8 +7,4 @@ #[deny(warnings)] //~^ WARNING incompatible with previous forbid //~| WARNING being phased out -//~| WARNING incompatible with previous forbid -//~| WARNING being phased out -//~| WARNING incompatible with previous forbid -//~| WARNING being phased out fn main() {} diff --git a/tests/ui/lint/issue-80988.stderr b/tests/ui/lint/issue-80988.stderr index 7a65881b5ed..afc93fcfeef 100644 --- a/tests/ui/lint/issue-80988.stderr +++ b/tests/ui/lint/issue-80988.stderr @@ -11,31 +11,5 @@ LL | #[deny(warnings)] = note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670> = note: `#[warn(forbidden_lint_groups)]` on by default -warning: deny(warnings) incompatible with previous forbid - --> $DIR/issue-80988.rs:7:8 - | -LL | #![forbid(warnings)] - | -------- `forbid` level set here -LL | -LL | #[deny(warnings)] - | ^^^^^^^^ overruled by previous forbid - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670> - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: deny(warnings) incompatible with previous forbid - --> $DIR/issue-80988.rs:7:8 - | -LL | #![forbid(warnings)] - | -------- `forbid` level set here -LL | -LL | #[deny(warnings)] - | ^^^^^^^^ overruled by previous forbid - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670> - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: 3 warnings emitted +warning: 1 warning emitted diff --git a/tests/ui/lint/lint-forbid-attr.rs b/tests/ui/lint/lint-forbid-attr.rs index 6d4cfd83424..270a379c2f8 100644 --- a/tests/ui/lint/lint-forbid-attr.rs +++ b/tests/ui/lint/lint-forbid-attr.rs @@ -2,6 +2,5 @@ #[allow(deprecated)] //~^ ERROR allow(deprecated) incompatible -//~| ERROR allow(deprecated) incompatible fn main() { } diff --git a/tests/ui/lint/lint-forbid-attr.stderr b/tests/ui/lint/lint-forbid-attr.stderr index bd476a0e362..fa7106b5e11 100644 --- a/tests/ui/lint/lint-forbid-attr.stderr +++ b/tests/ui/lint/lint-forbid-attr.stderr @@ -7,17 +7,6 @@ LL | LL | #[allow(deprecated)] | ^^^^^^^^^^ overruled by previous forbid -error[E0453]: allow(deprecated) incompatible with previous forbid - --> $DIR/lint-forbid-attr.rs:3:9 - | -LL | #![forbid(deprecated)] - | ---------- `forbid` level set here -LL | -LL | #[allow(deprecated)] - | ^^^^^^^^^^ overruled by previous forbid - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0453`. diff --git a/tests/ui/lint/lint-forbid-cmdline.rs b/tests/ui/lint/lint-forbid-cmdline.rs index 5246ccb57a6..32a92e09b14 100644 --- a/tests/ui/lint/lint-forbid-cmdline.rs +++ b/tests/ui/lint/lint-forbid-cmdline.rs @@ -1,6 +1,5 @@ // compile-flags: -F deprecated #[allow(deprecated)] //~ ERROR allow(deprecated) incompatible - //~| ERROR allow(deprecated) incompatible fn main() { } diff --git a/tests/ui/lint/lint-forbid-cmdline.stderr b/tests/ui/lint/lint-forbid-cmdline.stderr index ed49a2cb427..3920a742976 100644 --- a/tests/ui/lint/lint-forbid-cmdline.stderr +++ b/tests/ui/lint/lint-forbid-cmdline.stderr @@ -6,15 +6,6 @@ LL | #[allow(deprecated)] | = note: `forbid` lint level was set on command line -error[E0453]: allow(deprecated) incompatible with previous forbid - --> $DIR/lint-forbid-cmdline.rs:3:9 - | -LL | #[allow(deprecated)] - | ^^^^^^^^^^ overruled by previous forbid - | - = note: `forbid` lint level was set on command line - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0453`. diff --git a/tests/ui/lint/must_not_suspend/gated.rs b/tests/ui/lint/must_not_suspend/gated.rs index b73a7655529..fe8192b0eaa 100644 --- a/tests/ui/lint/must_not_suspend/gated.rs +++ b/tests/ui/lint/must_not_suspend/gated.rs @@ -3,8 +3,6 @@ // edition:2018 #![deny(must_not_suspend)] //~^ WARNING unknown lint: `must_not_suspend` -//~| WARNING unknown lint: `must_not_suspend` -//~| WARNING unknown lint: `must_not_suspend` async fn other() {} diff --git a/tests/ui/lint/must_not_suspend/gated.stderr b/tests/ui/lint/must_not_suspend/gated.stderr index f0d2117d42b..c238c1f3351 100644 --- a/tests/ui/lint/must_not_suspend/gated.stderr +++ b/tests/ui/lint/must_not_suspend/gated.stderr @@ -9,27 +9,5 @@ LL | #![deny(must_not_suspend)] = help: add `#![feature(must_not_suspend)]` to the crate attributes to enable = note: `#[warn(unknown_lints)]` on by default -warning: unknown lint: `must_not_suspend` - --> $DIR/gated.rs:4:1 - | -LL | #![deny(must_not_suspend)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `must_not_suspend` lint is unstable - = note: see issue #83310 <https://github.com/rust-lang/rust/issues/83310> for more information - = help: add `#![feature(must_not_suspend)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: unknown lint: `must_not_suspend` - --> $DIR/gated.rs:4:1 - | -LL | #![deny(must_not_suspend)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `must_not_suspend` lint is unstable - = note: see issue #83310 <https://github.com/rust-lang/rust/issues/83310> for more information - = help: add `#![feature(must_not_suspend)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: 3 warnings emitted +warning: 1 warning emitted diff --git a/tests/ui/lint/ptr_null_checks.rs b/tests/ui/lint/ptr_null_checks.rs index 3028084e962..4925019be1e 100644 --- a/tests/ui/lint/ptr_null_checks.rs +++ b/tests/ui/lint/ptr_null_checks.rs @@ -1,7 +1,5 @@ // check-pass -#![feature(ptr_from_ref)] - use std::ptr; extern "C" fn c_fn() {} diff --git a/tests/ui/lint/ptr_null_checks.stderr b/tests/ui/lint/ptr_null_checks.stderr index 0edc1b86536..70a27790c5b 100644 --- a/tests/ui/lint/ptr_null_checks.stderr +++ b/tests/ui/lint/ptr_null_checks.stderr @@ -1,5 +1,5 @@ warning: function pointers are not nullable, so checking them for null will always return false - --> $DIR/ptr_null_checks.rs:14:8 + --> $DIR/ptr_null_checks.rs:12:8 | LL | if (fn_ptr as *mut ()).is_null() {} | ^------^^^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | if (fn_ptr as *mut ()).is_null() {} = note: `#[warn(useless_ptr_null_checks)]` on by default warning: function pointers are not nullable, so checking them for null will always return false - --> $DIR/ptr_null_checks.rs:16:8 + --> $DIR/ptr_null_checks.rs:14:8 | LL | if (fn_ptr as *const u8).is_null() {} | ^------^^^^^^^^^^^^^^^^^^^^^^^^ @@ -20,7 +20,7 @@ LL | if (fn_ptr as *const u8).is_null() {} = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value warning: function pointers are not nullable, so checking them for null will always return false - --> $DIR/ptr_null_checks.rs:18:8 + --> $DIR/ptr_null_checks.rs:16:8 | LL | if (fn_ptr as *const ()) == std::ptr::null() {} | ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -30,7 +30,7 @@ LL | if (fn_ptr as *const ()) == std::ptr::null() {} = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value warning: function pointers are not nullable, so checking them for null will always return false - --> $DIR/ptr_null_checks.rs:20:8 + --> $DIR/ptr_null_checks.rs:18:8 | LL | if (fn_ptr as *mut ()) == std::ptr::null_mut() {} | ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -40,7 +40,7 @@ LL | if (fn_ptr as *mut ()) == std::ptr::null_mut() {} = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value warning: function pointers are not nullable, so checking them for null will always return false - --> $DIR/ptr_null_checks.rs:22:8 + --> $DIR/ptr_null_checks.rs:20:8 | LL | if (fn_ptr as *const ()) == (0 as *const ()) {} | ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -50,7 +50,7 @@ LL | if (fn_ptr as *const ()) == (0 as *const ()) {} = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value warning: function pointers are not nullable, so checking them for null will always return false - --> $DIR/ptr_null_checks.rs:24:8 + --> $DIR/ptr_null_checks.rs:22:8 | LL | if <*const _>::is_null(fn_ptr as *const ()) {} | ^^^^^^^^^^^^^^^^^^^^------^^^^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL | if <*const _>::is_null(fn_ptr as *const ()) {} = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value warning: function pointers are not nullable, so checking them for null will always return false - --> $DIR/ptr_null_checks.rs:26:8 + --> $DIR/ptr_null_checks.rs:24:8 | LL | if (fn_ptr as *mut fn() as *const fn() as *const ()).is_null() {} | ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -70,7 +70,7 @@ LL | if (fn_ptr as *mut fn() as *const fn() as *const ()).is_null() {} = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value warning: function pointers are not nullable, so checking them for null will always return false - --> $DIR/ptr_null_checks.rs:28:8 + --> $DIR/ptr_null_checks.rs:26:8 | LL | if (fn_ptr as *mut fn() as *const fn()).cast_mut().is_null() {} | ^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -80,7 +80,7 @@ LL | if (fn_ptr as *mut fn() as *const fn()).cast_mut().is_null() {} = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value warning: function pointers are not nullable, so checking them for null will always return false - --> $DIR/ptr_null_checks.rs:30:8 + --> $DIR/ptr_null_checks.rs:28:8 | LL | if ((fn_ptr as *mut fn()).cast() as *const fn()).cast_mut().is_null() {} | ^^------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -90,7 +90,7 @@ LL | if ((fn_ptr as *mut fn()).cast() as *const fn()).cast_mut().is_null() { = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value warning: function pointers are not nullable, so checking them for null will always return false - --> $DIR/ptr_null_checks.rs:32:8 + --> $DIR/ptr_null_checks.rs:30:8 | LL | if (fn_ptr as fn() as *const ()).is_null() {} | ^--------------^^^^^^^^^^^^^^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | if (fn_ptr as fn() as *const ()).is_null() {} = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value warning: function pointers are not nullable, so checking them for null will always return false - --> $DIR/ptr_null_checks.rs:34:8 + --> $DIR/ptr_null_checks.rs:32:8 | LL | if (c_fn as *const fn()).is_null() {} | ^----^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -110,7 +110,7 @@ LL | if (c_fn as *const fn()).is_null() {} = help: wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value warning: references are not nullable, so checking them for null will always return false - --> $DIR/ptr_null_checks.rs:38:8 + --> $DIR/ptr_null_checks.rs:36:8 | LL | if (&mut 8 as *mut i32).is_null() {} | ^------^^^^^^^^^^^^^^^^^^^^^^^ @@ -118,13 +118,13 @@ LL | if (&mut 8 as *mut i32).is_null() {} | expression has type `&mut i32` warning: returned pointer of `from_mut` call is never null, so checking it for null will always return false - --> $DIR/ptr_null_checks.rs:40:8 + --> $DIR/ptr_null_checks.rs:38:8 | LL | if ptr::from_mut(&mut 8).is_null() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: references are not nullable, so checking them for null will always return false - --> $DIR/ptr_null_checks.rs:42:8 + --> $DIR/ptr_null_checks.rs:40:8 | LL | if (&8 as *const i32).is_null() {} | ^--^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -132,25 +132,25 @@ LL | if (&8 as *const i32).is_null() {} | expression has type `&i32` warning: returned pointer of `from_ref` call is never null, so checking it for null will always return false - --> $DIR/ptr_null_checks.rs:44:8 + --> $DIR/ptr_null_checks.rs:42:8 | LL | if ptr::from_ref(&8).is_null() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: returned pointer of `from_ref` call is never null, so checking it for null will always return false - --> $DIR/ptr_null_checks.rs:46:8 + --> $DIR/ptr_null_checks.rs:44:8 | LL | if ptr::from_ref(&8).cast_mut().is_null() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: returned pointer of `from_ref` call is never null, so checking it for null will always return false - --> $DIR/ptr_null_checks.rs:48:8 + --> $DIR/ptr_null_checks.rs:46:8 | LL | if (ptr::from_ref(&8).cast_mut() as *mut i32).is_null() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: references are not nullable, so checking them for null will always return false - --> $DIR/ptr_null_checks.rs:50:8 + --> $DIR/ptr_null_checks.rs:48:8 | LL | if (&8 as *const i32) == std::ptr::null() {} | ^--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -158,7 +158,7 @@ LL | if (&8 as *const i32) == std::ptr::null() {} | expression has type `&i32` warning: references are not nullable, so checking them for null will always return false - --> $DIR/ptr_null_checks.rs:53:8 + --> $DIR/ptr_null_checks.rs:51:8 | LL | if (ref_num as *const i32) == std::ptr::null() {} | ^-------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -166,7 +166,7 @@ LL | if (ref_num as *const i32) == std::ptr::null() {} | expression has type `&i32` warning: references are not nullable, so checking them for null will always return false - --> $DIR/ptr_null_checks.rs:55:8 + --> $DIR/ptr_null_checks.rs:53:8 | LL | if (b"\0" as *const u8).is_null() {} | ^-----^^^^^^^^^^^^^^^^^^^^^^^^ @@ -174,7 +174,7 @@ LL | if (b"\0" as *const u8).is_null() {} | expression has type `&[u8; 1]` warning: references are not nullable, so checking them for null will always return false - --> $DIR/ptr_null_checks.rs:57:8 + --> $DIR/ptr_null_checks.rs:55:8 | LL | if ("aa" as *const str).is_null() {} | ^----^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -182,7 +182,7 @@ LL | if ("aa" as *const str).is_null() {} | expression has type `&str` warning: references are not nullable, so checking them for null will always return false - --> $DIR/ptr_null_checks.rs:59:8 + --> $DIR/ptr_null_checks.rs:57:8 | LL | if (&[1, 2] as *const i32).is_null() {} | ^-------^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -190,7 +190,7 @@ LL | if (&[1, 2] as *const i32).is_null() {} | expression has type `&[i32; 2]` warning: references are not nullable, so checking them for null will always return false - --> $DIR/ptr_null_checks.rs:61:8 + --> $DIR/ptr_null_checks.rs:59:8 | LL | if (&mut [1, 2] as *mut i32) == std::ptr::null_mut() {} | ^-----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -198,7 +198,7 @@ LL | if (&mut [1, 2] as *mut i32) == std::ptr::null_mut() {} | expression has type `&mut [i32; 2]` warning: references are not nullable, so checking them for null will always return false - --> $DIR/ptr_null_checks.rs:63:8 + --> $DIR/ptr_null_checks.rs:61:8 | LL | if (static_i32() as *const i32).is_null() {} | ^------------^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -206,7 +206,7 @@ LL | if (static_i32() as *const i32).is_null() {} | expression has type `&i32` warning: references are not nullable, so checking them for null will always return false - --> $DIR/ptr_null_checks.rs:65:8 + --> $DIR/ptr_null_checks.rs:63:8 | LL | if (&*{ static_i32() } as *const i32).is_null() {} | ^------------------^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -214,13 +214,13 @@ LL | if (&*{ static_i32() } as *const i32).is_null() {} | expression has type `&i32` warning: returned pointer of `as_ptr` call is never null, so checking it for null will always return false - --> $DIR/ptr_null_checks.rs:69:8 + --> $DIR/ptr_null_checks.rs:67:8 | LL | if ptr::NonNull::new(&mut 8).unwrap().as_ptr().is_null() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: returned pointer of `as_ptr` call is never null, so checking it for null will always return false - --> $DIR/ptr_null_checks.rs:71:8 + --> $DIR/ptr_null_checks.rs:69:8 | LL | if ptr::NonNull::<u8>::dangling().as_ptr().is_null() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/lint/reference_casting.rs b/tests/ui/lint/reference_casting.rs index 25e0c75f70d..84267c0af03 100644 --- a/tests/ui/lint/reference_casting.rs +++ b/tests/ui/lint/reference_casting.rs @@ -1,7 +1,5 @@ // check-fail -#![feature(ptr_from_ref)] - extern "C" { // N.B., mutability can be easily incorrect in FFI calls -- as // in C, the default is mutable pointers. @@ -116,6 +114,13 @@ unsafe fn assign_to_ref() { let value = num as *const i32 as *mut i32; *value = 1; //~^ ERROR assigning to `&T` is undefined behavior + let value = num as *const i32; + let value = value as *mut i32; + *value = 1; + //~^ ERROR assigning to `&T` is undefined behavior + let value = num as *const i32 as *mut i32; + *value = 1; + //~^ ERROR assigning to `&T` is undefined behavior let value_rebind = value; *value_rebind = 1; //~^ ERROR assigning to `&T` is undefined behavior diff --git a/tests/ui/lint/reference_casting.stderr b/tests/ui/lint/reference_casting.stderr index 8d5f8da6852..374a58d7b7b 100644 --- a/tests/ui/lint/reference_casting.stderr +++ b/tests/ui/lint/reference_casting.stderr @@ -1,5 +1,5 @@ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:19:16 + --> $DIR/reference_casting.rs:17:16 | LL | let _num = &mut *(num as *const i32 as *mut i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let _num = &mut *(num as *const i32 as *mut i32); = note: `#[deny(invalid_reference_casting)]` on by default error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:21:16 + --> $DIR/reference_casting.rs:19:16 | LL | let _num = &mut *(num as *const i32).cast_mut(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | let _num = &mut *(num as *const i32).cast_mut(); = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:23:16 + --> $DIR/reference_casting.rs:21:16 | LL | let _num = &mut *std::ptr::from_ref(num).cast_mut(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL | let _num = &mut *std::ptr::from_ref(num).cast_mut(); = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:25:16 + --> $DIR/reference_casting.rs:23:16 | LL | let _num = &mut *std::ptr::from_ref({ num }).cast_mut(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -32,7 +32,7 @@ LL | let _num = &mut *std::ptr::from_ref({ num }).cast_mut(); = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:27:16 + --> $DIR/reference_casting.rs:25:16 | LL | let _num = &mut *{ std::ptr::from_ref(num) }.cast_mut(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -40,7 +40,7 @@ LL | let _num = &mut *{ std::ptr::from_ref(num) }.cast_mut(); = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:29:16 + --> $DIR/reference_casting.rs:27:16 | LL | let _num = &mut *(std::ptr::from_ref({ num }) as *mut i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -48,7 +48,7 @@ LL | let _num = &mut *(std::ptr::from_ref({ num }) as *mut i32); = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:31:16 + --> $DIR/reference_casting.rs:29:16 | LL | let _num = &mut *(num as *const i32).cast::<i32>().cast_mut(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -56,7 +56,7 @@ LL | let _num = &mut *(num as *const i32).cast::<i32>().cast_mut(); = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:33:16 + --> $DIR/reference_casting.rs:31:16 | LL | let _num = &mut *(num as *const i32).cast::<i32>().cast_mut().cast_const().cast_mut(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -64,7 +64,7 @@ LL | let _num = &mut *(num as *const i32).cast::<i32>().cast_mut().cast_cons = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:35:16 + --> $DIR/reference_casting.rs:33:16 | LL | let _num = &mut *(std::ptr::from_ref(static_u8()) as *mut i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -72,7 +72,7 @@ LL | let _num = &mut *(std::ptr::from_ref(static_u8()) as *mut i32); = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:37:16 + --> $DIR/reference_casting.rs:35:16 | LL | let _num = &mut *std::mem::transmute::<_, *mut i32>(num); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -80,7 +80,7 @@ LL | let _num = &mut *std::mem::transmute::<_, *mut i32>(num); = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:39:16 + --> $DIR/reference_casting.rs:37:16 | LL | let _num = &mut *(std::mem::transmute::<_, *mut i32>(num) as *mut i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -88,7 +88,7 @@ LL | let _num = &mut *(std::mem::transmute::<_, *mut i32>(num) as *mut i32); = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:41:16 + --> $DIR/reference_casting.rs:39:16 | LL | let _num = &mut *std::cell::UnsafeCell::raw_get( | ________________^ @@ -100,7 +100,7 @@ LL | | ); = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:47:16 + --> $DIR/reference_casting.rs:45:16 | LL | let deferred = num as *const i32 as *mut i32; | ----------------------------- casting happend here @@ -110,7 +110,7 @@ LL | let _num = &mut *deferred; = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:50:16 + --> $DIR/reference_casting.rs:48:16 | LL | let deferred = (std::ptr::from_ref(num) as *const i32 as *const i32).cast_mut() as *mut i32; | ---------------------------------------------------------------------------- casting happend here @@ -120,7 +120,7 @@ LL | let _num = &mut *deferred; = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:53:16 + --> $DIR/reference_casting.rs:51:16 | LL | let deferred = (std::ptr::from_ref(num) as *const i32 as *const i32).cast_mut() as *mut i32; | ---------------------------------------------------------------------------- casting happend here @@ -131,7 +131,7 @@ LL | let _num = &mut *deferred_rebind; = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:55:16 + --> $DIR/reference_casting.rs:53:16 | LL | let _num = &mut *(num as *const _ as usize as *mut i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -139,7 +139,7 @@ LL | let _num = &mut *(num as *const _ as usize as *mut i32); = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:57:16 + --> $DIR/reference_casting.rs:55:16 | LL | let _num = &mut *(std::mem::transmute::<_, *mut _>(num as *const i32) as *mut i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -147,7 +147,7 @@ LL | let _num = &mut *(std::mem::transmute::<_, *mut _>(num as *const i32) a = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:64:16 + --> $DIR/reference_casting.rs:62:16 | LL | let num = NUM as *const i32 as *mut i32; | ----------------------------- casting happend here @@ -158,7 +158,7 @@ LL | let _num = &mut *num; = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:68:16 + --> $DIR/reference_casting.rs:66:16 | LL | let _num = &mut *(cell as *const _ as *mut i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -167,7 +167,7 @@ LL | let _num = &mut *(cell as *const _ as *mut i32); = note: even for types with interior mutability, the only legal way to obtain a mutable pointer from a shared reference is through `UnsafeCell::get` error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:72:9 + --> $DIR/reference_casting.rs:70:9 | LL | &mut *((this as *const _) as *mut _) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -175,7 +175,7 @@ LL | &mut *((this as *const _) as *mut _) = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:77:18 + --> $DIR/reference_casting.rs:75:18 | LL | unsafe { &mut *std::cell::UnsafeCell::raw_get(x as *const _ as *const _) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -183,7 +183,7 @@ LL | unsafe { &mut *std::cell::UnsafeCell::raw_get(x as *const _ as *con = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:82:18 + --> $DIR/reference_casting.rs:80:18 | LL | unsafe { &mut *std::cell::UnsafeCell::raw_get(x as *const _ as *const _) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -191,7 +191,7 @@ LL | unsafe { &mut *std::cell::UnsafeCell::raw_get(x as *const _ as *con = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:92:5 + --> $DIR/reference_casting.rs:90:5 | LL | *(a as *const _ as *mut _) = String::from("Replaced"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -199,7 +199,7 @@ LL | *(a as *const _ as *mut _) = String::from("Replaced"); = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:94:5 + --> $DIR/reference_casting.rs:92:5 | LL | *(a as *const _ as *mut String) += " world"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -207,7 +207,7 @@ LL | *(a as *const _ as *mut String) += " world"; = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:96:5 + --> $DIR/reference_casting.rs:94:5 | LL | *std::ptr::from_ref(num).cast_mut() += 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -215,7 +215,7 @@ LL | *std::ptr::from_ref(num).cast_mut() += 1; = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:98:5 + --> $DIR/reference_casting.rs:96:5 | LL | *std::ptr::from_ref({ num }).cast_mut() += 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -223,7 +223,7 @@ LL | *std::ptr::from_ref({ num }).cast_mut() += 1; = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:100:5 + --> $DIR/reference_casting.rs:98:5 | LL | *{ std::ptr::from_ref(num) }.cast_mut() += 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -231,7 +231,7 @@ LL | *{ std::ptr::from_ref(num) }.cast_mut() += 1; = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:102:5 + --> $DIR/reference_casting.rs:100:5 | LL | *(std::ptr::from_ref({ num }) as *mut i32) += 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -239,7 +239,7 @@ LL | *(std::ptr::from_ref({ num }) as *mut i32) += 1; = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:104:5 + --> $DIR/reference_casting.rs:102:5 | LL | *std::mem::transmute::<_, *mut i32>(num) += 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -247,7 +247,7 @@ LL | *std::mem::transmute::<_, *mut i32>(num) += 1; = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:106:5 + --> $DIR/reference_casting.rs:104:5 | LL | *(std::mem::transmute::<_, *mut i32>(num) as *mut i32) += 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -255,7 +255,7 @@ LL | *(std::mem::transmute::<_, *mut i32>(num) as *mut i32) += 1; = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:108:5 + --> $DIR/reference_casting.rs:106:5 | LL | / std::ptr::write( LL | | @@ -267,7 +267,7 @@ LL | | ); = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:113:5 + --> $DIR/reference_casting.rs:111:5 | LL | *((&std::cell::UnsafeCell::new(0)) as *const _ as *mut i32) = 5; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -276,7 +276,27 @@ LL | *((&std::cell::UnsafeCell::new(0)) as *const _ as *mut i32) = 5; = note: even for types with interior mutability, the only legal way to obtain a mutable pointer from a shared reference is through `UnsafeCell::get` error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:117:5 + --> $DIR/reference_casting.rs:115:5 + | +LL | let value = num as *const i32 as *mut i32; + | ----------------------------- casting happend here +LL | *value = 1; + | ^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> + +error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` + --> $DIR/reference_casting.rs:119:5 + | +LL | let value = value as *mut i32; + | ----------------- casting happend here +LL | *value = 1; + | ^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> + +error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` + --> $DIR/reference_casting.rs:122:5 | LL | let value = num as *const i32 as *mut i32; | ----------------------------- casting happend here @@ -286,7 +306,7 @@ LL | *value = 1; = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:120:5 + --> $DIR/reference_casting.rs:125:5 | LL | let value = num as *const i32 as *mut i32; | ----------------------------- casting happend here @@ -297,7 +317,7 @@ LL | *value_rebind = 1; = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:122:5 + --> $DIR/reference_casting.rs:127:5 | LL | *(num as *const i32).cast::<i32>().cast_mut() = 2; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -305,7 +325,7 @@ LL | *(num as *const i32).cast::<i32>().cast_mut() = 2; = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:124:5 + --> $DIR/reference_casting.rs:129:5 | LL | *(num as *const _ as usize as *mut i32) = 2; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -313,7 +333,7 @@ LL | *(num as *const _ as usize as *mut i32) = 2; = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:126:5 + --> $DIR/reference_casting.rs:131:5 | LL | let value = num as *const i32 as *mut i32; | ----------------------------- casting happend here @@ -324,7 +344,7 @@ LL | std::ptr::write(value, 2); = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:128:5 + --> $DIR/reference_casting.rs:133:5 | LL | let value = num as *const i32 as *mut i32; | ----------------------------- casting happend here @@ -335,7 +355,7 @@ LL | std::ptr::write_unaligned(value, 2); = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:130:5 + --> $DIR/reference_casting.rs:135:5 | LL | let value = num as *const i32 as *mut i32; | ----------------------------- casting happend here @@ -346,12 +366,12 @@ LL | std::ptr::write_volatile(value, 2); = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:134:9 + --> $DIR/reference_casting.rs:139:9 | LL | *(this as *const _ as *mut _) = a; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> -error: aborting due to 40 previous errors +error: aborting due to 42 previous errors diff --git a/tests/ui/lint/unused/issue-119383-if-let-guard.rs b/tests/ui/lint/unused/issue-119383-if-let-guard.rs new file mode 100644 index 00000000000..71197444f45 --- /dev/null +++ b/tests/ui/lint/unused/issue-119383-if-let-guard.rs @@ -0,0 +1,9 @@ +#![feature(if_let_guard)] +#![deny(unused_variables)] + +fn main() { + match () { + () if let Some(b) = Some(()) => {} //~ ERROR unused variable: `b` + _ => {} + } +} diff --git a/tests/ui/lint/unused/issue-119383-if-let-guard.stderr b/tests/ui/lint/unused/issue-119383-if-let-guard.stderr new file mode 100644 index 00000000000..5bf48bb80a8 --- /dev/null +++ b/tests/ui/lint/unused/issue-119383-if-let-guard.stderr @@ -0,0 +1,14 @@ +error: unused variable: `b` + --> $DIR/issue-119383-if-let-guard.rs:6:24 + | +LL | () if let Some(b) = Some(()) => {} + | ^ help: if this is intentional, prefix it with an underscore: `_b` + | +note: the lint level is defined here + --> $DIR/issue-119383-if-let-guard.rs:2:9 + | +LL | #![deny(unused_variables)] + | ^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/macros/issue-118786.rs b/tests/ui/macros/issue-118786.rs new file mode 100644 index 00000000000..84af3a65113 --- /dev/null +++ b/tests/ui/macros/issue-118786.rs @@ -0,0 +1,16 @@ +// compile-flags: --crate-type lib -O -C debug-assertions=yes + +// Regression test for issue 118786 + +macro_rules! make_macro { + ($macro_name:tt) => { + macro_rules! $macro_name { + //~^ ERROR macros that expand to items must be delimited with braces or followed by a semicolon + //~| ERROR macro expansion ignores token `{` and any following + //~| ERROR cannot find macro `macro_rules` in this scope + () => {} + } + } +} + +make_macro!((meow)); diff --git a/tests/ui/macros/issue-118786.stderr b/tests/ui/macros/issue-118786.stderr new file mode 100644 index 00000000000..ca3a40f31c1 --- /dev/null +++ b/tests/ui/macros/issue-118786.stderr @@ -0,0 +1,47 @@ +error: macros that expand to items must be delimited with braces or followed by a semicolon + --> $DIR/issue-118786.rs:7:22 + | +LL | macro_rules! $macro_name { + | ^^^^^^^^^^^ + | +help: change the delimiters to curly braces + | +LL | macro_rules! {} { + | ~ + +help: add a semicolon + | +LL | macro_rules! $macro_name; { + | + + +error: macro expansion ignores token `{` and any following + --> $DIR/issue-118786.rs:7:34 + | +LL | macro_rules! $macro_name { + | ^ +... +LL | make_macro!((meow)); + | ------------------- caused by the macro expansion here + | + = note: the usage of `make_macro!` is likely invalid in item context + +error: cannot find macro `macro_rules` in this scope + --> $DIR/issue-118786.rs:7:9 + | +LL | macro_rules! $macro_name { + | ^^^^^^^^^^^ +... +LL | make_macro!((meow)); + | ------------------- in this macro invocation + | +note: maybe you have forgotten to define a name for this `macro_rules!` + --> $DIR/issue-118786.rs:7:9 + | +LL | macro_rules! $macro_name { + | ^^^^^^^^^^^ +... +LL | make_macro!((meow)); + | ------------------- in this macro invocation + = note: this error originates in the macro `make_macro` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 3 previous errors + diff --git a/tests/ui/macros/rfc-3086-metavar-expr/count-and-length-are-distinct.rs b/tests/ui/macros/rfc-3086-metavar-expr/count-and-length-are-distinct.rs index ab8d95a41d0..1b8ce10ccce 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/count-and-length-are-distinct.rs +++ b/tests/ui/macros/rfc-3086-metavar-expr/count-and-length-are-distinct.rs @@ -10,11 +10,11 @@ fn main() { $( // inner-most repetition $( - ${ignore(l)} ${index()}, ${length()}, + ${ignore($l)} ${index()}, ${length()}, )* - ${count(l)}, ${index()}, ${length()}, + ${count($l)}, ${index()}, ${length()}, )* - ${count(l)}, + ${count($l)}, ] }; } @@ -72,30 +72,30 @@ fn main() { &[ $( $( $( &[ - ${ignore(i)} ${count(i, 0)}, + ${ignore($i)} ${count($i, 0)}, ][..], )* )* )* $( $( &[ - ${ignore(i)} ${count(i, 0)}, - ${ignore(i)} ${count(i, 1)}, + ${ignore($i)} ${count($i, 0)}, + ${ignore($i)} ${count($i, 1)}, ][..], )* )* $( &[ - ${ignore(i)} ${count(i, 0)}, - ${ignore(i)} ${count(i, 1)}, - ${ignore(i)} ${count(i, 2)}, + ${ignore($i)} ${count($i, 0)}, + ${ignore($i)} ${count($i, 1)}, + ${ignore($i)} ${count($i, 2)}, ][..], )* &[ - ${count(i, 0)}, - ${count(i, 1)}, - ${count(i, 2)}, - ${count(i, 3)}, + ${count($i, 0)}, + ${count($i, 1)}, + ${count($i, 2)}, + ${count($i, 3)}, ][..] ][..] } @@ -133,23 +133,23 @@ fn main() { &[7][..], // (a b c) (d e f) - &[2, 6][..], + &[6, 2][..], // (g h) (i j k l m) - &[2, 7][..], + &[7, 2][..], // (n) &[1, 1][..], // (o) (p q) (r s) - &[3, 5][..], + &[5, 3][..], // (t u v w x y z) - &[1, 7][..], + &[7, 1][..], // [ (a b c) (d e f) ] // [ (g h) (i j k l m) ] // [ (n) ] - &[3, 5, 14][..], + &[14, 5, 3][..], // [ (o) (p q) (r s) ] // [ (t u v w x y z) ] - &[2, 4, 12][..], + &[12, 4, 2][..], // { // [ (a b c) (d e f) ] @@ -160,7 +160,7 @@ fn main() { // [ (o) (p q) (r s) ] // [ (t u v w x y z) ] // } - &[2, 5, 9, 26][..] + &[26, 9, 5, 2][..] ][..] ); @@ -170,31 +170,31 @@ fn main() { &[ $( $( $( $( &[ - ${ignore(i)} ${length(3)}, - ${ignore(i)} ${length(2)}, - ${ignore(i)} ${length(1)}, - ${ignore(i)} ${length(0)}, + ${ignore($i)} ${length(3)}, + ${ignore($i)} ${length(2)}, + ${ignore($i)} ${length(1)}, + ${ignore($i)} ${length(0)}, ][..], )* )* )* )* $( $( $( &[ - ${ignore(i)} ${length(2)}, - ${ignore(i)} ${length(1)}, - ${ignore(i)} ${length(0)}, + ${ignore($i)} ${length(2)}, + ${ignore($i)} ${length(1)}, + ${ignore($i)} ${length(0)}, ][..], )* )* )* $( $( &[ - ${ignore(i)} ${length(1)}, - ${ignore(i)} ${length(0)}, + ${ignore($i)} ${length(1)}, + ${ignore($i)} ${length(0)}, ][..], )* )* $( &[ - ${ignore(i)} ${length(0)}, + ${ignore($i)} ${length(0)}, ][..], )* ][..] diff --git a/tests/ui/macros/rfc-3086-metavar-expr/feature-gate-macro_metavar_expr.rs b/tests/ui/macros/rfc-3086-metavar-expr/feature-gate-macro_metavar_expr.rs index d05cd1b31bc..950e70153ba 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/feature-gate-macro_metavar_expr.rs +++ b/tests/ui/macros/rfc-3086-metavar-expr/feature-gate-macro_metavar_expr.rs @@ -5,14 +5,14 @@ /// Count the number of idents in a macro repetition. macro_rules! count_idents { ( $( $i:ident ),* ) => { - ${count(i)} + ${count($i)} }; } /// Count the number of idents in a 2-dimensional macro repetition. macro_rules! count_idents_2 { ( $( [ $( $i:ident ),* ] ),* ) => { - ${count(i)} + ${count($i)} }; } @@ -21,17 +21,17 @@ macro_rules! count_depth_limits { ( $( { $( [ $( $outer:ident : ( $( $inner:ident )* ) )* ] )* } )* ) => { ( ( - ${count(inner)}, - ${count(inner, 0)}, - ${count(inner, 1)}, - ${count(inner, 2)}, - ${count(inner, 3)}, + ${count($inner)}, + ${count($inner, 0)}, + ${count($inner, 1)}, + ${count($inner, 2)}, + ${count($inner, 3)}, ), ( - ${count(outer)}, - ${count(outer, 0)}, - ${count(outer, 1)}, - ${count(outer, 2)}, + ${count($outer)}, + ${count($outer, 0)}, + ${count($outer, 1)}, + ${count($outer, 2)}, ), ) }; @@ -43,7 +43,7 @@ macro_rules! count_depth_limits { /// repetition binding. macro_rules! enumerate_literals { ( $( ($l:stmt) ),* ) => { - [$( ${ignore(l)} (${index()}, ${length()}) ),*] + [$( ${ignore($l)} (${index()}, ${length()}) ),*] }; } @@ -77,7 +77,7 @@ macro_rules! make_count_adders { $( macro_rules! $i { ( $$( $$j:ident ),* ) => { - $b + $${count(j)} + $b + $${count($j)} }; } )* @@ -122,7 +122,7 @@ fn main() { [ T: (t u v w x y z) ] } }, - ((26, 2, 5, 9, 26), (9, 2, 5, 9)) + ((26, 26, 9, 5, 2), (9, 9, 5, 2)) ); assert_eq!(enumerate_literals![("foo"), ("bar")], [(0, 2), (1, 2)]); assert_eq!( diff --git a/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.rs b/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.rs index 9cc572c23a1..3000bfed6a8 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.rs +++ b/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.rs @@ -1,7 +1,7 @@ #![feature(macro_metavar_expr)] macro_rules! foo { - ( $( $($t:ident),* );* ) => { ${count(t,)} } + ( $( $($t:ident),* );* ) => { ${count($t,)} } //~^ ERROR `count` followed by a comma must have an associated //~| ERROR expected expression, found `$` } diff --git a/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.stderr b/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.stderr index e9317a5c347..fd53c1686cf 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.stderr +++ b/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.stderr @@ -1,13 +1,13 @@ error: `count` followed by a comma must have an associated index indicating its depth --> $DIR/issue-111904.rs:4:37 | -LL | ( $( $($t:ident),* );* ) => { ${count(t,)} } +LL | ( $( $($t:ident),* );* ) => { ${count($t,)} } | ^^^^^ error: expected expression, found `$` --> $DIR/issue-111904.rs:4:35 | -LL | ( $( $($t:ident),* );* ) => { ${count(t,)} } +LL | ( $( $($t:ident),* );* ) => { ${count($t,)} } | ^ expected expression ... LL | foo!(a, a; b, b); diff --git a/tests/ui/macros/rfc-3086-metavar-expr/macro-expansion.rs b/tests/ui/macros/rfc-3086-metavar-expr/macro-expansion.rs index b954967c4fe..04924f0efa6 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/macro-expansion.rs +++ b/tests/ui/macros/rfc-3086-metavar-expr/macro-expansion.rs @@ -13,17 +13,17 @@ macro_rules! example { ( $( [ $( ( $( $x:ident )* ) )* ] )* ) => { Example { _indexes: &[], - _counts: &[${count(x, 0)}, ${count(x, 1)}, ${count(x, 2)}], + _counts: &[${count($x, 0)}, ${count($x, 1)}, ${count($x, 2)}], _nested: vec![ $( Example { _indexes: &[(${index()}, ${length()})], - _counts: &[${count(x, 0)}, ${count(x, 1)}], + _counts: &[${count($x, 0)}, ${count($x, 1)}], _nested: vec![ $( Example { _indexes: &[(${index(1)}, ${length(1)}), (${index()}, ${length()})], - _counts: &[${count(x)}], + _counts: &[${count($x)}], _nested: vec![ $( Example { @@ -34,7 +34,7 @@ macro_rules! example { ], _counts: &[], _nested: vec![], - ${ignore(x)} + ${ignore($x)} } ),* ] @@ -49,9 +49,9 @@ macro_rules! example { } static EXPECTED: &str = concat!( - "Example { _indexes: [], _counts: [2, 4, 13], _nested: [", + "Example { _indexes: [], _counts: [13, 4, 2], _nested: [", concat!( - "Example { _indexes: [(0, 2)], _counts: [3, 10], _nested: [", + "Example { _indexes: [(0, 2)], _counts: [10, 3], _nested: [", concat!( "Example { _indexes: [(0, 2), (0, 3)], _counts: [4], _nested: [", concat!( @@ -77,7 +77,7 @@ static EXPECTED: &str = concat!( "] }", ), "] }, ", - "Example { _indexes: [(1, 2)], _counts: [1, 3], _nested: [", + "Example { _indexes: [(1, 2)], _counts: [3, 1], _nested: [", concat!( "Example { _indexes: [(1, 2), (0, 1)], _counts: [3], _nested: [", concat!( diff --git a/tests/ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.rs b/tests/ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.rs index 6a0d68bd6b1..d195506af36 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.rs +++ b/tests/ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.rs @@ -3,9 +3,9 @@ macro_rules! a { ( $( { $( [ $( ( $( $foo:ident )* ) )* ] )* } )* ) => { ( - ${count(foo, 0)}, - ${count(foo, 10)}, - //~^ ERROR depth parameter on meta-variable expression `count` must be less than 4 + ${count($foo, 0)}, + ${count($foo, 10)}, + //~^ ERROR depth parameter of meta-variable expression `count` must be less than 4 ) }; } @@ -14,10 +14,10 @@ macro_rules! b { ( $( { $( [ $( $foo:ident )* ] )* } )* ) => { ( $( $( $( - ${ignore(foo)} + ${ignore($foo)} ${index(0)}, ${index(10)}, - //~^ ERROR depth parameter on meta-variable expression `index` must be less than 3 + //~^ ERROR depth parameter of meta-variable expression `index` must be less than 3 )* )* )* ) }; @@ -27,10 +27,10 @@ macro_rules! c { ( $( { $( $foo:ident )* } )* ) => { ( $( $( - ${ignore(foo)} + ${ignore($foo)} ${length(0)} ${length(10)} - //~^ ERROR depth parameter on meta-variable expression `length` must be less than 2 + //~^ ERROR depth parameter of meta-variable expression `length` must be less than 2 )* )* ) }; diff --git a/tests/ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.stderr b/tests/ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.stderr index 236122b6465..f757b8af219 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.stderr +++ b/tests/ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.stderr @@ -1,16 +1,16 @@ -error: depth parameter on meta-variable expression `count` must be less than 4 +error: depth parameter of meta-variable expression `count` must be less than 4 --> $DIR/out-of-bounds-arguments.rs:7:14 | -LL | ${count(foo, 10)}, - | ^^^^^^^^^^^^^^^^ +LL | ${count($foo, 10)}, + | ^^^^^^^^^^^^^^^^^ -error: depth parameter on meta-variable expression `index` must be less than 3 +error: depth parameter of meta-variable expression `index` must be less than 3 --> $DIR/out-of-bounds-arguments.rs:19:18 | LL | ${index(10)}, | ^^^^^^^^^^^ -error: depth parameter on meta-variable expression `length` must be less than 2 +error: depth parameter of meta-variable expression `length` must be less than 2 --> $DIR/out-of-bounds-arguments.rs:32:18 | LL | ${length(10)} diff --git a/tests/ui/macros/rfc-3086-metavar-expr/required-feature.rs b/tests/ui/macros/rfc-3086-metavar-expr/required-feature.rs index b4fef11f1e2..53d045700f9 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/required-feature.rs +++ b/tests/ui/macros/rfc-3086-metavar-expr/required-feature.rs @@ -1,6 +1,6 @@ macro_rules! count { ( $( $e:stmt ),* ) => { - ${ count(e) } + ${ count($e) } //~^ ERROR meta-variable expressions are unstable }; } @@ -19,7 +19,7 @@ macro_rules! dollar_dollar { macro_rules! index { ( $( $e:stmt ),* ) => { - $( ${ignore(e)} ${index()} )* + $( ${ignore($e)} ${index()} )* //~^ ERROR meta-variable expressions are unstable //~| ERROR meta-variable expressions are unstable }; @@ -27,14 +27,14 @@ macro_rules! index { macro_rules! ignore { ( $( $i:stmt ),* ) => {{ - 0 $( + 1 ${ignore(i)} )* + 0 $( + 1 ${ignore($i)} )* //~^ ERROR meta-variable expressions are unstable }}; } macro_rules! length { ( $( $e:stmt ),* ) => { - $( ${ignore(e)} ${length()} )* + $( ${ignore($e)} ${length()} )* //~^ ERROR meta-variable expressions are unstable //~| ERROR meta-variable expressions are unstable }; diff --git a/tests/ui/macros/rfc-3086-metavar-expr/required-feature.stderr b/tests/ui/macros/rfc-3086-metavar-expr/required-feature.stderr index ecf598b104d..2c2cbb15b72 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/required-feature.stderr +++ b/tests/ui/macros/rfc-3086-metavar-expr/required-feature.stderr @@ -1,8 +1,8 @@ error[E0658]: meta-variable expressions are unstable --> $DIR/required-feature.rs:3:10 | -LL | ${ count(e) } - | ^^^^^^^^^^^^ +LL | ${ count($e) } + | ^^^^^^^^^^^^^ | = note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable @@ -46,17 +46,17 @@ LL | ( $$( $$any:tt )* ) => { $$( $$any )* }; error[E0658]: meta-variable expressions are unstable --> $DIR/required-feature.rs:22:13 | -LL | $( ${ignore(e)} ${index()} )* - | ^^^^^^^^^^^ +LL | $( ${ignore($e)} ${index()} )* + | ^^^^^^^^^^^^ | = note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable error[E0658]: meta-variable expressions are unstable - --> $DIR/required-feature.rs:22:26 + --> $DIR/required-feature.rs:22:27 | -LL | $( ${ignore(e)} ${index()} )* - | ^^^^^^^^^ +LL | $( ${ignore($e)} ${index()} )* + | ^^^^^^^^^ | = note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable @@ -64,8 +64,8 @@ LL | $( ${ignore(e)} ${index()} )* error[E0658]: meta-variable expressions are unstable --> $DIR/required-feature.rs:30:19 | -LL | 0 $( + 1 ${ignore(i)} )* - | ^^^^^^^^^^^ +LL | 0 $( + 1 ${ignore($i)} )* + | ^^^^^^^^^^^^ | = note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable @@ -73,17 +73,17 @@ LL | 0 $( + 1 ${ignore(i)} )* error[E0658]: meta-variable expressions are unstable --> $DIR/required-feature.rs:37:13 | -LL | $( ${ignore(e)} ${length()} )* - | ^^^^^^^^^^^ +LL | $( ${ignore($e)} ${length()} )* + | ^^^^^^^^^^^^ | = note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable error[E0658]: meta-variable expressions are unstable - --> $DIR/required-feature.rs:37:26 + --> $DIR/required-feature.rs:37:27 | -LL | $( ${ignore(e)} ${length()} )* - | ^^^^^^^^^^ +LL | $( ${ignore($e)} ${length()} )* + | ^^^^^^^^^^ | = note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable diff --git a/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.rs b/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.rs index fdf16442d2a..05c65fe8690 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.rs +++ b/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.rs @@ -5,24 +5,17 @@ // `round` = Left hand side round brackets macro_rules! curly__no_rhs_dollar__round { - ( $( $i:ident ),* ) => { ${ count(i) } }; + ( $( $i:ident ),* ) => { ${ count($i) } }; } macro_rules! curly__no_rhs_dollar__no_round { - ( $i:ident ) => { ${ count(i) } }; + ( $i:ident ) => { ${ count($i) } }; //~^ ERROR `count` can not be placed inside the inner-most repetition } -macro_rules! curly__rhs_dollar__round { - ( $( $i:ident ),* ) => { ${ count($i) } }; - //~^ ERROR expected identifier, found `$` - //~| ERROR expected expression, found `$` -} - macro_rules! curly__rhs_dollar__no_round { ( $i:ident ) => { ${ count($i) } }; - //~^ ERROR expected identifier, found `$` - //~| ERROR expected expression, found `$` + //~^ ERROR `count` can not be placed inside the inner-most repetition } macro_rules! no_curly__no_rhs_dollar__round { @@ -60,16 +53,16 @@ macro_rules! extra_garbage_after_metavar { ${count() a b c} //~^ ERROR unexpected token: a //~| ERROR expected expression, found `$` - ${count(i a b c)} + ${count($i a b c)} //~^ ERROR unexpected token: a - ${count(i, 1 a b c)} + ${count($i, 1 a b c)} //~^ ERROR unexpected token: a - ${count(i) a b c} + ${count($i) a b c} //~^ ERROR unexpected token: a - ${ignore(i) a b c} + ${ignore($i) a b c} //~^ ERROR unexpected token: a - ${ignore(i a b c)} + ${ignore($i a b c)} //~^ ERROR unexpected token: a ${index() a b c} @@ -100,8 +93,8 @@ macro_rules! metavar_in_the_lhs { macro_rules! metavar_token_without_ident { ( $( $i:ident ),* ) => { ${ ignore() } }; - //~^ ERROR expected identifier - //~| ERROR expected expression, found `$` + //~^ ERROR meta-variable expressions must be referenced using a dollar sign + //~| ERROR expected expression } macro_rules! metavar_with_literal_suffix { @@ -125,14 +118,16 @@ macro_rules! open_brackets_without_tokens { macro_rules! unknown_count_ident { ( $( $i:ident )* ) => { ${count(foo)} - //~^ ERROR variable `foo` is not recognized in meta-variable expression + //~^ ERROR meta-variable expressions must be referenced using a dollar sign + //~| ERROR expected expression }; } macro_rules! unknown_ignore_ident { ( $( $i:ident )* ) => { ${ignore(bar)} - //~^ ERROR variable `bar` is not recognized in meta-variable expression + //~^ ERROR meta-variable expressions must be referenced using a dollar sign + //~| ERROR expected expression }; } @@ -145,7 +140,6 @@ macro_rules! unknown_metavar { fn main() { curly__no_rhs_dollar__round!(a, b, c); curly__no_rhs_dollar__no_round!(a); - curly__rhs_dollar__round!(a, b, c); curly__rhs_dollar__no_round!(a); no_curly__no_rhs_dollar__round!(a, b, c); no_curly__no_rhs_dollar__no_round!(a); diff --git a/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.stderr b/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.stderr index a6cff95fd91..0dda38290ab 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.stderr +++ b/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.stderr @@ -1,197 +1,197 @@ -error: expected identifier, found `$` - --> $DIR/syntax-errors.rs:17:33 - | -LL | ( $( $i:ident ),* ) => { ${ count($i) } }; - | ^^^^^ - help: try removing `$` - -error: expected identifier, found `$` - --> $DIR/syntax-errors.rs:23:26 - | -LL | ( $i:ident ) => { ${ count($i) } }; - | ^^^^^ - help: try removing `$` - error: unexpected token: $ - --> $DIR/syntax-errors.rs:53:8 + --> $DIR/syntax-errors.rs:46:8 | LL | ( $$ $a:ident ) => { | ^ note: `$$` and meta-variable expressions are not allowed inside macro parameter definitions - --> $DIR/syntax-errors.rs:53:8 + --> $DIR/syntax-errors.rs:46:8 | LL | ( $$ $a:ident ) => { | ^ error: unexpected token: a - --> $DIR/syntax-errors.rs:60:19 + --> $DIR/syntax-errors.rs:53:19 | LL | ${count() a b c} | ^ | note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:60:19 + --> $DIR/syntax-errors.rs:53:19 | LL | ${count() a b c} | ^ error: unexpected token: a - --> $DIR/syntax-errors.rs:63:19 + --> $DIR/syntax-errors.rs:56:20 | -LL | ${count(i a b c)} - | ^ +LL | ${count($i a b c)} + | ^ | note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:63:19 + --> $DIR/syntax-errors.rs:56:20 | -LL | ${count(i a b c)} - | ^ +LL | ${count($i a b c)} + | ^ error: unexpected token: a - --> $DIR/syntax-errors.rs:65:22 + --> $DIR/syntax-errors.rs:58:23 | -LL | ${count(i, 1 a b c)} - | ^ +LL | ${count($i, 1 a b c)} + | ^ | note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:65:22 + --> $DIR/syntax-errors.rs:58:23 | -LL | ${count(i, 1 a b c)} - | ^ +LL | ${count($i, 1 a b c)} + | ^ error: unexpected token: a - --> $DIR/syntax-errors.rs:67:20 + --> $DIR/syntax-errors.rs:60:21 | -LL | ${count(i) a b c} - | ^ +LL | ${count($i) a b c} + | ^ | note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:67:20 + --> $DIR/syntax-errors.rs:60:21 | -LL | ${count(i) a b c} - | ^ +LL | ${count($i) a b c} + | ^ error: unexpected token: a - --> $DIR/syntax-errors.rs:70:21 + --> $DIR/syntax-errors.rs:63:22 | -LL | ${ignore(i) a b c} - | ^ +LL | ${ignore($i) a b c} + | ^ | note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:70:21 + --> $DIR/syntax-errors.rs:63:22 | -LL | ${ignore(i) a b c} - | ^ +LL | ${ignore($i) a b c} + | ^ error: unexpected token: a - --> $DIR/syntax-errors.rs:72:20 + --> $DIR/syntax-errors.rs:65:21 | -LL | ${ignore(i a b c)} - | ^ +LL | ${ignore($i a b c)} + | ^ | note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:72:20 + --> $DIR/syntax-errors.rs:65:21 | -LL | ${ignore(i a b c)} - | ^ +LL | ${ignore($i a b c)} + | ^ error: unexpected token: a - --> $DIR/syntax-errors.rs:75:19 + --> $DIR/syntax-errors.rs:68:19 | LL | ${index() a b c} | ^ | note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:75:19 + --> $DIR/syntax-errors.rs:68:19 | LL | ${index() a b c} | ^ error: unexpected token: a - --> $DIR/syntax-errors.rs:77:19 + --> $DIR/syntax-errors.rs:70:19 | LL | ${index(1 a b c)} | ^ | note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:77:19 + --> $DIR/syntax-errors.rs:70:19 | LL | ${index(1 a b c)} | ^ error: unexpected token: a - --> $DIR/syntax-errors.rs:80:19 + --> $DIR/syntax-errors.rs:73:19 | LL | ${index() a b c} | ^ | note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:80:19 + --> $DIR/syntax-errors.rs:73:19 | LL | ${index() a b c} | ^ error: unexpected token: a - --> $DIR/syntax-errors.rs:82:19 + --> $DIR/syntax-errors.rs:75:19 | LL | ${index(1 a b c)} | ^ | note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:82:19 + --> $DIR/syntax-errors.rs:75:19 | LL | ${index(1 a b c)} | ^ error: meta-variable expression depth must be a literal - --> $DIR/syntax-errors.rs:89:33 + --> $DIR/syntax-errors.rs:82:33 | LL | ( $( $i:ident ),* ) => { ${ index(IDX) } }; | ^^^^^ error: unexpected token: { - --> $DIR/syntax-errors.rs:95:8 + --> $DIR/syntax-errors.rs:88:8 | LL | ( ${ length() } ) => { | ^^^^^^^^^^^^ note: `$$` and meta-variable expressions are not allowed inside macro parameter definitions - --> $DIR/syntax-errors.rs:95:8 + --> $DIR/syntax-errors.rs:88:8 | LL | ( ${ length() } ) => { | ^^^^^^^^^^^^ error: expected one of: `*`, `+`, or `?` - --> $DIR/syntax-errors.rs:95:8 + --> $DIR/syntax-errors.rs:88:8 | LL | ( ${ length() } ) => { | ^^^^^^^^^^^^ -error: expected identifier - --> $DIR/syntax-errors.rs:102:33 +error: meta-variables within meta-variable expressions must be referenced using a dollar sign + --> $DIR/syntax-errors.rs:95:33 | LL | ( $( $i:ident ),* ) => { ${ ignore() } }; | ^^^^^^ error: only unsuffixes integer literals are supported in meta-variable expressions - --> $DIR/syntax-errors.rs:108:33 + --> $DIR/syntax-errors.rs:101:33 | LL | ( $( $i:ident ),* ) => { ${ index(1u32) } }; | ^^^^^ error: meta-variable expression parameter must be wrapped in parentheses - --> $DIR/syntax-errors.rs:114:33 + --> $DIR/syntax-errors.rs:107:33 | LL | ( $( $i:ident ),* ) => { ${ count{i} } }; | ^^^^^ error: expected identifier - --> $DIR/syntax-errors.rs:120:31 + --> $DIR/syntax-errors.rs:113:31 | LL | ( $( $i:ident ),* ) => { ${ {} } }; | ^^^^^^ +error: meta-variables within meta-variable expressions must be referenced using a dollar sign + --> $DIR/syntax-errors.rs:120:11 + | +LL | ${count(foo)} + | ^^^^^ + +error: meta-variables within meta-variable expressions must be referenced using a dollar sign + --> $DIR/syntax-errors.rs:128:11 + | +LL | ${ignore(bar)} + | ^^^^^^ + error: unrecognized meta-variable expression - --> $DIR/syntax-errors.rs:140:33 + --> $DIR/syntax-errors.rs:135:33 | LL | ( $( $i:ident ),* ) => { ${ aaaaaaaaaaaaaa(i) } }; | ^^^^^^^^^^^^^^ help: supported expressions are count, ignore, index and length @@ -199,39 +199,23 @@ LL | ( $( $i:ident ),* ) => { ${ aaaaaaaaaaaaaa(i) } }; error: `count` can not be placed inside the inner-most repetition --> $DIR/syntax-errors.rs:12:24 | -LL | ( $i:ident ) => { ${ count(i) } }; - | ^^^^^^^^^^^^ - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:17:30 - | -LL | ( $( $i:ident ),* ) => { ${ count($i) } }; - | ^ expected expression -... -LL | curly__rhs_dollar__round!(a, b, c); - | ---------------------------------- in this macro invocation - | - = note: this error originates in the macro `curly__rhs_dollar__round` (in Nightly builds, run with -Z macro-backtrace for more info) +LL | ( $i:ident ) => { ${ count($i) } }; + | ^^^^^^^^^^^^^ -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:23:23 +error: `count` can not be placed inside the inner-most repetition + --> $DIR/syntax-errors.rs:17:24 | LL | ( $i:ident ) => { ${ count($i) } }; - | ^ expected expression -... -LL | curly__rhs_dollar__no_round!(a); - | ------------------------------- in this macro invocation - | - = note: this error originates in the macro `curly__rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info) + | ^^^^^^^^^^^^^ error: variable 'i' is still repeating at this depth - --> $DIR/syntax-errors.rs:41:36 + --> $DIR/syntax-errors.rs:34:36 | LL | ( $( $i:ident ),* ) => { count($i) }; | ^^ error: expected expression, found `$` - --> $DIR/syntax-errors.rs:60:9 + --> $DIR/syntax-errors.rs:53:9 | LL | ${count() a b c} | ^ expected expression @@ -242,7 +226,7 @@ LL | extra_garbage_after_metavar!(a); = note: this error originates in the macro `extra_garbage_after_metavar` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected expression, found `$` - --> $DIR/syntax-errors.rs:89:30 + --> $DIR/syntax-errors.rs:82:30 | LL | ( $( $i:ident ),* ) => { ${ index(IDX) } }; | ^ expected expression @@ -253,7 +237,7 @@ LL | metavar_depth_is_not_literal!(a); = note: this error originates in the macro `metavar_depth_is_not_literal` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected expression, found `$` - --> $DIR/syntax-errors.rs:102:30 + --> $DIR/syntax-errors.rs:95:30 | LL | ( $( $i:ident ),* ) => { ${ ignore() } }; | ^ expected expression @@ -264,7 +248,7 @@ LL | metavar_token_without_ident!(a); = note: this error originates in the macro `metavar_token_without_ident` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected expression, found `$` - --> $DIR/syntax-errors.rs:108:30 + --> $DIR/syntax-errors.rs:101:30 | LL | ( $( $i:ident ),* ) => { ${ index(1u32) } }; | ^ expected expression @@ -275,7 +259,7 @@ LL | metavar_with_literal_suffix!(a); = note: this error originates in the macro `metavar_with_literal_suffix` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected expression, found `$` - --> $DIR/syntax-errors.rs:114:30 + --> $DIR/syntax-errors.rs:107:30 | LL | ( $( $i:ident ),* ) => { ${ count{i} } }; | ^ expected expression @@ -286,7 +270,7 @@ LL | metavar_without_parens!(a); = note: this error originates in the macro `metavar_without_parens` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected expression, found `$` - --> $DIR/syntax-errors.rs:120:30 + --> $DIR/syntax-errors.rs:113:30 | LL | ( $( $i:ident ),* ) => { ${ {} } }; | ^ expected expression @@ -296,20 +280,30 @@ LL | open_brackets_without_tokens!(a); | = note: this error originates in the macro `open_brackets_without_tokens` (in Nightly builds, run with -Z macro-backtrace for more info) -error: variable `foo` is not recognized in meta-variable expression - --> $DIR/syntax-errors.rs:127:17 +error: expected expression, found `$` + --> $DIR/syntax-errors.rs:120:9 | LL | ${count(foo)} - | ^^^ + | ^ expected expression +... +LL | unknown_count_ident!(a); + | ----------------------- in this macro invocation + | + = note: this error originates in the macro `unknown_count_ident` (in Nightly builds, run with -Z macro-backtrace for more info) -error: variable `bar` is not recognized in meta-variable expression - --> $DIR/syntax-errors.rs:134:18 +error: expected expression, found `$` + --> $DIR/syntax-errors.rs:128:9 | LL | ${ignore(bar)} - | ^^^ + | ^ expected expression +... +LL | unknown_ignore_ident!(a); + | ------------------------ in this macro invocation + | + = note: this error originates in the macro `unknown_ignore_ident` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected expression, found `$` - --> $DIR/syntax-errors.rs:140:30 + --> $DIR/syntax-errors.rs:135:30 | LL | ( $( $i:ident ),* ) => { ${ aaaaaaaaaaaaaa(i) } }; | ^ expected expression @@ -320,7 +314,7 @@ LL | unknown_metavar!(a); = note: this error originates in the macro `unknown_metavar` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0425]: cannot find value `i` in this scope - --> $DIR/syntax-errors.rs:29:36 + --> $DIR/syntax-errors.rs:22:36 | LL | ( $( $i:ident ),* ) => { count(i) }; | ^ not found in this scope @@ -331,7 +325,7 @@ LL | no_curly__no_rhs_dollar__round!(a, b, c); = note: this error originates in the macro `no_curly__no_rhs_dollar__round` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0425]: cannot find value `i` in this scope - --> $DIR/syntax-errors.rs:35:29 + --> $DIR/syntax-errors.rs:28:29 | LL | ( $i:ident ) => { count(i) }; | ^ not found in this scope @@ -342,13 +336,13 @@ LL | no_curly__no_rhs_dollar__no_round!(a); = note: this error originates in the macro `no_curly__no_rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0425]: cannot find value `a` in this scope - --> $DIR/syntax-errors.rs:153:37 + --> $DIR/syntax-errors.rs:147:37 | LL | no_curly__rhs_dollar__no_round!(a); | ^ not found in this scope error[E0425]: cannot find function `count` in this scope - --> $DIR/syntax-errors.rs:29:30 + --> $DIR/syntax-errors.rs:22:30 | LL | ( $( $i:ident ),* ) => { count(i) }; | ^^^^^ not found in this scope @@ -359,7 +353,7 @@ LL | no_curly__no_rhs_dollar__round!(a, b, c); = note: this error originates in the macro `no_curly__no_rhs_dollar__round` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0425]: cannot find function `count` in this scope - --> $DIR/syntax-errors.rs:35:23 + --> $DIR/syntax-errors.rs:28:23 | LL | ( $i:ident ) => { count(i) }; | ^^^^^ not found in this scope @@ -370,7 +364,7 @@ LL | no_curly__no_rhs_dollar__no_round!(a); = note: this error originates in the macro `no_curly__no_rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0425]: cannot find function `count` in this scope - --> $DIR/syntax-errors.rs:46:23 + --> $DIR/syntax-errors.rs:39:23 | LL | ( $i:ident ) => { count($i) }; | ^^^^^ not found in this scope @@ -380,6 +374,6 @@ LL | no_curly__rhs_dollar__no_round!(a); | = note: this error originates in the macro `no_curly__rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 40 previous errors +error: aborting due to 39 previous errors For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/macros/stringify.rs b/tests/ui/macros/stringify.rs index 6fc12509aad..192e6e0cc98 100644 --- a/tests/ui/macros/stringify.rs +++ b/tests/ui/macros/stringify.rs @@ -204,6 +204,16 @@ fn test_expr() { } ], "match self { Ok => 1, Err => 0, }" ); + macro_rules! c2_match_arm { + ([ $expr:expr ], $expr_expected:expr, $tokens_expected:expr $(,)?) => { + c2!(expr, [ match () { _ => $expr } ], $expr_expected, $tokens_expected); + }; + } + c2_match_arm!( + [ { 1 } - 1 ], + "match () { _ => ({ 1 }) - 1, }", + "match() { _ => { 1 } - 1 }", + ); // ExprKind::Closure c1!(expr, [ || {} ], "|| {}"); @@ -651,6 +661,16 @@ fn test_stmt() { "let (a, b): (u32, u32) = (1, 2);", "let(a, b): (u32, u32) = (1, 2)" // FIXME ); + macro_rules! c2_let_expr_minus_one { + ([ $expr:expr ], $stmt_expected:expr, $tokens_expected:expr $(,)?) => { + c2!(stmt, [ let _ = $expr - 1 ], $stmt_expected, $tokens_expected); + }; + } + c2_let_expr_minus_one!( + [ match void {} ], + "let _ = match void {} - 1;", + "let _ = match void {} - 1", + ); // StmtKind::Item c1!(stmt, [ struct S; ], "struct S;"); @@ -661,6 +681,46 @@ fn test_stmt() { // StmtKind::Semi c2!(stmt, [ 1 + 1 ], "1 + 1;", "1 + 1"); + macro_rules! c2_expr_as_stmt { + // Parse as expr, then reparse as stmt. + // + // The c2_minus_one macro below can't directly call `c2!(stmt, ...)` + // because `$expr - 1` cannot be parsed directly as a stmt. A statement + // boundary occurs after the `match void {}`, after which the `-` token + // hits "no rules expected this token in macro call". + // + // The unwanted statement boundary is exactly why the pretty-printer is + // injecting parentheses around the subexpression, which is the behavior + // we are interested in testing. + ([ $expr:expr ], $stmt_expected:expr, $tokens_expected:expr $(,)?) => { + c2!(stmt, [ $expr ], $stmt_expected, $tokens_expected); + }; + } + macro_rules! c2_minus_one { + ([ $expr:expr ], $stmt_expected:expr, $tokens_expected:expr $(,)?) => { + c2_expr_as_stmt!([ $expr - 1 ], $stmt_expected, $tokens_expected); + }; + } + c2_minus_one!( + [ match void {} ], + "(match void {}) - 1;", + "match void {} - 1", + ); + c2_minus_one!( + [ match void {}() ], + "(match void {})() - 1;", + "match void {}() - 1", + ); + c2_minus_one!( + [ match void {}[0] ], + "(match void {})[0] - 1;", + "match void {}[0] - 1", + ); + c2_minus_one!( + [ loop { break 1; } ], + "(loop { break 1; }) - 1;", + "loop { break 1; } - 1", + ); // StmtKind::Empty c1!(stmt, [ ; ], ";"); diff --git a/tests/ui/malformed/malformed-interpolated.rs b/tests/ui/malformed/malformed-interpolated.rs index 0d84e723fc3..0d801ebd3ac 100644 --- a/tests/ui/malformed/malformed-interpolated.rs +++ b/tests/ui/malformed/malformed-interpolated.rs @@ -10,7 +10,7 @@ macro_rules! check { check!("0"); // OK check!(0); // OK check!(0u8); //~ ERROR suffixed literals are not allowed in attributes -check!(-0); //~ ERROR unexpected expression: `-0` -check!(0 + 0); //~ ERROR unexpected expression: `0 + 0` +check!(-0); //~ ERROR attribute value must be a literal +check!(0 + 0); //~ ERROR attribute value must be a literal fn main() {} diff --git a/tests/ui/malformed/malformed-interpolated.stderr b/tests/ui/malformed/malformed-interpolated.stderr index c24d9f15388..92e99b7a70b 100644 --- a/tests/ui/malformed/malformed-interpolated.stderr +++ b/tests/ui/malformed/malformed-interpolated.stderr @@ -6,13 +6,13 @@ LL | check!(0u8); | = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) -error: unexpected expression: `-0` +error: attribute value must be a literal --> $DIR/malformed-interpolated.rs:13:8 | LL | check!(-0); | ^^ -error: unexpected expression: `0 + 0` +error: attribute value must be a literal --> $DIR/malformed-interpolated.rs:14:8 | LL | check!(0 + 0); diff --git a/tests/ui/methods/disambiguate-associated-function-first-arg.rs b/tests/ui/methods/disambiguate-associated-function-first-arg.rs new file mode 100644 index 00000000000..4c8192fc14b --- /dev/null +++ b/tests/ui/methods/disambiguate-associated-function-first-arg.rs @@ -0,0 +1,49 @@ +struct A {} + +fn main() { + let _a = A {}; + _a.new(1); + //~^ ERROR no method named `new` found for struct `A` in the current scope +} + +trait M { + fn new(_a: i32); +} +impl M for A { + fn new(_a: i32) {} +} + +trait N { + fn new(_a: Self, _b: i32); +} +impl N for A { + fn new(_a: Self, _b: i32) {} +} + +trait O { + fn new(_a: Self, _b: i32); +} +impl O for A { + fn new(_a: A, _b: i32) {} +} + +struct S; + +trait TraitA { + fn f(self); +} +trait TraitB { + fn f(self); +} + +impl<T> TraitA for T { + fn f(self) {} +} +impl<T> TraitB for T { + fn f(self) {} +} + +fn test() { + S.f(); + //~^ multiple applicable items in scope +} diff --git a/tests/ui/methods/disambiguate-associated-function-first-arg.stderr b/tests/ui/methods/disambiguate-associated-function-first-arg.stderr new file mode 100644 index 00000000000..341b7a91003 --- /dev/null +++ b/tests/ui/methods/disambiguate-associated-function-first-arg.stderr @@ -0,0 +1,67 @@ +error[E0599]: no method named `new` found for struct `A` in the current scope + --> $DIR/disambiguate-associated-function-first-arg.rs:5:8 + | +LL | struct A {} + | -------- method `new` not found for this struct +... +LL | _a.new(1); + | ^^^ this is an associated function, not a method + | + = note: found the following associated functions; to be used as methods, functions must have a `self` parameter +note: candidate #1 is defined in the trait `M` + --> $DIR/disambiguate-associated-function-first-arg.rs:10:5 + | +LL | fn new(_a: i32); + | ^^^^^^^^^^^^^^^^ +note: candidate #2 is defined in the trait `N` + --> $DIR/disambiguate-associated-function-first-arg.rs:17:5 + | +LL | fn new(_a: Self, _b: i32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: candidate #3 is defined in the trait `O` + --> $DIR/disambiguate-associated-function-first-arg.rs:24:5 + | +LL | fn new(_a: Self, _b: i32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: disambiguate the associated function for candidate #1 + | +LL | <A as M>::new(1); + | ~~~~~~~~~~~~~~~~ +help: disambiguate the associated function for candidate #2 + | +LL | <A as N>::new(_a, 1); + | ~~~~~~~~~~~~~~~~~~~~ +help: disambiguate the associated function for candidate #3 + | +LL | <A as O>::new(_a, 1); + | ~~~~~~~~~~~~~~~~~~~~ + +error[E0034]: multiple applicable items in scope + --> $DIR/disambiguate-associated-function-first-arg.rs:47:7 + | +LL | S.f(); + | ^ multiple `f` found + | +note: candidate #1 is defined in an impl of the trait `TraitA` for the type `T` + --> $DIR/disambiguate-associated-function-first-arg.rs:40:5 + | +LL | fn f(self) {} + | ^^^^^^^^^^ +note: candidate #2 is defined in an impl of the trait `TraitB` for the type `T` + --> $DIR/disambiguate-associated-function-first-arg.rs:43:5 + | +LL | fn f(self) {} + | ^^^^^^^^^^ +help: disambiguate the method for candidate #1 + | +LL | TraitA::f(S); + | ~~~~~~~~~~~~ +help: disambiguate the method for candidate #2 + | +LL | TraitB::f(S); + | ~~~~~~~~~~~~ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0034, E0599. +For more information about an error, try `rustc --explain E0034`. diff --git a/tests/ui/methods/method-ambiguity-no-rcvr.stderr b/tests/ui/methods/method-ambiguity-no-rcvr.stderr index 73f6043f256..3b6eb07393a 100644 --- a/tests/ui/methods/method-ambiguity-no-rcvr.stderr +++ b/tests/ui/methods/method-ambiguity-no-rcvr.stderr @@ -20,12 +20,12 @@ LL | fn foo() {} | ^^^^^^^^ help: disambiguate the associated function for candidate #1 | -LL | <Qux as Foo>::foo(Qux); - | ~~~~~~~~~~~~~~~~~~~~~~ +LL | <Qux as Foo>::foo(); + | ~~~~~~~~~~~~~~~~~~~ help: disambiguate the associated function for candidate #2 | -LL | <Qux as FooBar>::foo(Qux); - | ~~~~~~~~~~~~~~~~~~~~~~~~~ +LL | <Qux as FooBar>::foo(); + | ~~~~~~~~~~~~~~~~~~~~~~ error: aborting due to 1 previous error diff --git a/tests/ui/mir/lint/no-storage.rs b/tests/ui/mir/lint/no-storage.rs new file mode 100644 index 00000000000..246a0b34e5d --- /dev/null +++ b/tests/ui/mir/lint/no-storage.rs @@ -0,0 +1,30 @@ +// compile-flags: -Zlint-mir --crate-type=lib -Ztreat-err-as-bug +// failure-status: 101 +// dont-check-compiler-stderr +// regex-error-pattern: use of local .*, which has no storage here +#![feature(custom_mir, core_intrinsics)] +extern crate core; +use core::intrinsics::mir::*; + +#[custom_mir(dialect = "built")] +pub fn f(a: bool) { + mir!( + let b: (); + { + match a { true => bb1, _ => bb2 } + } + bb1 = { + StorageLive(b); + Goto(bb3) + } + bb2 = { + Goto(bb3) + } + bb3 = { + b = (); + RET = b; + StorageDead(b); + Return() + } + ) +} diff --git a/tests/ui/mir/validate/storage-live.rs b/tests/ui/mir/lint/storage-live.rs index ed3c26ed6da..f34a2c7de37 100644 --- a/tests/ui/mir/validate/storage-live.rs +++ b/tests/ui/mir/lint/storage-live.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zvalidate-mir -Ztreat-err-as-bug +// compile-flags: -Zlint-mir -Ztreat-err-as-bug // failure-status: 101 // error-pattern: broken MIR in // error-pattern: StorageLive(_1) which already has storage here diff --git a/tests/ui/mir/validate/storage-live.stderr b/tests/ui/mir/lint/storage-live.stderr index 1037ddc88ef..1037ddc88ef 100644 --- a/tests/ui/mir/validate/storage-live.stderr +++ b/tests/ui/mir/lint/storage-live.stderr diff --git a/tests/ui/mir/lint/storage-return.rs b/tests/ui/mir/lint/storage-return.rs new file mode 100644 index 00000000000..a2f63b449b4 --- /dev/null +++ b/tests/ui/mir/lint/storage-return.rs @@ -0,0 +1,19 @@ +// compile-flags: -Zlint-mir -Ztreat-err-as-bug +// failure-status: 101 +// dont-check-compiler-stderr +// error-pattern: has storage when returning +#![feature(custom_mir, core_intrinsics)] +extern crate core; +use core::intrinsics::mir::*; + +#[custom_mir(dialect = "built")] +fn main() { + mir!( + let a: (); + { + StorageLive(a); + RET = a; + Return() + } + ) +} diff --git a/tests/ui/missing/missing-block-hint.stderr b/tests/ui/missing/missing-block-hint.stderr index 16954223a45..18719289abd 100644 --- a/tests/ui/missing/missing-block-hint.stderr +++ b/tests/ui/missing/missing-block-hint.stderr @@ -9,6 +9,10 @@ note: the `if` expression is missing a block after this condition | LL | if (foo) => {} | ^^^^^ +help: you might have meant to write a "greater than or equal to" comparison + | +LL | if (foo) >= {} + | ~~ error: expected `{`, found `bar` --> $DIR/missing-block-hint.rs:7:13 diff --git a/tests/ui/never_type/never-from-impl-is-reserved.rs b/tests/ui/never_type/never-from-impl-is-reserved.rs index f358e045cf0..97fac59149b 100644 --- a/tests/ui/never_type/never-from-impl-is-reserved.rs +++ b/tests/ui/never_type/never-from-impl-is-reserved.rs @@ -1,7 +1,7 @@ // check that the `for<T> T: From<!>` impl is reserved // revisions: current next -//[next] compile-flags: -Ztrait-solver=next-coherence +//[next] compile-flags: -Znext-solver=coherence #![feature(never_type)] diff --git a/tests/ui/nll/closure-requirements/escape-argument-callee.rs b/tests/ui/nll/closure-requirements/escape-argument-callee.rs index 3aea511b056..d643a1b2a0d 100644 --- a/tests/ui/nll/closure-requirements/escape-argument-callee.rs +++ b/tests/ui/nll/closure-requirements/escape-argument-callee.rs @@ -12,7 +12,7 @@ // that appear free in its type (hence, we see it before the closure's // "external requirements" report). -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals #![feature(rustc_attrs)] diff --git a/tests/ui/nll/closure-requirements/escape-argument.rs b/tests/ui/nll/closure-requirements/escape-argument.rs index 066cd436016..7b1e6e9c820 100644 --- a/tests/ui/nll/closure-requirements/escape-argument.rs +++ b/tests/ui/nll/closure-requirements/escape-argument.rs @@ -12,7 +12,7 @@ // basically checking that the MIR type checker correctly enforces the // closure signature. -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals #![feature(rustc_attrs)] diff --git a/tests/ui/nll/closure-requirements/escape-upvar-nested.rs b/tests/ui/nll/closure-requirements/escape-upvar-nested.rs index 765a3cf961c..b104bc2479e 100644 --- a/tests/ui/nll/closure-requirements/escape-upvar-nested.rs +++ b/tests/ui/nll/closure-requirements/escape-upvar-nested.rs @@ -5,7 +5,7 @@ // // except that the closure does so via a second closure. -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals #![feature(rustc_attrs)] diff --git a/tests/ui/nll/closure-requirements/escape-upvar-ref.rs b/tests/ui/nll/closure-requirements/escape-upvar-ref.rs index 0a562a0a1bc..97c2d7dc291 100644 --- a/tests/ui/nll/closure-requirements/escape-upvar-ref.rs +++ b/tests/ui/nll/closure-requirements/escape-upvar-ref.rs @@ -9,7 +9,7 @@ // `'b`. This relationship is propagated to the closure creator, // which reports an error. -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals #![feature(rustc_attrs)] diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.rs b/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.rs index 35a864b8851..31f537d19d2 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.rs +++ b/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.rs @@ -1,7 +1,7 @@ // Test where we fail to approximate due to demanding a postdom // relationship between our upper bounds. -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals #![feature(rustc_attrs)] diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-ref.rs b/tests/ui/nll/closure-requirements/propagate-approximated-ref.rs index 7291c6e9749..295b9cb7755 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-ref.rs +++ b/tests/ui/nll/closure-requirements/propagate-approximated-ref.rs @@ -12,7 +12,7 @@ // Note: the use of `Cell` here is to introduce invariance. One less // variable. -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals #![feature(rustc_attrs)] diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.rs b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.rs index afe6f10a52f..e27a7d591e7 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.rs +++ b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.rs @@ -2,7 +2,7 @@ // where `'x` is bound in closure type but `'a` is free. This forces // us to approximate `'x` one way or the other. -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals #![feature(rustc_attrs)] diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.rs b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.rs index 3722090754b..f11dc769a03 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.rs +++ b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.rs @@ -3,7 +3,7 @@ // because `'y` is higher-ranked but we know of no relations to other // regions. Note that `'static` shows up in the stderr output as `'0`. -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals #![feature(rustc_attrs)] diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.rs b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.rs index 9898777c727..5e5aa3a3cce 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.rs +++ b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.rs @@ -4,7 +4,7 @@ // relations to other regions. Note that `'static` shows up in the // stderr output as `'0`. -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals #![feature(rustc_attrs)] diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-val.rs b/tests/ui/nll/closure-requirements/propagate-approximated-val.rs index 5bb5eea991b..83cb37516de 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-val.rs +++ b/tests/ui/nll/closure-requirements/propagate-approximated-val.rs @@ -5,7 +5,7 @@ // relationships. In the 'main' variant, there are a number of // anonymous regions as well. -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals #![feature(rustc_attrs)] diff --git a/tests/ui/nll/closure-requirements/propagate-despite-same-free-region.rs b/tests/ui/nll/closure-requirements/propagate-despite-same-free-region.rs index 704a026d29b..5a25e29816d 100644 --- a/tests/ui/nll/closure-requirements/propagate-despite-same-free-region.rs +++ b/tests/ui/nll/closure-requirements/propagate-despite-same-free-region.rs @@ -3,7 +3,7 @@ // need to propagate; but in fact we do because identity of free // regions is erased. -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals // check-pass #![feature(rustc_attrs)] diff --git a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.rs b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.rs index dcd05d7fa2c..0fb57d47d2d 100644 --- a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.rs +++ b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.rs @@ -7,7 +7,7 @@ // as it knows of no relationships between `'x` and any // non-higher-ranked regions. -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals #![feature(rustc_attrs)] diff --git a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.rs b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.rs index 98be92d1cd6..3bdd923543e 100644 --- a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.rs +++ b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.rs @@ -7,7 +7,7 @@ // as it only knows of regions that `'x` is outlived by, and none that // `'x` outlives. -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals #![feature(rustc_attrs)] diff --git a/tests/ui/nll/closure-requirements/propagate-from-trait-match.rs b/tests/ui/nll/closure-requirements/propagate-from-trait-match.rs index cda781d8e26..5fe2f46ee79 100644 --- a/tests/ui/nll/closure-requirements/propagate-from-trait-match.rs +++ b/tests/ui/nll/closure-requirements/propagate-from-trait-match.rs @@ -4,7 +4,7 @@ // the same `'a` for which it implements `Trait`, which can only be the `'a` // from the function definition. -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals #![feature(rustc_attrs)] #![allow(dead_code)] diff --git a/tests/ui/nll/closure-requirements/region-lbr-anon-does-not-outlive-static.rs b/tests/ui/nll/closure-requirements/region-lbr-anon-does-not-outlive-static.rs index 8147da09d43..6e7db4578a0 100644 --- a/tests/ui/nll/closure-requirements/region-lbr-anon-does-not-outlive-static.rs +++ b/tests/ui/nll/closure-requirements/region-lbr-anon-does-not-outlive-static.rs @@ -3,7 +3,7 @@ // a variety of errors from the older, AST-based machinery (notably // borrowck), and then we get the NLL error at the end. -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals fn foo(x: &u32) -> &'static u32 { &*x diff --git a/tests/ui/nll/closure-requirements/region-lbr-named-does-not-outlive-static.rs b/tests/ui/nll/closure-requirements/region-lbr-named-does-not-outlive-static.rs index 4acd2fc92f3..c1b9e249c09 100644 --- a/tests/ui/nll/closure-requirements/region-lbr-named-does-not-outlive-static.rs +++ b/tests/ui/nll/closure-requirements/region-lbr-named-does-not-outlive-static.rs @@ -3,7 +3,7 @@ // a variety of errors from the older, AST-based machinery (notably // borrowck), and then we get the NLL error at the end. -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals fn foo<'a>(x: &'a u32) -> &'static u32 { &*x diff --git a/tests/ui/nll/closure-requirements/region-lbr1-does-not-outlive-ebr2.rs b/tests/ui/nll/closure-requirements/region-lbr1-does-not-outlive-ebr2.rs index 06e96be80d5..1d31c9cb5a5 100644 --- a/tests/ui/nll/closure-requirements/region-lbr1-does-not-outlive-ebr2.rs +++ b/tests/ui/nll/closure-requirements/region-lbr1-does-not-outlive-ebr2.rs @@ -3,7 +3,7 @@ // a variety of errors from the older, AST-based machinery (notably // borrowck), and then we get the NLL error at the end. -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals fn foo<'a, 'b>(x: &'a u32, y: &'b u32) -> &'b u32 { &*x diff --git a/tests/ui/nll/closure-requirements/region-lbr1-does-outlive-lbr2-because-implied-bound.rs b/tests/ui/nll/closure-requirements/region-lbr1-does-outlive-lbr2-because-implied-bound.rs index 014959fdbd4..4e57fef167a 100644 --- a/tests/ui/nll/closure-requirements/region-lbr1-does-outlive-lbr2-because-implied-bound.rs +++ b/tests/ui/nll/closure-requirements/region-lbr1-does-outlive-lbr2-because-implied-bound.rs @@ -2,7 +2,7 @@ // report an error because of the (implied) bound that `'b: 'a`. // check-pass -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals fn foo<'a, 'b>(x: &'a &'b u32) -> &'a u32 { &**x diff --git a/tests/ui/nll/closure-requirements/return-wrong-bound-region.rs b/tests/ui/nll/closure-requirements/return-wrong-bound-region.rs index e34a3f6f2cb..0277715b590 100644 --- a/tests/ui/nll/closure-requirements/return-wrong-bound-region.rs +++ b/tests/ui/nll/closure-requirements/return-wrong-bound-region.rs @@ -2,7 +2,7 @@ // the first, but actually returns the second. This should fail within // the closure. -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals #![feature(rustc_attrs)] diff --git a/tests/ui/nll/issue-53119.rs b/tests/ui/nll/issue-53119.rs index 015b72367f1..d19a9a0327c 100644 --- a/tests/ui/nll/issue-53119.rs +++ b/tests/ui/nll/issue-53119.rs @@ -1,6 +1,6 @@ // check-pass // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver use std::ops::Deref; diff --git a/tests/ui/nll/ty-outlives/impl-trait-captures.rs b/tests/ui/nll/ty-outlives/impl-trait-captures.rs index 67b31b8bcd4..faab2cf8bcb 100644 --- a/tests/ui/nll/ty-outlives/impl-trait-captures.rs +++ b/tests/ui/nll/ty-outlives/impl-trait-captures.rs @@ -1,4 +1,4 @@ -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals #![allow(warnings)] diff --git a/tests/ui/nll/ty-outlives/impl-trait-outlives.rs b/tests/ui/nll/ty-outlives/impl-trait-outlives.rs index 68ccb51fcd0..2c2eb703a15 100644 --- a/tests/ui/nll/ty-outlives/impl-trait-outlives.rs +++ b/tests/ui/nll/ty-outlives/impl-trait-outlives.rs @@ -1,4 +1,4 @@ -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals #![allow(warnings)] diff --git a/tests/ui/nll/ty-outlives/projection-implied-bounds.rs b/tests/ui/nll/ty-outlives/projection-implied-bounds.rs index e1dac082409..59854fe6d8a 100644 --- a/tests/ui/nll/ty-outlives/projection-implied-bounds.rs +++ b/tests/ui/nll/ty-outlives/projection-implied-bounds.rs @@ -1,7 +1,7 @@ // Test that we can deduce when projections like `T::Item` outlive the // function body. Test that this does not imply that `T: 'a` holds. -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals use std::cell::Cell; diff --git a/tests/ui/nll/ty-outlives/projection-no-regions-closure.rs b/tests/ui/nll/ty-outlives/projection-no-regions-closure.rs index 2d9c008c759..f908381d4ac 100644 --- a/tests/ui/nll/ty-outlives/projection-no-regions-closure.rs +++ b/tests/ui/nll/ty-outlives/projection-no-regions-closure.rs @@ -1,4 +1,4 @@ -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals // Tests closures that propagate an outlives relationship to their // creator where the subject is a projection with no regions (`<T as diff --git a/tests/ui/nll/ty-outlives/projection-no-regions-fn.rs b/tests/ui/nll/ty-outlives/projection-no-regions-fn.rs index a10a0366ae8..d04f88f829e 100644 --- a/tests/ui/nll/ty-outlives/projection-no-regions-fn.rs +++ b/tests/ui/nll/ty-outlives/projection-no-regions-fn.rs @@ -1,4 +1,4 @@ -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals #![allow(warnings)] diff --git a/tests/ui/nll/ty-outlives/projection-one-region-closure.rs b/tests/ui/nll/ty-outlives/projection-one-region-closure.rs index af361e990e5..5d7b5fd72c9 100644 --- a/tests/ui/nll/ty-outlives/projection-one-region-closure.rs +++ b/tests/ui/nll/ty-outlives/projection-one-region-closure.rs @@ -12,7 +12,7 @@ // // Ensuring that both `T: 'a` and `'b: 'a` holds does work (`elements_outlive`). -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals #![allow(warnings)] #![feature(rustc_attrs)] diff --git a/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.rs b/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.rs index 6f8513491df..3cd586f968d 100644 --- a/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.rs +++ b/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.rs @@ -4,7 +4,7 @@ // case, the best way to satisfy the trait bound is to show that `'b: // 'a`, which can be done in various ways. -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals #![allow(warnings)] #![feature(rustc_attrs)] diff --git a/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.rs b/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.rs index 7c0a3bc72c3..85be5fbffbc 100644 --- a/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.rs +++ b/tests/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.rs @@ -2,7 +2,7 @@ // outlive `'static`. In this case, we don't get any errors, and in fact // we don't even propagate constraints from the closures to the callers. -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals // check-pass #![allow(warnings)] diff --git a/tests/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.rs b/tests/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.rs index 7b4a3c03a62..92794400b24 100644 --- a/tests/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.rs +++ b/tests/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.rs @@ -5,7 +5,7 @@ // the trait bound, and hence we propagate it to the caller as a type // test. -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals #![allow(warnings)] #![feature(rustc_attrs)] diff --git a/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.rs b/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.rs index 4d83805993a..56485593c92 100644 --- a/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.rs +++ b/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.rs @@ -1,4 +1,4 @@ -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals #![allow(warnings)] #![feature(rustc_attrs)] diff --git a/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs b/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs index 72b18c16732..9695400c400 100644 --- a/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs +++ b/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs @@ -1,4 +1,4 @@ -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals #![allow(warnings)] #![feature(rustc_attrs)] diff --git a/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.rs b/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.rs index b8028761050..9e69792d724 100644 --- a/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.rs +++ b/tests/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.rs @@ -2,7 +2,7 @@ // `correct_region` for an explanation of how this test is setup; it's // somewhat intricate. -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals #![allow(warnings)] #![feature(rustc_attrs)] diff --git a/tests/ui/nll/ty-outlives/ty-param-implied-bounds.rs b/tests/ui/nll/ty-outlives/ty-param-implied-bounds.rs index 9042844e848..145ae0d735b 100644 --- a/tests/ui/nll/ty-outlives/ty-param-implied-bounds.rs +++ b/tests/ui/nll/ty-outlives/ty-param-implied-bounds.rs @@ -1,4 +1,4 @@ -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals // check-pass // Test that we assume that universal types like `T` outlive the diff --git a/tests/ui/nll/user-annotations/dump-adt-brace-struct.rs b/tests/ui/nll/user-annotations/dump-adt-brace-struct.rs index 1d0b0d55af6..36a16c8dcc6 100644 --- a/tests/ui/nll/user-annotations/dump-adt-brace-struct.rs +++ b/tests/ui/nll/user-annotations/dump-adt-brace-struct.rs @@ -1,7 +1,7 @@ // Unit test for the "user substitutions" that are annotated on each // node. -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals #![allow(warnings)] #![feature(rustc_attrs)] diff --git a/tests/ui/nll/user-annotations/dump-fn-method.rs b/tests/ui/nll/user-annotations/dump-fn-method.rs index 9bdbbc37caa..086b2d2f6fc 100644 --- a/tests/ui/nll/user-annotations/dump-fn-method.rs +++ b/tests/ui/nll/user-annotations/dump-fn-method.rs @@ -1,7 +1,7 @@ // Unit test for the "user substitutions" that are annotated on each // node. -// compile-flags:-Zverbose +// compile-flags:-Zverbose-internals #![feature(rustc_attrs)] diff --git a/tests/ui/object-safety/call-when-assoc-ty-is-sized.rs b/tests/ui/object-safety/call-when-assoc-ty-is-sized.rs index 0b30a88fdd4..21dda7b8c9b 100644 --- a/tests/ui/object-safety/call-when-assoc-ty-is-sized.rs +++ b/tests/ui/object-safety/call-when-assoc-ty-is-sized.rs @@ -1,6 +1,6 @@ // check-pass // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver trait Foo { type Bar<'a> diff --git a/tests/ui/packed/dyn-trait.rs b/tests/ui/packed/dyn-trait.rs new file mode 100644 index 00000000000..bb73c26c18a --- /dev/null +++ b/tests/ui/packed/dyn-trait.rs @@ -0,0 +1,21 @@ +// run-pass +use std::ptr::addr_of; + +// When the unsized tail is a `dyn Trait`, its alignments is only dynamically known. This means the +// packed(2) needs to be applied at runtime: the actual alignment of the field is `min(2, +// usual_alignment)`. Here we check that we do this right by comparing size, alignment, and field +// offset before and after unsizing. +fn main() { + #[repr(C, packed(2))] + struct Packed<T: ?Sized>(u8, core::mem::ManuallyDrop<T>); + + let p = Packed(0, core::mem::ManuallyDrop::new(1)); + let p: &Packed<usize> = &p; + let sized = (core::mem::size_of_val(p), core::mem::align_of_val(p)); + let sized_offset = unsafe { addr_of!(p.1).cast::<u8>().offset_from(addr_of!(p.0)) }; + let p: &Packed<dyn Send> = p; + let un_sized = (core::mem::size_of_val(p), core::mem::align_of_val(p)); + let un_sized_offset = unsafe { addr_of!(p.1).cast::<u8>().offset_from(addr_of!(p.0)) }; + assert_eq!(sized, un_sized); + assert_eq!(sized_offset, un_sized_offset); +} diff --git a/tests/ui/panic-handler/panic-handler-duplicate.stderr b/tests/ui/panic-handler/panic-handler-duplicate.stderr index 5c50b7016b2..299847474cd 100644 --- a/tests/ui/panic-handler/panic-handler-duplicate.stderr +++ b/tests/ui/panic-handler/panic-handler-duplicate.stderr @@ -1,14 +1,18 @@ error[E0152]: found duplicate lang item `panic_impl` --> $DIR/panic-handler-duplicate.rs:15:1 | -LL | fn panic2(info: &PanicInfo) -> ! { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | / fn panic2(info: &PanicInfo) -> ! { +LL | | loop {} +LL | | } + | |_^ | note: the lang item is first defined here --> $DIR/panic-handler-duplicate.rs:10:1 | -LL | fn panic(info: &PanicInfo) -> ! { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | / fn panic(info: &PanicInfo) -> ! { +LL | | loop {} +LL | | } + | |_^ error: aborting due to 1 previous error diff --git a/tests/ui/panic-handler/panic-handler-std.stderr b/tests/ui/panic-handler/panic-handler-std.stderr index ad9addec8eb..48c216ce27e 100644 --- a/tests/ui/panic-handler/panic-handler-std.stderr +++ b/tests/ui/panic-handler/panic-handler-std.stderr @@ -1,8 +1,10 @@ error[E0152]: found duplicate lang item `panic_impl` --> $DIR/panic-handler-std.rs:8:1 | -LL | fn panic(info: PanicInfo) -> ! { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | / fn panic(info: PanicInfo) -> ! { +LL | | loop {} +LL | | } + | |_^ | = note: the lang item is first defined in crate `std` (which `panic_handler_std` depends on) = note: first definition in `std` loaded from SYSROOT/libstd-*.rlib diff --git a/tests/ui/panics/abort-on-panic.rs b/tests/ui/panics/abort-on-panic.rs index 7fbee85ffd1..ff31fc24317 100644 --- a/tests/ui/panics/abort-on-panic.rs +++ b/tests/ui/panics/abort-on-panic.rs @@ -1,6 +1,6 @@ // run-pass // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver #![allow(unused_must_use)] #![feature(c_unwind)] diff --git a/tests/ui/parser/attribute/attr-stmt-expr-attr-bad.rs b/tests/ui/parser/attribute/attr-stmt-expr-attr-bad.rs index 2c402e4c65e..d1950087c4c 100644 --- a/tests/ui/parser/attribute/attr-stmt-expr-attr-bad.rs +++ b/tests/ui/parser/attribute/attr-stmt-expr-attr-bad.rs @@ -84,15 +84,15 @@ fn main() {} #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] 10 => () } } //~^ ERROR inclusive range with no end -//~| ERROR expected one of `,`, `=>`, `if`, `|`, or `}`, found `#` +//~| ERROR expected one of `=>`, `if`, or `|`, found `#` #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] -10 => () } } //~^ ERROR inclusive range with no end -//~| ERROR expected one of `,`, `=>`, `if`, `|`, or `}`, found `#` +//~| ERROR expected one of `=>`, `if`, or `|`, found `#` #[cfg(FALSE)] fn e() { match 0 { 0..=-#[attr] 10 => () } } //~^ ERROR unexpected token: `#` #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } } //~^ ERROR inclusive range with no end -//~| ERROR expected one of `,`, `=>`, `if`, `|`, or `}`, found `#` +//~| ERROR expected one of `=>`, `if`, or `|`, found `#` #[cfg(FALSE)] fn e() { let _ = x.#![attr]foo(); } //~^ ERROR unexpected token: `#` diff --git a/tests/ui/parser/attribute/attr-stmt-expr-attr-bad.stderr b/tests/ui/parser/attribute/attr-stmt-expr-attr-bad.stderr index a0e95c5c1ed..e46c591080d 100644 --- a/tests/ui/parser/attribute/attr-stmt-expr-attr-bad.stderr +++ b/tests/ui/parser/attribute/attr-stmt-expr-attr-bad.stderr @@ -365,11 +365,11 @@ LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] 10 => () } } | = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) -error: expected one of `,`, `=>`, `if`, `|`, or `}`, found `#` +error: expected one of `=>`, `if`, or `|`, found `#` --> $DIR/attr-stmt-expr-attr-bad.rs:85:38 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] 10 => () } } - | ^ expected one of `,`, `=>`, `if`, `|`, or `}` + | ^ expected one of `=>`, `if`, or `|` error[E0586]: inclusive range with no end --> $DIR/attr-stmt-expr-attr-bad.rs:88:35 @@ -379,11 +379,11 @@ LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] -10 => () } } | = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) -error: expected one of `,`, `=>`, `if`, `|`, or `}`, found `#` +error: expected one of `=>`, `if`, or `|`, found `#` --> $DIR/attr-stmt-expr-attr-bad.rs:88:38 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] -10 => () } } - | ^ expected one of `,`, `=>`, `if`, `|`, or `}` + | ^ expected one of `=>`, `if`, or `|` error: unexpected token: `#` --> $DIR/attr-stmt-expr-attr-bad.rs:91:39 @@ -399,11 +399,11 @@ LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } } | = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) -error: expected one of `,`, `=>`, `if`, `|`, or `}`, found `#` +error: expected one of `=>`, `if`, or `|`, found `#` --> $DIR/attr-stmt-expr-attr-bad.rs:93:38 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } } - | ^ expected one of `,`, `=>`, `if`, `|`, or `}` + | ^ expected one of `=>`, `if`, or `|` error: unexpected token: `#` --> $DIR/attr-stmt-expr-attr-bad.rs:97:34 diff --git a/tests/ui/parser/bad-let-else-statement.rs b/tests/ui/parser/bad-let-else-statement.rs new file mode 100644 index 00000000000..7b927c89ba0 --- /dev/null +++ b/tests/ui/parser/bad-let-else-statement.rs @@ -0,0 +1,164 @@ +#![feature(inline_const)] +#![feature(yeet_expr)] +#![allow(incomplete_features)] // Necessary for now, while explicit_tail_calls is incomplete +#![feature(explicit_tail_calls)] + +fn a() { + let foo = { + 1 + } else { + //~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed + return; + }; +} + +fn b() { + let foo = for i in 1..2 { + break; + } else { + //~^ ERROR `for...else` loops are not supported + return; + }; +} + +fn c() { + let foo = if true { + 1 + } else { + 0 + } else { + //~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed + return; + }; +} + +fn d() { + let foo = loop { + break; + } else { + //~^ ERROR loop...else` loops are not supported + return; + }; +} + +fn e() { + let foo = match true { + true => 1, + false => 0 + } else { + //~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed + return; + }; +} + +struct X {a: i32} +fn f() { + let foo = X { + a: 1 + } else { + //~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed + return; + }; +} + +fn g() { + let foo = while false { + break; + } else { + //~^ ERROR `while...else` loops are not supported + return; + }; +} + +fn h() { + let foo = const { + 1 + } else { + //~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed + return; + }; +} + +fn i() { + let foo = &{ + 1 + } else { + //~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed + return; + }; +} + +fn j() { + let bar = 0; + let foo = bar = { + 1 + } else { + //~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed + return; + }; +} + +fn k() { + let foo = 1 + { + 1 + } else { + //~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed + return; + }; +} + +fn l() { + let foo = 1..{ + 1 + } else { + //~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed + return; + }; +} + +fn m() { + let foo = return { + () + } else { + //~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed + return; + }; +} + +fn n() { + let foo = -{ + 1 + } else { + //~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed + return; + }; +} + +fn o() -> Result<(), ()> { + let foo = do yeet { + () + } else { + //~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed + return Ok(()); + }; +} + +fn p() { + let foo = become { + () + } else { + //~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed + return; + }; +} + +fn q() { + let foo = |x: i32| { + x + } else { + //~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed + return; + }; +} + +fn main() {} diff --git a/tests/ui/parser/bad-let-else-statement.stderr b/tests/ui/parser/bad-let-else-statement.stderr new file mode 100644 index 00000000000..7cbda25e417 --- /dev/null +++ b/tests/ui/parser/bad-let-else-statement.stderr @@ -0,0 +1,232 @@ +error: right curly brace `}` before `else` in a `let...else` statement not allowed + --> $DIR/bad-let-else-statement.rs:9:5 + | +LL | } else { + | ^ + | +help: wrap the expression in parentheses + | +LL ~ let foo = ({ +LL | 1 +LL ~ }) else { + | + +error: `for...else` loops are not supported + --> $DIR/bad-let-else-statement.rs:18:7 + | +LL | let foo = for i in 1..2 { + | --- `else` is attached to this loop +LL | break; +LL | } else { + | _______^ +LL | | +LL | | return; +LL | | }; + | |_____^ + | + = note: consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run + +error: right curly brace `}` before `else` in a `let...else` statement not allowed + --> $DIR/bad-let-else-statement.rs:29:5 + | +LL | } else { + | ^ + | +help: wrap the expression in parentheses + | +LL ~ let foo = (if true { +LL | 1 +LL | } else { +LL | 0 +LL ~ }) else { + | + +error: `loop...else` loops are not supported + --> $DIR/bad-let-else-statement.rs:38:7 + | +LL | let foo = loop { + | ---- `else` is attached to this loop +LL | break; +LL | } else { + | _______^ +LL | | +LL | | return; +LL | | }; + | |_____^ + | + = note: consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run + +error: right curly brace `}` before `else` in a `let...else` statement not allowed + --> $DIR/bad-let-else-statement.rs:48:5 + | +LL | } else { + | ^ + | +help: wrap the expression in parentheses + | +LL ~ let foo = (match true { +LL | true => 1, +LL | false => 0 +LL ~ }) else { + | + +error: right curly brace `}` before `else` in a `let...else` statement not allowed + --> $DIR/bad-let-else-statement.rs:58:5 + | +LL | } else { + | ^ + | +help: wrap the expression in parentheses + | +LL ~ let foo = (X { +LL | a: 1 +LL ~ }) else { + | + +error: `while...else` loops are not supported + --> $DIR/bad-let-else-statement.rs:67:7 + | +LL | let foo = while false { + | ----- `else` is attached to this loop +LL | break; +LL | } else { + | _______^ +LL | | +LL | | return; +LL | | }; + | |_____^ + | + = note: consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run + +error: right curly brace `}` before `else` in a `let...else` statement not allowed + --> $DIR/bad-let-else-statement.rs:76:5 + | +LL | } else { + | ^ + | +help: wrap the expression in parentheses + | +LL ~ let foo = (const { +LL | 1 +LL ~ }) else { + | + +error: right curly brace `}` before `else` in a `let...else` statement not allowed + --> $DIR/bad-let-else-statement.rs:85:5 + | +LL | } else { + | ^ + | +help: wrap the expression in parentheses + | +LL ~ let foo = &({ +LL | 1 +LL ~ }) else { + | + +error: right curly brace `}` before `else` in a `let...else` statement not allowed + --> $DIR/bad-let-else-statement.rs:95:5 + | +LL | } else { + | ^ + | +help: wrap the expression in parentheses + | +LL ~ let foo = bar = ({ +LL | 1 +LL ~ }) else { + | + +error: right curly brace `}` before `else` in a `let...else` statement not allowed + --> $DIR/bad-let-else-statement.rs:104:5 + | +LL | } else { + | ^ + | +help: wrap the expression in parentheses + | +LL ~ let foo = 1 + ({ +LL | 1 +LL ~ }) else { + | + +error: right curly brace `}` before `else` in a `let...else` statement not allowed + --> $DIR/bad-let-else-statement.rs:113:5 + | +LL | } else { + | ^ + | +help: wrap the expression in parentheses + | +LL ~ let foo = 1..({ +LL | 1 +LL ~ }) else { + | + +error: right curly brace `}` before `else` in a `let...else` statement not allowed + --> $DIR/bad-let-else-statement.rs:122:5 + | +LL | } else { + | ^ + | +help: wrap the expression in parentheses + | +LL ~ let foo = return ({ +LL | () +LL ~ }) else { + | + +error: right curly brace `}` before `else` in a `let...else` statement not allowed + --> $DIR/bad-let-else-statement.rs:131:5 + | +LL | } else { + | ^ + | +help: wrap the expression in parentheses + | +LL ~ let foo = -({ +LL | 1 +LL ~ }) else { + | + +error: right curly brace `}` before `else` in a `let...else` statement not allowed + --> $DIR/bad-let-else-statement.rs:140:5 + | +LL | } else { + | ^ + | +help: wrap the expression in parentheses + | +LL ~ let foo = do yeet ({ +LL | () +LL ~ }) else { + | + +error: right curly brace `}` before `else` in a `let...else` statement not allowed + --> $DIR/bad-let-else-statement.rs:149:5 + | +LL | } else { + | ^ + | +help: wrap the expression in parentheses + | +LL ~ let foo = become ({ +LL | () +LL ~ }) else { + | + +error: right curly brace `}` before `else` in a `let...else` statement not allowed + --> $DIR/bad-let-else-statement.rs:158:5 + | +LL | } else { + | ^ + | +help: wrap the expression in parentheses + | +LL ~ let foo = |x: i32| ({ +LL | x +LL ~ }) else { + | + +error: aborting due to 17 previous errors + diff --git a/tests/ui/parser/bad-lit-suffixes.rs b/tests/ui/parser/bad-lit-suffixes.rs index 8cb9ef7e0c9..c614f493885 100644 --- a/tests/ui/parser/bad-lit-suffixes.rs +++ b/tests/ui/parser/bad-lit-suffixes.rs @@ -28,11 +28,12 @@ fn main() { } #[rustc_dummy = "string"suffix] -//~^ ERROR unexpected expression: `"string"suffix` +//~^ ERROR suffixes on string literals are invalid fn f() {} #[must_use = "string"suffix] -//~^ ERROR unexpected expression: `"string"suffix` +//~^ ERROR suffixes on string literals are invalid +//~| ERROR malformed `must_use` attribute input fn g() {} #[link(name = "string"suffix)] diff --git a/tests/ui/parser/bad-lit-suffixes.stderr b/tests/ui/parser/bad-lit-suffixes.stderr index 756f99ab12c..b5dacdf7d0d 100644 --- a/tests/ui/parser/bad-lit-suffixes.stderr +++ b/tests/ui/parser/bad-lit-suffixes.stderr @@ -10,26 +10,39 @@ error: suffixes on string literals are invalid LL | "C"suffix | ^^^^^^^^^ invalid suffix `suffix` -error: unexpected expression: `"string"suffix` +error: suffixes on string literals are invalid --> $DIR/bad-lit-suffixes.rs:30:17 | LL | #[rustc_dummy = "string"suffix] - | ^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^ invalid suffix `suffix` -error: unexpected expression: `"string"suffix` +error: suffixes on string literals are invalid --> $DIR/bad-lit-suffixes.rs:34:14 | LL | #[must_use = "string"suffix] - | ^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^ invalid suffix `suffix` + +error: malformed `must_use` attribute input + --> $DIR/bad-lit-suffixes.rs:34:1 + | +LL | #[must_use = "string"suffix] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[must_use = "reason"] + | +LL | #[must_use] + | error: suffixes on string literals are invalid - --> $DIR/bad-lit-suffixes.rs:38:15 + --> $DIR/bad-lit-suffixes.rs:39:15 | LL | #[link(name = "string"suffix)] | ^^^^^^^^^^^^^^ invalid suffix `suffix` error: invalid suffix `suffix` for number literal - --> $DIR/bad-lit-suffixes.rs:42:41 + --> $DIR/bad-lit-suffixes.rs:43:41 | LL | #[rustc_layout_scalar_valid_range_start(0suffix)] | ^^^^^^^ invalid suffix `suffix` @@ -136,5 +149,5 @@ LL | 1.0e10suffix; | = help: valid suffixes are `f32` and `f64` -error: aborting due to 20 previous errors +error: aborting due to 21 previous errors diff --git a/tests/ui/parser/bounds-type.rs b/tests/ui/parser/bounds-type.rs index 4ae4549ea58..bd5f6105f51 100644 --- a/tests/ui/parser/bounds-type.rs +++ b/tests/ui/parser/bounds-type.rs @@ -13,6 +13,7 @@ struct S< T: ~const ?Tr, // OK T: ~const Tr + 'a, // OK T: ~const 'a, //~ ERROR `~const` may only modify trait bounds, not lifetime bounds + T: const 'a, //~ ERROR `const` may only modify trait bounds, not lifetime bounds >; fn main() {} diff --git a/tests/ui/parser/bounds-type.stderr b/tests/ui/parser/bounds-type.stderr index 005bc1e54bd..d1210e88d66 100644 --- a/tests/ui/parser/bounds-type.stderr +++ b/tests/ui/parser/bounds-type.stderr @@ -10,5 +10,11 @@ error: `~const` may only modify trait bounds, not lifetime bounds LL | T: ~const 'a, | ^^^^^^ -error: aborting due to 2 previous errors +error: `const` may only modify trait bounds, not lifetime bounds + --> $DIR/bounds-type.rs:16:8 + | +LL | T: const 'a, + | ^^^^^ + +error: aborting due to 3 previous errors diff --git a/tests/ui/parser/trait-item-with-defaultness-fail-semantic.rs b/tests/ui/parser/defaultness-invalid-places-fail-semantic.rs index f2d97b7bac3..bff53f66e19 100644 --- a/tests/ui/parser/trait-item-with-defaultness-fail-semantic.rs +++ b/tests/ui/parser/defaultness-invalid-places-fail-semantic.rs @@ -10,3 +10,7 @@ trait X { default fn f1(); //~ ERROR `default` is only allowed on items in trait impls default fn f2() {} //~ ERROR `default` is only allowed on items in trait impls } + +default const E: u8 = 0; //~ ERROR `default` is only allowed on items in trait impls +default type F = (); //~ ERROR `default` is only allowed on items in trait impls +default fn h() {} //~ ERROR `default` is only allowed on items in trait impls diff --git a/tests/ui/parser/trait-item-with-defaultness-fail-semantic.stderr b/tests/ui/parser/defaultness-invalid-places-fail-semantic.stderr index be858cd651d..41fad3a5de3 100644 --- a/tests/ui/parser/trait-item-with-defaultness-fail-semantic.stderr +++ b/tests/ui/parser/defaultness-invalid-places-fail-semantic.stderr @@ -1,5 +1,5 @@ error: `default` is only allowed on items in trait impls - --> $DIR/trait-item-with-defaultness-fail-semantic.rs:6:5 + --> $DIR/defaultness-invalid-places-fail-semantic.rs:6:5 | LL | default const A: u8; | -------^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | default const A: u8; | `default` because of this error: `default` is only allowed on items in trait impls - --> $DIR/trait-item-with-defaultness-fail-semantic.rs:7:5 + --> $DIR/defaultness-invalid-places-fail-semantic.rs:7:5 | LL | default const B: u8 = 0; | -------^^^^^^^^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | default const B: u8 = 0; | `default` because of this error: `default` is only allowed on items in trait impls - --> $DIR/trait-item-with-defaultness-fail-semantic.rs:8:5 + --> $DIR/defaultness-invalid-places-fail-semantic.rs:8:5 | LL | default type D; | -------^^^^^^^^ @@ -23,7 +23,7 @@ LL | default type D; | `default` because of this error: `default` is only allowed on items in trait impls - --> $DIR/trait-item-with-defaultness-fail-semantic.rs:9:5 + --> $DIR/defaultness-invalid-places-fail-semantic.rs:9:5 | LL | default type C: Ord; | -------^^^^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | default type C: Ord; | `default` because of this error: `default` is only allowed on items in trait impls - --> $DIR/trait-item-with-defaultness-fail-semantic.rs:10:5 + --> $DIR/defaultness-invalid-places-fail-semantic.rs:10:5 | LL | default fn f1(); | -------^^^^^^^^^ @@ -39,15 +39,39 @@ LL | default fn f1(); | `default` because of this error: `default` is only allowed on items in trait impls - --> $DIR/trait-item-with-defaultness-fail-semantic.rs:11:5 + --> $DIR/defaultness-invalid-places-fail-semantic.rs:11:5 | LL | default fn f2() {} | -------^^^^^^^^ | | | `default` because of this +error: `default` is only allowed on items in trait impls + --> $DIR/defaultness-invalid-places-fail-semantic.rs:14:1 + | +LL | default const E: u8 = 0; + | -------^^^^^^^^^^^^^^^^^ + | | + | `default` because of this + +error: `default` is only allowed on items in trait impls + --> $DIR/defaultness-invalid-places-fail-semantic.rs:15:1 + | +LL | default type F = (); + | -------^^^^^^^^^^^^^ + | | + | `default` because of this + +error: `default` is only allowed on items in trait impls + --> $DIR/defaultness-invalid-places-fail-semantic.rs:16:1 + | +LL | default fn h() {} + | -------^^^^^^^ + | | + | `default` because of this + warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/trait-item-with-defaultness-fail-semantic.rs:1:12 + --> $DIR/defaultness-invalid-places-fail-semantic.rs:1:12 | LL | #![feature(specialization)] | ^^^^^^^^^^^^^^ @@ -56,5 +80,5 @@ LL | #![feature(specialization)] = help: consider using `min_specialization` instead, which is more stable and complete = note: `#[warn(incomplete_features)]` on by default -error: aborting due to 6 previous errors; 1 warning emitted +error: aborting due to 9 previous errors; 1 warning emitted diff --git a/tests/ui/parser/eq-gt-to-gt-eq.fixed b/tests/ui/parser/eq-gt-to-gt-eq.fixed new file mode 100644 index 00000000000..44cb464fc0c --- /dev/null +++ b/tests/ui/parser/eq-gt-to-gt-eq.fixed @@ -0,0 +1,45 @@ +// run-rustfix +// Check that we try to correct `=>` to `>=` in conditions. +#![allow(unused)] + +fn main() { + let a = 0; + let b = 1; + if a >= b {} //~ERROR +} + +fn foo() { + let a = 0; + if a >= 1 {} //~ERROR +} + +fn a() { + let a = 0; + if 1 >= a {} //~ERROR +} + +fn bar() { + let a = 0; + let b = 1; + if a >= b && a != b {} //~ERROR +} + +fn qux() { + let a = 0; + let b = 1; + if a != b && a >= b {} //~ERROR +} + +fn baz() { + let a = 0; + let b = 1; + let _ = a >= b; //~ERROR +} + +fn b() { + let a = 0; + let b = 1; + match a >= b { //~ERROR + _ => todo!(), + } +} diff --git a/tests/ui/parser/eq-gt-to-gt-eq.rs b/tests/ui/parser/eq-gt-to-gt-eq.rs new file mode 100644 index 00000000000..dca67c89cc0 --- /dev/null +++ b/tests/ui/parser/eq-gt-to-gt-eq.rs @@ -0,0 +1,45 @@ +// run-rustfix +// Check that we try to correct `=>` to `>=` in conditions. +#![allow(unused)] + +fn main() { + let a = 0; + let b = 1; + if a => b {} //~ERROR +} + +fn foo() { + let a = 0; + if a => 1 {} //~ERROR +} + +fn a() { + let a = 0; + if 1 => a {} //~ERROR +} + +fn bar() { + let a = 0; + let b = 1; + if a => b && a != b {} //~ERROR +} + +fn qux() { + let a = 0; + let b = 1; + if a != b && a => b {} //~ERROR +} + +fn baz() { + let a = 0; + let b = 1; + let _ = a => b; //~ERROR +} + +fn b() { + let a = 0; + let b = 1; + match a => b { //~ERROR + _ => todo!(), + } +} diff --git a/tests/ui/parser/eq-gt-to-gt-eq.stderr b/tests/ui/parser/eq-gt-to-gt-eq.stderr new file mode 100644 index 00000000000..73f465f7b9b --- /dev/null +++ b/tests/ui/parser/eq-gt-to-gt-eq.stderr @@ -0,0 +1,106 @@ +error: expected `{`, found `=>` + --> $DIR/eq-gt-to-gt-eq.rs:8:10 + | +LL | if a => b {} + | ^^ expected `{` + | +note: the `if` expression is missing a block after this condition + --> $DIR/eq-gt-to-gt-eq.rs:8:8 + | +LL | if a => b {} + | ^ +help: you might have meant to write a "greater than or equal to" comparison + | +LL | if a >= b {} + | ~~ + +error: expected `{`, found `=>` + --> $DIR/eq-gt-to-gt-eq.rs:13:10 + | +LL | if a => 1 {} + | ^^ expected `{` + | +note: the `if` expression is missing a block after this condition + --> $DIR/eq-gt-to-gt-eq.rs:13:8 + | +LL | if a => 1 {} + | ^ +help: you might have meant to write a "greater than or equal to" comparison + | +LL | if a >= 1 {} + | ~~ + +error: expected `{`, found `=>` + --> $DIR/eq-gt-to-gt-eq.rs:18:10 + | +LL | if 1 => a {} + | ^^ expected `{` + | +note: the `if` expression is missing a block after this condition + --> $DIR/eq-gt-to-gt-eq.rs:18:8 + | +LL | if 1 => a {} + | ^ +help: you might have meant to write a "greater than or equal to" comparison + | +LL | if 1 >= a {} + | ~~ + +error: expected `{`, found `=>` + --> $DIR/eq-gt-to-gt-eq.rs:24:10 + | +LL | if a => b && a != b {} + | ^^ expected `{` + | +note: the `if` expression is missing a block after this condition + --> $DIR/eq-gt-to-gt-eq.rs:24:8 + | +LL | if a => b && a != b {} + | ^ +help: you might have meant to write a "greater than or equal to" comparison + | +LL | if a >= b && a != b {} + | ~~ + +error: expected `{`, found `=>` + --> $DIR/eq-gt-to-gt-eq.rs:30:20 + | +LL | if a != b && a => b {} + | ^^ expected `{` + | +note: the `if` expression is missing a block after this condition + --> $DIR/eq-gt-to-gt-eq.rs:30:8 + | +LL | if a != b && a => b {} + | ^^^^^^^^^^^ +help: you might have meant to write a "greater than or equal to" comparison + | +LL | if a != b && a >= b {} + | ~~ + +error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `=>` + --> $DIR/eq-gt-to-gt-eq.rs:36:15 + | +LL | let _ = a => b; + | ^^ expected one of 8 possible tokens + | +help: you might have meant to write a "greater than or equal to" comparison + | +LL | let _ = a >= b; + | ~~ + +error: expected one of `!`, `.`, `::`, `?`, `{`, or an operator, found `=>` + --> $DIR/eq-gt-to-gt-eq.rs:42:13 + | +LL | match a => b { + | ----- ^^ expected one of `!`, `.`, `::`, `?`, `{`, or an operator + | | + | while parsing this `match` expression + | +help: you might have meant to write a "greater than or equal to" comparison + | +LL | match a >= b { + | ~~ + +error: aborting due to 7 previous errors + diff --git a/tests/ui/parser/issue-119042.rs b/tests/ui/parser/issue-119042.rs new file mode 100644 index 00000000000..a4fee169d1c --- /dev/null +++ b/tests/ui/parser/issue-119042.rs @@ -0,0 +1,7 @@ +// check-pass + +macro_rules! a { ($ty:ty) => {} } + +a! { for<T = &i32> fn() } + +fn main() {} diff --git a/tests/ui/parser/issues/issue-104620.rs b/tests/ui/parser/issues/issue-104620.rs index f49476c4408..fd0916b4411 100644 --- a/tests/ui/parser/issues/issue-104620.rs +++ b/tests/ui/parser/issues/issue-104620.rs @@ -1,4 +1,4 @@ #![feature(rustc_attrs)] -#![rustc_dummy=5z] //~ ERROR unexpected expression: `5z` +#![rustc_dummy=5z] //~ ERROR invalid suffix `z` for number literal fn main() {} diff --git a/tests/ui/parser/issues/issue-104620.stderr b/tests/ui/parser/issues/issue-104620.stderr index fa20b5f8b16..040c63a5fbf 100644 --- a/tests/ui/parser/issues/issue-104620.stderr +++ b/tests/ui/parser/issues/issue-104620.stderr @@ -1,8 +1,10 @@ -error: unexpected expression: `5z` +error: invalid suffix `z` for number literal --> $DIR/issue-104620.rs:3:16 | LL | #![rustc_dummy=5z] - | ^^ + | ^^ invalid suffix `z` + | + = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) error: aborting due to 1 previous error diff --git a/tests/ui/parser/issues/issue-24375.rs b/tests/ui/parser/issues/issue-24375.rs index 8d1bc579e7b..1d128d33e4f 100644 --- a/tests/ui/parser/issues/issue-24375.rs +++ b/tests/ui/parser/issues/issue-24375.rs @@ -3,7 +3,7 @@ static tmp : [&'static str; 2] = ["hello", "he"]; fn main() { let z = "hello"; match z { - tmp[0] => {} //~ ERROR expected one of `,`, `=>`, `@`, `if`, `|`, or `}`, found `[` + tmp[0] => {} //~ ERROR expected one of `=>`, `@`, `if`, or `|`, found `[` _ => {} } } diff --git a/tests/ui/parser/issues/issue-24375.stderr b/tests/ui/parser/issues/issue-24375.stderr index 2b980a5520f..bb1e19e9e6d 100644 --- a/tests/ui/parser/issues/issue-24375.stderr +++ b/tests/ui/parser/issues/issue-24375.stderr @@ -1,8 +1,8 @@ -error: expected one of `,`, `=>`, `@`, `if`, `|`, or `}`, found `[` +error: expected one of `=>`, `@`, `if`, or `|`, found `[` --> $DIR/issue-24375.rs:6:12 | LL | tmp[0] => {} - | ^ expected one of `,`, `=>`, `@`, `if`, `|`, or `}` + | ^ expected one of `=>`, `@`, `if`, or `|` error: aborting due to 1 previous error diff --git a/tests/ui/parser/macro/mbe-bare-trait-object-maybe-trait-bound.rs b/tests/ui/parser/macro/mbe-bare-trait-object-maybe-trait-bound.rs new file mode 100644 index 00000000000..fe062d62e5a --- /dev/null +++ b/tests/ui/parser/macro/mbe-bare-trait-object-maybe-trait-bound.rs @@ -0,0 +1,16 @@ +// Check that `?Trait` matches the macro fragment specifier `ty`. +// Syntactically trait object types can be "bare" (i.e., lack the prefix `dyn`), +// even in newer editions like Rust 2021. +// Therefore the arm `?$Trait:path` shouldn't get reached. + +// edition: 2021 +// check-pass + +macro_rules! check { + ($Ty:ty) => {}; + (?$Trait:path) => { compile_error!("non-ty"); }; +} + +check! { ?Trait } + +fn main() {} diff --git a/tests/ui/parser/match-arm-without-body.rs b/tests/ui/parser/match-arm-without-body.rs index c3487c2c658..4723abff8b6 100644 --- a/tests/ui/parser/match-arm-without-body.rs +++ b/tests/ui/parser/match-arm-without-body.rs @@ -66,8 +66,6 @@ fn main() { pat!() //~^ ERROR expected `,` following `match` arm //~| HELP missing a comma here - //~| ERROR `match` arm with no body - //~| HELP add a body after the pattern _ => {} } match Some(false) { diff --git a/tests/ui/parser/match-arm-without-body.stderr b/tests/ui/parser/match-arm-without-body.stderr index 3a06ed050b5..a3f7e32c177 100644 --- a/tests/ui/parser/match-arm-without-body.stderr +++ b/tests/ui/parser/match-arm-without-body.stderr @@ -1,8 +1,8 @@ -error: expected one of `,`, `=>`, `if`, `|`, or `}`, found reserved identifier `_` +error: expected one of `=>`, `if`, or `|`, found reserved identifier `_` --> $DIR/match-arm-without-body.rs:13:9 | LL | Some(_) - | - expected one of `,`, `=>`, `if`, `|`, or `}` + | - expected one of `=>`, `if`, or `|` LL | _ => {} | ^ unexpected token @@ -44,11 +44,11 @@ LL + LL ~ _ => {} | -error: expected one of `,`, `.`, `=>`, `?`, `}`, or an operator, found reserved identifier `_` +error: expected one of `.`, `=>`, `?`, or an operator, found reserved identifier `_` --> $DIR/match-arm-without-body.rs:36:9 | LL | Some(_) if true - | - expected one of `,`, `.`, `=>`, `?`, `}`, or an operator + | - expected one of `.`, `=>`, `?`, or an operator LL | _ => {} | ^ unexpected token @@ -68,19 +68,19 @@ error: `match` arm with no body --> $DIR/match-arm-without-body.rs:30:9 | LL | Some(_) if true - | ^^^^^^^^^^^^^^^- help: add a body after the pattern: `=> todo!(),` + | ^^^^^^^- help: add a body after the pattern: `=> todo!(),` error: `match` arm with no body --> $DIR/match-arm-without-body.rs:40:9 | LL | Some(_) if true, - | ^^^^^^^^^^^^^^^- help: add a body after the pattern: `=> todo!(),` + | ^^^^^^^- help: add a body after the pattern: `=> todo!(),` error: `match` arm with no body --> $DIR/match-arm-without-body.rs:45:9 | LL | Some(_) if true, - | ^^^^^^^^^^^^^^^- help: add a body after the pattern: `=> todo!(),` + | ^^^^^^^- help: add a body after the pattern: `=> todo!(),` error: `match` arm with no body --> $DIR/match-arm-without-body.rs:51:9 @@ -98,19 +98,13 @@ error: `match` arm with no body --> $DIR/match-arm-without-body.rs:61:9 | LL | pat!() if true, - | ^^^^^^^^^^^^^^- help: add a body after the pattern: `=> todo!(),` - -error: `match` arm with no body - --> $DIR/match-arm-without-body.rs:66:9 - | -LL | pat!() | ^^^^^^- help: add a body after the pattern: `=> todo!(),` error: `match` arm with no body - --> $DIR/match-arm-without-body.rs:74:9 + --> $DIR/match-arm-without-body.rs:72:9 | LL | pat!(), | ^^^^^^- help: add a body after the pattern: `=> todo!(),` -error: aborting due to 14 previous errors +error: aborting due to 13 previous errors diff --git a/tests/ui/parser/pat-lt-bracket-1.rs b/tests/ui/parser/pat-lt-bracket-1.rs index 33da15adb9e..2e2001434f2 100644 --- a/tests/ui/parser/pat-lt-bracket-1.rs +++ b/tests/ui/parser/pat-lt-bracket-1.rs @@ -1,7 +1,7 @@ fn main() { match 42 { x < 7 => (), - //~^ error: expected one of `,`, `=>`, `@`, `if`, `|`, or `}`, found `<` + //~^ error: expected one of `=>`, `@`, `if`, or `|`, found `<` _ => () } } diff --git a/tests/ui/parser/pat-lt-bracket-1.stderr b/tests/ui/parser/pat-lt-bracket-1.stderr index f39487052ad..14e679bbee0 100644 --- a/tests/ui/parser/pat-lt-bracket-1.stderr +++ b/tests/ui/parser/pat-lt-bracket-1.stderr @@ -1,8 +1,8 @@ -error: expected one of `,`, `=>`, `@`, `if`, `|`, or `}`, found `<` +error: expected one of `=>`, `@`, `if`, or `|`, found `<` --> $DIR/pat-lt-bracket-1.rs:3:7 | LL | x < 7 => (), - | ^ expected one of `,`, `=>`, `@`, `if`, `|`, or `}` + | ^ expected one of `=>`, `@`, `if`, or `|` error: aborting due to 1 previous error diff --git a/tests/ui/parser/recover/recover-fn-ptr-with-generics.rs b/tests/ui/parser/recover/recover-fn-ptr-with-generics.rs index 31de418be5f..76c56a715d2 100644 --- a/tests/ui/parser/recover/recover-fn-ptr-with-generics.rs +++ b/tests/ui/parser/recover/recover-fn-ptr-with-generics.rs @@ -21,7 +21,7 @@ fn main() { let _: extern fn<'a: 'static>(); //~^ ERROR function pointer types may not have generic parameters - //~| ERROR lifetime bounds cannot be used in this context + //~| ERROR bounds cannot be used in this context let _: for<'any> extern "C" fn<'u>(); //~^ ERROR function pointer types may not have generic parameters diff --git a/tests/ui/parser/recover/recover-fn-ptr-with-generics.stderr b/tests/ui/parser/recover/recover-fn-ptr-with-generics.stderr index 069fcffe9a0..6b6cb2d6bdd 100644 --- a/tests/ui/parser/recover/recover-fn-ptr-with-generics.stderr +++ b/tests/ui/parser/recover/recover-fn-ptr-with-generics.stderr @@ -100,7 +100,7 @@ error[E0412]: cannot find type `T` in this scope LL | type Identity = fn<T>(T) -> T; | ^ not found in this scope -error: lifetime bounds cannot be used in this context +error: bounds cannot be used in this context --> $DIR/recover-fn-ptr-with-generics.rs:22:26 | LL | let _: extern fn<'a: 'static>(); diff --git a/tests/ui/parser/trait-object-delimiters.rs b/tests/ui/parser/trait-object-delimiters.rs index e9b13defe03..240ae3084d6 100644 --- a/tests/ui/parser/trait-object-delimiters.rs +++ b/tests/ui/parser/trait-object-delimiters.rs @@ -8,7 +8,7 @@ fn foo2(_: &dyn (Drop + AsRef<str>)) {} //~ ERROR incorrect parentheses around t fn foo2_no_space(_: &dyn(Drop + AsRef<str>)) {} //~ ERROR incorrect parentheses around trait bounds fn foo3(_: &dyn {Drop + AsRef<str>}) {} //~ ERROR expected parameter name, found `{` -//~^ ERROR expected one of `!`, `(`, `)`, `*`, `,`, `?`, `for`, `~`, lifetime, or path, found `{` +//~^ ERROR expected one of `!`, `(`, `)`, `*`, `,`, `?`, `const`, `for`, `~`, lifetime, or path, found `{` //~| ERROR at least one trait is required for an object type fn foo4(_: &dyn <Drop + AsRef<str>>) {} //~ ERROR expected identifier, found `<` diff --git a/tests/ui/parser/trait-object-delimiters.stderr b/tests/ui/parser/trait-object-delimiters.stderr index 51954675093..2ddb734cee0 100644 --- a/tests/ui/parser/trait-object-delimiters.stderr +++ b/tests/ui/parser/trait-object-delimiters.stderr @@ -34,11 +34,11 @@ error: expected parameter name, found `{` LL | fn foo3(_: &dyn {Drop + AsRef<str>}) {} | ^ expected parameter name -error: expected one of `!`, `(`, `)`, `*`, `,`, `?`, `for`, `~`, lifetime, or path, found `{` +error: expected one of `!`, `(`, `)`, `*`, `,`, `?`, `const`, `for`, `~`, lifetime, or path, found `{` --> $DIR/trait-object-delimiters.rs:10:17 | LL | fn foo3(_: &dyn {Drop + AsRef<str>}) {} - | -^ expected one of 10 possible tokens + | -^ expected one of 11 possible tokens | | | help: missing `,` diff --git a/tests/ui/partialeq_help.stderr b/tests/ui/partialeq_help.stderr index fdff94f425c..f5de1308e87 100644 --- a/tests/ui/partialeq_help.stderr +++ b/tests/ui/partialeq_help.stderr @@ -5,6 +5,10 @@ LL | a == b; | ^^ no implementation for `&T == T` | = help: the trait `PartialEq<T>` is not implemented for `&T` +help: consider dereferencing here + | +LL | *a == b; + | + help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement | LL | fn foo<T: PartialEq>(a: &T, b: T) where &T: PartialEq<T> { @@ -17,6 +21,10 @@ LL | a == b; | ^^ no implementation for `&T == T` | = help: the trait `PartialEq<T>` is not implemented for `&T` +help: consider dereferencing here + | +LL | *a == b; + | + help: consider extending the `where` clause, but there might be an alternative better way to express this requirement | LL | fn foo2<T: PartialEq>(a: &T, b: T) where &T: PartialEq<T> { diff --git a/tests/ui/pattern/usefulness/impl-trait.rs b/tests/ui/pattern/usefulness/impl-trait.rs new file mode 100644 index 00000000000..ceb97315e9d --- /dev/null +++ b/tests/ui/pattern/usefulness/impl-trait.rs @@ -0,0 +1,155 @@ +#![feature(never_type)] +#![feature(exhaustive_patterns)] +#![feature(type_alias_impl_trait)] +#![feature(non_exhaustive_omitted_patterns_lint)] +#![deny(unreachable_patterns)] +// Test that the lint traversal handles opaques correctly +#![deny(non_exhaustive_omitted_patterns)] + +fn main() {} + +#[derive(Copy, Clone)] +enum Void {} + +fn return_never_rpit(x: Void) -> impl Copy { + if false { + match return_never_rpit(x) { + _ => {} //~ ERROR unreachable + } + } + x +} +fn friend_of_return_never_rpit(x: Void) { + match return_never_rpit(x) {} + //~^ ERROR non-empty +} + +type T = impl Copy; +fn return_never_tait(x: Void) -> T { + if false { + match return_never_tait(x) { + _ => {} //~ ERROR unreachable + } + } + x +} +fn friend_of_return_never_tait(x: Void) { + match return_never_tait(x) {} + //~^ ERROR non-empty +} + +fn option_never(x: Void) -> Option<impl Copy> { + if false { + match option_never(x) { + None => {} + Some(_) => {} //~ ERROR unreachable + } + match option_never(x) { + None => {} + _ => {} //~ ERROR unreachable + } + } + Some(x) +} + +fn option_never2(x: Void) -> impl Copy { + if false { + match option_never2(x) { + None => {} + Some(_) => {} //~ ERROR unreachable + } + match option_never2(x) { + None => {} + _ => {} //~ ERROR unreachable + } + match option_never2(x) { + None => {} + } + } + Some(x) +} + +fn inner_never(x: Void) { + type T = impl Copy; + let y: T = x; + match y { + _ => {} //~ ERROR unreachable + } +} + +// This one caused ICE https://github.com/rust-lang/rust/issues/117100. +fn inner_tuple() { + type T = impl Copy; + let foo: T = Some((1u32, 2u32)); + match foo { + _ => {} + Some((a, b)) => {} //~ ERROR unreachable + } +} + +type U = impl Copy; +fn unify_never(x: Void, u: U) -> U { + if false { + match u { + _ => {} //~ ERROR unreachable + } + } + x +} + +type V = impl Copy; +fn infer_in_match(x: Option<V>) { + match x { + None => {} + Some((a, b)) => {} + Some((mut x, mut y)) => { + //~^ ERROR unreachable + x = 42; + y = "foo"; + } + } +} + +type W = impl Copy; +#[derive(Copy, Clone)] +struct Rec<'a> { + n: u32, + w: Option<&'a W>, +} +fn recursive_opaque() -> W { + if false { + match recursive_opaque() { + // Check for the ol' ICE when the type is recursively opaque. + _ => {} + Rec { n: 0, w: Some(Rec { n: 0, w: _ }) } => {} //~ ERROR unreachable + } + } + let w: Option<&'static W> = None; + Rec { n: 0, w } +} + +type X = impl Copy; +struct SecretelyVoid(X); +fn nested_empty_opaque(x: Void) -> X { + if false { + let opaque_void = nested_empty_opaque(x); + let secretely_void = SecretelyVoid(opaque_void); + match secretely_void { + _ => {} //~ ERROR unreachable + } + } + x +} + +type Y = (impl Copy, impl Copy); +struct SecretelyDoubleVoid(Y); +fn super_nested_empty_opaque(x: Void) -> Y { + if false { + let opaque_void = super_nested_empty_opaque(x); + let secretely_void = SecretelyDoubleVoid(opaque_void); + match secretely_void { + _ => {} //~ ERROR unreachable + } + } + (x, x) +} diff --git a/tests/ui/pattern/usefulness/impl-trait.stderr b/tests/ui/pattern/usefulness/impl-trait.stderr new file mode 100644 index 00000000000..ba8b12f9f66 --- /dev/null +++ b/tests/ui/pattern/usefulness/impl-trait.stderr @@ -0,0 +1,119 @@ +error: unreachable pattern + --> $DIR/impl-trait.rs:17:13 + | +LL | _ => {} + | ^ + | +note: the lint level is defined here + --> $DIR/impl-trait.rs:5:9 + | +LL | #![deny(unreachable_patterns)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: unreachable pattern + --> $DIR/impl-trait.rs:31:13 + | +LL | _ => {} + | ^ + +error: unreachable pattern + --> $DIR/impl-trait.rs:45:13 + | +LL | Some(_) => {} + | ^^^^^^^ + +error: unreachable pattern + --> $DIR/impl-trait.rs:49:13 + | +LL | _ => {} + | ^ + +error: unreachable pattern + --> $DIR/impl-trait.rs:59:13 + | +LL | Some(_) => {} + | ^^^^^^^ + +error: unreachable pattern + --> $DIR/impl-trait.rs:63:13 + | +LL | _ => {} + | ^ + +error: unreachable pattern + --> $DIR/impl-trait.rs:76:9 + | +LL | _ => {} + | ^ + +error: unreachable pattern + --> $DIR/impl-trait.rs:86:9 + | +LL | _ => {} + | - matches any value +LL | Some((a, b)) => {} + | ^^^^^^^^^^^^ unreachable pattern + +error: unreachable pattern + --> $DIR/impl-trait.rs:94:13 + | +LL | _ => {} + | ^ + +error: unreachable pattern + --> $DIR/impl-trait.rs:105:9 + | +LL | Some((mut x, mut y)) => { + | ^^^^^^^^^^^^^^^^^^^^ + +error: unreachable pattern + --> $DIR/impl-trait.rs:124:13 + | +LL | _ => {} + | - matches any value +LL | Rec { n: 0, w: Some(Rec { n: 0, w: _ }) } => {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unreachable pattern + +error: unreachable pattern + --> $DIR/impl-trait.rs:138:13 + | +LL | _ => {} + | ^ + +error: unreachable pattern + --> $DIR/impl-trait.rs:151:13 + | +LL | _ => {} + | ^ + +error[E0004]: non-exhaustive patterns: type `impl Copy` is non-empty + --> $DIR/impl-trait.rs:23:11 + | +LL | match return_never_rpit(x) {} + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: the matched value is of type `impl Copy` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match return_never_rpit(x) { +LL + _ => todo!(), +LL + } + | + +error[E0004]: non-exhaustive patterns: type `T` is non-empty + --> $DIR/impl-trait.rs:37:11 + | +LL | match return_never_tait(x) {} + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: the matched value is of type `T` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match return_never_tait(x) { +LL + _ => todo!(), +LL + } + | + +error: aborting due to 15 previous errors + +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/pattern/usefulness/issue-118437-exponential-time-on-diagonal-match.rs b/tests/ui/pattern/usefulness/issue-118437-exponential-time-on-diagonal-match.rs new file mode 100644 index 00000000000..39ad2d4abf3 --- /dev/null +++ b/tests/ui/pattern/usefulness/issue-118437-exponential-time-on-diagonal-match.rs @@ -0,0 +1,72 @@ +// check-pass +struct BaseCommand { + field01: bool, + field02: bool, + field03: bool, + field04: bool, + field05: bool, + field06: bool, + field07: bool, + field08: bool, + field09: bool, + field10: bool, + field11: bool, + field12: bool, + field13: bool, + field14: bool, + field15: bool, + field16: bool, + field17: bool, + field18: bool, + field19: bool, + field20: bool, + field21: bool, + field22: bool, + field23: bool, + field24: bool, + field25: bool, + field26: bool, + field27: bool, + field28: bool, + field29: bool, + field30: bool, +} + +fn request_key(command: BaseCommand) { + match command { + BaseCommand { field01: true, .. } => {} + BaseCommand { field02: true, .. } => {} + BaseCommand { field03: true, .. } => {} + BaseCommand { field04: true, .. } => {} + BaseCommand { field05: true, .. } => {} + BaseCommand { field06: true, .. } => {} + BaseCommand { field07: true, .. } => {} + BaseCommand { field08: true, .. } => {} + BaseCommand { field09: true, .. } => {} + BaseCommand { field10: true, .. } => {} + BaseCommand { field11: true, .. } => {} + BaseCommand { field12: true, .. } => {} + BaseCommand { field13: true, .. } => {} + BaseCommand { field14: true, .. } => {} + BaseCommand { field15: true, .. } => {} + BaseCommand { field16: true, .. } => {} + BaseCommand { field17: true, .. } => {} + BaseCommand { field18: true, .. } => {} + BaseCommand { field19: true, .. } => {} + BaseCommand { field20: true, .. } => {} + BaseCommand { field21: true, .. } => {} + BaseCommand { field22: true, .. } => {} + BaseCommand { field23: true, .. } => {} + BaseCommand { field24: true, .. } => {} + BaseCommand { field25: true, .. } => {} + BaseCommand { field26: true, .. } => {} + BaseCommand { field27: true, .. } => {} + BaseCommand { field28: true, .. } => {} + BaseCommand { field29: true, .. } => {} + BaseCommand { field30: true, .. } => {} + + _ => {} + } +} + +fn main() {} diff --git a/tests/ui/print_type_sizes/coroutine_discr_placement.stdout b/tests/ui/print_type_sizes/coroutine_discr_placement.stdout index f34a8e9a706..71a7f3c6381 100644 --- a/tests/ui/print_type_sizes/coroutine_discr_placement.stdout +++ b/tests/ui/print_type_sizes/coroutine_discr_placement.stdout @@ -9,3 +9,9 @@ print-type-size padding: 3 bytes print-type-size local `.z`: 4 bytes, alignment: 4 bytes print-type-size variant `Returned`: 0 bytes print-type-size variant `Panicked`: 0 bytes +print-type-size type: `std::mem::ManuallyDrop<i32>`: 4 bytes, alignment: 4 bytes +print-type-size field `.value`: 4 bytes +print-type-size type: `std::mem::MaybeUninit<i32>`: 4 bytes, alignment: 4 bytes +print-type-size variant `MaybeUninit`: 4 bytes +print-type-size field `.uninit`: 0 bytes +print-type-size field `.value`: 4 bytes diff --git a/tests/ui/privacy/import-list-stem-visibility-issue-119126.rs b/tests/ui/privacy/import-list-stem-visibility-issue-119126.rs new file mode 100644 index 00000000000..21f7828fc84 --- /dev/null +++ b/tests/ui/privacy/import-list-stem-visibility-issue-119126.rs @@ -0,0 +1,14 @@ +// check-pass +// edition: 2018 + +mod outer { + mod inner { + pub mod inner2 {} + } + pub(crate) use inner::{}; + pub(crate) use inner::{{}}; + pub(crate) use inner::{inner2::{}}; + pub(crate) use inner::{inner2::{{}}}; +} + +fn main() {} diff --git a/tests/ui/privacy/unresolved-trait-impl-item.rs b/tests/ui/privacy/unresolved-trait-impl-item.rs new file mode 100644 index 00000000000..fea7c462a8e --- /dev/null +++ b/tests/ui/privacy/unresolved-trait-impl-item.rs @@ -0,0 +1,15 @@ +// edition:2018 + +trait MyTrait { + async fn resolved(&self); + const RESOLVED_WRONG: u8 = 0; +} + +impl MyTrait for i32 { + async fn resolved(&self) {} + + async fn unresolved(&self) {} //~ ERROR method `unresolved` is not a member of trait `MyTrait` + async fn RESOLVED_WRONG() {} //~ ERROR doesn't match its trait `MyTrait` +} + +fn main() {} diff --git a/tests/ui/privacy/unresolved-trait-impl-item.stderr b/tests/ui/privacy/unresolved-trait-impl-item.stderr new file mode 100644 index 00000000000..588e47c26bc --- /dev/null +++ b/tests/ui/privacy/unresolved-trait-impl-item.stderr @@ -0,0 +1,22 @@ +error[E0407]: method `unresolved` is not a member of trait `MyTrait` + --> $DIR/unresolved-trait-impl-item.rs:11:5 + | +LL | async fn unresolved(&self) {} + | ^^^^^^^^^----------^^^^^^^^^^ + | | | + | | help: there is an associated function with a similar name: `resolved` + | not a member of trait `MyTrait` + +error[E0324]: item `RESOLVED_WRONG` is an associated method, which doesn't match its trait `MyTrait` + --> $DIR/unresolved-trait-impl-item.rs:12:5 + | +LL | const RESOLVED_WRONG: u8 = 0; + | ----------------------------- item in trait +... +LL | async fn RESOLVED_WRONG() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ does not match trait + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0324, E0407. +For more information about an error, try `rustc --explain E0324`. diff --git a/tests/ui/proc-macro/auxiliary/env.rs b/tests/ui/proc-macro/auxiliary/env.rs new file mode 100644 index 00000000000..58bcb08bf06 --- /dev/null +++ b/tests/ui/proc-macro/auxiliary/env.rs @@ -0,0 +1,28 @@ +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] +#![feature(proc_macro_tracked_env)] + +extern crate proc_macro; + +use proc_macro::TokenStream; +use proc_macro::tracked_env::var; + +#[proc_macro] +pub fn generate_const(input: TokenStream) -> TokenStream { + let the_const = match var("THE_CONST") { + Ok(x) if x == "12" => { + "const THE_CONST: u32 = 12;" + } + _ => { + "const THE_CONST: u32 = 0;" + } + }; + let another = if var("ANOTHER").is_ok() { + "const ANOTHER: u32 = 1;" + } else { + "const ANOTHER: u32 = 2;" + }; + format!("{the_const}{another}").parse().unwrap() +} diff --git a/tests/ui/proc-macro/env.rs b/tests/ui/proc-macro/env.rs new file mode 100644 index 00000000000..1b1d1873eb3 --- /dev/null +++ b/tests/ui/proc-macro/env.rs @@ -0,0 +1,17 @@ +// aux-build:env.rs +// run-pass +// rustc-env: THE_CONST=1 +// compile-flags: -Zunstable-options --env THE_CONST=12 --env ANOTHER=4 + +#![crate_name = "foo"] + +extern crate env; + +use env::generate_const; + +generate_const!(); + +fn main() { + assert_eq!(THE_CONST, 12); + assert_eq!(ANOTHER, 1); +} diff --git a/tests/ui/proc-macro/inner-attr-non-inline-mod.stderr b/tests/ui/proc-macro/inner-attr-non-inline-mod.stderr index 2d357d04d5c..36825e5a398 100644 --- a/tests/ui/proc-macro/inner-attr-non-inline-mod.stderr +++ b/tests/ui/proc-macro/inner-attr-non-inline-mod.stderr @@ -38,3 +38,14 @@ LL | #![rustfmt::skip] error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0658`. +Future incompatibility report: Future breakage diagnostic: +error: custom inner attributes are unstable + --> $DIR/module_with_attrs.rs:3:4 + | +LL | #![rustfmt::skip] + | ^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266> + = note: `#[deny(soft_unstable)]` on by default + diff --git a/tests/ui/proc-macro/proc-macro-gates.stderr b/tests/ui/proc-macro/proc-macro-gates.stderr index 3feb9b8290f..ab98784bfbd 100644 --- a/tests/ui/proc-macro/proc-macro-gates.stderr +++ b/tests/ui/proc-macro/proc-macro-gates.stderr @@ -89,3 +89,14 @@ LL | #![test] error: aborting due to 10 previous errors For more information about this error, try `rustc --explain E0658`. +Future incompatibility report: Future breakage diagnostic: +error: inner macro attributes are unstable + --> $DIR/proc-macro-gates.rs:49:8 + | +LL | #![test] + | ^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266> + = note: `#[deny(soft_unstable)]` on by default + diff --git a/tests/ui/recursion/issue-95134.rs b/tests/ui/recursion/issue-95134.rs index 7ee31d85c2b..2f1cffa2fa9 100644 --- a/tests/ui/recursion/issue-95134.rs +++ b/tests/ui/recursion/issue-95134.rs @@ -3,7 +3,6 @@ // compile-flags: -Copt-level=0 // dont-check-failure-status // dont-check-compiler-stderr -// ignore-compare-mode-next-solver (hangs) pub fn encode_num<Writer: ExampleWriter>(n: u32, mut writer: Writer) -> Result<(), Writer::Error> { if n > 15 { diff --git a/tests/ui/regions/resolve-re-error-ice.rs b/tests/ui/regions/resolve-re-error-ice.rs index f37b27a82b3..bf6defb9bae 100644 --- a/tests/ui/regions/resolve-re-error-ice.rs +++ b/tests/ui/regions/resolve-re-error-ice.rs @@ -1,8 +1,3 @@ -// check-pass - -// Allow this for now, can remove this UI test when this becomes a hard error. -#![allow(implied_bounds_entailment)] - use std::collections::hash_map::{Keys, HashMap}; use std::marker::PhantomData; @@ -15,6 +10,7 @@ struct Subject<'a, T, V, R>(PhantomData<(&'a T, V, R)>); impl<'a, K, V, R> MapAssertion<'a, K, V, R> for Subject<'a, HashMap<K, V>, (), R> { fn key_set(&self) -> Subject<'a, Keys<K, V>, (), R> { + //~^ ERROR cannot infer an appropriate lifetime for lifetime parameter '_ in generic type due to conflicting requirements todo!() } } diff --git a/tests/ui/regions/resolve-re-error-ice.stderr b/tests/ui/regions/resolve-re-error-ice.stderr index e7003e1c32f..41c5f0fa92e 100644 --- a/tests/ui/regions/resolve-re-error-ice.stderr +++ b/tests/ui/regions/resolve-re-error-ice.stderr @@ -1,15 +1,37 @@ -Future incompatibility report: Future breakage diagnostic: -warning: impl method assumes more implied bounds than the corresponding trait method - --> $DIR/resolve-re-error-ice.rs:17:16 +error[E0495]: cannot infer an appropriate lifetime for lifetime parameter '_ in generic type due to conflicting requirements + --> $DIR/resolve-re-error-ice.rs:12:5 | LL | fn key_set(&self) -> Subject<'a, Keys<K, V>, (), R> { - | ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this type to make the impl signature compatible: `Subject<'_, std::collections::hash_map::Keys<'_, K, V>, (), R>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #105572 <https://github.com/rust-lang/rust/issues/105572> -note: the lint level is defined here - --> $DIR/resolve-re-error-ice.rs:4:10 +note: first, the lifetime cannot outlive the anonymous lifetime defined here... + --> $DIR/resolve-re-error-ice.rs:5:16 | -LL | #![allow(implied_bounds_entailment)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn key_set(&self) -> Subject<Keys<K, V>, (), R>; + | ^^^^^ +note: ...so that the method type is compatible with trait + --> $DIR/resolve-re-error-ice.rs:12:5 + | +LL | fn key_set(&self) -> Subject<'a, Keys<K, V>, (), R> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: expected `fn(&Subject<'_, _, _, _>) -> Subject<'_, std::collections::hash_map::Keys<'_, _, _>, _, _>` + found `fn(&Subject<'_, _, _, _>) -> Subject<'a, std::collections::hash_map::Keys<'_, _, _>, _, _>` +note: but, the lifetime must be valid for the lifetime `'a` as defined here... + --> $DIR/resolve-re-error-ice.rs:10:6 + | +LL | impl<'a, K, V, R> MapAssertion<'a, K, V, R> for Subject<'a, HashMap<K, V>, (), R> + | ^^ +note: ...so that the type `std::collections::hash_map::Keys<'_, K, V>` will meet its required lifetime bounds... + --> $DIR/resolve-re-error-ice.rs:12:5 + | +LL | fn key_set(&self) -> Subject<'a, Keys<K, V>, (), R> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...that is required by this bound + --> $DIR/resolve-re-error-ice.rs:8:29 + | +LL | struct Subject<'a, T, V, R>(PhantomData<(&'a T, V, R)>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error +For more information about this error, try `rustc --explain E0495`. diff --git a/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.rs b/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.rs index c27e8c4b019..c7665affb99 100644 --- a/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.rs +++ b/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.rs @@ -1,7 +1,7 @@ // Check that we can manually implement an object-unsafe trait for its trait object. // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver // run-pass #![feature(object_safe_for_dispatch)] diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/drop-order.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/drop-order.rs new file mode 100644 index 00000000000..9bb25a66f09 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/drop-order.rs @@ -0,0 +1,59 @@ +// check drop order of temporaries create in match guards. +// For normal guards all temporaries are dropped before the body of the arm. +// For let guards temporaries live until the end of the arm. + +// run-pass + +#![feature(if_let_guard)] +#![allow(irrefutable_let_patterns)] + +use std::sync::Mutex; + +static A: Mutex<Vec<i32>> = Mutex::new(Vec::new()); + +struct D(i32); + +fn make_d(x: i32) -> D { + A.lock().unwrap().push(x); + D(x) +} + +impl Drop for D { + fn drop(&mut self) { + A.lock().unwrap().push(!self.0); + } +} + +fn if_guard(num: i32) { + let _d = make_d(1); + match num { + 1 | 2 if make_d(2).0 == 2 => { + make_d(3); + } + _ => {} + } +} + +fn if_let_guard(num: i32) { + let _d = make_d(1); + match num { + 1 | 2 if let D(ref _x) = make_d(2) => { + make_d(3); + } + _ => {} + } +} + +fn main() { + if_guard(1); + if_guard(2); + if_let_guard(1); + if_let_guard(2); + let expected = [ + 1, 2, !2, 3, !3, !1, + 1, 2, !2, 3, !3, !1, + 1, 2, 3, !3, !2, !1, + 1, 2, 3, !3, !2, !1, + ]; + assert_eq!(*A.lock().unwrap(), expected); +} diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/loop-mutability.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/loop-mutability.rs new file mode 100644 index 00000000000..349a24579a4 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/loop-mutability.rs @@ -0,0 +1,19 @@ +// check-pass + +#![feature(if_let_guard)] + +fn split_last(_: &()) -> Option<(&i32, &i32)> { + None +} + +fn assign_twice() { + loop { + match () { + #[allow(irrefutable_let_patterns)] + () if let _ = split_last(&()) => {} + _ => {} + } + } +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/scoping-consistency-async.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/scoping-consistency-async.rs new file mode 100644 index 00000000000..86a170141f8 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/scoping-consistency-async.rs @@ -0,0 +1,32 @@ +// Check that temporaries in if-let guards are correctly scoped. +// Regression test for #116079. + +// build-pass +// edition:2018 +// -Zvalidate-mir + +#![feature(if_let_guard)] + +static mut A: [i32; 5] = [1, 2, 3, 4, 5]; + +async fn fun() { + unsafe { + match A { + _ => (), + i if let Some(1) = async { Some(1) }.await => (), + _ => (), + } + } +} + +async fn funner() { + unsafe { + match A { + _ => (), + _ | _ if let Some(1) = async { Some(1) }.await => (), + _ => (), + } + } +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/scoping-consistency.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/scoping-consistency.rs new file mode 100644 index 00000000000..37fe610637e --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/scoping-consistency.rs @@ -0,0 +1,24 @@ +// Check that temporaries in if-let guards are correctly scoped. + +// build-pass +// -Zvalidate-mir + +#![feature(if_let_guard)] + +fn fun() { + match 0 { + _ => (), + _ if let Some(s) = std::convert::identity(&Some(String::new())) => {} + _ => (), + } +} + +fn funner() { + match 0 { + _ => (), + _ | _ if let Some(s) = std::convert::identity(&Some(String::new())) => {} + _ => (), + } +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-expected-behavior.run.stderr b/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-expected-behavior.run.stderr index 1a26f34a52d..2c018ca875d 100644 --- a/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-expected-behavior.run.stderr +++ b/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-expected-behavior.run.stderr @@ -1,28 +1,28 @@ -[$DIR/dbg-macro-expected-behavior.rs:22] Unit = Unit -[$DIR/dbg-macro-expected-behavior.rs:23] a = Unit -[$DIR/dbg-macro-expected-behavior.rs:29] Point { x: 42, y: 24 } = Point { +[$DIR/dbg-macro-expected-behavior.rs:22:19] Unit = Unit +[$DIR/dbg-macro-expected-behavior.rs:23:19] a = Unit +[$DIR/dbg-macro-expected-behavior.rs:29:24] Point { x: 42, y: 24 } = Point { x: 42, y: 24, } -[$DIR/dbg-macro-expected-behavior.rs:30] b = Point { +[$DIR/dbg-macro-expected-behavior.rs:30:24] b = Point { x: 42, y: 24, } -[$DIR/dbg-macro-expected-behavior.rs:38] -[$DIR/dbg-macro-expected-behavior.rs:42] &a = NoCopy( +[$DIR/dbg-macro-expected-behavior.rs:38:17] +[$DIR/dbg-macro-expected-behavior.rs:42:27] &a = NoCopy( 1337, ) -[$DIR/dbg-macro-expected-behavior.rs:42] dbg!(&a) = NoCopy( +[$DIR/dbg-macro-expected-behavior.rs:42:22] dbg!(&a) = NoCopy( 1337, ) -[$DIR/dbg-macro-expected-behavior.rs:47] f(&42) = 42 +[$DIR/dbg-macro-expected-behavior.rs:47:18] f(&42) = 42 before -[$DIR/dbg-macro-expected-behavior.rs:52] { foo += 1; eprintln!("before"); 7331 } = 7331 -[$DIR/dbg-macro-expected-behavior.rs:60] ("Yeah",) = ( +[$DIR/dbg-macro-expected-behavior.rs:52:22] { foo += 1; eprintln!("before"); 7331 } = 7331 +[$DIR/dbg-macro-expected-behavior.rs:60:27] ("Yeah",) = ( "Yeah", ) -[$DIR/dbg-macro-expected-behavior.rs:63] 1 = 1 -[$DIR/dbg-macro-expected-behavior.rs:63] 2 = 2 -[$DIR/dbg-macro-expected-behavior.rs:67] 1u8 = 1 -[$DIR/dbg-macro-expected-behavior.rs:67] 2u32 = 2 -[$DIR/dbg-macro-expected-behavior.rs:67] "Yeah" = "Yeah" +[$DIR/dbg-macro-expected-behavior.rs:63:29] 1 = 1 +[$DIR/dbg-macro-expected-behavior.rs:63:29] 2 = 2 +[$DIR/dbg-macro-expected-behavior.rs:67:37] 1u8 = 1 +[$DIR/dbg-macro-expected-behavior.rs:67:37] 2u32 = 2 +[$DIR/dbg-macro-expected-behavior.rs:67:37] "Yeah" = "Yeah" diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type.stderr index 290ef6e2f5f..58ad1849d4f 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type.stderr @@ -6,7 +6,7 @@ LL | type Bar: ~const std::ops::Add; | = note: this item cannot have `~const` trait bounds -error: ~const can only be applied to `#[const_trait]` traits +error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/assoc-type.rs:17:22 | LL | type Bar: ~const std::ops::Add; diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-pass.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-pass.stderr index 60cd000f2d8..e72d259e8a5 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-pass.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-pass.stderr @@ -5,6 +5,7 @@ LL | a.plus(b) | ^^^^^^^ | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = help: add `#![feature(effects)]` to the crate attributes to enable error[E0015]: cannot call non-const operator in constants --> $DIR/call-const-trait-method-pass.rs:39:22 @@ -18,6 +19,7 @@ note: impl defined here, but it is not `const` LL | impl const std::ops::Add for Int { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: calls in constants are limited to constant functions, tuple structs and tuple variants + = help: add `#![feature(effects)]` to the crate attributes to enable error: aborting due to 2 previous errors diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/call.rs index 5f48c235373..e85976b7e1d 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/call.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call.rs @@ -1,6 +1,6 @@ // check-pass -#![feature(const_closures, const_trait_impl)] +#![feature(const_closures, const_trait_impl, effects)] #![allow(incomplete_features)] pub const _: () = { diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-bounds-non-const-trait.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-bounds-non-const-trait.rs new file mode 100644 index 00000000000..3582e5e050c --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-bounds-non-const-trait.rs @@ -0,0 +1,12 @@ +// Regression test for issue #117244. +#![feature(const_trait_impl, effects)] + +trait NonConst {} + +const fn perform<T: ~const NonConst>() {} +//~^ ERROR `~const` can only be applied to `#[const_trait]` traits + +fn operate<T: const NonConst>() {} +//~^ ERROR `const` can only be applied to `#[const_trait]` traits + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-bounds-non-const-trait.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-bounds-non-const-trait.stderr new file mode 100644 index 00000000000..08954987d31 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-bounds-non-const-trait.stderr @@ -0,0 +1,14 @@ +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-bounds-non-const-trait.rs:6:28 + | +LL | const fn perform<T: ~const NonConst>() {} + | ^^^^^^^^ + +error: `const` can only be applied to `#[const_trait]` traits + --> $DIR/const-bounds-non-const-trait.rs:9:21 + | +LL | fn operate<T: const NonConst>() {} + | ^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-parse-not-item.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-parse-not-item.stderr index fc9b5557a64..ace2e7e46c4 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-parse-not-item.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-parse-not-item.stderr @@ -1,4 +1,4 @@ -error: ~const can only be applied to `#[const_trait]` traits +error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/const-closure-parse-not-item.rs:7:32 | LL | const fn test() -> impl ~const Fn() { diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr index 73ee0f2151a..d70b0d66177 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr @@ -1,4 +1,4 @@ -error: ~const can only be applied to `#[const_trait]` traits +error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/const-closure-trait-method-fail.rs:14:39 | LL | const fn need_const_closure<T: ~const FnOnce(()) -> i32>(x: T) -> i32 { diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method.stderr index 33ae7131b92..1642de78692 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method.stderr @@ -1,4 +1,4 @@ -error: ~const can only be applied to `#[const_trait]` traits +error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/const-closure-trait-method.rs:14:39 | LL | const fn need_const_closure<T: ~const FnOnce(()) -> i32>(x: T) -> i32 { diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closures.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closures.stderr index 6d61b23e4b7..2e448c64d7a 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closures.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closures.stderr @@ -1,22 +1,22 @@ -error: ~const can only be applied to `#[const_trait]` traits +error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/const-closures.rs:8:19 | LL | F: ~const FnOnce() -> u8, | ^^^^^^^^^^^^^^ -error: ~const can only be applied to `#[const_trait]` traits +error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/const-closures.rs:9:19 | LL | F: ~const FnMut() -> u8, | ^^^^^^^^^^^^^ -error: ~const can only be applied to `#[const_trait]` traits +error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/const-closures.rs:10:19 | LL | F: ~const Fn() -> u8, | ^^^^^^^^^^ -error: ~const can only be applied to `#[const_trait]` traits +error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/const-closures.rs:23:27 | LL | const fn answer<F: ~const Fn() -> u8>(f: &F) -> u8 { diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.precise.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.precise.stderr index 13350a6d14a..7529af9293d 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.precise.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.precise.stderr @@ -7,7 +7,7 @@ LL | impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> { = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` = note: adding a non-const method body in the future would be a breaking change -error: ~const can only be applied to `#[const_trait]` traits +error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/const-drop-fail-2.rs:29:26 | LL | const fn check<T: ~const Destruct>(_: T) {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stock.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stock.stderr index 13350a6d14a..7529af9293d 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stock.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stock.stderr @@ -7,7 +7,7 @@ LL | impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> { = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` = note: adding a non-const method body in the future would be a breaking change -error: ~const can only be applied to `#[const_trait]` traits +error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/const-drop-fail-2.rs:29:26 | LL | const fn check<T: ~const Destruct>(_: T) {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.precise.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.precise.stderr index daaba08d7dd..f166bdf6cec 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.precise.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.precise.stderr @@ -1,10 +1,15 @@ -error: `~const` is not allowed here - --> $DIR/const-drop.rs:67:38 +error[E0493]: destructor of `T` cannot be evaluated at compile-time + --> $DIR/const-drop.rs:19:32 | -LL | pub struct ConstDropWithBound<T: ~const SomeTrait>(pub core::marker::PhantomData<T>); - | ^^^^^^ +LL | const fn a<T: ~const Destruct>(_: T) {} + | ^ the destructor for this type cannot be evaluated in constant functions + +error[E0493]: destructor of `S<'_>` cannot be evaluated at compile-time + --> $DIR/const-drop.rs:24:13 | - = note: this item cannot have `~const` trait bounds +LL | let _ = S(&mut c); + | ^^^^^^^^^ the destructor for this type cannot be evaluated in constant functions -error: aborting due to 1 previous error +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.rs index 9da84cdb052..4836d2b02ce 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.rs @@ -4,7 +4,7 @@ #![feature(const_trait_impl)] #![feature(const_mut_refs)] #![feature(never_type)] -// #![cfg_attr(precise, feature(const_precise_live_drops))] +#![cfg_attr(precise, feature(const_precise_live_drops))] use std::marker::Destruct; @@ -63,8 +63,7 @@ mod t { fn foo() {} } - // FIXME(effects): This should be a `const` bound instead of a `~const` one. - pub struct ConstDropWithBound<T: ~const SomeTrait>(pub core::marker::PhantomData<T>); + pub struct ConstDropWithBound<T: const SomeTrait>(pub core::marker::PhantomData<T>); impl<T: ~const SomeTrait> const Drop for ConstDropWithBound<T> { fn drop(&mut self) { diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.stock.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.stock.stderr index daaba08d7dd..23e36887025 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.stock.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.stock.stderr @@ -1,10 +1,19 @@ -error: `~const` is not allowed here - --> $DIR/const-drop.rs:67:38 +error[E0493]: destructor of `T` cannot be evaluated at compile-time + --> $DIR/const-drop.rs:19:32 | -LL | pub struct ConstDropWithBound<T: ~const SomeTrait>(pub core::marker::PhantomData<T>); - | ^^^^^^ +LL | const fn a<T: ~const Destruct>(_: T) {} + | ^ - value is dropped here + | | + | the destructor for this type cannot be evaluated in constant functions + +error[E0493]: destructor of `S<'_>` cannot be evaluated at compile-time + --> $DIR/const-drop.rs:24:13 | - = note: this item cannot have `~const` trait bounds +LL | let _ = S(&mut c); + | ^^^^^^^^^- value is dropped here + | | + | the destructor for this type cannot be evaluated in constant functions -error: aborting due to 1 previous error +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-trait-bounds-trait-objects.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-trait-bounds-trait-objects.rs new file mode 100644 index 00000000000..86706671316 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-trait-bounds-trait-objects.rs @@ -0,0 +1,9 @@ +#![feature(const_trait_impl)] +// edition: 2021 + +#[const_trait] +trait Trait {} + +fn main() { + let _: &dyn const Trait; //~ ERROR const trait bounds are not allowed in trait object types +} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-trait-bounds-trait-objects.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-trait-bounds-trait-objects.stderr new file mode 100644 index 00000000000..8b9ba94d099 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-trait-bounds-trait-objects.stderr @@ -0,0 +1,8 @@ +error: const trait bounds are not allowed in trait object types + --> $DIR/const-trait-bounds-trait-objects.rs:8:17 + | +LL | let _: &dyn const Trait; + | ^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-trait-bounds.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-trait-bounds.rs new file mode 100644 index 00000000000..1ebebe632c7 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-trait-bounds.rs @@ -0,0 +1,31 @@ +// check-pass + +#![feature(const_trait_impl, effects, generic_const_exprs)] +#![allow(incomplete_features)] + +fn main() { + let _ = process::<()>([()]); + let _ = Struct::<(), 4> { field: [1, 0] }; +} + +fn process<T: const Trait>(input: [(); T::make(2)]) -> [(); T::make(2)] { + input +} + +struct Struct<T: const Trait, const P: usize> +where + [u32; T::make(P)]:, +{ + field: [u32; T::make(P)], +} + +#[const_trait] +trait Trait { + fn make(input: usize) -> usize; +} + +impl const Trait for () { + fn make(input: usize) -> usize { + input / 2 + } +} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate-default-method-body-is-const.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate-default-method-body-is-const.rs index bde8bf20f46..34a0ba1e271 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate-default-method-body-is-const.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate-default-method-body-is-const.rs @@ -3,7 +3,7 @@ // // check-pass -#![feature(const_trait_impl)] +#![feature(const_trait_impl, effects)] // aux-build: cross-crate.rs extern crate cross_crate; diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/const_closure-const_trait_impl-ice-113381.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/const_closure-const_trait_impl-ice-113381.rs index 6598d1da0f8..7d811a2cc1f 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/const_closure-const_trait_impl-ice-113381.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/const_closure-const_trait_impl-ice-113381.rs @@ -1,3 +1,5 @@ +// check-pass +// FIXME(effects) this shouldn't pass #![feature(const_closures, const_trait_impl, effects)] #![allow(incomplete_features)] @@ -11,5 +13,5 @@ impl Foo for () { fn main() { (const || { (()).foo() })(); - //~^ ERROR: cannot call non-const fn + // FIXME(effects) ~^ ERROR: cannot call non-const fn } diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/const_closure-const_trait_impl-ice-113381.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/const_closure-const_trait_impl-ice-113381.stderr deleted file mode 100644 index 413e217020d..00000000000 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/const_closure-const_trait_impl-ice-113381.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0015]: cannot call non-const fn `<() as Foo>::foo` in constant functions - --> $DIR/const_closure-const_trait_impl-ice-113381.rs:13:22 - | -LL | (const || { (()).foo() })(); - | ^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/ice-112822-expected-type-for-param.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/ice-112822-expected-type-for-param.rs new file mode 100644 index 00000000000..c6be75a6a2f --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/ice-112822-expected-type-for-param.rs @@ -0,0 +1,16 @@ +#![feature(const_trait_impl, effects)] + +const fn test() -> impl ~const Fn() { //~ ERROR `~const` can only be applied to `#[const_trait]` traits + const move || { //~ ERROR const closures are experimental + let sl: &[u8] = b"foo"; + + match sl { + [first, remainder @ ..] => { + assert_eq!(first, &b'f'); + } + [] => panic!(), + } + } +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/ice-112822-expected-type-for-param.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/ice-112822-expected-type-for-param.stderr new file mode 100644 index 00000000000..fe6b613d154 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/ice-112822-expected-type-for-param.stderr @@ -0,0 +1,18 @@ +error[E0658]: const closures are experimental + --> $DIR/ice-112822-expected-type-for-param.rs:4:5 + | +LL | const move || { + | ^^^^^ + | + = note: see issue #106003 <https://github.com/rust-lang/rust/issues/106003> for more information + = help: add `#![feature(const_closures)]` to the crate attributes to enable + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/ice-112822-expected-type-for-param.rs:3:32 + | +LL | const fn test() -> impl ~const Fn() { + | ^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.rs index 2a2e8cec3f0..59fb48e794c 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.rs @@ -1,12 +1,13 @@ // check-pass #![crate_type = "lib"] -#![feature(no_core, lang_items, unboxed_closures, auto_traits, intrinsics, rustc_attrs)] +#![feature(no_core, lang_items, unboxed_closures, auto_traits, intrinsics, rustc_attrs, staged_api)] #![feature(fundamental)] #![feature(const_trait_impl, effects, const_mut_refs)] #![allow(internal_features)] #![no_std] #![no_core] +#![stable(feature = "minicore", since = "1.0.0")] #[lang = "sized"] trait Sized {} @@ -82,6 +83,7 @@ trait FnMut<Args: Tuple>: ~const FnOnce<Args> { #[lang = "fn_once"] #[rustc_paren_sugar] trait FnOnce<Args: Tuple> { + #[lang = "fn_once_output"] type Output; extern "rust-call" fn call_once(self, args: Args) -> Self::Output; @@ -93,7 +95,7 @@ struct ConstFnMutClosure<CapturedData, Function> { } #[lang = "tuple_trait"] -pub trait Tuple {} +trait Tuple {} macro_rules! impl_fn_mut_tuple { ($($var:ident)*) => { @@ -509,3 +511,17 @@ trait StructuralPartialEq {} trait StructuralEq {} const fn drop<T: ~const Destruct>(_: T) {} + +extern "rust-intrinsic" { + #[rustc_const_stable(feature = "const_eval_select", since = "1.0.0")] + fn const_eval_select<ARG: Tuple, F, G, RET>( + arg: ARG, + called_in_const: F, + called_at_rt: G, + ) -> RET + /* where clauses enforced by built-in method confirmation: + where + F: const FnOnce<Arg, Output = RET>, + G: FnOnce<Arg, Output = RET>, + */; +} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/feature-gate.gated.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/feature-gate.gated.stderr index 663cdd1fe57..12f9355e41d 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/feature-gate.gated.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/feature-gate.gated.stderr @@ -1,5 +1,5 @@ error: fatal error triggered by #[rustc_error] - --> $DIR/feature-gate.rs:14:1 + --> $DIR/feature-gate.rs:22:1 | LL | fn main() {} | ^^^^^^^^^ diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/feature-gate.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/feature-gate.rs index 0b409fbaac9..015d90aaf21 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/feature-gate.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/feature-gate.rs @@ -10,5 +10,13 @@ trait T {} impl const T for S {} //[stock]~^ ERROR const trait impls are experimental +const fn f<A: ~const T>() {} //[stock]~ ERROR const trait impls are experimental +fn g<A: const T>() {} //[stock]~ ERROR const trait impls are experimental + +macro_rules! discard { ($ty:ty) => {} } + +discard! { impl ~const T } //[stock]~ ERROR const trait impls are experimental +discard! { impl const T } //[stock]~ ERROR const trait impls are experimental + #[rustc_error] fn main() {} //[gated]~ ERROR fatal error triggered by #[rustc_error] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/feature-gate.stock.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/feature-gate.stock.stderr index 0e938c1c55d..c9826aeb166 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/feature-gate.stock.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/feature-gate.stock.stderr @@ -7,6 +7,42 @@ LL | impl const T for S {} = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable +error[E0658]: const trait impls are experimental + --> $DIR/feature-gate.rs:13:15 + | +LL | const fn f<A: ~const T>() {} + | ^^^^^^ + | + = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + +error[E0658]: const trait impls are experimental + --> $DIR/feature-gate.rs:14:9 + | +LL | fn g<A: const T>() {} + | ^^^^^ + | + = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + +error[E0658]: const trait impls are experimental + --> $DIR/feature-gate.rs:18:17 + | +LL | discard! { impl ~const T } + | ^^^^^^ + | + = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + +error[E0658]: const trait impls are experimental + --> $DIR/feature-gate.rs:19:17 + | +LL | discard! { impl const T } + | ^^^^^ + | + = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + error[E0658]: `const_trait` is a temporary placeholder for marking a trait that is suitable for `const` `impls` and all default bodies as `const`, which may be removed or renamed in the future. --> $DIR/feature-gate.rs:8:1 | @@ -16,6 +52,6 @@ LL | #[const_trait] = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable -error: aborting due to 2 previous errors +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/generic-bound.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/generic-bound.stderr index 1e8a70ffd29..f42fee59bf0 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/generic-bound.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/generic-bound.stderr @@ -10,6 +10,7 @@ note: impl defined here, but it is not `const` LL | impl<T> const std::ops::Add for S<T> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = help: add `#![feature(effects)]` to the crate attributes to enable error: aborting due to 1 previous error diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102985.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102985.stderr index 077f6c7b234..0fa4c8fe04c 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102985.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102985.stderr @@ -4,7 +4,9 @@ error[E0015]: cannot call non-const closure in constants LL | n => n(), | ^^^ | + = note: closures need an RFC before allowed to be called in constants = note: calls in constants are limited to constant functions, tuple structs and tuple variants + = help: add `#![feature(effects)]` to the crate attributes to enable error: aborting due to 1 previous error diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-79450.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-79450.rs index b604c65d751..269fd87ba0d 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-79450.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-79450.rs @@ -1,5 +1,5 @@ #![feature(const_fmt_arguments_new)] -#![feature(const_trait_impl)] +#![feature(const_trait_impl, effects)] #[const_trait] trait Tr { diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-88155.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-88155.stderr index 157b54214fa..e5347a09598 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-88155.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-88155.stderr @@ -5,6 +5,7 @@ LL | T::assoc() | ^^^^^^^^^^ | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = help: add `#![feature(effects)]` to the crate attributes to enable error: aborting due to 1 previous error diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.gated.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.gated.stderr index 89e59e5db6e..28254ac15a8 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.gated.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.gated.stderr @@ -6,6 +6,7 @@ LL | "a" => (), //FIXME [gated]~ ERROR can't compare `str` with `str` in | = note: `str` cannot be compared in compile-time, and therefore cannot be used in `match`es = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = help: add `#![feature(effects)]` to the crate attributes to enable error: aborting due to 1 previous error diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/mbe-bare-trait-objects-const-trait-bounds.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/mbe-bare-trait-objects-const-trait-bounds.rs new file mode 100644 index 00000000000..2304a766aaf --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/mbe-bare-trait-objects-const-trait-bounds.rs @@ -0,0 +1,20 @@ +// Ensure that we don't consider `const Trait` and `~const Trait` to +// match the macro fragment specifier `ty` as that would be a breaking +// change theoretically speaking. Syntactically trait object types can +// be "bare", i.e., lack the prefix `dyn`. +// By contrast, `?Trait` *does* match `ty` and therefore an arm like +// `?$Trait:path` would never be reached. +// See `parser/macro/mbe-bare-trait-object-maybe-trait-bound.rs`. + +// check-pass + +macro_rules! check { + ($Type:ty) => { compile_error!("ty"); }; + (const $Trait:path) => {}; + (~const $Trait:path) => {}; +} + +check! { const Trait } +check! { ~const Trait } + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/mbe-const-trait-bound-theoretical-regression.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/mbe-const-trait-bound-theoretical-regression.rs new file mode 100644 index 00000000000..9105cb6b043 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/mbe-const-trait-bound-theoretical-regression.rs @@ -0,0 +1,20 @@ +// Demonstrates and records a theoretical regressions / breaking changes caused by the +// introduction of const trait bounds. + +// Setting the edition to 2018 since we don't regress `demo! { dyn const }` in Rust <2018. +// edition:2018 + +macro_rules! demo { + ($ty:ty) => { compile_error!("ty"); }; + (impl $c:ident) => {}; + (dyn $c:ident) => {}; +} + +demo! { impl const } +//~^ ERROR expected identifier, found `<eof>` + +demo! { dyn const } +//~^ ERROR const trait impls are experimental +//~| ERROR expected identifier, found `<eof>` + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/mbe-const-trait-bound-theoretical-regression.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/mbe-const-trait-bound-theoretical-regression.stderr new file mode 100644 index 00000000000..254d31930b3 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/mbe-const-trait-bound-theoretical-regression.stderr @@ -0,0 +1,30 @@ +error: expected identifier, found `<eof>` + --> $DIR/mbe-const-trait-bound-theoretical-regression.rs:13:14 + | +LL | ($ty:ty) => { compile_error!("ty"); }; + | ------ while parsing argument for this `ty` macro fragment +... +LL | demo! { impl const } + | ^^^^^ expected identifier + +error: expected identifier, found `<eof>` + --> $DIR/mbe-const-trait-bound-theoretical-regression.rs:16:13 + | +LL | ($ty:ty) => { compile_error!("ty"); }; + | ------ while parsing argument for this `ty` macro fragment +... +LL | demo! { dyn const } + | ^^^^^ expected identifier + +error[E0658]: const trait impls are experimental + --> $DIR/mbe-const-trait-bound-theoretical-regression.rs:16:13 + | +LL | demo! { dyn const } + | ^^^^^ + | + = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/mbe-dyn-const-2015.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/mbe-dyn-const-2015.rs new file mode 100644 index 00000000000..817e9ee5257 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/mbe-dyn-const-2015.rs @@ -0,0 +1,13 @@ +// Ensure that the introduction of const trait bound didn't regress this code in Rust 2015. +// See also `mbe-const-trait-bound-theoretical-regression.rs`. + +// check-pass + +macro_rules! check { + ($ty:ty) => { compile_error!("ty"); }; + (dyn $c:ident) => {}; +} + +check! { dyn const } + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/mutually-exclusive-trait-bound-modifiers.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/mutually-exclusive-trait-bound-modifiers.rs new file mode 100644 index 00000000000..37e285f2c65 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/mutually-exclusive-trait-bound-modifiers.rs @@ -0,0 +1,20 @@ +#![feature(const_trait_impl)] + +const fn maybe_const_maybe<T: ~const ?Sized>() {} +//~^ ERROR `~const` and `?` are mutually exclusive + +fn const_maybe<T: const ?Sized>() {} +//~^ ERROR `const` and `?` are mutually exclusive + +const fn maybe_const_negative<T: ~const !Trait>() {} +//~^ ERROR `~const` and `!` are mutually exclusive +//~| ERROR negative bounds are not supported + +fn const_negative<T: const !Trait>() {} +//~^ ERROR `const` and `!` are mutually exclusive +//~| ERROR negative bounds are not supported + +#[const_trait] +trait Trait {} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/mutually-exclusive-trait-bound-modifiers.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/mutually-exclusive-trait-bound-modifiers.stderr new file mode 100644 index 00000000000..1938f740170 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/mutually-exclusive-trait-bound-modifiers.stderr @@ -0,0 +1,38 @@ +error: `~const` and `?` are mutually exclusive + --> $DIR/mutually-exclusive-trait-bound-modifiers.rs:3:31 + | +LL | const fn maybe_const_maybe<T: ~const ?Sized>() {} + | ^^^^^^^^^^^^^ + +error: `const` and `?` are mutually exclusive + --> $DIR/mutually-exclusive-trait-bound-modifiers.rs:6:19 + | +LL | fn const_maybe<T: const ?Sized>() {} + | ^^^^^^^^^^^^ + +error: `~const` and `!` are mutually exclusive + --> $DIR/mutually-exclusive-trait-bound-modifiers.rs:9:34 + | +LL | const fn maybe_const_negative<T: ~const !Trait>() {} + | ^^^^^^^^^^^^^ + +error: `const` and `!` are mutually exclusive + --> $DIR/mutually-exclusive-trait-bound-modifiers.rs:13:22 + | +LL | fn const_negative<T: const !Trait>() {} + | ^^^^^^^^^^^^ + +error: negative bounds are not supported + --> $DIR/mutually-exclusive-trait-bound-modifiers.rs:9:41 + | +LL | const fn maybe_const_negative<T: ~const !Trait>() {} + | ^ + +error: negative bounds are not supported + --> $DIR/mutually-exclusive-trait-bound-modifiers.rs:13:28 + | +LL | fn const_negative<T: const !Trait>() {} + | ^ + +error: aborting due to 6 previous errors + diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/non-const-op-const-closure-non-const-outer.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/non-const-op-const-closure-non-const-outer.stderr index 97ad83130d4..d82a49be75e 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/non-const-op-const-closure-non-const-outer.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/non-const-op-const-closure-non-const-outer.stderr @@ -5,6 +5,7 @@ LL | (const || { (()).foo() })(); | ^^^^^ | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = help: add `#![feature(effects)]` to the crate attributes to enable error: aborting due to 1 previous error diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.stderr index b2e09d82a90..ae76cab2f2e 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.stderr @@ -1,4 +1,4 @@ -error: ~const can only be applied to `#[const_trait]` traits +error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/non-const-op-in-closure-in-const.rs:10:51 | LL | impl<A, B> const Convert<B> for A where B: ~const From<A> { diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.rs index ada475909a3..e0c20b819e8 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.rs @@ -1,4 +1,4 @@ -#![feature(const_trait_impl, min_specialization, rustc_attrs)] +#![feature(const_trait_impl, effects, min_specialization, rustc_attrs)] // known-bug: #110395 #[rustc_specialization_trait] #[const_trait] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.stderr index 0b35feddc55..5210a694201 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.stderr @@ -1,11 +1,12 @@ -error[E0015]: cannot call non-const fn `<T as A>::a` in constant functions - --> $DIR/specializing-constness-2.rs:27:5 +error[E0119]: conflicting implementations of trait `A` + --> $DIR/specializing-constness-2.rs:20:1 | -LL | <T as A>::a(); - | ^^^^^^^^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants +LL | impl<T: Default> A for T { + | ------------------------ first implementation here +... +LL | impl<T: Default + ~const Sup> const A for T { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.nn.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.nn.stderr index 12bcdb034bc..eae313ef087 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.nn.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.nn.stderr @@ -1,23 +1,23 @@ error: `~const` is not allowed here - --> $DIR/super-traits-fail-2.rs:11:12 + --> $DIR/super-traits-fail-2.rs:10:12 | LL | trait Bar: ~const Foo {} | ^^^^^^ | note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds - --> $DIR/super-traits-fail-2.rs:11:1 + --> $DIR/super-traits-fail-2.rs:10:1 | LL | trait Bar: ~const Foo {} | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-2.rs:11:19 +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-2.rs:10:19 | LL | trait Bar: ~const Foo {} | ^^^ -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-2.rs:11:19 +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-2.rs:10:19 | LL | trait Bar: ~const Foo {} | ^^^ diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.ny.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.ny.stderr index b60399c57dc..be3153d6a08 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.ny.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.ny.stderr @@ -1,11 +1,11 @@ -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-2.rs:11:19 +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-2.rs:10:19 | LL | trait Bar: ~const Foo {} | ^^^ -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-2.rs:11:19 +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-2.rs:10:19 | LL | trait Bar: ~const Foo {} | ^^^ diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.rs index 93fd96f8f29..abdf0feee03 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.rs @@ -1,5 +1,4 @@ -#![feature(const_trait_impl)] -// known-bug: #110395 +#![feature(const_trait_impl, effects)] // revisions: yy yn ny nn #[cfg_attr(any(yy, yn), const_trait)] @@ -9,12 +8,14 @@ trait Foo { #[cfg_attr(any(yy, ny), const_trait)] trait Bar: ~const Foo {} -// FIXME [ny,nn]~^ ERROR: ~const can only be applied to `#[const_trait]` -// FIXME [ny,nn]~| ERROR: ~const can only be applied to `#[const_trait]` +//[ny,nn]~^ ERROR: `~const` can only be applied to `#[const_trait]` +//[ny,nn]~| ERROR: `~const` can only be applied to `#[const_trait]` +//[yn,nn]~^^^ ERROR: `~const` is not allowed here const fn foo<T: Bar>(x: &T) { x.a(); - // FIXME [yn,yy]~^ ERROR the trait bound + //[yy,yn]~^ ERROR mismatched types + // FIXME(effects) diagnostic } fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yn.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yn.stderr index e465ebaffa8..c05c4d50a33 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yn.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yn.stderr @@ -1,14 +1,24 @@ error: `~const` is not allowed here - --> $DIR/super-traits-fail-2.rs:11:12 + --> $DIR/super-traits-fail-2.rs:10:12 | LL | trait Bar: ~const Foo {} | ^^^^^^ | note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds - --> $DIR/super-traits-fail-2.rs:11:1 + --> $DIR/super-traits-fail-2.rs:10:1 | LL | trait Bar: ~const Foo {} | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 1 previous error +error[E0308]: mismatched types + --> $DIR/super-traits-fail-2.rs:16:5 + | +LL | x.a(); + | ^^^^^ expected `host`, found `true` + | + = note: expected constant `host` + found constant `true` + +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yy.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yy.stderr index 1faa5b4dd2c..852c02cad5c 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yy.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yy.stderr @@ -1,11 +1,12 @@ -error[E0015]: cannot call non-const fn `<T as Foo>::a` in constant functions - --> $DIR/super-traits-fail-2.rs:16:7 +error[E0308]: mismatched types + --> $DIR/super-traits-fail-2.rs:16:5 | LL | x.a(); - | ^^^ + | ^^^^^ expected `host`, found `true` | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = note: expected constant `host` + found constant `true` error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.nn.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.nn.stderr index e10c51ef45a..834d6f4dcf3 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.nn.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.nn.stderr @@ -1,31 +1,31 @@ error: `~const` is not allowed here - --> $DIR/super-traits-fail-3.rs:13:12 + --> $DIR/super-traits-fail-3.rs:12:12 | LL | trait Bar: ~const Foo {} | ^^^^^^ | note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds - --> $DIR/super-traits-fail-3.rs:13:1 + --> $DIR/super-traits-fail-3.rs:12:1 | LL | trait Bar: ~const Foo {} | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:13:19 +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:12:19 | LL | trait Bar: ~const Foo {} | ^^^ -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:13:19 +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:12:19 | LL | trait Bar: ~const Foo {} | ^^^ | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:18:24 +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:17:24 | LL | const fn foo<T: ~const Bar>(x: &T) { | ^^^ diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.ny.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.ny.stderr index cd0ee73277d..4fdd2284c47 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.ny.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.ny.stderr @@ -1,11 +1,11 @@ -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:13:19 +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:12:19 | LL | trait Bar: ~const Foo {} | ^^^ -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:13:19 +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:12:19 | LL | trait Bar: ~const Foo {} | ^^^ diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.rs index 5994057b2db..30131d5849c 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.rs @@ -1,8 +1,7 @@ -#![feature(const_trait_impl)] +#![feature(const_trait_impl, effects)] // revisions: yy yn ny nn -//[yy] known-bug: #110395 -//FIXME [yy] check-pass +//[yy] check-pass #[cfg_attr(any(yy, yn), const_trait)] trait Foo { @@ -11,12 +10,12 @@ trait Foo { #[cfg_attr(any(yy, ny), const_trait)] trait Bar: ~const Foo {} -//[ny,nn]~^ ERROR: ~const can only be applied to `#[const_trait]` -//[ny,nn]~| ERROR: ~const can only be applied to `#[const_trait]` +//[ny,nn]~^ ERROR: `~const` can only be applied to `#[const_trait]` +//[ny,nn]~| ERROR: `~const` can only be applied to `#[const_trait]` //[yn,nn]~^^^ ERROR: `~const` is not allowed here const fn foo<T: ~const Bar>(x: &T) { - //[yn,nn]~^ ERROR: ~const can only be applied to `#[const_trait]` + //[yn,nn]~^ ERROR: `~const` can only be applied to `#[const_trait]` x.a(); } diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.yn.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.yn.stderr index 34f6515b572..ab7c814eb49 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.yn.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.yn.stderr @@ -1,17 +1,17 @@ error: `~const` is not allowed here - --> $DIR/super-traits-fail-3.rs:13:12 + --> $DIR/super-traits-fail-3.rs:12:12 | LL | trait Bar: ~const Foo {} | ^^^^^^ | note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds - --> $DIR/super-traits-fail-3.rs:13:1 + --> $DIR/super-traits-fail-3.rs:12:1 | LL | trait Bar: ~const Foo {} | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:18:24 +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:17:24 | LL | const fn foo<T: ~const Bar>(x: &T) { | ^^^ diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.yy.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.yy.stderr deleted file mode 100644 index 5cccc025161..00000000000 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.yy.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0015]: cannot call non-const fn `<T as Foo>::a` in constant functions - --> $DIR/super-traits-fail-3.rs:20:7 - | -LL | x.a(); - | ^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs index bbe1194f7a3..5ecb75094f0 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs @@ -52,4 +52,7 @@ trait Child1 where Self: ~const Trait {} //~ ERROR `~const` is not allowed // non-const impl impl<T: ~const Trait> Trait for T {} //~ ERROR `~const` is not allowed +// inherent impl (regression test for issue #117004) +impl<T: ~const Trait> Struct<T> {} //~ ERROR `~const` is not allowed + fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-invalid-places.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-invalid-places.stderr index c6e18924fd8..497ec5bcf84 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-invalid-places.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-invalid-places.stderr @@ -194,6 +194,18 @@ note: this impl is not `const`, so it cannot have `~const` trait bounds LL | impl<T: ~const Trait> Trait for T {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: `~const` is not allowed here + --> $DIR/tilde-const-invalid-places.rs:56:9 + | +LL | impl<T: ~const Trait> Struct<T> {} + | ^^^^^^ + | +note: inherent impls cannot have `~const` trait bounds + --> $DIR/tilde-const-invalid-places.rs:56:1 + | +LL | impl<T: ~const Trait> Struct<T> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0658]: generic const items are experimental --> $DIR/tilde-const-invalid-places.rs:19:15 | @@ -239,6 +251,6 @@ LL | type Type<T: ~const Trait> = (); = note: see issue #8995 <https://github.com/rust-lang/rust/issues/8995> for more information = help: add `#![feature(inherent_associated_types)]` to the crate attributes to enable -error: aborting due to 26 previous errors +error: aborting due to 27 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-maybe-trait.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-maybe-trait.rs deleted file mode 100644 index ed911d965d6..00000000000 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-maybe-trait.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![feature(const_trait_impl)] - -const fn tilde_question<T: ~const ?Sized>() {} -//~^ ERROR `~const` and `?` are mutually exclusive - -fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-maybe-trait.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-maybe-trait.stderr deleted file mode 100644 index 5850ab41c6b..00000000000 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-maybe-trait.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: `~const` and `?` are mutually exclusive - --> $DIR/tilde-const-maybe-trait.rs:3:28 - | -LL | const fn tilde_question<T: ~const ?Sized>() {} - | ^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.rs index fbdc3a4f370..bfd9fe42e67 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.rs @@ -1,5 +1,4 @@ -// known-bug: #110395 -// FIXME check-pass +// check-pass #![feature(const_trait_impl, effects)] #[const_trait] @@ -9,8 +8,8 @@ trait Foo { struct Bar<T>(T); -impl<T: ~const Foo> Bar<T> { - const fn foo(&self) { +impl<T> Bar<T> { + const fn foo(&self) where T: ~const Foo { self.0.foo() } } diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.stderr deleted file mode 100644 index 0925bfa7e57..00000000000 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/tilde_const_on_impl_bound.rs:14:9 - | -LL | self.0.foo() - | ^^^^^^^^^^^^ expected `host`, found `true` - | - = note: expected constant `host` - found constant `true` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-default-body-stability.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-default-body-stability.rs index 8d56295e738..aa3b09ec966 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-default-body-stability.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-default-body-stability.rs @@ -1,7 +1,7 @@ // known-bug: #110395 #![feature(staged_api)] -#![feature(const_trait_impl)] +#![feature(const_trait_impl, effects)] #![feature(const_t_try)] #![feature(const_try)] #![feature(try_trait_v2)] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-default-body-stability.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-default-body-stability.stderr index deed05ae179..62c4bc3b7ae 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-default-body-stability.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-default-body-stability.stderr @@ -1,29 +1,39 @@ -error[E0015]: `?` cannot determine the branch of `T` in constant functions - --> $DIR/trait-default-body-stability.rs:44:9 +error: const `impl` for trait `Try` which is not marked with `#[const_trait]` + --> $DIR/trait-default-body-stability.rs:18:12 | -LL | T? - | ^^ +LL | impl const Try for T { + | ^^^ | -note: impl defined here, but it is not `const` - --> $DIR/trait-default-body-stability.rs:18:1 + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change + +error: const `impl` for trait `FromResidual` which is not marked with `#[const_trait]` + --> $DIR/trait-default-body-stability.rs:33:12 | -LL | impl const Try for T { - | ^^^^^^^^^^^^^^^^^^^^ - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants +LL | impl const FromResidual for T { + | ^^^^^^^^^^^^ + | + = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` + = note: adding a non-const method body in the future would be a breaking change -error[E0015]: `?` cannot convert from residual of `T` in constant functions - --> $DIR/trait-default-body-stability.rs:44:9 +error[E0207]: the const parameter `host` is not constrained by the impl trait, self type, or predicates + --> $DIR/trait-default-body-stability.rs:18:6 | -LL | T? - | ^^ +LL | impl const Try for T { + | ^^^^^ unconstrained const parameter | -note: impl defined here, but it is not `const` - --> $DIR/trait-default-body-stability.rs:33:1 + = note: expressions using a const parameter must map each value to a distinct output value + = note: proving the result of expressions other than the parameter are unique is not supported + +error[E0207]: the const parameter `host` is not constrained by the impl trait, self type, or predicates + --> $DIR/trait-default-body-stability.rs:33:6 | LL | impl const FromResidual for T { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + | ^^^^^ unconstrained const parameter + | + = note: expressions using a const parameter must map each value to a distinct output value + = note: proving the result of expressions other than the parameter are unique is not supported -error: aborting due to 2 previous errors +error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/without-tilde.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/without-tilde.rs deleted file mode 100644 index d63381b5f2c..00000000000 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/without-tilde.rs +++ /dev/null @@ -1,6 +0,0 @@ -// compile-flags: -Z parse-only - -#![feature(const_trait_impl)] - -struct S<T: const Tr>; -//~^ ERROR const bounds must start with `~` diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/without-tilde.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/without-tilde.stderr deleted file mode 100644 index 646cdfc78f9..00000000000 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/without-tilde.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: const bounds must start with `~` - --> $DIR/without-tilde.rs:5:13 - | -LL | struct S<T: const Tr>; - | -^^^^ - | | - | help: add `~`: `~` - -error: aborting due to 1 previous error - diff --git a/tests/ui/sanitize/sanitizer-cfi-generalize-pointers-attr-cfg.rs b/tests/ui/sanitize/sanitizer-cfi-generalize-pointers-attr-cfg.rs index 3a0fc143da6..5b8de5c219e 100644 --- a/tests/ui/sanitize/sanitizer-cfi-generalize-pointers-attr-cfg.rs +++ b/tests/ui/sanitize/sanitizer-cfi-generalize-pointers-attr-cfg.rs @@ -5,5 +5,7 @@ // check-pass // compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers +#![feature(cfg_sanitizer_cfi)] + #[cfg(sanitizer_cfi_generalize_pointers)] fn main() {} diff --git a/tests/ui/sanitize/sanitizer-cfi-normalize-integers-attr-cfg.rs b/tests/ui/sanitize/sanitizer-cfi-normalize-integers-attr-cfg.rs index dafc20162ab..4972ccf3167 100644 --- a/tests/ui/sanitize/sanitizer-cfi-normalize-integers-attr-cfg.rs +++ b/tests/ui/sanitize/sanitizer-cfi-normalize-integers-attr-cfg.rs @@ -5,5 +5,7 @@ // check-pass // compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers +#![feature(cfg_sanitizer_cfi)] + #[cfg(sanitizer_cfi_normalize_integers)] fn main() {} diff --git a/tests/ui/self/elision/nested-item.stderr b/tests/ui/self/elision/nested-item.stderr index 752fd82332c..7bad26fa133 100644 --- a/tests/ui/self/elision/nested-item.stderr +++ b/tests/ui/self/elision/nested-item.stderr @@ -21,10 +21,19 @@ LL | fn wrap(self: Wrap<{ fn bar(&self) {} }>) -> &() { | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | fn wrap(self: Wrap<{ fn bar(&self) {} }>) -> &'static () { | +++++++ +help: instead, you are more likely to want to change the argument to be borrowed... + | +LL | fn wrap(self: &Wrap<{ fn bar(&self) {} }>) -> &() { + | + +help: ...or alternatively, you might want to return an owned value + | +LL - fn wrap(self: Wrap<{ fn bar(&self) {} }>) -> &() { +LL + fn wrap(self: Wrap<{ fn bar(&self) {} }>) -> () { + | error[E0412]: cannot find type `Wrap` in this scope --> $DIR/nested-item.rs:5:15 diff --git a/tests/ui/sized/recursive-type-2.rs b/tests/ui/sized/recursive-type-binding.rs index 7d95417a6ff..7d95417a6ff 100644 --- a/tests/ui/sized/recursive-type-2.rs +++ b/tests/ui/sized/recursive-type-binding.rs diff --git a/tests/ui/sized/recursive-type-2.stderr b/tests/ui/sized/recursive-type-binding.stderr index 4e7f40a0153..d9c2efa4d53 100644 --- a/tests/ui/sized/recursive-type-2.stderr +++ b/tests/ui/sized/recursive-type-binding.stderr @@ -3,7 +3,7 @@ error[E0391]: cycle detected when computing layout of `Foo<()>` = note: ...which requires computing layout of `<() as A>::Assoc`... = note: ...which again requires computing layout of `Foo<()>`, completing the cycle note: cycle used when elaborating drops for `main` - --> $DIR/recursive-type-2.rs:11:1 + --> $DIR/recursive-type-binding.rs:11:1 | LL | fn main() { | ^^^^^^^^^ diff --git a/tests/ui/sized/recursive-type-coercion-from-never.rs b/tests/ui/sized/recursive-type-coercion-from-never.rs new file mode 100644 index 00000000000..a1b65463731 --- /dev/null +++ b/tests/ui/sized/recursive-type-coercion-from-never.rs @@ -0,0 +1,16 @@ +// build-fail +//~^ ERROR cycle detected when computing layout of `Foo<()>` + +// Regression test for a stack overflow: https://github.com/rust-lang/rust/issues/113197 + +trait A { type Assoc; } + +impl A for () { + type Assoc = Foo<()>; +} + +struct Foo<T: A>(T::Assoc); + +fn main() { + Foo::<()>(todo!()); +} diff --git a/tests/ui/sized/recursive-type-coercion-from-never.stderr b/tests/ui/sized/recursive-type-coercion-from-never.stderr new file mode 100644 index 00000000000..7580e780dda --- /dev/null +++ b/tests/ui/sized/recursive-type-coercion-from-never.stderr @@ -0,0 +1,14 @@ +error[E0391]: cycle detected when computing layout of `Foo<()>` + | + = note: ...which requires computing layout of `<() as A>::Assoc`... + = note: ...which again requires computing layout of `Foo<()>`, completing the cycle +note: cycle used when elaborating drops for `main` + --> $DIR/recursive-type-coercion-from-never.rs:14:1 + | +LL | fn main() { + | ^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/sized/recursive-type-1.rs b/tests/ui/sized/recursive-type-pass.rs index cd6805967e5..cd6805967e5 100644 --- a/tests/ui/sized/recursive-type-1.rs +++ b/tests/ui/sized/recursive-type-pass.rs diff --git a/tests/ui/specialization/const_trait_impl.stderr b/tests/ui/specialization/const_trait_impl.stderr index d13cd8f5555..913d51875cd 100644 --- a/tests/ui/specialization/const_trait_impl.stderr +++ b/tests/ui/specialization/const_trait_impl.stderr @@ -1,16 +1,16 @@ -error: ~const can only be applied to `#[const_trait]` traits +error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/const_trait_impl.rs:34:16 | LL | impl<T: ~const Default> const A for T { | ^^^^^^^ -error: ~const can only be applied to `#[const_trait]` traits +error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/const_trait_impl.rs:40:16 | LL | impl<T: ~const Default + ~const Sup> const A for T { | ^^^^^^^ -error: ~const can only be applied to `#[const_trait]` traits +error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/const_trait_impl.rs:46:16 | LL | impl<T: ~const Default + ~const Sub> const A for T { diff --git a/tests/ui/specialization/specialization-default-items-drop-coherence.rs b/tests/ui/specialization/specialization-default-items-drop-coherence.rs index 44c598f19cb..37903c21071 100644 --- a/tests/ui/specialization/specialization-default-items-drop-coherence.rs +++ b/tests/ui/specialization/specialization-default-items-drop-coherence.rs @@ -1,6 +1,6 @@ // revisions: classic coherence next -//[next] compile-flags: -Ztrait-solver=next -//[coherence] compile-flags: -Ztrait-solver=next-coherence +//[next] compile-flags: -Znext-solver +//[coherence] compile-flags: -Znext-solver=coherence //[classic] check-pass //[classic] known-bug: #105782 diff --git a/tests/ui/stable-mir-print/basic_function.rs b/tests/ui/stable-mir-print/basic_function.rs new file mode 100644 index 00000000000..6394edcbb78 --- /dev/null +++ b/tests/ui/stable-mir-print/basic_function.rs @@ -0,0 +1,15 @@ +// compile-flags: -Z unpretty=stable-mir -Z mir-opt-level=3 +// check-pass +// only-x86_64 + +fn foo(i:i32) -> i32 { + i + 1 +} + +fn bar(vec: &mut Vec<i32>) -> Vec<i32> { + let mut new_vec = vec.clone(); + new_vec.push(1); + new_vec +} + +fn main(){} diff --git a/tests/ui/stable-mir-print/basic_function.stdout b/tests/ui/stable-mir-print/basic_function.stdout new file mode 100644 index 00000000000..d9b33a4257c --- /dev/null +++ b/tests/ui/stable-mir-print/basic_function.stdout @@ -0,0 +1,234 @@ +// WARNING: This is highly experimental output it's intended for stable-mir developers only. +// If you find a bug or want to improve the output open a issue at https://github.com/rust-lang/project-stable-mir. +fn foo(_0: i32) -> i32 { + let mut _0: (i32, bool); +} + bb0: { + _2 = 1 Add const 1_i32 + assert(!move _2 bool),"attempt to compute `{} + {}`, which would overflow", 1, const 1_i32) -> [success: bb1, unwind continue] + } + bb1: { + _0 = move _2 + return + } +fn bar(_0: &mut Ty { + id: 10, + kind: RigidTy( + Adt( + AdtDef( + DefId { + id: 3, + name: "std::vec::Vec", + }, + ), + GenericArgs( + [ + Type( + Ty { + id: 11, + kind: Param( + ParamTy { + index: 0, + name: "T", + }, + ), + }, + ), + Type( + Ty { + id: 12, + kind: Param( + ParamTy { + index: 1, + name: "A", + }, + ), + }, + ), + ], + ), + ), + ), +}) -> Ty { + id: 10, + kind: RigidTy( + Adt( + AdtDef( + DefId { + id: 3, + name: "std::vec::Vec", + }, + ), + GenericArgs( + [ + Type( + Ty { + id: 11, + kind: Param( + ParamTy { + index: 0, + name: "T", + }, + ), + }, + ), + Type( + Ty { + id: 12, + kind: Param( + ParamTy { + index: 1, + name: "A", + }, + ), + }, + ), + ], + ), + ), + ), +} { + let mut _0: Ty { + id: 10, + kind: RigidTy( + Adt( + AdtDef( + DefId { + id: 3, + name: "std::vec::Vec", + }, + ), + GenericArgs( + [ + Type( + Ty { + id: 11, + kind: Param( + ParamTy { + index: 0, + name: "T", + }, + ), + }, + ), + Type( + Ty { + id: 12, + kind: Param( + ParamTy { + index: 1, + name: "A", + }, + ), + }, + ), + ], + ), + ), + ), +}; + let mut _1: &Ty { + id: 10, + kind: RigidTy( + Adt( + AdtDef( + DefId { + id: 3, + name: "std::vec::Vec", + }, + ), + GenericArgs( + [ + Type( + Ty { + id: 11, + kind: Param( + ParamTy { + index: 0, + name: "T", + }, + ), + }, + ), + Type( + Ty { + id: 12, + kind: Param( + ParamTy { + index: 1, + name: "A", + }, + ), + }, + ), + ], + ), + ), + ), +}; + let _2: (); + let mut _3: &mut Ty { + id: 10, + kind: RigidTy( + Adt( + AdtDef( + DefId { + id: 3, + name: "std::vec::Vec", + }, + ), + GenericArgs( + [ + Type( + Ty { + id: 11, + kind: Param( + ParamTy { + index: 0, + name: "T", + }, + ), + }, + ), + Type( + Ty { + id: 12, + kind: Param( + ParamTy { + index: 1, + name: "A", + }, + ), + }, + ), + ], + ), + ), + ), +}; +} + bb0: { + _3 = refShared1 + _2 = const <Vec<i32> as Clone>::clone(move _3) -> [return: bb1, unwind continue] + } + bb1: { + _5 = refMut { + kind: TwoPhaseBorrow, +}2 + _4 = const Vec::<i32>::push(move _5, const 1_i32) -> [return: bb2, unwind: bb3] + } + bb2: { + _0 = move _2 + return + } + bb3: { + drop(_2) -> [return: bb4, unwind terminate] + } + bb4: { + resume + } +fn main() -> () { +} + bb0: { + return + } diff --git a/tests/ui/stats/hir-stats.stderr b/tests/ui/stats/hir-stats.stderr index e6da83296ce..5296475c94a 100644 --- a/tests/ui/stats/hir-stats.stderr +++ b/tests/ui/stats/hir-stats.stderr @@ -15,20 +15,20 @@ ast-stats-1 Arm 96 ( 1.5%) 2 48 ast-stats-1 ForeignItem 96 ( 1.5%) 1 96 ast-stats-1 - Fn 96 ( 1.5%) 1 ast-stats-1 FnDecl 120 ( 1.8%) 5 24 -ast-stats-1 FieldDef 160 ( 2.5%) 2 80 -ast-stats-1 Stmt 160 ( 2.5%) 5 32 +ast-stats-1 FieldDef 160 ( 2.4%) 2 80 +ast-stats-1 Stmt 160 ( 2.4%) 5 32 ast-stats-1 - Local 32 ( 0.5%) 1 ast-stats-1 - MacCall 32 ( 0.5%) 1 ast-stats-1 - Expr 96 ( 1.5%) 3 -ast-stats-1 Param 160 ( 2.5%) 4 40 +ast-stats-1 Param 160 ( 2.4%) 4 40 ast-stats-1 Block 192 ( 2.9%) 6 32 ast-stats-1 Variant 208 ( 3.2%) 2 104 -ast-stats-1 GenericBound 256 ( 3.9%) 4 64 -ast-stats-1 - Trait 256 ( 3.9%) 4 +ast-stats-1 GenericBound 288 ( 4.4%) 4 72 +ast-stats-1 - Trait 288 ( 4.4%) 4 ast-stats-1 AssocItem 352 ( 5.4%) 4 88 ast-stats-1 - Type 176 ( 2.7%) 2 ast-stats-1 - Fn 176 ( 2.7%) 2 -ast-stats-1 GenericParam 480 ( 7.4%) 5 96 +ast-stats-1 GenericParam 480 ( 7.3%) 5 96 ast-stats-1 Pat 504 ( 7.7%) 7 72 ast-stats-1 - Struct 72 ( 1.1%) 1 ast-stats-1 - Wild 72 ( 1.1%) 1 @@ -45,15 +45,15 @@ ast-stats-1 - Ptr 64 ( 1.0%) 1 ast-stats-1 - Ref 64 ( 1.0%) 1 ast-stats-1 - ImplicitSelf 128 ( 2.0%) 2 ast-stats-1 - Path 640 ( 9.8%) 10 -ast-stats-1 Item 1_224 (18.8%) 9 136 +ast-stats-1 Item 1_224 (18.7%) 9 136 ast-stats-1 - Trait 136 ( 2.1%) 1 ast-stats-1 - Enum 136 ( 2.1%) 1 ast-stats-1 - ForeignMod 136 ( 2.1%) 1 ast-stats-1 - Impl 136 ( 2.1%) 1 ast-stats-1 - Fn 272 ( 4.2%) 2 -ast-stats-1 - Use 408 ( 6.3%) 3 +ast-stats-1 - Use 408 ( 6.2%) 3 ast-stats-1 ---------------------------------------------------------------- -ast-stats-1 Total 6_520 +ast-stats-1 Total 6_552 ast-stats-1 ast-stats-2 POST EXPANSION AST STATS ast-stats-2 Name Accumulated Size Count Item Size @@ -81,16 +81,16 @@ ast-stats-2 - Expr 96 ( 1.3%) 3 ast-stats-2 Param 160 ( 2.2%) 4 40 ast-stats-2 Block 192 ( 2.7%) 6 32 ast-stats-2 Variant 208 ( 2.9%) 2 104 -ast-stats-2 GenericBound 256 ( 3.6%) 4 64 -ast-stats-2 - Trait 256 ( 3.6%) 4 +ast-stats-2 GenericBound 288 ( 4.0%) 4 72 +ast-stats-2 - Trait 288 ( 4.0%) 4 ast-stats-2 AssocItem 352 ( 4.9%) 4 88 ast-stats-2 - Type 176 ( 2.5%) 2 ast-stats-2 - Fn 176 ( 2.5%) 2 ast-stats-2 GenericParam 480 ( 6.7%) 5 96 -ast-stats-2 Pat 504 ( 7.1%) 7 72 +ast-stats-2 Pat 504 ( 7.0%) 7 72 ast-stats-2 - Struct 72 ( 1.0%) 1 ast-stats-2 - Wild 72 ( 1.0%) 1 -ast-stats-2 - Ident 360 ( 5.1%) 5 +ast-stats-2 - Ident 360 ( 5.0%) 5 ast-stats-2 Expr 648 ( 9.1%) 9 72 ast-stats-2 - Path 72 ( 1.0%) 1 ast-stats-2 - Match 72 ( 1.0%) 1 @@ -99,12 +99,12 @@ ast-stats-2 - InlineAsm 72 ( 1.0%) 1 ast-stats-2 - Lit 144 ( 2.0%) 2 ast-stats-2 - Block 216 ( 3.0%) 3 ast-stats-2 PathSegment 792 (11.1%) 33 24 -ast-stats-2 Ty 896 (12.6%) 14 64 +ast-stats-2 Ty 896 (12.5%) 14 64 ast-stats-2 - Ptr 64 ( 0.9%) 1 ast-stats-2 - Ref 64 ( 0.9%) 1 ast-stats-2 - ImplicitSelf 128 ( 1.8%) 2 -ast-stats-2 - Path 640 ( 9.0%) 10 -ast-stats-2 Item 1_496 (21.0%) 11 136 +ast-stats-2 - Path 640 ( 8.9%) 10 +ast-stats-2 Item 1_496 (20.9%) 11 136 ast-stats-2 - Trait 136 ( 1.9%) 1 ast-stats-2 - Enum 136 ( 1.9%) 1 ast-stats-2 - ExternCrate 136 ( 1.9%) 1 @@ -113,7 +113,7 @@ ast-stats-2 - Impl 136 ( 1.9%) 1 ast-stats-2 - Fn 272 ( 3.8%) 2 ast-stats-2 - Use 544 ( 7.6%) 4 ast-stats-2 ---------------------------------------------------------------- -ast-stats-2 Total 7_120 +ast-stats-2 Total 7_152 ast-stats-2 hir-stats HIR STATS hir-stats Name Accumulated Size Count Item Size @@ -125,9 +125,9 @@ hir-stats ExprField 40 ( 0.4%) 1 40 hir-stats TraitItemRef 56 ( 0.6%) 2 28 hir-stats Local 64 ( 0.7%) 1 64 hir-stats Param 64 ( 0.7%) 2 32 +hir-stats Body 72 ( 0.8%) 3 24 hir-stats InlineAsm 72 ( 0.8%) 1 72 hir-stats ImplItemRef 72 ( 0.8%) 2 36 -hir-stats Body 96 ( 1.1%) 3 32 hir-stats FieldDef 96 ( 1.1%) 2 48 hir-stats Arm 96 ( 1.1%) 2 48 hir-stats Stmt 96 ( 1.1%) 3 32 @@ -146,7 +146,7 @@ hir-stats - Trait 192 ( 2.1%) 4 hir-stats WherePredicate 192 ( 2.1%) 3 64 hir-stats - BoundPredicate 192 ( 2.1%) 3 hir-stats Block 288 ( 3.2%) 6 48 -hir-stats Pat 360 ( 3.9%) 5 72 +hir-stats Pat 360 ( 4.0%) 5 72 hir-stats - Wild 72 ( 0.8%) 1 hir-stats - Struct 72 ( 0.8%) 1 hir-stats - Binding 216 ( 2.4%) 3 @@ -172,7 +172,7 @@ hir-stats - Impl 88 ( 1.0%) 1 hir-stats - Fn 176 ( 1.9%) 2 hir-stats - Use 352 ( 3.9%) 4 hir-stats Path 1_240 (13.6%) 31 40 -hir-stats PathSegment 1_920 (21.0%) 40 48 +hir-stats PathSegment 1_920 (21.1%) 40 48 hir-stats ---------------------------------------------------------------- -hir-stats Total 9_136 +hir-stats Total 9_112 hir-stats diff --git a/tests/ui/structs-enums/type-sizes.rs b/tests/ui/structs-enums/type-sizes.rs index 406e5c8441e..490d6a2f918 100644 --- a/tests/ui/structs-enums/type-sizes.rs +++ b/tests/ui/structs-enums/type-sizes.rs @@ -4,7 +4,6 @@ #![allow(dead_code)] #![feature(never_type)] #![feature(pointer_is_aligned)] -#![feature(ptr_from_ref)] #![feature(strict_provenance)] use std::mem::size_of; diff --git a/tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr b/tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr index 50806a67255..2dfaa731194 100644 --- a/tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr +++ b/tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr @@ -5,10 +5,19 @@ LL | fn g(mut x: impl Iterator<Item = &()>) -> Option<&()> { x.next() } | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | fn g(mut x: impl Iterator<Item = &()>) -> Option<&'static ()> { x.next() } | +++++++ +help: consider introducing a named lifetime parameter + | +LL | fn g<'a>(mut x: impl Iterator<Item = &'a ()>) -> Option<&'a ()> { x.next() } + | ++++ ~~~ ~~~ +help: alternatively, you might want to return an owned value + | +LL - fn g(mut x: impl Iterator<Item = &()>) -> Option<&()> { x.next() } +LL + fn g(mut x: impl Iterator<Item = &()>) -> Option<()> { x.next() } + | error[E0106]: missing lifetime specifier --> $DIR/impl-trait-missing-lifetime-gated.rs:19:60 @@ -17,10 +26,19 @@ LL | async fn i(mut x: impl Iterator<Item = &()>) -> Option<&()> { x.next() | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | async fn i(mut x: impl Iterator<Item = &()>) -> Option<&'static ()> { x.next() } | +++++++ +help: consider introducing a named lifetime parameter + | +LL | async fn i<'a>(mut x: impl Iterator<Item = &'a ()>) -> Option<&'a ()> { x.next() } + | ++++ ~~~ ~~~ +help: alternatively, you might want to return an owned value + | +LL - async fn i(mut x: impl Iterator<Item = &()>) -> Option<&()> { x.next() } +LL + async fn i(mut x: impl Iterator<Item = &()>) -> Option<()> { x.next() } + | error[E0106]: missing lifetime specifier --> $DIR/impl-trait-missing-lifetime-gated.rs:27:58 @@ -29,10 +47,19 @@ LL | fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() | ^^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`, or if you will only have owned values | LL | fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'static ()> { x.next() } | ~~~~~~~ +help: consider introducing a named lifetime parameter + | +LL | fn g<'a>(mut x: impl Iterator<Item = &'a ()>) -> Option<&'a ()> { x.next() } + | ++++ ~~~ ~~~ +help: alternatively, you might want to return an owned value + | +LL - fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } +LL + fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<()> { x.next() } + | error[E0106]: missing lifetime specifier --> $DIR/impl-trait-missing-lifetime-gated.rs:37:64 @@ -41,10 +68,19 @@ LL | async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.n | ^^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`, or if you will only have owned values | LL | async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'static ()> { x.next() } | ~~~~~~~ +help: consider introducing a named lifetime parameter + | +LL | async fn i<'a>(mut x: impl Iterator<Item = &'a ()>) -> Option<&'a ()> { x.next() } + | ++++ ~~~ ~~~ +help: alternatively, you might want to return an owned value + | +LL - async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } +LL + async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<()> { x.next() } + | error[E0106]: missing lifetime specifier --> $DIR/impl-trait-missing-lifetime-gated.rs:47:37 @@ -53,10 +89,19 @@ LL | fn g(mut x: impl Foo) -> Option<&()> { x.next() } | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | fn g(mut x: impl Foo) -> Option<&'static ()> { x.next() } | +++++++ +help: consider introducing a named lifetime parameter + | +LL | fn g<'a>(mut x: impl Foo) -> Option<&'a ()> { x.next() } + | ++++ ~~~ +help: alternatively, you might want to return an owned value + | +LL - fn g(mut x: impl Foo) -> Option<&()> { x.next() } +LL + fn g(mut x: impl Foo) -> Option<()> { x.next() } + | error[E0106]: missing lifetime specifier --> $DIR/impl-trait-missing-lifetime-gated.rs:58:41 @@ -65,10 +110,19 @@ LL | fn g(mut x: impl Foo<()>) -> Option<&()> { x.next() } | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | fn g(mut x: impl Foo<()>) -> Option<&'static ()> { x.next() } | +++++++ +help: consider introducing a named lifetime parameter + | +LL | fn g<'a>(mut x: impl Foo<()>) -> Option<&'a ()> { x.next() } + | ++++ ~~~ +help: alternatively, you might want to return an owned value + | +LL - fn g(mut x: impl Foo<()>) -> Option<&()> { x.next() } +LL + fn g(mut x: impl Foo<()>) -> Option<()> { x.next() } + | error[E0658]: anonymous lifetimes in `impl Trait` are unstable --> $DIR/impl-trait-missing-lifetime-gated.rs:6:35 diff --git a/tests/ui/suggestions/impl-trait-missing-lifetime.stderr b/tests/ui/suggestions/impl-trait-missing-lifetime.stderr index 2c29cfa0b91..c1dbaae0649 100644 --- a/tests/ui/suggestions/impl-trait-missing-lifetime.stderr +++ b/tests/ui/suggestions/impl-trait-missing-lifetime.stderr @@ -5,10 +5,19 @@ LL | fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } | ^^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`, or if you will only have owned values | LL | fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'static ()> { x.next() } | ~~~~~~~ +help: consider introducing a named lifetime parameter + | +LL | fn g<'a>(mut x: impl Iterator<Item = &'a ()>) -> Option<&'a ()> { x.next() } + | ++++ ~~~ ~~~ +help: alternatively, you might want to return an owned value + | +LL - fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } +LL + fn g(mut x: impl Iterator<Item = &'_ ()>) -> Option<()> { x.next() } + | error[E0106]: missing lifetime specifier --> $DIR/impl-trait-missing-lifetime.rs:16:60 @@ -17,10 +26,19 @@ LL | async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next( | ^^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`, or if you will only have owned values | LL | async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'static ()> { x.next() } | ~~~~~~~ +help: consider introducing a named lifetime parameter + | +LL | async fn i<'a>(mut x: impl Iterator<Item = &'a ()>) -> Option<&'a ()> { x.next() } + | ++++ ~~~ ~~~ +help: alternatively, you might want to return an owned value + | +LL - async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<&'_ ()> { x.next() } +LL + async fn i(mut x: impl Iterator<Item = &'_ ()>) -> Option<()> { x.next() } + | error: lifetime may not live long enough --> $DIR/impl-trait-missing-lifetime.rs:16:69 diff --git a/tests/ui/suggestions/missing-lifetime-specifier.stderr b/tests/ui/suggestions/missing-lifetime-specifier.stderr index fa4bc2fa79d..e41f547ce9b 100644 --- a/tests/ui/suggestions/missing-lifetime-specifier.stderr +++ b/tests/ui/suggestions/missing-lifetime-specifier.stderr @@ -5,7 +5,7 @@ LL | static a: RefCell<HashMap<i32, Vec<Vec<Foo>>>> = RefCell::new(HashMap:: | ^^^ expected 2 lifetime parameters | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`, or if you will only have owned values | LL | static a: RefCell<HashMap<i32, Vec<Vec<Foo<'static, 'static>>>>> = RefCell::new(HashMap::new()); | ++++++++++++++++++ @@ -32,7 +32,7 @@ LL | static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap: | expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | static b: RefCell<HashMap<i32, Vec<Vec<&'static Bar<'static, 'static>>>>> = RefCell::new(HashMap::new()); | +++++++ ++++++++++++++++++ @@ -59,7 +59,7 @@ LL | static c: RefCell<HashMap<i32, Vec<Vec<Qux<i32>>>>> = RefCell::new(Hash | ^ expected 2 lifetime parameters | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`, or if you will only have owned values | LL | static c: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'static, i32>>>>> = RefCell::new(HashMap::new()); | +++++++++++++++++ @@ -86,7 +86,7 @@ LL | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(Has | expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | static d: RefCell<HashMap<i32, Vec<Vec<&'static Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new()); | +++++++ +++++++++++++++++ @@ -113,7 +113,7 @@ LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | static f: RefCell<HashMap<i32, Vec<Vec<&'static Tar<'static, i32>>>>> = RefCell::new(HashMap::new()); | +++++++ diff --git a/tests/ui/suggestions/return-elided-lifetime.stderr b/tests/ui/suggestions/return-elided-lifetime.stderr index 273d95bc747..7bfffd30184 100644 --- a/tests/ui/suggestions/return-elided-lifetime.stderr +++ b/tests/ui/suggestions/return-elided-lifetime.stderr @@ -5,10 +5,15 @@ LL | fn f1() -> &i32 { loop {} } | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | fn f1() -> &'static i32 { loop {} } | +++++++ +help: instead, you are more likely to want to return an owned value + | +LL - fn f1() -> &i32 { loop {} } +LL + fn f1() -> i32 { loop {} } + | error[E0106]: missing lifetime specifiers --> $DIR/return-elided-lifetime.rs:8:14 @@ -19,7 +24,7 @@ LL | fn f1_() -> (&i32, &i32) { loop {} } | expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | fn f1_() -> (&'static i32, &'static i32) { loop {} } | +++++++ +++++++ @@ -31,10 +36,19 @@ LL | fn f2(a: i32, b: i32) -> &i32 { loop {} } | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | fn f2(a: i32, b: i32) -> &'static i32 { loop {} } | +++++++ +help: instead, you are more likely to want to change one of the arguments to be borrowed... + | +LL | fn f2(a: &i32, b: &i32) -> &i32 { loop {} } + | + + +help: ...or alternatively, you might want to return an owned value + | +LL - fn f2(a: i32, b: i32) -> &i32 { loop {} } +LL + fn f2(a: i32, b: i32) -> i32 { loop {} } + | error[E0106]: missing lifetime specifiers --> $DIR/return-elided-lifetime.rs:13:28 @@ -45,7 +59,7 @@ LL | fn f2_(a: i32, b: i32) -> (&i32, &i32) { loop {} } | expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | fn f2_(a: i32, b: i32) -> (&'static i32, &'static i32) { loop {} } | +++++++ +++++++ diff --git a/tests/ui/suggestions/suggest-trait-in-ufcs-in-hrtb.stderr b/tests/ui/suggestions/suggest-trait-in-ufcs-in-hrtb.stderr index c0f0c414227..cabaa76a886 100644 --- a/tests/ui/suggestions/suggest-trait-in-ufcs-in-hrtb.stderr +++ b/tests/ui/suggestions/suggest-trait-in-ufcs-in-hrtb.stderr @@ -2,7 +2,14 @@ error[E0223]: ambiguous associated type --> $DIR/suggest-trait-in-ufcs-in-hrtb.rs:5:38 | LL | impl<S> Foo for Bar<S> where for<'a> <&'a S>::Item: Foo {} - | ^^^^^^^^^^^^^ help: use fully-qualified syntax: `<&'a S as IntoIterator>::Item` + | ^^^^^^^^^^^^^ + | +help: use fully-qualified syntax + | +LL | impl<S> Foo for Bar<S> where for<'a> <&'a S as IntoAsyncIterator>::Item: Foo {} + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +LL | impl<S> Foo for Bar<S> where for<'a> <&'a S as IntoIterator>::Item: Foo {} + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: aborting due to 1 previous error diff --git a/tests/ui/symbol-names/types.rs b/tests/ui/symbol-names/types.rs index 0ae699c93c2..475e8d89abf 100644 --- a/tests/ui/symbol-names/types.rs +++ b/tests/ui/symbol-names/types.rs @@ -1,7 +1,7 @@ // build-fail // revisions: legacy verbose-legacy // compile-flags: --crate-name=a -C symbol-mangling-version=legacy -Z unstable-options -//[verbose-legacy]compile-flags: -Zverbose +//[verbose-legacy]compile-flags: -Zverbose-internals // normalize-stderr-test: "h[[:xdigit:]]{16}" -> "h[HASH]" #![feature(never_type)] diff --git a/tests/ui/symbol-names/verbose.rs b/tests/ui/symbol-names/verbose.rs index e00c592b6d2..2aa43e87627 100644 --- a/tests/ui/symbol-names/verbose.rs +++ b/tests/ui/symbol-names/verbose.rs @@ -1,10 +1,10 @@ -// Regression test for issue #57596, where -Zverbose flag unintentionally +// Regression test for issue #57596, where -Zverbose-internals flag unintentionally // affected produced symbols making it impossible to link between crates // with a different value of the flag (for symbols involving generic // arguments equal to defaults of their respective parameters). // // build-pass -// compile-flags: -Zverbose +// compile-flags: -Zverbose-internals pub fn error(msg: String) -> Box<dyn std::error::Error> { msg.into() diff --git a/tests/ui/thir-print/thir-tree-match.stdout b/tests/ui/thir-print/thir-tree-match.stdout index 60c9283abcf..e752e4a8702 100644 --- a/tests/ui/thir-print/thir-tree-match.stdout +++ b/tests/ui/thir-print/thir-tree-match.stdout @@ -124,7 +124,7 @@ body: body: Expr { ty: bool - temp_lifetime: Some(Node(13)) + temp_lifetime: Some(Node(12)) span: $DIR/thir-tree-match.rs:17:36: 17:40 (#0) kind: Scope { @@ -133,7 +133,7 @@ body: value: Expr { ty: bool - temp_lifetime: Some(Node(13)) + temp_lifetime: Some(Node(12)) span: $DIR/thir-tree-match.rs:17:36: 17:40 (#0) kind: Literal( lit: Spanned { node: Bool(true), span: $DIR/thir-tree-match.rs:17:36: 17:40 (#0) }, neg: false) @@ -176,7 +176,7 @@ body: body: Expr { ty: bool - temp_lifetime: Some(Node(19)) + temp_lifetime: Some(Node(18)) span: $DIR/thir-tree-match.rs:18:27: 18:32 (#0) kind: Scope { @@ -185,7 +185,7 @@ body: value: Expr { ty: bool - temp_lifetime: Some(Node(19)) + temp_lifetime: Some(Node(18)) span: $DIR/thir-tree-match.rs:18:27: 18:32 (#0) kind: Literal( lit: Spanned { node: Bool(false), span: $DIR/thir-tree-match.rs:18:27: 18:32 (#0) }, neg: false) @@ -220,7 +220,7 @@ body: body: Expr { ty: bool - temp_lifetime: Some(Node(24)) + temp_lifetime: Some(Node(23)) span: $DIR/thir-tree-match.rs:19:24: 19:28 (#0) kind: Scope { @@ -229,7 +229,7 @@ body: value: Expr { ty: bool - temp_lifetime: Some(Node(24)) + temp_lifetime: Some(Node(23)) span: $DIR/thir-tree-match.rs:19:24: 19:28 (#0) kind: Literal( lit: Spanned { node: Bool(true), span: $DIR/thir-tree-match.rs:19:24: 19:28 (#0) }, neg: false) diff --git a/tests/ui/track-diagnostics/track.rs b/tests/ui/track-diagnostics/track.rs index 97bd7789a63..08f926610d7 100644 --- a/tests/ui/track-diagnostics/track.rs +++ b/tests/ui/track-diagnostics/track.rs @@ -1,5 +1,7 @@ // compile-flags: -Z track-diagnostics // error-pattern: created at +// rustc-env:RUST_BACKTRACE=0 +// failure-status: 101 // Normalize the emitted location so this doesn't need // updating everytime someone adds or removes a line. diff --git a/tests/ui/track-diagnostics/track.stderr b/tests/ui/track-diagnostics/track.stderr index 60254dc475b..54b1ea2764a 100644 --- a/tests/ui/track-diagnostics/track.stderr +++ b/tests/ui/track-diagnostics/track.stderr @@ -13,15 +13,31 @@ LL | break rust -Ztrack-diagnostics: created at compiler/rustc_passes/src/loops.rs:LL:CC error: internal compiler error: It looks like you're trying to break rust; would you like some ICE? + --> $DIR/track.rs:LL:CC + | +LL | break rust + | ^^^^^^^^^^ +-Ztrack-diagnostics: created at compiler/rustc_hir_typeck/src/lib.rs:LL:CC + | + = note: the compiler expectedly panicked. this is a feature. + = note: we would appreciate a joke overview: https://github.com/rust-lang/rust/issues/43162#issuecomment-320764675 + = note: rustc $VERSION running on $TARGET + = note: compiler flags: ... -Z ui-testing ... -Z track-diagnostics -note: the compiler expectedly panicked. this is a feature. +thread 'rustc' panicked at compiler/rustc_hir_typeck/src/lib.rs:LL:CC: +Box<dyn Any> +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -note: we would appreciate a joke overview: https://github.com/rust-lang/rust/issues/43162#issuecomment-320764675 +note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md note: rustc $VERSION running on $TARGET note: compiler flags: ... -Z ui-testing ... -Z track-diagnostics +query stack during panic: +#0 [typeck] type-checking `main` +#1 [analysis] running analysis passes on this crate +end of query stack error: aborting due to 3 previous errors Some errors have detailed explanations: E0268, E0425. diff --git a/tests/ui/traits/deny-builtin-object-impl.rs b/tests/ui/traits/deny-builtin-object-impl.rs index dce03a43b68..d0eb6382e41 100644 --- a/tests/ui/traits/deny-builtin-object-impl.rs +++ b/tests/ui/traits/deny-builtin-object-impl.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver #![feature(rustc_attrs)] diff --git a/tests/ui/traits/issue-102989.rs b/tests/ui/traits/issue-102989.rs index 216cd78e56f..f1ecee0a552 100644 --- a/tests/ui/traits/issue-102989.rs +++ b/tests/ui/traits/issue-102989.rs @@ -7,6 +7,7 @@ trait Sized { } //~ ERROR found duplicate lang item `sized` fn ref_Struct(self: &Struct, f: &u32) -> &u32 { //~^ ERROR `self` parameter is only allowed in associated functions //~| ERROR cannot find type `Struct` in this scope + //~| ERROR mismatched types let x = x << 1; //~^ ERROR cannot find value `x` in this scope } diff --git a/tests/ui/traits/issue-102989.stderr b/tests/ui/traits/issue-102989.stderr index 7d0098fe885..40e49df2b2d 100644 --- a/tests/ui/traits/issue-102989.stderr +++ b/tests/ui/traits/issue-102989.stderr @@ -13,7 +13,7 @@ LL | fn ref_Struct(self: &Struct, f: &u32) -> &u32 { | ^^^^^^ not found in this scope error[E0425]: cannot find value `x` in this scope - --> $DIR/issue-102989.rs:10:13 + --> $DIR/issue-102989.rs:11:13 | LL | let x = x << 1; | ^ help: a local variable with a similar name exists: `f` @@ -22,13 +22,27 @@ error[E0152]: found duplicate lang item `sized` --> $DIR/issue-102989.rs:5:1 | LL | trait Sized { } - | ^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ | = note: the lang item is first defined in crate `core` (which `std` depends on) = note: first definition in `core` loaded from SYSROOT/libcore-*.rlib = note: second definition in the local crate (`issue_102989`) -error: aborting due to 4 previous errors +error[E0308]: mismatched types + --> $DIR/issue-102989.rs:7:42 + | +LL | fn ref_Struct(self: &Struct, f: &u32) -> &u32 { + | ---------- ^^^^ expected `&u32`, found `()` + | | + | implicitly returns `()` as its body has no tail or `return` expression + | +help: consider returning the local binding `f` + | +LL ~ let x = x << 1; +LL + f + | + +error: aborting due to 5 previous errors -Some errors have detailed explanations: E0152, E0412, E0425. +Some errors have detailed explanations: E0152, E0308, E0412, E0425. For more information about an error, try `rustc --explain E0152`. diff --git a/tests/ui/traits/issue-117794.rs b/tests/ui/traits/issue-117794.rs new file mode 100644 index 00000000000..a66d6eb10ed --- /dev/null +++ b/tests/ui/traits/issue-117794.rs @@ -0,0 +1,10 @@ +trait Foo {} + +trait T { + fn a(&self) -> impl Foo { + self.b(|| 0) + //~^ ERROR no method named `b` found for reference `&Self` in the current scope + } +} + +fn main() {} diff --git a/tests/ui/traits/issue-117794.stderr b/tests/ui/traits/issue-117794.stderr new file mode 100644 index 00000000000..af63b47f07d --- /dev/null +++ b/tests/ui/traits/issue-117794.stderr @@ -0,0 +1,9 @@ +error[E0599]: no method named `b` found for reference `&Self` in the current scope + --> $DIR/issue-117794.rs:5:14 + | +LL | self.b(|| 0) + | ^ help: there is a method with a similar name: `a` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/traits/issue-24010.rs b/tests/ui/traits/issue-24010.rs index fd7d6751d5c..1eaa5bf0c67 100644 --- a/tests/ui/traits/issue-24010.rs +++ b/tests/ui/traits/issue-24010.rs @@ -1,6 +1,6 @@ // run-pass // revisions: classic next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver trait Foo: Fn(i32) -> i32 + Send {} diff --git a/tests/ui/traits/issue-90662-projection-caching.rs b/tests/ui/traits/issue-90662-projection-caching.rs index 879f30071bf..e08ab53fbb0 100644 --- a/tests/ui/traits/issue-90662-projection-caching.rs +++ b/tests/ui/traits/issue-90662-projection-caching.rs @@ -1,7 +1,15 @@ +// revisions: old next +//[next] compile-flags: -Znext-solver=coherence // check-pass // Regression test for issue #90662 -// Tests that projection caching does not cause a spurious error +// Tests that projection caching does not cause a spurious error. +// Coherence relies on the following overflowing goal to still constrain +// `?0` to `dyn Service`. +// +// Projection(<ServiceImpl as Provider<TestModule>>::Interface. ?0) +// +// cc https://github.com/rust-lang/trait-system-refactor-initiative/issues/70. trait HasProvider<T: ?Sized> {} trait Provider<M> { diff --git a/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr b/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr index a53879657f5..8f5b937e586 100644 --- a/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr +++ b/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr @@ -50,7 +50,7 @@ LL | is_send((8, TestType)); | required by a bound introduced by this call | = help: within `({integer}, dummy1c::TestType)`, the trait `Send` is not implemented for `dummy1c::TestType` - = note: required because it appears within the type `({integer}, TestType)` + = note: required because it appears within the type `({integer}, dummy1c::TestType)` note: required by a bound in `is_send` --> $DIR/negated-auto-traits-error.rs:16:15 | @@ -67,7 +67,7 @@ LL | is_send(Box::new(TestType)); | = note: the trait bound `Unique<dummy2::TestType>: Send` is not satisfied = note: required for `Unique<dummy2::TestType>` to implement `Send` -note: required because it appears within the type `Box<TestType>` +note: required because it appears within the type `Box<dummy2::TestType>` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL note: required by a bound in `is_send` --> $DIR/negated-auto-traits-error.rs:16:15 @@ -88,13 +88,13 @@ LL | is_send(Box::new(Outer2(TestType))); | required by a bound introduced by this call | = help: within `Outer2<dummy3::TestType>`, the trait `Send` is not implemented for `dummy3::TestType` -note: required because it appears within the type `Outer2<TestType>` +note: required because it appears within the type `Outer2<dummy3::TestType>` --> $DIR/negated-auto-traits-error.rs:12:8 | LL | struct Outer2<T>(T); | ^^^^^^ = note: required for `Unique<Outer2<dummy3::TestType>>` to implement `Send` -note: required because it appears within the type `Box<Outer2<TestType>>` +note: required because it appears within the type `Box<Outer2<dummy3::TestType>>` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL note: required by a bound in `is_send` --> $DIR/negated-auto-traits-error.rs:16:15 diff --git a/tests/ui/traits/new-solver/alias-bound-preference.rs b/tests/ui/traits/next-solver/alias-bound-preference.rs index e4e0f634ef7..1c6e1209610 100644 --- a/tests/ui/traits/new-solver/alias-bound-preference.rs +++ b/tests/ui/traits/next-solver/alias-bound-preference.rs @@ -1,5 +1,5 @@ // revisions: old next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver // run-pass // A test for https://github.com/rust-lang/trait-system-refactor-initiative/issues/45. diff --git a/tests/ui/traits/new-solver/alias-bound-unsound.rs b/tests/ui/traits/next-solver/alias-bound-unsound.rs index 907a3010355..4e279a84a33 100644 --- a/tests/ui/traits/new-solver/alias-bound-unsound.rs +++ b/tests/ui/traits/next-solver/alias-bound-unsound.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // Makes sure that alias bounds are not unsound! @@ -23,9 +23,10 @@ fn main() { let x = String::from("hello, world"); drop(<() as Foo>::copy_me(&x)); //~^ ERROR overflow evaluating the requirement `<() as Foo>::Item: Sized` - //~| ERROR overflow evaluating the requirement `<() as Foo>::Item normalizes-to _` + //~| ERROR overflow evaluating the requirement `<() as Foo>::Item == _` //~| ERROR overflow evaluating the requirement `<() as Foo>::Item well-formed` //~| ERROR overflow evaluating the requirement `String <: <() as Foo>::Item` //~| ERROR overflow evaluating the requirement `&<() as Foo>::Item well-formed` + //~| ERROR overflow evaluating the requirement `<() as Foo>::Item normalizes-to _` println!("{x}"); } diff --git a/tests/ui/traits/new-solver/alias-bound-unsound.stderr b/tests/ui/traits/next-solver/alias-bound-unsound.stderr index 29d4d983c03..ac3f19b3fe6 100644 --- a/tests/ui/traits/new-solver/alias-bound-unsound.stderr +++ b/tests/ui/traits/next-solver/alias-bound-unsound.stderr @@ -19,7 +19,7 @@ LL | drop(<() as Foo>::copy_me(&x)); | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`alias_bound_unsound`) -error[E0275]: overflow evaluating the requirement `<() as Foo>::Item normalizes-to _` +error[E0275]: overflow evaluating the requirement `<() as Foo>::Item == _` --> $DIR/alias-bound-unsound.rs:24:10 | LL | drop(<() as Foo>::copy_me(&x)); @@ -52,6 +52,14 @@ LL | drop(<() as Foo>::copy_me(&x)); | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`alias_bound_unsound`) -error: aborting due to 6 previous errors +error[E0275]: overflow evaluating the requirement `<() as Foo>::Item normalizes-to _` + --> $DIR/alias-bound-unsound.rs:24:10 + | +LL | drop(<() as Foo>::copy_me(&x)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`alias_bound_unsound`) + +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/traits/new-solver/alias-eq-in-canonical-response.rs b/tests/ui/traits/next-solver/alias-eq-in-canonical-response.rs index 4bfb6323a53..aa7c94791a7 100644 --- a/tests/ui/traits/new-solver/alias-eq-in-canonical-response.rs +++ b/tests/ui/traits/next-solver/alias-eq-in-canonical-response.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver trait Foo { type Gat<'a> diff --git a/tests/ui/traits/new-solver/alias-relate/deeply-nested-no-hang.rs b/tests/ui/traits/next-solver/alias-relate/deeply-nested-no-hang.rs index 4abce7b57d5..91cfda37adf 100644 --- a/tests/ui/traits/new-solver/alias-relate/deeply-nested-no-hang.rs +++ b/tests/ui/traits/next-solver/alias-relate/deeply-nested-no-hang.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // regression test for trait-system-refactor-initiative#68 trait Identity { type Assoc: ?Sized; diff --git a/tests/ui/traits/new-solver/alias-relate/opaque-hidden-ty-is-rigid-alias.rs b/tests/ui/traits/next-solver/alias-relate/opaque-hidden-ty-is-rigid-alias.rs index 29a73e1a967..88bbd13f9a2 100644 --- a/tests/ui/traits/new-solver/alias-relate/opaque-hidden-ty-is-rigid-alias.rs +++ b/tests/ui/traits/next-solver/alias-relate/opaque-hidden-ty-is-rigid-alias.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver fn test<T: Iterator>(x: T::Item) -> impl Sized { x diff --git a/tests/ui/traits/new-solver/alias-sub.rs b/tests/ui/traits/next-solver/alias-sub.rs index 30c1981a92e..f7f23a024dd 100644 --- a/tests/ui/traits/new-solver/alias-sub.rs +++ b/tests/ui/traits/next-solver/alias-sub.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass trait Trait { diff --git a/tests/ui/traits/new-solver/alias_eq_cant_be_furthur_normalized.rs b/tests/ui/traits/next-solver/alias_eq_cant_be_furthur_normalized.rs index dc726ba51f9..04d1b949692 100644 --- a/tests/ui/traits/new-solver/alias_eq_cant_be_furthur_normalized.rs +++ b/tests/ui/traits/next-solver/alias_eq_cant_be_furthur_normalized.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check that a goal such as `alias-eq(<T as TraitB>::Assoc<bool>, <T as TraitB>::Assoc<?0>)` // succeeds with a constraint that `?0 = bool` diff --git a/tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.rs b/tests/ui/traits/next-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.rs index 3c7fc7403b1..48157192a10 100644 --- a/tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.rs +++ b/tests/ui/traits/next-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass // (should not pass, should be turned into a coherence-only test) diff --git a/tests/ui/traits/new-solver/alias_eq_simple.rs b/tests/ui/traits/next-solver/alias_eq_simple.rs index 6792cf3ce35..21ad1a4fa3c 100644 --- a/tests/ui/traits/new-solver/alias_eq_simple.rs +++ b/tests/ui/traits/next-solver/alias_eq_simple.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // test that the new solver can handle `alias-eq(<i32 as TraitB>::Assoc, u32)` diff --git a/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.rs b/tests/ui/traits/next-solver/alias_eq_substs_eq_not_intercrate.rs index 204f6e8b071..4717aa80499 100644 --- a/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.rs +++ b/tests/ui/traits/next-solver/alias_eq_substs_eq_not_intercrate.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check that a `alias-eq(<?a as TraitB>::Assoc, <?b as TraitB>::Assoc)` goal fails // during coherence. We must not incorrectly constrain `?a` and `?b` to be diff --git a/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.stderr b/tests/ui/traits/next-solver/alias_eq_substs_eq_not_intercrate.stderr index 8c6840f72a7..8c6840f72a7 100644 --- a/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.stderr +++ b/tests/ui/traits/next-solver/alias_eq_substs_eq_not_intercrate.stderr diff --git a/tests/ui/traits/new-solver/array-default.rs b/tests/ui/traits/next-solver/array-default.rs index 5077137b09b..6bfbce7d433 100644 --- a/tests/ui/traits/new-solver/array-default.rs +++ b/tests/ui/traits/next-solver/array-default.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass fn has_default<const N: usize>() where [(); N]: Default {} diff --git a/tests/ui/traits/new-solver/assembly/assemble-normalizing-self-ty-impl-ambiguity.rs b/tests/ui/traits/next-solver/assembly/assemble-normalizing-self-ty-impl-ambiguity.rs index 826e8c1e0b1..4401abd0783 100644 --- a/tests/ui/traits/new-solver/assembly/assemble-normalizing-self-ty-impl-ambiguity.rs +++ b/tests/ui/traits/next-solver/assembly/assemble-normalizing-self-ty-impl-ambiguity.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass // Checks that we do not get ambiguity by considering an impl diff --git a/tests/ui/traits/new-solver/assembly/runaway-impl-candidate-selection.rs b/tests/ui/traits/next-solver/assembly/runaway-impl-candidate-selection.rs index 1dca86d3630..1edc1a8c58c 100644 --- a/tests/ui/traits/new-solver/assembly/runaway-impl-candidate-selection.rs +++ b/tests/ui/traits/next-solver/assembly/runaway-impl-candidate-selection.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // In the new solver, we are trying to select `<?0 as Iterator>::Item: Debug`, // which, naively can be unified with every impl of `Debug` if we're not careful. diff --git a/tests/ui/traits/new-solver/assembly/runaway-impl-candidate-selection.stderr b/tests/ui/traits/next-solver/assembly/runaway-impl-candidate-selection.stderr index 4bd55ee80c6..4bd55ee80c6 100644 --- a/tests/ui/traits/new-solver/assembly/runaway-impl-candidate-selection.stderr +++ b/tests/ui/traits/next-solver/assembly/runaway-impl-candidate-selection.stderr diff --git a/tests/ui/traits/new-solver/async.fail.stderr b/tests/ui/traits/next-solver/async.fail.stderr index ebd0ada2604..ebd0ada2604 100644 --- a/tests/ui/traits/new-solver/async.fail.stderr +++ b/tests/ui/traits/next-solver/async.fail.stderr diff --git a/tests/ui/traits/new-solver/async.rs b/tests/ui/traits/next-solver/async.rs index 155b71eb749..5833c052234 100644 --- a/tests/ui/traits/new-solver/async.rs +++ b/tests/ui/traits/next-solver/async.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // edition: 2021 // revisions: pass fail //[pass] check-pass diff --git a/tests/ui/traits/new-solver/auto-with-drop_tracking_mir.fail.stderr b/tests/ui/traits/next-solver/auto-with-drop_tracking_mir.fail.stderr index ac05dfb2d46..ac05dfb2d46 100644 --- a/tests/ui/traits/new-solver/auto-with-drop_tracking_mir.fail.stderr +++ b/tests/ui/traits/next-solver/auto-with-drop_tracking_mir.fail.stderr diff --git a/tests/ui/traits/new-solver/auto-with-drop_tracking_mir.rs b/tests/ui/traits/next-solver/auto-with-drop_tracking_mir.rs index 6b54718e35c..d4010a55244 100644 --- a/tests/ui/traits/new-solver/auto-with-drop_tracking_mir.rs +++ b/tests/ui/traits/next-solver/auto-with-drop_tracking_mir.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // edition: 2021 // revisions: pass fail //[pass] check-pass diff --git a/tests/ui/traits/new-solver/borrowck-error.rs b/tests/ui/traits/next-solver/borrowck-error.rs index 4787a2c7e11..25f1445941b 100644 --- a/tests/ui/traits/new-solver/borrowck-error.rs +++ b/tests/ui/traits/next-solver/borrowck-error.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver use std::collections::HashMap; diff --git a/tests/ui/traits/new-solver/borrowck-error.stderr b/tests/ui/traits/next-solver/borrowck-error.stderr index 4cb41e7d597..4cb41e7d597 100644 --- a/tests/ui/traits/new-solver/borrowck-error.stderr +++ b/tests/ui/traits/next-solver/borrowck-error.stderr diff --git a/tests/ui/traits/new-solver/builtin-fn-must-return-sized.rs b/tests/ui/traits/next-solver/builtin-fn-must-return-sized.rs index ba473653ecf..eab25214d63 100644 --- a/tests/ui/traits/new-solver/builtin-fn-must-return-sized.rs +++ b/tests/ui/traits/next-solver/builtin-fn-must-return-sized.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver #![feature(fn_traits)] #![feature(unboxed_closures)] diff --git a/tests/ui/traits/new-solver/builtin-fn-must-return-sized.stderr b/tests/ui/traits/next-solver/builtin-fn-must-return-sized.stderr index 08047852f20..08047852f20 100644 --- a/tests/ui/traits/new-solver/builtin-fn-must-return-sized.stderr +++ b/tests/ui/traits/next-solver/builtin-fn-must-return-sized.stderr diff --git a/tests/ui/traits/new-solver/canonical-int-var-eq-in-response.rs b/tests/ui/traits/next-solver/canonical-int-var-eq-in-response.rs index 4b013983a4a..ea2740523c9 100644 --- a/tests/ui/traits/new-solver/canonical-int-var-eq-in-response.rs +++ b/tests/ui/traits/next-solver/canonical-int-var-eq-in-response.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass trait Mirror { diff --git a/tests/ui/traits/new-solver/canonical-ty-var-eq-in-response.rs b/tests/ui/traits/next-solver/canonical-ty-var-eq-in-response.rs index d1c6b1077e8..b1e4a9e58cf 100644 --- a/tests/ui/traits/new-solver/canonical-ty-var-eq-in-response.rs +++ b/tests/ui/traits/next-solver/canonical-ty-var-eq-in-response.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver trait Mirror { type Item; diff --git a/tests/ui/traits/new-solver/canonicalize-effect-var.rs b/tests/ui/traits/next-solver/canonicalize-effect-var.rs index 35b69ed1a6b..4a13ba37303 100644 --- a/tests/ui/traits/new-solver/canonicalize-effect-var.rs +++ b/tests/ui/traits/next-solver/canonicalize-effect-var.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass #![feature(effects)] diff --git a/tests/ui/traits/new-solver/cast-checks-handling-projections.rs b/tests/ui/traits/next-solver/cast-checks-handling-projections.rs index 3b261062f78..406b4dc1211 100644 --- a/tests/ui/traits/new-solver/cast-checks-handling-projections.rs +++ b/tests/ui/traits/next-solver/cast-checks-handling-projections.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass fn main() { diff --git a/tests/ui/traits/new-solver/closure-inference-guidance.rs b/tests/ui/traits/next-solver/closure-inference-guidance.rs index d2ad0cc0316..8175b92f882 100644 --- a/tests/ui/traits/new-solver/closure-inference-guidance.rs +++ b/tests/ui/traits/next-solver/closure-inference-guidance.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass fn foo(i: isize) -> isize { i + 1 } diff --git a/tests/ui/traits/next-solver/closure-signature-inference-2.rs b/tests/ui/traits/next-solver/closure-signature-inference-2.rs new file mode 100644 index 00000000000..8fece7ba91f --- /dev/null +++ b/tests/ui/traits/next-solver/closure-signature-inference-2.rs @@ -0,0 +1,21 @@ +// compile-flags: -Znext-solver +// check-pass + +fn map<T: Default, U, F: FnOnce(T) -> U>(f: F) { + f(T::default()); +} + +fn main() { + map::<i32, _ /* ?U */, _ /* ?F */>(|x| x.to_string()); + // PREVIOUSLY when confirming the `map` call, we register: + // + // (1.) ?F: FnOnce<(i32,)> + // (2.) <?F as FnOnce<(i32,)>>::Output projects-to ?U + // + // While (1.) is ambiguous, (2.) immediately gets processed + // and we infer `?U := <?F as FnOnce<(i32,)>>::Output`. + // + // Thus, the only pending obligation that remains is (1.). + // Since it is a trait obligation, we don't use it to deduce + // the closure signature, and we fail! +} diff --git a/tests/ui/traits/next-solver/closure-signature-inference.rs b/tests/ui/traits/next-solver/closure-signature-inference.rs new file mode 100644 index 00000000000..355fc790229 --- /dev/null +++ b/tests/ui/traits/next-solver/closure-signature-inference.rs @@ -0,0 +1,15 @@ +// compile-flags: -Znext-solver +// check-pass + +struct A; +impl A { + fn hi(self) {} +} + +fn hello() -> Result<(A,), ()> { + Err(()) +} + +fn main() { + let x = hello().map(|(x,)| x.hi()); +} diff --git a/tests/ui/traits/new-solver/closure-substs-ambiguity.rs b/tests/ui/traits/next-solver/closure-substs-ambiguity.rs index 48432f4020f..cc9ee58f27f 100644 --- a/tests/ui/traits/new-solver/closure-substs-ambiguity.rs +++ b/tests/ui/traits/next-solver/closure-substs-ambiguity.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass fn main() { diff --git a/tests/ui/traits/next-solver/coerce-ambig-alias-to-rigid-alias.rs b/tests/ui/traits/next-solver/coerce-ambig-alias-to-rigid-alias.rs new file mode 100644 index 00000000000..bcb48b5acc7 --- /dev/null +++ b/tests/ui/traits/next-solver/coerce-ambig-alias-to-rigid-alias.rs @@ -0,0 +1,15 @@ +// compile-flags: -Znext-solver +// check-pass + +trait Trait { + type Assoc; +} + +fn call<T: Trait>(_: <T as Trait>::Assoc, _: T) {} + +fn foo<T: Trait>(rigid: <T as Trait>::Assoc, t: T) { + // Check that we can coerce `<?0 as Trait>::Assoc` to `<T as Trait>::Assoc`. + call::<_ /* ?0 */>(rigid, t); +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/coherence/issue-102048.rs b/tests/ui/traits/next-solver/coherence/issue-102048.rs index 11636bfeb55..600e63d4d44 100644 --- a/tests/ui/traits/new-solver/coherence/issue-102048.rs +++ b/tests/ui/traits/next-solver/coherence/issue-102048.rs @@ -17,7 +17,7 @@ // that to `i32`. We then try to unify `i32` from `impl1` with `u32` from `impl2` which fails, // causing coherence to consider these two impls distinct. -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver pub trait Trait<T> {} pub trait WithAssoc1<'a> { diff --git a/tests/ui/traits/new-solver/coherence/issue-102048.stderr b/tests/ui/traits/next-solver/coherence/issue-102048.stderr index 4e93ae28496..4e93ae28496 100644 --- a/tests/ui/traits/new-solver/coherence/issue-102048.stderr +++ b/tests/ui/traits/next-solver/coherence/issue-102048.stderr diff --git a/tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-norm-overflow.rs b/tests/ui/traits/next-solver/coherence/trait_ref_is_knowable-norm-overflow.rs index b39ae0333ad..af471b5e193 100644 --- a/tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-norm-overflow.rs +++ b/tests/ui/traits/next-solver/coherence/trait_ref_is_knowable-norm-overflow.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // Coherence should handle overflow while normalizing for // `trait_ref_is_knowable` correctly. diff --git a/tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-norm-overflow.stderr b/tests/ui/traits/next-solver/coherence/trait_ref_is_knowable-norm-overflow.stderr index e3c0dabf549..e3c0dabf549 100644 --- a/tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-norm-overflow.stderr +++ b/tests/ui/traits/next-solver/coherence/trait_ref_is_knowable-norm-overflow.stderr diff --git a/tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-normalization-1.rs b/tests/ui/traits/next-solver/coherence/trait_ref_is_knowable-normalization-1.rs index c38e3baf5b4..e6ffb55b441 100644 --- a/tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-normalization-1.rs +++ b/tests/ui/traits/next-solver/coherence/trait_ref_is_knowable-normalization-1.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass trait Id { diff --git a/tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-normalization-2.rs b/tests/ui/traits/next-solver/coherence/trait_ref_is_knowable-normalization-2.rs index 2d53266db09..d16f9d22ce0 100644 --- a/tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-normalization-2.rs +++ b/tests/ui/traits/next-solver/coherence/trait_ref_is_knowable-normalization-2.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass use std::future::{Future, IntoFuture}; diff --git a/tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-normalization-3.rs b/tests/ui/traits/next-solver/coherence/trait_ref_is_knowable-normalization-3.rs index 2f27de4e4f4..90de6b847d0 100644 --- a/tests/ui/traits/new-solver/coherence/trait_ref_is_knowable-normalization-3.rs +++ b/tests/ui/traits/next-solver/coherence/trait_ref_is_knowable-normalization-3.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass trait Id { diff --git a/tests/ui/traits/new-solver/const-param-placeholder.fail.stderr b/tests/ui/traits/next-solver/const-param-placeholder.fail.stderr index 163710706b0..163710706b0 100644 --- a/tests/ui/traits/new-solver/const-param-placeholder.fail.stderr +++ b/tests/ui/traits/next-solver/const-param-placeholder.fail.stderr diff --git a/tests/ui/traits/new-solver/const-param-placeholder.rs b/tests/ui/traits/next-solver/const-param-placeholder.rs index a83102a4cdd..c22bc54cfca 100644 --- a/tests/ui/traits/new-solver/const-param-placeholder.rs +++ b/tests/ui/traits/next-solver/const-param-placeholder.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // revisions: pass fail //[pass] check-pass diff --git a/tests/ui/traits/new-solver/coroutine.fail.stderr b/tests/ui/traits/next-solver/coroutine.fail.stderr index 14e67727d0b..14e67727d0b 100644 --- a/tests/ui/traits/new-solver/coroutine.fail.stderr +++ b/tests/ui/traits/next-solver/coroutine.fail.stderr diff --git a/tests/ui/traits/new-solver/coroutine.rs b/tests/ui/traits/next-solver/coroutine.rs index af16f70fb56..727e2356859 100644 --- a/tests/ui/traits/new-solver/coroutine.rs +++ b/tests/ui/traits/next-solver/coroutine.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // edition: 2021 // revisions: pass fail //[pass] check-pass diff --git a/tests/ui/traits/new-solver/cycles/coinduction/fixpoint-exponential-growth.rs b/tests/ui/traits/next-solver/cycles/coinduction/fixpoint-exponential-growth.rs index 07c7d4fb29c..947b52da7c2 100644 --- a/tests/ui/traits/new-solver/cycles/coinduction/fixpoint-exponential-growth.rs +++ b/tests/ui/traits/next-solver/cycles/coinduction/fixpoint-exponential-growth.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // Proving `W<?0>: Trait` instantiates `?0` with `(W<?1>, W<?2>)` and then // proves `W<?1>: Trait` and `W<?2>: Trait`, resulting in a coinductive cycle. diff --git a/tests/ui/traits/new-solver/cycles/coinduction/fixpoint-exponential-growth.stderr b/tests/ui/traits/next-solver/cycles/coinduction/fixpoint-exponential-growth.stderr index 150100f2c53..150100f2c53 100644 --- a/tests/ui/traits/new-solver/cycles/coinduction/fixpoint-exponential-growth.stderr +++ b/tests/ui/traits/next-solver/cycles/coinduction/fixpoint-exponential-growth.stderr diff --git a/tests/ui/traits/new-solver/cycles/coinduction/incompleteness-unstable-result.rs b/tests/ui/traits/next-solver/cycles/coinduction/incompleteness-unstable-result.rs index 0cd14f05c8d..a3c07b98722 100644 --- a/tests/ui/traits/new-solver/cycles/coinduction/incompleteness-unstable-result.rs +++ b/tests/ui/traits/next-solver/cycles/coinduction/incompleteness-unstable-result.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver #![feature(rustc_attrs)] // This test is incredibly subtle. At its core the goal is to get a coinductive cycle, diff --git a/tests/ui/traits/new-solver/cycles/coinduction/incompleteness-unstable-result.stderr b/tests/ui/traits/next-solver/cycles/coinduction/incompleteness-unstable-result.stderr index d4932191791..d4932191791 100644 --- a/tests/ui/traits/new-solver/cycles/coinduction/incompleteness-unstable-result.stderr +++ b/tests/ui/traits/next-solver/cycles/coinduction/incompleteness-unstable-result.stderr diff --git a/tests/ui/traits/new-solver/cycles/double-cycle-inductive-coinductive.rs b/tests/ui/traits/next-solver/cycles/double-cycle-inductive-coinductive.rs index 5617e45adf6..0f19bc2c592 100644 --- a/tests/ui/traits/new-solver/cycles/double-cycle-inductive-coinductive.rs +++ b/tests/ui/traits/next-solver/cycles/double-cycle-inductive-coinductive.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver #![feature(rustc_attrs)] // Test that having both an inductive and a coinductive cycle diff --git a/tests/ui/traits/new-solver/cycles/double-cycle-inductive-coinductive.stderr b/tests/ui/traits/next-solver/cycles/double-cycle-inductive-coinductive.stderr index a3404da51f0..a3404da51f0 100644 --- a/tests/ui/traits/new-solver/cycles/double-cycle-inductive-coinductive.stderr +++ b/tests/ui/traits/next-solver/cycles/double-cycle-inductive-coinductive.stderr diff --git a/tests/ui/traits/new-solver/cycles/fixpoint-rerun-all-cycle-heads.rs b/tests/ui/traits/next-solver/cycles/fixpoint-rerun-all-cycle-heads.rs index 27906392340..c7e2e2d5e04 100644 --- a/tests/ui/traits/new-solver/cycles/fixpoint-rerun-all-cycle-heads.rs +++ b/tests/ui/traits/next-solver/cycles/fixpoint-rerun-all-cycle-heads.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver #![feature(rustc_attrs)] // Check that we correctly rerun the trait solver for heads of cycles, diff --git a/tests/ui/traits/new-solver/cycles/fixpoint-rerun-all-cycle-heads.stderr b/tests/ui/traits/next-solver/cycles/fixpoint-rerun-all-cycle-heads.stderr index 7b3075f4ff3..7b3075f4ff3 100644 --- a/tests/ui/traits/new-solver/cycles/fixpoint-rerun-all-cycle-heads.stderr +++ b/tests/ui/traits/next-solver/cycles/fixpoint-rerun-all-cycle-heads.stderr diff --git a/tests/ui/traits/new-solver/cycles/inductive-cycle-but-err.rs b/tests/ui/traits/next-solver/cycles/inductive-cycle-but-err.rs index cda98789886..fdc7afea378 100644 --- a/tests/ui/traits/new-solver/cycles/inductive-cycle-but-err.rs +++ b/tests/ui/traits/next-solver/cycles/inductive-cycle-but-err.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver #![feature(trivial_bounds, marker_trait_attr)] #![allow(trivial_bounds)] // This previously triggered a bug in the provisional cache. diff --git a/tests/ui/traits/new-solver/cycles/inductive-cycle-but-err.stderr b/tests/ui/traits/next-solver/cycles/inductive-cycle-but-err.stderr index acacaf6a331..acacaf6a331 100644 --- a/tests/ui/traits/new-solver/cycles/inductive-cycle-but-err.stderr +++ b/tests/ui/traits/next-solver/cycles/inductive-cycle-but-err.stderr diff --git a/tests/ui/traits/new-solver/cycles/inductive-cycle-but-ok.rs b/tests/ui/traits/next-solver/cycles/inductive-cycle-but-ok.rs index d4851eb694b..d6d9762bb73 100644 --- a/tests/ui/traits/new-solver/cycles/inductive-cycle-but-ok.rs +++ b/tests/ui/traits/next-solver/cycles/inductive-cycle-but-ok.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass #![feature(trivial_bounds, marker_trait_attr)] #![allow(trivial_bounds)] diff --git a/tests/ui/traits/new-solver/cycles/inductive-cycle-discarded-coinductive-constraints.rs b/tests/ui/traits/next-solver/cycles/inductive-cycle-discarded-coinductive-constraints.rs index 530e6d0ecf3..a32f7a13a03 100644 --- a/tests/ui/traits/new-solver/cycles/inductive-cycle-discarded-coinductive-constraints.rs +++ b/tests/ui/traits/next-solver/cycles/inductive-cycle-discarded-coinductive-constraints.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver #![feature(rustc_attrs, marker_trait_attr)] #[rustc_coinductive] trait Trait {} diff --git a/tests/ui/traits/new-solver/cycles/inductive-fixpoint-hang.rs b/tests/ui/traits/next-solver/cycles/inductive-fixpoint-hang.rs index 062c6ae98d5..efeb8d0231e 100644 --- a/tests/ui/traits/new-solver/cycles/inductive-fixpoint-hang.rs +++ b/tests/ui/traits/next-solver/cycles/inductive-fixpoint-hang.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // This currently hangs if we do not erase constraints from // overflow. diff --git a/tests/ui/traits/new-solver/cycles/inductive-fixpoint-hang.stderr b/tests/ui/traits/next-solver/cycles/inductive-fixpoint-hang.stderr index 42451920744..42451920744 100644 --- a/tests/ui/traits/new-solver/cycles/inductive-fixpoint-hang.stderr +++ b/tests/ui/traits/next-solver/cycles/inductive-fixpoint-hang.stderr diff --git a/tests/ui/traits/new-solver/cycles/inductive-not-on-stack.rs b/tests/ui/traits/next-solver/cycles/inductive-not-on-stack.rs index f06b98a79cf..f2f6e009d54 100644 --- a/tests/ui/traits/new-solver/cycles/inductive-not-on-stack.rs +++ b/tests/ui/traits/next-solver/cycles/inductive-not-on-stack.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver #![feature(rustc_attrs, trivial_bounds)] // We have to be careful here: diff --git a/tests/ui/traits/new-solver/cycles/inductive-not-on-stack.stderr b/tests/ui/traits/next-solver/cycles/inductive-not-on-stack.stderr index 859b3f3f1c7..859b3f3f1c7 100644 --- a/tests/ui/traits/new-solver/cycles/inductive-not-on-stack.stderr +++ b/tests/ui/traits/next-solver/cycles/inductive-not-on-stack.stderr diff --git a/tests/ui/traits/new-solver/cycles/leak-check-coinductive-cycle.rs b/tests/ui/traits/next-solver/cycles/leak-check-coinductive-cycle.rs index a6d31872673..9ff362ec882 100644 --- a/tests/ui/traits/new-solver/cycles/leak-check-coinductive-cycle.rs +++ b/tests/ui/traits/next-solver/cycles/leak-check-coinductive-cycle.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass #![feature(rustc_attrs)] diff --git a/tests/ui/traits/new-solver/cycles/provisional-result-done.rs b/tests/ui/traits/next-solver/cycles/provisional-result-done.rs index 589d34dd7ab..0f3b84ce520 100644 --- a/tests/ui/traits/new-solver/cycles/provisional-result-done.rs +++ b/tests/ui/traits/next-solver/cycles/provisional-result-done.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass // This tests checks that we update results in the provisional cache when diff --git a/tests/ui/traits/new-solver/deduce-closure-signature-after-normalization.rs b/tests/ui/traits/next-solver/deduce-closure-signature-after-normalization.rs index 51f62bc2312..08f26686b2f 100644 --- a/tests/ui/traits/new-solver/deduce-closure-signature-after-normalization.rs +++ b/tests/ui/traits/next-solver/deduce-closure-signature-after-normalization.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass trait Foo { diff --git a/tests/ui/traits/new-solver/deduce-ty-from-object.rs b/tests/ui/traits/next-solver/deduce-ty-from-object.rs index 7398bce7b61..b627fd720e3 100644 --- a/tests/ui/traits/new-solver/deduce-ty-from-object.rs +++ b/tests/ui/traits/next-solver/deduce-ty-from-object.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver fn main() { let x: Box<dyn Iterator<Item = ()>> = Box::new(std::iter::empty()); diff --git a/tests/ui/traits/new-solver/dedup-regions.rs b/tests/ui/traits/next-solver/dedup-regions.rs index f376f39a5a6..dd406333f27 100644 --- a/tests/ui/traits/new-solver/dedup-regions.rs +++ b/tests/ui/traits/next-solver/dedup-regions.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass struct A(*mut ()); diff --git a/tests/ui/traits/new-solver/destruct.rs b/tests/ui/traits/next-solver/destruct.rs index 30d7777b78a..5093344e4b6 100644 --- a/tests/ui/traits/new-solver/destruct.rs +++ b/tests/ui/traits/next-solver/destruct.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass #![feature(const_trait_impl)] diff --git a/tests/ui/traits/new-solver/dont-coerce-infer-to-dyn.rs b/tests/ui/traits/next-solver/dont-coerce-infer-to-dyn.rs index c2ac80459ca..da07869f3b6 100644 --- a/tests/ui/traits/new-solver/dont-coerce-infer-to-dyn.rs +++ b/tests/ui/traits/next-solver/dont-coerce-infer-to-dyn.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass use std::fmt::Display; diff --git a/tests/ui/traits/new-solver/dont-elaborate-for-projections.rs b/tests/ui/traits/next-solver/dont-elaborate-for-projections.rs index e608250063c..9123871db97 100644 --- a/tests/ui/traits/new-solver/dont-elaborate-for-projections.rs +++ b/tests/ui/traits/next-solver/dont-elaborate-for-projections.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass trait Iter<'a, I: 'a>: Iterator<Item = &'a I> {} diff --git a/tests/ui/traits/new-solver/dont-ice-on-assoc-projection.rs b/tests/ui/traits/next-solver/dont-ice-on-assoc-projection.rs index b9798c79d5e..1e1ef8c23a2 100644 --- a/tests/ui/traits/new-solver/dont-ice-on-assoc-projection.rs +++ b/tests/ui/traits/next-solver/dont-ice-on-assoc-projection.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next-coherence +// compile-flags: -Znext-solver=coherence // Makes sure we don't ICE on associated const projection when the feature gate // is not enabled, since we should avoid encountering ICEs on stable if possible. diff --git a/tests/ui/traits/new-solver/dont-ice-on-assoc-projection.stderr b/tests/ui/traits/next-solver/dont-ice-on-assoc-projection.stderr index 368f5cd0c3b..368f5cd0c3b 100644 --- a/tests/ui/traits/new-solver/dont-ice-on-assoc-projection.stderr +++ b/tests/ui/traits/next-solver/dont-ice-on-assoc-projection.stderr diff --git a/tests/ui/traits/new-solver/dont-loop-fulfill-on-region-constraints.rs b/tests/ui/traits/next-solver/dont-loop-fulfill-on-region-constraints.rs index b241e3bf865..a85098a95ad 100644 --- a/tests/ui/traits/new-solver/dont-loop-fulfill-on-region-constraints.rs +++ b/tests/ui/traits/next-solver/dont-loop-fulfill-on-region-constraints.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass trait Eq<'a, 'b, T> {} diff --git a/tests/ui/traits/new-solver/dont-normalize-proj-with-error.rs b/tests/ui/traits/next-solver/dont-normalize-proj-with-error.rs index 19a6fa990ff..fd1682cd61a 100644 --- a/tests/ui/traits/new-solver/dont-normalize-proj-with-error.rs +++ b/tests/ui/traits/next-solver/dont-normalize-proj-with-error.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // Test that we don't incorrectly leak unconstrained inference variables // if the projection contained an error. This caused an ICE in writeback. diff --git a/tests/ui/traits/new-solver/dont-normalize-proj-with-error.stderr b/tests/ui/traits/next-solver/dont-normalize-proj-with-error.stderr index 576ede52aff..576ede52aff 100644 --- a/tests/ui/traits/new-solver/dont-normalize-proj-with-error.stderr +++ b/tests/ui/traits/next-solver/dont-normalize-proj-with-error.stderr diff --git a/tests/ui/traits/new-solver/dont-remap-tait-substs.rs b/tests/ui/traits/next-solver/dont-remap-tait-substs.rs index 309bee8aa8c..b089f0df3c7 100644 --- a/tests/ui/traits/new-solver/dont-remap-tait-substs.rs +++ b/tests/ui/traits/next-solver/dont-remap-tait-substs.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass // Makes sure we don't prepopulate the MIR typeck of `define` diff --git a/tests/ui/traits/new-solver/dont-type_of-tait-in-defining-scope.not_send.stderr b/tests/ui/traits/next-solver/dont-type_of-tait-in-defining-scope.not_send.stderr index 076dab29d89..076dab29d89 100644 --- a/tests/ui/traits/new-solver/dont-type_of-tait-in-defining-scope.not_send.stderr +++ b/tests/ui/traits/next-solver/dont-type_of-tait-in-defining-scope.not_send.stderr diff --git a/tests/ui/traits/new-solver/dont-type_of-tait-in-defining-scope.rs b/tests/ui/traits/next-solver/dont-type_of-tait-in-defining-scope.rs index 08f14d7494d..a1f38e69e53 100644 --- a/tests/ui/traits/new-solver/dont-type_of-tait-in-defining-scope.rs +++ b/tests/ui/traits/next-solver/dont-type_of-tait-in-defining-scope.rs @@ -1,5 +1,5 @@ // revisions: is_send not_send -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver //[is_send] check-pass #![feature(type_alias_impl_trait)] diff --git a/tests/ui/traits/new-solver/dyn-any-dont-prefer-impl.rs b/tests/ui/traits/next-solver/dyn-any-dont-prefer-impl.rs index af35a6195e0..bb1c24a001f 100644 --- a/tests/ui/traits/new-solver/dyn-any-dont-prefer-impl.rs +++ b/tests/ui/traits/next-solver/dyn-any-dont-prefer-impl.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass // Test that selection prefers the builtin trait object impl for `Any` diff --git a/tests/ui/traits/new-solver/elaborate-item-bounds.rs b/tests/ui/traits/next-solver/elaborate-item-bounds.rs index 076aefcf8fc..0f1f6c0445c 100644 --- a/tests/ui/traits/new-solver/elaborate-item-bounds.rs +++ b/tests/ui/traits/next-solver/elaborate-item-bounds.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass trait Foo { diff --git a/tests/ui/traits/new-solver/equating-projection-cyclically.rs b/tests/ui/traits/next-solver/equating-projection-cyclically.rs index 845597e9ce1..e7c80cfd797 100644 --- a/tests/ui/traits/new-solver/equating-projection-cyclically.rs +++ b/tests/ui/traits/next-solver/equating-projection-cyclically.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver trait Test { type Assoc; diff --git a/tests/ui/traits/new-solver/escaping-bound-vars-in-writeback-normalization.rs b/tests/ui/traits/next-solver/escaping-bound-vars-in-writeback-normalization.rs index 29784c32a1b..77bedc351e7 100644 --- a/tests/ui/traits/new-solver/escaping-bound-vars-in-writeback-normalization.rs +++ b/tests/ui/traits/next-solver/escaping-bound-vars-in-writeback-normalization.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass trait Trivial { diff --git a/tests/ui/traits/new-solver/float-canonical.rs b/tests/ui/traits/next-solver/float-canonical.rs index b8748cd433b..90d75bacbf4 100644 --- a/tests/ui/traits/new-solver/float-canonical.rs +++ b/tests/ui/traits/next-solver/float-canonical.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass fn foo(x: f64) { diff --git a/tests/ui/traits/new-solver/fn-trait-closure.rs b/tests/ui/traits/next-solver/fn-trait-closure.rs index bd65737ee39..cd2ae1f6fb2 100644 --- a/tests/ui/traits/new-solver/fn-trait-closure.rs +++ b/tests/ui/traits/next-solver/fn-trait-closure.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass fn require_fn(_: impl Fn() -> i32) {} diff --git a/tests/ui/traits/new-solver/fn-trait.rs b/tests/ui/traits/next-solver/fn-trait.rs index 0a19e626553..1e3d8a21c7c 100644 --- a/tests/ui/traits/new-solver/fn-trait.rs +++ b/tests/ui/traits/next-solver/fn-trait.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver fn require_fn(_: impl Fn() -> i32) {} diff --git a/tests/ui/traits/new-solver/fn-trait.stderr b/tests/ui/traits/next-solver/fn-trait.stderr index e33487235e6..e33487235e6 100644 --- a/tests/ui/traits/new-solver/fn-trait.stderr +++ b/tests/ui/traits/next-solver/fn-trait.stderr diff --git a/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-1.rs b/tests/ui/traits/next-solver/generalize/generalize-proj-new-universe-index-1.rs index b0b9b6bbd20..4a70bd5f815 100644 --- a/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-1.rs +++ b/tests/ui/traits/next-solver/generalize/generalize-proj-new-universe-index-1.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass // A minimization of an ambiguity when using typenum. See diff --git a/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-2.rs b/tests/ui/traits/next-solver/generalize/generalize-proj-new-universe-index-2.rs index 7fe242f4714..70758e7deaa 100644 --- a/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-2.rs +++ b/tests/ui/traits/next-solver/generalize/generalize-proj-new-universe-index-2.rs @@ -1,7 +1,5 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // known-bug: trait-system-refactor-initiative#60 -// dont-check-failure-status -// dont-check-compiler-stderr // Generalizing a projection containing an inference variable // which cannot be named by the `root_vid` can result in ambiguity. diff --git a/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-2.stderr b/tests/ui/traits/next-solver/generalize/generalize-proj-new-universe-index-2.stderr index b2a523ba620..4548ab1e297 100644 --- a/tests/ui/traits/new-solver/generalize/generalize-proj-new-universe-index-2.stderr +++ b/tests/ui/traits/next-solver/generalize/generalize-proj-new-universe-index-2.stderr @@ -1,9 +1,10 @@ -error[E0284]: type annotations needed: cannot satisfy `<<Leaf as WithAssoc<_>>::Assoc as Id>::Assoc == <<Leaf as WithAssoc<_>>::Assoc as Id>::Assoc` +error[E0284]: type annotations needed --> $DIR/generalize-proj-new-universe-index-2.rs:74:5 | LL | bound::<<Rigid as IdHigherRankedBound>::Assoc, <Wrapper<Leaf> as Id>::Assoc, _>() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot satisfy `<<Leaf as WithAssoc<_>>::Assoc as Id>::Assoc == <<Leaf as WithAssoc<_>>::Assoc as Id>::Assoc` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `V` declared on the function `bound` | + = note: cannot satisfy `<<Rigid as IdHigherRankedBound>::Assoc as WithAssoc<<Wrapper<Leaf> as Id>::Assoc>>::Assoc == _` note: required by a bound in `bound` --> $DIR/generalize-proj-new-universe-index-2.rs:69:21 | diff --git a/tests/ui/traits/new-solver/generalize/occurs-check-nested-alias.next.stderr b/tests/ui/traits/next-solver/generalize/occurs-check-nested-alias.next.stderr index ad8b24a39c7..ad8b24a39c7 100644 --- a/tests/ui/traits/new-solver/generalize/occurs-check-nested-alias.next.stderr +++ b/tests/ui/traits/next-solver/generalize/occurs-check-nested-alias.next.stderr diff --git a/tests/ui/traits/new-solver/generalize/occurs-check-nested-alias.rs b/tests/ui/traits/next-solver/generalize/occurs-check-nested-alias.rs index 02ac091c0a8..e51508d684f 100644 --- a/tests/ui/traits/new-solver/generalize/occurs-check-nested-alias.rs +++ b/tests/ui/traits/next-solver/generalize/occurs-check-nested-alias.rs @@ -3,7 +3,7 @@ // Currently always fails to generalize the outer alias, even if it // is treated as rigid by `alias-relate`. -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver //[next] known-bug: trait-system-refactor-initiative#8 #![crate_type = "lib"] #![allow(unused)] diff --git a/tests/ui/traits/new-solver/higher-ranked-dyn-bounds.rs b/tests/ui/traits/next-solver/higher-ranked-dyn-bounds.rs index c886aeeda3e..b87210d7fb3 100644 --- a/tests/ui/traits/new-solver/higher-ranked-dyn-bounds.rs +++ b/tests/ui/traits/next-solver/higher-ranked-dyn-bounds.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass trait Trait<'a> { diff --git a/tests/ui/traits/new-solver/int-var-alias-eq.rs b/tests/ui/traits/next-solver/int-var-alias-eq.rs index 790197e2d97..26ba7f8e511 100644 --- a/tests/ui/traits/new-solver/int-var-alias-eq.rs +++ b/tests/ui/traits/next-solver/int-var-alias-eq.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // HIR typeck ends up equating `<?0i as Add>::Output == ?0i`. // Want to make sure that we emit an alias-eq goal for this, diff --git a/tests/ui/traits/new-solver/int-var-is-send.rs b/tests/ui/traits/next-solver/int-var-is-send.rs index 083aa90e1f6..d8b963f2008 100644 --- a/tests/ui/traits/new-solver/int-var-is-send.rs +++ b/tests/ui/traits/next-solver/int-var-is-send.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass fn needs_send(_: impl Send) {} diff --git a/tests/ui/traits/next-solver/issue-118950-root-region.rs b/tests/ui/traits/next-solver/issue-118950-root-region.rs new file mode 100644 index 00000000000..10fb7d525b7 --- /dev/null +++ b/tests/ui/traits/next-solver/issue-118950-root-region.rs @@ -0,0 +1,22 @@ +// compile-flags: -Znext-solver +// +// This is a gnarly test but I don't know how to minimize it, frankly. + +#![feature(lazy_type_alias)] +//~^ WARN the feature `lazy_type_alias` is incomplete + +trait ToUnit<'a> { + type Unit; +} + +trait Overlap<T> {} + +type Assoc<'a, T> = <*const T as ToUnit<'a>>::Unit; + +impl<T> Overlap<T> for T {} + +impl<T> Overlap<for<'a> fn(Assoc<'a, T>)> for T where Missing: Overlap<T> {} +//~^ ERROR conflicting implementations of trait `Overlap<fn(_)>` for type `fn(_)` +//~| ERROR cannot find type `Missing` in this scope + +fn main() {} diff --git a/tests/ui/traits/next-solver/issue-118950-root-region.stderr b/tests/ui/traits/next-solver/issue-118950-root-region.stderr new file mode 100644 index 00000000000..c16a48d5f15 --- /dev/null +++ b/tests/ui/traits/next-solver/issue-118950-root-region.stderr @@ -0,0 +1,36 @@ +error[E0412]: cannot find type `Missing` in this scope + --> $DIR/issue-118950-root-region.rs:18:55 + | +LL | impl<T> Overlap<for<'a> fn(Assoc<'a, T>)> for T where Missing: Overlap<T> {} + | ^^^^^^^ not found in this scope + +warning: the feature `lazy_type_alias` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/issue-118950-root-region.rs:5:12 + | +LL | #![feature(lazy_type_alias)] + | ^^^^^^^^^^^^^^^ + | + = note: see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information + = note: `#[warn(incomplete_features)]` on by default + +WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Weak, AliasTy { args: [ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) }) +WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Weak, AliasTy { args: [RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) }) +WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Weak, AliasTy { args: [ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) }) +WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Weak, AliasTy { args: [RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) }) +WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Weak, AliasTy { args: [ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) }) +WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Weak, AliasTy { args: [RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) }) +WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Weak, AliasTy { args: [ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) }) +WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Weak, AliasTy { args: [RePlaceholder(!1_BoundRegion { var: 0, kind: BrNamed(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), 'a) }), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) }) +error[E0119]: conflicting implementations of trait `Overlap<fn(_)>` for type `fn(_)` + --> $DIR/issue-118950-root-region.rs:18:1 + | +LL | impl<T> Overlap<T> for T {} + | ------------------------ first implementation here +LL | +LL | impl<T> Overlap<for<'a> fn(Assoc<'a, T>)> for T where Missing: Overlap<T> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `fn(_)` + +error: aborting due to 2 previous errors; 1 warning emitted + +Some errors have detailed explanations: E0119, E0412. +For more information about an error, try `rustc --explain E0119`. diff --git a/tests/ui/traits/new-solver/iter-filter-projection.rs b/tests/ui/traits/next-solver/iter-filter-projection.rs index 8fb62323aa5..f948831ad52 100644 --- a/tests/ui/traits/new-solver/iter-filter-projection.rs +++ b/tests/ui/traits/next-solver/iter-filter-projection.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass use std::{iter, slice}; diff --git a/tests/ui/traits/new-solver/lazy-nested-obligations-1.rs b/tests/ui/traits/next-solver/lazy-nested-obligations-1.rs index af00cbb3ba8..f9e73a93c27 100644 --- a/tests/ui/traits/new-solver/lazy-nested-obligations-1.rs +++ b/tests/ui/traits/next-solver/lazy-nested-obligations-1.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // Issue 94358 fn foo<C>(_: C) diff --git a/tests/ui/traits/new-solver/lazy-nested-obligations-2.rs b/tests/ui/traits/next-solver/lazy-nested-obligations-2.rs index 20f504928c7..b85f9d9736c 100644 --- a/tests/ui/traits/new-solver/lazy-nested-obligations-2.rs +++ b/tests/ui/traits/next-solver/lazy-nested-obligations-2.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass pub trait With { diff --git a/tests/ui/traits/new-solver/lazy-nested-obligations-3.rs b/tests/ui/traits/next-solver/lazy-nested-obligations-3.rs index baf39957240..5fb4832dd08 100644 --- a/tests/ui/traits/new-solver/lazy-nested-obligations-3.rs +++ b/tests/ui/traits/next-solver/lazy-nested-obligations-3.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // Issue 96750 use std::marker::PhantomData; diff --git a/tests/ui/traits/new-solver/member-constraints-in-root-universe.rs b/tests/ui/traits/next-solver/member-constraints-in-root-universe.rs index 97c44305864..16e95e94ce5 100644 --- a/tests/ui/traits/new-solver/member-constraints-in-root-universe.rs +++ b/tests/ui/traits/next-solver/member-constraints-in-root-universe.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass trait Trait { diff --git a/tests/ui/traits/new-solver/more-object-bound.rs b/tests/ui/traits/next-solver/more-object-bound.rs index bb730b18ef7..8522f034d87 100644 --- a/tests/ui/traits/new-solver/more-object-bound.rs +++ b/tests/ui/traits/next-solver/more-object-bound.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // From #80800 trait SuperTrait { diff --git a/tests/ui/traits/new-solver/more-object-bound.stderr b/tests/ui/traits/next-solver/more-object-bound.stderr index e3be2931e12..e3be2931e12 100644 --- a/tests/ui/traits/new-solver/more-object-bound.stderr +++ b/tests/ui/traits/next-solver/more-object-bound.stderr diff --git a/tests/ui/traits/new-solver/negative-coherence-bounds.rs b/tests/ui/traits/next-solver/negative-coherence-bounds.rs index 5436b02c3de..5436b02c3de 100644 --- a/tests/ui/traits/new-solver/negative-coherence-bounds.rs +++ b/tests/ui/traits/next-solver/negative-coherence-bounds.rs diff --git a/tests/ui/traits/new-solver/negative-coherence-bounds.stderr b/tests/ui/traits/next-solver/negative-coherence-bounds.stderr index 4127f51f56d..4127f51f56d 100644 --- a/tests/ui/traits/new-solver/negative-coherence-bounds.stderr +++ b/tests/ui/traits/next-solver/negative-coherence-bounds.stderr diff --git a/tests/ui/traits/new-solver/nested-alias-bound.rs b/tests/ui/traits/next-solver/nested-alias-bound.rs index c365902dbe5..2e3de0ac66d 100644 --- a/tests/ui/traits/new-solver/nested-alias-bound.rs +++ b/tests/ui/traits/next-solver/nested-alias-bound.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass trait A { diff --git a/tests/ui/traits/new-solver/nested-obligations-with-bound-vars-gat.rs b/tests/ui/traits/next-solver/nested-obligations-with-bound-vars-gat.rs index 92bad959095..94c6c285680 100644 --- a/tests/ui/traits/new-solver/nested-obligations-with-bound-vars-gat.rs +++ b/tests/ui/traits/next-solver/nested-obligations-with-bound-vars-gat.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // Issue 96230 use std::fmt::Debug; diff --git a/tests/ui/traits/new-solver/normalize-async-closure-in-trait.rs b/tests/ui/traits/next-solver/normalize-async-closure-in-trait.rs index cc16cc87169..b58db2be841 100644 --- a/tests/ui/traits/new-solver/normalize-async-closure-in-trait.rs +++ b/tests/ui/traits/next-solver/normalize-async-closure-in-trait.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass // edition:2021 diff --git a/tests/ui/traits/new-solver/normalize-param-env-1.rs b/tests/ui/traits/next-solver/normalize-param-env-1.rs index b02a5d62330..92d4051378b 100644 --- a/tests/ui/traits/new-solver/normalize-param-env-1.rs +++ b/tests/ui/traits/next-solver/normalize-param-env-1.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // Issue 108933 trait Add<Rhs> { diff --git a/tests/ui/traits/new-solver/normalize-param-env-2.rs b/tests/ui/traits/next-solver/normalize-param-env-2.rs index 7c2cebdd200..ce084651bfb 100644 --- a/tests/ui/traits/new-solver/normalize-param-env-2.rs +++ b/tests/ui/traits/next-solver/normalize-param-env-2.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // Issue 92505 trait A<T> { diff --git a/tests/ui/traits/new-solver/normalize-param-env-3.rs b/tests/ui/traits/next-solver/normalize-param-env-3.rs index ce2974b2a16..e15e1155a1a 100644 --- a/tests/ui/traits/new-solver/normalize-param-env-3.rs +++ b/tests/ui/traits/next-solver/normalize-param-env-3.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // Issue 100177 trait GenericTrait<T> {} diff --git a/tests/ui/traits/new-solver/normalize-rcvr-for-inherent.rs b/tests/ui/traits/next-solver/normalize-rcvr-for-inherent.rs index d70534feb07..d308b1695f5 100644 --- a/tests/ui/traits/new-solver/normalize-rcvr-for-inherent.rs +++ b/tests/ui/traits/next-solver/normalize-rcvr-for-inherent.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass // Verify that we can assemble inherent impl candidates on a possibly diff --git a/tests/ui/traits/new-solver/normalize-unsize-rhs.rs b/tests/ui/traits/next-solver/normalize-unsize-rhs.rs index 1bb5c9b4111..6ca82d1b872 100644 --- a/tests/ui/traits/new-solver/normalize-unsize-rhs.rs +++ b/tests/ui/traits/next-solver/normalize-unsize-rhs.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass trait A {} diff --git a/tests/ui/traits/new-solver/normalized-const-built-in-op.rs b/tests/ui/traits/next-solver/normalized-const-built-in-op.rs index 2443e517813..0fffe7b4369 100644 --- a/tests/ui/traits/new-solver/normalized-const-built-in-op.rs +++ b/tests/ui/traits/next-solver/normalized-const-built-in-op.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass const fn foo() { diff --git a/tests/ui/traits/new-solver/normalizes_to_ignores_unnormalizable_candidate.rs b/tests/ui/traits/next-solver/normalizes_to_ignores_unnormalizable_candidate.rs index 46343241b45..7dc87daccd9 100644 --- a/tests/ui/traits/new-solver/normalizes_to_ignores_unnormalizable_candidate.rs +++ b/tests/ui/traits/next-solver/normalizes_to_ignores_unnormalizable_candidate.rs @@ -1,5 +1,5 @@ // [no_self_infer] check-pass -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // revisions: self_infer no_self_infer // checks that the new solver is smart enough to infer `?0 = U` when solving: @@ -7,7 +7,7 @@ // with `normalizes-to(<Vec<U> as Trait>::Assoc, u8)` in the paramenv even when // there is a separate `Vec<T>: Trait` bound in the paramenv. // -// FIXME(-Ztrait-solver=next) +// FIXME(-Znext-solver) // This could also compile for `normalizes-to(<?0 as Trait>::Assoc, u8)` but // we currently immediately consider a goal ambiguous if the self type is an // inference variable. diff --git a/tests/ui/traits/new-solver/normalizes_to_ignores_unnormalizable_candidate.self_infer.stderr b/tests/ui/traits/next-solver/normalizes_to_ignores_unnormalizable_candidate.self_infer.stderr index c1a8b74df08..c1a8b74df08 100644 --- a/tests/ui/traits/new-solver/normalizes_to_ignores_unnormalizable_candidate.self_infer.stderr +++ b/tests/ui/traits/next-solver/normalizes_to_ignores_unnormalizable_candidate.self_infer.stderr diff --git a/tests/ui/traits/new-solver/object-soundness-requires-generalization.rs b/tests/ui/traits/next-solver/object-soundness-requires-generalization.rs index d02dada72c9..6e709d9ae8e 100644 --- a/tests/ui/traits/new-solver/object-soundness-requires-generalization.rs +++ b/tests/ui/traits/next-solver/object-soundness-requires-generalization.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // ignore-test trait Trait { diff --git a/tests/ui/traits/new-solver/object-unsafety.rs b/tests/ui/traits/next-solver/object-unsafety.rs index da843c91478..cfa53948b97 100644 --- a/tests/ui/traits/new-solver/object-unsafety.rs +++ b/tests/ui/traits/next-solver/object-unsafety.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver trait Setup { type From: Copy; @@ -13,11 +13,10 @@ pub fn copy_any<T>(t: &T) -> T { //~^ ERROR the type `&<dyn Setup<From = T> as Setup>::From` is not well-formed //~| ERROR the trait bound `dyn Setup<From = T>: Setup` is not satisfied //~| ERROR mismatched types - //~| ERROR mismatched types //~| ERROR the type `<dyn Setup<From = T> as Setup>::From` is not well-formed //~| ERROR the size for values of type `<dyn Setup<From = T> as Setup>::From` cannot be known at compilation time - // FIXME(-Ztrait-solver=next): These error messages are horrible and some of them + // FIXME(-Znext-solver): These error messages are horrible and some of them // are even simple fallout from previous error. } diff --git a/tests/ui/traits/new-solver/object-unsafety.stderr b/tests/ui/traits/next-solver/object-unsafety.stderr index 914a8f9d4c5..ee38c256e5f 100644 --- a/tests/ui/traits/new-solver/object-unsafety.stderr +++ b/tests/ui/traits/next-solver/object-unsafety.stderr @@ -36,20 +36,6 @@ note: function defined here LL | fn copy<U: Setup + ?Sized>(from: &U::From) -> U::From { | ^^^^ -------------- -error[E0308]: mismatched types - --> $DIR/object-unsafety.rs:12:5 - | -LL | pub fn copy_any<T>(t: &T) -> T { - | - - expected `T` because of return type - | | - | expected this type parameter -LL | copy::<dyn Setup<From=T>>(t) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ - | - = note: expected type parameter `T` - found associated type `<dyn Setup<From = T> as Setup>::From` - = note: you might be missing a type parameter or trait bound - error: the type `<dyn Setup<From = T> as Setup>::From` is not well-formed --> $DIR/object-unsafety.rs:12:5 | @@ -72,7 +58,7 @@ help: consider further restricting the associated type LL | pub fn copy_any<T>(t: &T) -> T where <dyn Setup<From = T> as Setup>::From: Sized { | +++++++++++++++++++++++++++++++++++++++++++++++++ -error: aborting due to 6 previous errors +error: aborting due to 5 previous errors Some errors have detailed explanations: E0277, E0308. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/new-solver/opportunistic-region-resolve.rs b/tests/ui/traits/next-solver/opportunistic-region-resolve.rs index 2610789cd48..d852332d0e5 100644 --- a/tests/ui/traits/new-solver/opportunistic-region-resolve.rs +++ b/tests/ui/traits/next-solver/opportunistic-region-resolve.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass #![feature(rustc_attrs)] diff --git a/tests/ui/traits/new-solver/overflow/exponential-trait-goals.rs b/tests/ui/traits/next-solver/overflow/exponential-trait-goals.rs index 3d2e70a639f..a465bcecfe0 100644 --- a/tests/ui/traits/new-solver/overflow/exponential-trait-goals.rs +++ b/tests/ui/traits/next-solver/overflow/exponential-trait-goals.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver trait Trait {} diff --git a/tests/ui/traits/new-solver/overflow/exponential-trait-goals.stderr b/tests/ui/traits/next-solver/overflow/exponential-trait-goals.stderr index 90b54b1e789..90b54b1e789 100644 --- a/tests/ui/traits/new-solver/overflow/exponential-trait-goals.stderr +++ b/tests/ui/traits/next-solver/overflow/exponential-trait-goals.stderr diff --git a/tests/ui/traits/new-solver/overflow/global-cache.rs b/tests/ui/traits/next-solver/overflow/global-cache.rs index adc03da04a8..fe4032ca62e 100644 --- a/tests/ui/traits/new-solver/overflow/global-cache.rs +++ b/tests/ui/traits/next-solver/overflow/global-cache.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // Check that we consider the reached depth of global cache // entries when detecting overflow. We would otherwise be unstable diff --git a/tests/ui/traits/new-solver/overflow/global-cache.stderr b/tests/ui/traits/next-solver/overflow/global-cache.stderr index 67616619384..67616619384 100644 --- a/tests/ui/traits/new-solver/overflow/global-cache.stderr +++ b/tests/ui/traits/next-solver/overflow/global-cache.stderr diff --git a/tests/ui/traits/next-solver/overflow/recursion-limit-normalizes-to-constraints.rs b/tests/ui/traits/next-solver/overflow/recursion-limit-normalizes-to-constraints.rs new file mode 100644 index 00000000000..03ef93dc233 --- /dev/null +++ b/tests/ui/traits/next-solver/overflow/recursion-limit-normalizes-to-constraints.rs @@ -0,0 +1,25 @@ +// compile-flags: -Znext-solver=coherence +// check-pass + +// A regression test for trait-system-refactor-initiative#70. + +trait Trait { + type Assoc; +} + +struct W<T: ?Sized>(*mut T); +impl<T: ?Sized> Trait for W<W<T>> +where + W<T>: Trait, +{ + type Assoc = (); +} + +trait NoOverlap {} +impl<T: Trait<Assoc = u32>> NoOverlap for T {} +// `Projection(<W<_> as Trait>::Assoc, u32)` should result in error even +// though applying the impl results in overflow. This is necessary to match +// the behavior of the old solver. +impl<T: ?Sized> NoOverlap for W<T> {} + +fn main() {} diff --git a/tests/ui/traits/new-solver/overflow/recursion-limit-zero-issue-115351.rs b/tests/ui/traits/next-solver/overflow/recursion-limit-zero-issue-115351.rs index 539c9614e82..52a17a14281 100644 --- a/tests/ui/traits/new-solver/overflow/recursion-limit-zero-issue-115351.rs +++ b/tests/ui/traits/next-solver/overflow/recursion-limit-zero-issue-115351.rs @@ -2,7 +2,7 @@ //~| ERROR overflow evaluating the requirement `Self: Trait` // This is a non-regression test for issue #115351, where a recursion limit of 0 caused an ICE. -// compile-flags: -Ztrait-solver=next --crate-type=lib +// compile-flags: -Znext-solver --crate-type=lib // check-fail #![recursion_limit = "0"] diff --git a/tests/ui/traits/new-solver/overflow/recursion-limit-zero-issue-115351.stderr b/tests/ui/traits/next-solver/overflow/recursion-limit-zero-issue-115351.stderr index 16b25d90ace..16b25d90ace 100644 --- a/tests/ui/traits/new-solver/overflow/recursion-limit-zero-issue-115351.stderr +++ b/tests/ui/traits/next-solver/overflow/recursion-limit-zero-issue-115351.stderr diff --git a/tests/ui/traits/new-solver/overflow/recursive-self-normalization-2.rs b/tests/ui/traits/next-solver/overflow/recursive-self-normalization-2.rs index d086db475ac..327ef865de9 100644 --- a/tests/ui/traits/new-solver/overflow/recursive-self-normalization-2.rs +++ b/tests/ui/traits/next-solver/overflow/recursive-self-normalization-2.rs @@ -1,5 +1,4 @@ -//~ ERROR overflow -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver trait Foo1 { type Assoc1; @@ -15,6 +14,7 @@ fn needs_bar<S: Bar>() {} fn test<T: Foo1<Assoc1 = <T as Foo2>::Assoc2> + Foo2<Assoc2 = <T as Foo1>::Assoc1>>() { needs_bar::<T::Assoc1>(); //~^ ERROR overflow evaluating the requirement `<T as Foo1>::Assoc1: Bar` + //~| ERROR overflow evaluating the requirement `<T as Foo2>::Assoc2` } fn main() {} diff --git a/tests/ui/traits/new-solver/overflow/recursive-self-normalization-2.stderr b/tests/ui/traits/next-solver/overflow/recursive-self-normalization-2.stderr index 1dc63fae98c..eda62b99c44 100644 --- a/tests/ui/traits/new-solver/overflow/recursive-self-normalization-2.stderr +++ b/tests/ui/traits/next-solver/overflow/recursive-self-normalization-2.stderr @@ -1,17 +1,21 @@ error[E0275]: overflow evaluating the requirement `<T as Foo1>::Assoc1: Bar` - --> $DIR/recursive-self-normalization-2.rs:16:17 + --> $DIR/recursive-self-normalization-2.rs:15:17 | LL | needs_bar::<T::Assoc1>(); | ^^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`recursive_self_normalization_2`) note: required by a bound in `needs_bar` - --> $DIR/recursive-self-normalization-2.rs:13:17 + --> $DIR/recursive-self-normalization-2.rs:12:17 | LL | fn needs_bar<S: Bar>() {} | ^^^ required by this bound in `needs_bar` error[E0275]: overflow evaluating the requirement `<T as Foo2>::Assoc2` + --> $DIR/recursive-self-normalization-2.rs:15:5 + | +LL | needs_bar::<T::Assoc1>(); + | ^^^^^^^^^^^^^^^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`recursive_self_normalization_2`) diff --git a/tests/ui/traits/new-solver/overflow/recursive-self-normalization.rs b/tests/ui/traits/next-solver/overflow/recursive-self-normalization.rs index d15df7dea73..f45d208e666 100644 --- a/tests/ui/traits/new-solver/overflow/recursive-self-normalization.rs +++ b/tests/ui/traits/next-solver/overflow/recursive-self-normalization.rs @@ -1,5 +1,4 @@ -//~ ERROR overflow evaluating the requirement `<T as Foo>::Assoc` [E0275] -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver trait Foo { type Assoc; @@ -11,6 +10,7 @@ fn needs_bar<S: Bar>() {} fn test<T: Foo<Assoc = <T as Foo>::Assoc>>() { needs_bar::<T::Assoc>(); //~^ ERROR overflow evaluating the requirement `<T as Foo>::Assoc: Bar` + //~| ERROR overflow evaluating the requirement `<T as Foo>::Assoc` [E0275] } fn main() {} diff --git a/tests/ui/traits/new-solver/overflow/recursive-self-normalization.stderr b/tests/ui/traits/next-solver/overflow/recursive-self-normalization.stderr index afc5bfa54ac..b0a0a69761a 100644 --- a/tests/ui/traits/new-solver/overflow/recursive-self-normalization.stderr +++ b/tests/ui/traits/next-solver/overflow/recursive-self-normalization.stderr @@ -1,17 +1,21 @@ error[E0275]: overflow evaluating the requirement `<T as Foo>::Assoc: Bar` - --> $DIR/recursive-self-normalization.rs:12:17 + --> $DIR/recursive-self-normalization.rs:11:17 | LL | needs_bar::<T::Assoc>(); | ^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`recursive_self_normalization`) note: required by a bound in `needs_bar` - --> $DIR/recursive-self-normalization.rs:9:17 + --> $DIR/recursive-self-normalization.rs:8:17 | LL | fn needs_bar<S: Bar>() {} | ^^^ required by this bound in `needs_bar` error[E0275]: overflow evaluating the requirement `<T as Foo>::Assoc` + --> $DIR/recursive-self-normalization.rs:11:5 + | +LL | needs_bar::<T::Assoc>(); + | ^^^^^^^^^^^^^^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`recursive_self_normalization`) diff --git a/tests/ui/traits/new-solver/param-candidate-doesnt-shadow-project.rs b/tests/ui/traits/next-solver/param-candidate-doesnt-shadow-project.rs index bdf999ec5dd..f67b073c53c 100644 --- a/tests/ui/traits/new-solver/param-candidate-doesnt-shadow-project.rs +++ b/tests/ui/traits/next-solver/param-candidate-doesnt-shadow-project.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass trait Foo { diff --git a/tests/ui/traits/new-solver/param-discr-kind.rs b/tests/ui/traits/next-solver/param-discr-kind.rs index e319ddea106..c66b0b9f45f 100644 --- a/tests/ui/traits/new-solver/param-discr-kind.rs +++ b/tests/ui/traits/next-solver/param-discr-kind.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass fn foo<T>(x: T) { diff --git a/tests/ui/traits/new-solver/pointee.rs b/tests/ui/traits/next-solver/pointee.rs index 93c0542ace4..a56df549a8d 100644 --- a/tests/ui/traits/new-solver/pointee.rs +++ b/tests/ui/traits/next-solver/pointee.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass #![feature(ptr_metadata)] diff --git a/tests/ui/traits/new-solver/pointer-like.rs b/tests/ui/traits/next-solver/pointer-like.rs index 98630176976..f6cc718c6e2 100644 --- a/tests/ui/traits/new-solver/pointer-like.rs +++ b/tests/ui/traits/next-solver/pointer-like.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver #![feature(pointer_like_trait)] diff --git a/tests/ui/traits/new-solver/pointer-like.stderr b/tests/ui/traits/next-solver/pointer-like.stderr index 4b624fd0d35..4b624fd0d35 100644 --- a/tests/ui/traits/new-solver/pointer-like.stderr +++ b/tests/ui/traits/next-solver/pointer-like.stderr diff --git a/tests/ui/traits/new-solver/prefer-candidate-no-constraints.rs b/tests/ui/traits/next-solver/prefer-candidate-no-constraints.rs index 6f8164f3a40..a47f819f192 100644 --- a/tests/ui/traits/new-solver/prefer-candidate-no-constraints.rs +++ b/tests/ui/traits/next-solver/prefer-candidate-no-constraints.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass trait Foo {} diff --git a/tests/ui/traits/new-solver/prefer-param-env-on-ambiguity.rs b/tests/ui/traits/next-solver/prefer-param-env-on-ambiguity.rs index 909b33ec3d5..f8c0223e187 100644 --- a/tests/ui/traits/new-solver/prefer-param-env-on-ambiguity.rs +++ b/tests/ui/traits/next-solver/prefer-param-env-on-ambiguity.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass trait Foo<'a> {} diff --git a/tests/ui/traits/new-solver/projection-discr-kind.rs b/tests/ui/traits/next-solver/projection-discr-kind.rs index 20296b287b1..bf557f8633a 100644 --- a/tests/ui/traits/new-solver/projection-discr-kind.rs +++ b/tests/ui/traits/next-solver/projection-discr-kind.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // Check that `<T::Assoc as DiscriminantKind>::Discriminant` doesn't normalize // to itself and cause overflow/ambiguity. diff --git a/tests/ui/traits/new-solver/projection-discr-kind.stderr b/tests/ui/traits/next-solver/projection-discr-kind.stderr index 69999c75522..69999c75522 100644 --- a/tests/ui/traits/new-solver/projection-discr-kind.stderr +++ b/tests/ui/traits/next-solver/projection-discr-kind.stderr diff --git a/tests/ui/traits/new-solver/projection/param-env-trait-candidate-1.rs b/tests/ui/traits/next-solver/projection/param-env-trait-candidate-1.rs index e36d574efe2..b337c067374 100644 --- a/tests/ui/traits/new-solver/projection/param-env-trait-candidate-1.rs +++ b/tests/ui/traits/next-solver/projection/param-env-trait-candidate-1.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // See https://github.com/rust-lang/trait-system-refactor-initiative/issues/1 // a minimization of a pattern in core. diff --git a/tests/ui/traits/new-solver/projection/param-env-trait-candidate-2.rs b/tests/ui/traits/next-solver/projection/param-env-trait-candidate-2.rs index c8050997a1d..db8dc1eb9be 100644 --- a/tests/ui/traits/new-solver/projection/param-env-trait-candidate-2.rs +++ b/tests/ui/traits/next-solver/projection/param-env-trait-candidate-2.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // See https://github.com/rust-lang/trait-system-refactor-initiative/issues/1, // a minimization of a pattern in core. diff --git a/tests/ui/traits/new-solver/slice-match-byte-lit.rs b/tests/ui/traits/next-solver/slice-match-byte-lit.rs index 4f848062595..1edc9f1e8e9 100644 --- a/tests/ui/traits/new-solver/slice-match-byte-lit.rs +++ b/tests/ui/traits/next-solver/slice-match-byte-lit.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass fn test(s: &[u8]) { diff --git a/tests/ui/traits/new-solver/specialization-transmute.rs b/tests/ui/traits/next-solver/specialization-transmute.rs index fac7d76f8cf..58b62f52dfd 100644 --- a/tests/ui/traits/new-solver/specialization-transmute.rs +++ b/tests/ui/traits/next-solver/specialization-transmute.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver #![feature(specialization)] //~^ WARN the feature `specialization` is incomplete diff --git a/tests/ui/traits/new-solver/specialization-transmute.stderr b/tests/ui/traits/next-solver/specialization-transmute.stderr index eaf32a475ac..eaf32a475ac 100644 --- a/tests/ui/traits/new-solver/specialization-transmute.stderr +++ b/tests/ui/traits/next-solver/specialization-transmute.stderr diff --git a/tests/ui/traits/new-solver/specialization-unconstrained.rs b/tests/ui/traits/next-solver/specialization-unconstrained.rs index 7fd753109be..950fb1512bc 100644 --- a/tests/ui/traits/new-solver/specialization-unconstrained.rs +++ b/tests/ui/traits/next-solver/specialization-unconstrained.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver #![feature(specialization)] //~^ WARN the feature `specialization` is incomplete diff --git a/tests/ui/traits/new-solver/specialization-unconstrained.stderr b/tests/ui/traits/next-solver/specialization-unconstrained.stderr index ed4dafa1484..ed4dafa1484 100644 --- a/tests/ui/traits/new-solver/specialization-unconstrained.stderr +++ b/tests/ui/traits/next-solver/specialization-unconstrained.stderr diff --git a/tests/ui/traits/new-solver/stall-num-var-auto-trait.fallback.stderr b/tests/ui/traits/next-solver/stall-num-var-auto-trait.fallback.stderr index 2e3c22c8d38..2e3c22c8d38 100644 --- a/tests/ui/traits/new-solver/stall-num-var-auto-trait.fallback.stderr +++ b/tests/ui/traits/next-solver/stall-num-var-auto-trait.fallback.stderr diff --git a/tests/ui/traits/new-solver/stall-num-var-auto-trait.rs b/tests/ui/traits/next-solver/stall-num-var-auto-trait.rs index 0539c3a4292..f5bf985cdb2 100644 --- a/tests/ui/traits/new-solver/stall-num-var-auto-trait.rs +++ b/tests/ui/traits/next-solver/stall-num-var-auto-trait.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // revisions: fallback constrain //[constrain] check-pass diff --git a/tests/ui/traits/new-solver/structural-resolve-field.rs b/tests/ui/traits/next-solver/structural-resolve-field.rs index 01899c9ad64..b247e237534 100644 --- a/tests/ui/traits/new-solver/structural-resolve-field.rs +++ b/tests/ui/traits/next-solver/structural-resolve-field.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass #[derive(Default)] diff --git a/tests/ui/traits/new-solver/tait-eq-proj-2.rs b/tests/ui/traits/next-solver/tait-eq-proj-2.rs index 77ea8bc246e..a3df053dd83 100644 --- a/tests/ui/traits/new-solver/tait-eq-proj-2.rs +++ b/tests/ui/traits/next-solver/tait-eq-proj-2.rs @@ -1,9 +1,9 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass #![feature(type_alias_impl_trait)] -// Similar to tests/ui/traits/new-solver/tait-eq-proj.rs +// Similar to tests/ui/traits/next-solver/tait-eq-proj.rs // but check the alias-sub relation in the other direction. type Tait = impl Iterator<Item = impl Sized>; diff --git a/tests/ui/traits/new-solver/tait-eq-proj.rs b/tests/ui/traits/next-solver/tait-eq-proj.rs index 01ef2ec953a..871e8e1e9fc 100644 --- a/tests/ui/traits/new-solver/tait-eq-proj.rs +++ b/tests/ui/traits/next-solver/tait-eq-proj.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass #![feature(type_alias_impl_trait)] diff --git a/tests/ui/traits/new-solver/tait-eq-tait.rs b/tests/ui/traits/next-solver/tait-eq-tait.rs index 70d9dc0eaa8..2629a124c3a 100644 --- a/tests/ui/traits/new-solver/tait-eq-tait.rs +++ b/tests/ui/traits/next-solver/tait-eq-tait.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass // Not exactly sure if this is the inference behavior we *want*, diff --git a/tests/ui/traits/new-solver/temporary-ambiguity.rs b/tests/ui/traits/next-solver/temporary-ambiguity.rs index c6c11a1a1de..6102de7e446 100644 --- a/tests/ui/traits/new-solver/temporary-ambiguity.rs +++ b/tests/ui/traits/next-solver/temporary-ambiguity.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass // Checks that we don't explode when we assemble >1 candidate for a goal. diff --git a/tests/ui/traits/new-solver/trait-upcast-lhs-needs-normalization.rs b/tests/ui/traits/next-solver/trait-upcast-lhs-needs-normalization.rs index 79114b93b78..2a482f74668 100644 --- a/tests/ui/traits/new-solver/trait-upcast-lhs-needs-normalization.rs +++ b/tests/ui/traits/next-solver/trait-upcast-lhs-needs-normalization.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver pub trait A {} pub trait B: A {} diff --git a/tests/ui/traits/new-solver/try-example.rs b/tests/ui/traits/next-solver/try-example.rs index e826f3a0059..92b0b597881 100644 --- a/tests/ui/traits/new-solver/try-example.rs +++ b/tests/ui/traits/next-solver/try-example.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver use std::error::Error; diff --git a/tests/ui/traits/new-solver/two-projection-param-candidates-are-ambiguous.rs b/tests/ui/traits/next-solver/two-projection-param-candidates-are-ambiguous.rs index 3c7fc0d813d..d25e372b5d8 100644 --- a/tests/ui/traits/new-solver/two-projection-param-candidates-are-ambiguous.rs +++ b/tests/ui/traits/next-solver/two-projection-param-candidates-are-ambiguous.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // When we're solving `<T as Foo>::Assoc = i32`, we actually first solve // `<T as Foo>::Assoc = ?1t`, then unify `?1t` with `i32`. That goal diff --git a/tests/ui/traits/new-solver/two-projection-param-candidates-are-ambiguous.stderr b/tests/ui/traits/next-solver/two-projection-param-candidates-are-ambiguous.stderr index dfff9f11b87..dfff9f11b87 100644 --- a/tests/ui/traits/new-solver/two-projection-param-candidates-are-ambiguous.stderr +++ b/tests/ui/traits/next-solver/two-projection-param-candidates-are-ambiguous.stderr diff --git a/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.fails.stderr b/tests/ui/traits/next-solver/unevaluated-const-impl-trait-ref.fails.stderr index 4be90c702a0..4be90c702a0 100644 --- a/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.fails.stderr +++ b/tests/ui/traits/next-solver/unevaluated-const-impl-trait-ref.fails.stderr diff --git a/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.rs b/tests/ui/traits/next-solver/unevaluated-const-impl-trait-ref.rs index 26c595bc974..77a169d48de 100644 --- a/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.rs +++ b/tests/ui/traits/next-solver/unevaluated-const-impl-trait-ref.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // revisions: works fails //[works] check-pass diff --git a/tests/ui/traits/new-solver/unsafe-auto-trait-impl.rs b/tests/ui/traits/next-solver/unsafe-auto-trait-impl.rs index bcfc747ebb1..f66bf0b87ec 100644 --- a/tests/ui/traits/new-solver/unsafe-auto-trait-impl.rs +++ b/tests/ui/traits/next-solver/unsafe-auto-trait-impl.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass struct Foo(*mut ()); diff --git a/tests/ui/traits/new-solver/unsize-although-ambiguous.rs b/tests/ui/traits/next-solver/unsize-although-ambiguous.rs index 431988a5fff..8217701b9f8 100644 --- a/tests/ui/traits/new-solver/unsize-although-ambiguous.rs +++ b/tests/ui/traits/next-solver/unsize-although-ambiguous.rs @@ -1,5 +1,5 @@ // check-pass -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver use std::fmt::Display; diff --git a/tests/ui/traits/new-solver/unsize-good.rs b/tests/ui/traits/next-solver/unsize-good.rs index 87ed9cfd10a..04ebe66f21c 100644 --- a/tests/ui/traits/new-solver/unsize-good.rs +++ b/tests/ui/traits/next-solver/unsize-good.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass #![feature(unsized_tuple_coercion)] diff --git a/tests/ui/traits/new-solver/upcast-right-substs.rs b/tests/ui/traits/next-solver/upcast-right-substs.rs index 97eb189d5c7..5e4d958c895 100644 --- a/tests/ui/traits/new-solver/upcast-right-substs.rs +++ b/tests/ui/traits/next-solver/upcast-right-substs.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // check-pass trait Foo: Bar<i32> + Bar<u32> {} diff --git a/tests/ui/traits/new-solver/upcast-wrong-substs.rs b/tests/ui/traits/next-solver/upcast-wrong-substs.rs index 3376f9787d3..0cd253007fc 100644 --- a/tests/ui/traits/new-solver/upcast-wrong-substs.rs +++ b/tests/ui/traits/next-solver/upcast-wrong-substs.rs @@ -1,4 +1,4 @@ -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver trait Foo: Bar<i32> + Bar<u32> {} diff --git a/tests/ui/traits/new-solver/upcast-wrong-substs.stderr b/tests/ui/traits/next-solver/upcast-wrong-substs.stderr index 00ba1ef678f..00ba1ef678f 100644 --- a/tests/ui/traits/new-solver/upcast-wrong-substs.stderr +++ b/tests/ui/traits/next-solver/upcast-wrong-substs.stderr diff --git a/tests/ui/traits/new-solver/winnow-specializing-impls.rs b/tests/ui/traits/next-solver/winnow-specializing-impls.rs index 06f64de7403..d70a9159611 100644 --- a/tests/ui/traits/new-solver/winnow-specializing-impls.rs +++ b/tests/ui/traits/next-solver/winnow-specializing-impls.rs @@ -1,5 +1,5 @@ // build-pass -// compile-flags: -Ztrait-solver=next +// compile-flags: -Znext-solver // Tests that the specializing impl `<() as Foo>` holds during codegen. diff --git a/tests/ui/traits/non-lifetime-via-dyn-builtin.rs b/tests/ui/traits/non-lifetime-via-dyn-builtin.rs index 9a8a5ced2e2..996cd295dc4 100644 --- a/tests/ui/traits/non-lifetime-via-dyn-builtin.rs +++ b/tests/ui/traits/non-lifetime-via-dyn-builtin.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver // check-pass #![feature(non_lifetime_binders)] diff --git a/tests/ui/traits/non_lifetime_binders/bounds-on-type-binders.rs b/tests/ui/traits/non_lifetime_binders/bounds-on-type-binders.rs new file mode 100644 index 00000000000..2535eb99c59 --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/bounds-on-type-binders.rs @@ -0,0 +1,14 @@ +// check-fail + +#![allow(incomplete_features)] +#![feature(non_lifetime_binders)] + +trait Trait {} + +trait Trait2 +where + for<T: Trait> ():, +{ //~^ ERROR bounds cannot be used in this context +} + +fn main() {} diff --git a/tests/ui/traits/non_lifetime_binders/bounds-on-type-binders.stderr b/tests/ui/traits/non_lifetime_binders/bounds-on-type-binders.stderr new file mode 100644 index 00000000000..0a2f4cea614 --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/bounds-on-type-binders.stderr @@ -0,0 +1,8 @@ +error: bounds cannot be used in this context + --> $DIR/bounds-on-type-binders.rs:10:12 + | +LL | for<T: Trait> ():, + | ^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/traits/non_lifetime_binders/issue-118697.rs b/tests/ui/traits/non_lifetime_binders/issue-118697.rs new file mode 100644 index 00000000000..a282d0c5a40 --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/issue-118697.rs @@ -0,0 +1,9 @@ +#![allow(incomplete_features)] +#![feature(non_lifetime_binders)] + +type T = dyn for<V = A(&())> Fn(()); +//~^ ERROR default parameter is not allowed in this binder +//~| ERROR cannot find type `A` in this scope +//~| ERROR late-bound type parameter not allowed on trait object types + +fn main() {} diff --git a/tests/ui/traits/non_lifetime_binders/issue-118697.stderr b/tests/ui/traits/non_lifetime_binders/issue-118697.stderr new file mode 100644 index 00000000000..52ce568d69d --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/issue-118697.stderr @@ -0,0 +1,21 @@ +error[E0412]: cannot find type `A` in this scope + --> $DIR/issue-118697.rs:4:22 + | +LL | type T = dyn for<V = A(&())> Fn(()); + | ^ not found in this scope + +error: default parameter is not allowed in this binder + --> $DIR/issue-118697.rs:4:22 + | +LL | type T = dyn for<V = A(&())> Fn(()); + | ^^^^^^ + +error: late-bound type parameter not allowed on trait object types + --> $DIR/issue-118697.rs:4:18 + | +LL | type T = dyn for<V = A(&())> Fn(()); + | ^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/traits/reservation-impl/coherence-conflict.rs b/tests/ui/traits/reservation-impl/coherence-conflict.rs index 6bbd90f94dc..cdea162d64a 100644 --- a/tests/ui/traits/reservation-impl/coherence-conflict.rs +++ b/tests/ui/traits/reservation-impl/coherence-conflict.rs @@ -1,6 +1,6 @@ // check that reservation impls are accounted for in negative reasoning. // revisions: old next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver #![feature(rustc_attrs)] trait MyTrait {} diff --git a/tests/ui/traits/reservation-impl/no-use.rs b/tests/ui/traits/reservation-impl/no-use.rs index 864f1791fd0..10aad3605ea 100644 --- a/tests/ui/traits/reservation-impl/no-use.rs +++ b/tests/ui/traits/reservation-impl/no-use.rs @@ -1,6 +1,6 @@ // check that reservation impls can't be used as normal impls in positive reasoning. // revisions: old next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver #![feature(rustc_attrs)] trait MyTrait { fn foo(&self); } diff --git a/tests/ui/traits/reservation-impl/non-lattice-ok.rs b/tests/ui/traits/reservation-impl/non-lattice-ok.rs index 7787904d9b2..9a3c2b4f991 100644 --- a/tests/ui/traits/reservation-impl/non-lattice-ok.rs +++ b/tests/ui/traits/reservation-impl/non-lattice-ok.rs @@ -34,7 +34,7 @@ // check that reservation impls can't be used as normal impls in positive reasoning. // revisions: old next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver #![feature(rustc_attrs, never_type)] diff --git a/tests/ui/traits/reservation-impl/ok.rs b/tests/ui/traits/reservation-impl/ok.rs index 8ff6645a2b3..2d945f6adeb 100644 --- a/tests/ui/traits/reservation-impl/ok.rs +++ b/tests/ui/traits/reservation-impl/ok.rs @@ -4,7 +4,7 @@ // but still. // revisions: old next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver #![feature(rustc_attrs)] diff --git a/tests/ui/traits/trait-upcasting/fewer-associated.rs b/tests/ui/traits/trait-upcasting/fewer-associated.rs index 937818aac58..e7ca6fa5208 100644 --- a/tests/ui/traits/trait-upcasting/fewer-associated.rs +++ b/tests/ui/traits/trait-upcasting/fewer-associated.rs @@ -1,7 +1,7 @@ // check-pass // issue: 114035 // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver trait A: B { type Assoc; diff --git a/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.rs b/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.rs index 4b730dab7cc..5a493fd48b3 100644 --- a/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.rs +++ b/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver trait Super { type Assoc; diff --git a/tests/ui/traits/trait-upcasting/issue-11515.rs b/tests/ui/traits/trait-upcasting/issue-11515.rs index 66ab1ce260a..a1edb53ec37 100644 --- a/tests/ui/traits/trait-upcasting/issue-11515.rs +++ b/tests/ui/traits/trait-upcasting/issue-11515.rs @@ -1,6 +1,6 @@ // check-pass // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver struct Test { func: Box<dyn FnMut() + 'static>, diff --git a/tests/ui/traits/trait-upcasting/normalization.rs b/tests/ui/traits/trait-upcasting/normalization.rs index c57640e7e34..b594969483a 100644 --- a/tests/ui/traits/trait-upcasting/normalization.rs +++ b/tests/ui/traits/trait-upcasting/normalization.rs @@ -1,7 +1,7 @@ // check-pass // issue: 114113 // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver trait Mirror { type Assoc; diff --git a/tests/ui/traits/trait-upcasting/type-checking-test-1.rs b/tests/ui/traits/trait-upcasting/type-checking-test-1.rs index 3b6ec3b65e7..7d3deeeaa61 100644 --- a/tests/ui/traits/trait-upcasting/type-checking-test-1.rs +++ b/tests/ui/traits/trait-upcasting/type-checking-test-1.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver trait Foo: Bar<i32> + Bar<u32> {} trait Bar<T> { diff --git a/tests/ui/traits/trait-upcasting/upcast-through-struct-tail.rs b/tests/ui/traits/trait-upcasting/upcast-through-struct-tail.rs index 9981d436062..f8cf793e4a4 100644 --- a/tests/ui/traits/trait-upcasting/upcast-through-struct-tail.rs +++ b/tests/ui/traits/trait-upcasting/upcast-through-struct-tail.rs @@ -1,6 +1,6 @@ // check-pass // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver struct Wrapper<T: ?Sized>(T); diff --git a/tests/ui/transmutability/primitives/bool-mut.rs b/tests/ui/transmutability/primitives/bool-mut.rs index 49dbe90e4b8..6ee168d1a71 100644 --- a/tests/ui/transmutability/primitives/bool-mut.rs +++ b/tests/ui/transmutability/primitives/bool-mut.rs @@ -1,5 +1,5 @@ // check-fail -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver #![feature(transmutability)] mod assert { diff --git a/tests/ui/transmutability/primitives/bool.rs b/tests/ui/transmutability/primitives/bool.rs index 654e7b47ede..ac4024b7f33 100644 --- a/tests/ui/transmutability/primitives/bool.rs +++ b/tests/ui/transmutability/primitives/bool.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver #![feature(transmutability)] mod assert { diff --git a/tests/ui/transmutability/primitives/numbers.rs b/tests/ui/transmutability/primitives/numbers.rs index e980e91ed06..1afc7d677ee 100644 --- a/tests/ui/transmutability/primitives/numbers.rs +++ b/tests/ui/transmutability/primitives/numbers.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver #![crate_type = "lib"] #![feature(transmutability)] diff --git a/tests/ui/transmutability/primitives/unit.rs b/tests/ui/transmutability/primitives/unit.rs index 12eac175106..5ea96cf8ba7 100644 --- a/tests/ui/transmutability/primitives/unit.rs +++ b/tests/ui/transmutability/primitives/unit.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver //! The unit type, `()`, should be one byte. diff --git a/tests/ui/type-alias-impl-trait/assoc-type-const.rs b/tests/ui/type-alias-impl-trait/assoc-type-const.rs index 6632a3450e5..e385fe045fc 100644 --- a/tests/ui/type-alias-impl-trait/assoc-type-const.rs +++ b/tests/ui/type-alias-impl-trait/assoc-type-const.rs @@ -3,7 +3,7 @@ // check-pass // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver #![feature(impl_trait_in_assoc_type)] trait UnwrapItemsExt<'a, const C: usize> { diff --git a/tests/ui/type-alias-impl-trait/cross_inference.rs b/tests/ui/type-alias-impl-trait/cross_inference.rs index 5eaf0ddda99..c5ef75fee61 100644 --- a/tests/ui/type-alias-impl-trait/cross_inference.rs +++ b/tests/ui/type-alias-impl-trait/cross_inference.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver // check-pass #![feature(type_alias_impl_trait)] diff --git a/tests/ui/type-alias-impl-trait/issue-76202-trait-impl-for-tait.rs b/tests/ui/type-alias-impl-trait/issue-76202-trait-impl-for-tait.rs index 386b77d4d16..af1c18bbb59 100644 --- a/tests/ui/type-alias-impl-trait/issue-76202-trait-impl-for-tait.rs +++ b/tests/ui/type-alias-impl-trait/issue-76202-trait-impl-for-tait.rs @@ -2,7 +2,7 @@ // Tests that we don't ICE when we have a trait impl on a TAIT. // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver // check-pass #![feature(type_alias_impl_trait)] diff --git a/tests/ui/type-alias-impl-trait/issue-78450.rs b/tests/ui/type-alias-impl-trait/issue-78450.rs index 236e9f4e88c..c51dfb6782b 100644 --- a/tests/ui/type-alias-impl-trait/issue-78450.rs +++ b/tests/ui/type-alias-impl-trait/issue-78450.rs @@ -1,6 +1,6 @@ // check-pass // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver #![feature(impl_trait_in_assoc_type)] diff --git a/tests/ui/type-alias-impl-trait/normalize-hidden-types.rs b/tests/ui/type-alias-impl-trait/normalize-hidden-types.rs index 8d80546444a..371cac6da7c 100644 --- a/tests/ui/type-alias-impl-trait/normalize-hidden-types.rs +++ b/tests/ui/type-alias-impl-trait/normalize-hidden-types.rs @@ -1,7 +1,7 @@ // Regression test for #112691 // // revisions: current next -// [next] compile-flags: -Ztrait-solver=next +// [next] compile-flags: -Znext-solver // [next] check-pass // [current]: known-bug: #112691 diff --git a/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.rs b/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.rs index 0f0002f7797..222841f3467 100644 --- a/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.rs +++ b/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.rs @@ -6,7 +6,7 @@ //! have a situation where the RPIT gets constrained outside its anchor. // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver //[next] check-pass //[current] known-bug: #108498 diff --git a/tests/ui/type-alias-impl-trait/self-referential-3.rs b/tests/ui/type-alias-impl-trait/self-referential-3.rs index 18f09b54867..922ac662071 100644 --- a/tests/ui/type-alias-impl-trait/self-referential-3.rs +++ b/tests/ui/type-alias-impl-trait/self-referential-3.rs @@ -1,3 +1,5 @@ +// ignore-compare-mode-next-solver (hangs) + #![feature(type_alias_impl_trait)] type Bar<'a, 'b> = impl PartialEq<Bar<'a, 'b>> + std::fmt::Debug; diff --git a/tests/ui/type-alias-impl-trait/self-referential-3.stderr b/tests/ui/type-alias-impl-trait/self-referential-3.stderr index 15ebcdafca6..32eac622e51 100644 --- a/tests/ui/type-alias-impl-trait/self-referential-3.stderr +++ b/tests/ui/type-alias-impl-trait/self-referential-3.stderr @@ -1,5 +1,5 @@ error[E0277]: can't compare `&i32` with `Bar<'a, 'b>` - --> $DIR/self-referential-3.rs:5:31 + --> $DIR/self-referential-3.rs:7:31 | LL | fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { | ^^^^^^^^^^^ no implementation for `&i32 == Bar<'a, 'b>` diff --git a/tests/ui/type-alias-impl-trait/self-referential-4.rs b/tests/ui/type-alias-impl-trait/self-referential-4.rs index 36742c8ad57..caa9e33bad0 100644 --- a/tests/ui/type-alias-impl-trait/self-referential-4.rs +++ b/tests/ui/type-alias-impl-trait/self-referential-4.rs @@ -1,3 +1,5 @@ +// ignore-compare-mode-next-solver (hangs) + #![feature(type_alias_impl_trait)] type Bar<'a, 'b> = impl PartialEq<Bar<'b, 'static>> + std::fmt::Debug; diff --git a/tests/ui/type-alias-impl-trait/self-referential-4.stderr b/tests/ui/type-alias-impl-trait/self-referential-4.stderr index 98c762e3d38..e7f9e232a27 100644 --- a/tests/ui/type-alias-impl-trait/self-referential-4.stderr +++ b/tests/ui/type-alias-impl-trait/self-referential-4.stderr @@ -1,5 +1,5 @@ error[E0277]: can't compare `&i32` with `Bar<'b, 'static>` - --> $DIR/self-referential-4.rs:5:31 + --> $DIR/self-referential-4.rs:7:31 | LL | fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { | ^^^^^^^^^^^ no implementation for `&i32 == Bar<'b, 'static>` @@ -10,7 +10,7 @@ LL | i = help: the trait `PartialEq` is implemented for `i32` error[E0277]: can't compare `&i32` with `Foo<'static, 'b>` - --> $DIR/self-referential-4.rs:11:31 + --> $DIR/self-referential-4.rs:13:31 | LL | fn foo<'a, 'b>(i: &'a i32) -> Foo<'a, 'b> { | ^^^^^^^^^^^ no implementation for `&i32 == Foo<'static, 'b>` @@ -21,7 +21,7 @@ LL | i = help: the trait `PartialEq` is implemented for `i32` error[E0277]: can't compare `&i32` with `Moo<'static, 'a>` - --> $DIR/self-referential-4.rs:17:31 + --> $DIR/self-referential-4.rs:19:31 | LL | fn moo<'a, 'b>(i: &'a i32) -> Moo<'a, 'b> { | ^^^^^^^^^^^ no implementation for `&i32 == Moo<'static, 'a>` diff --git a/tests/ui/type-alias-impl-trait/self-referential.rs b/tests/ui/type-alias-impl-trait/self-referential.rs index 34b7c24df9f..0900d7279ca 100644 --- a/tests/ui/type-alias-impl-trait/self-referential.rs +++ b/tests/ui/type-alias-impl-trait/self-referential.rs @@ -1,3 +1,5 @@ +// ignore-compare-mode-next-solver (hangs) + #![feature(type_alias_impl_trait)] type Bar<'a, 'b> = impl PartialEq<Bar<'b, 'a>> + std::fmt::Debug; diff --git a/tests/ui/type-alias-impl-trait/self-referential.stderr b/tests/ui/type-alias-impl-trait/self-referential.stderr index 9a17d495b62..27506b8d06f 100644 --- a/tests/ui/type-alias-impl-trait/self-referential.stderr +++ b/tests/ui/type-alias-impl-trait/self-referential.stderr @@ -1,5 +1,5 @@ error[E0277]: can't compare `&i32` with `Bar<'b, 'a>` - --> $DIR/self-referential.rs:5:31 + --> $DIR/self-referential.rs:7:31 | LL | fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { | ^^^^^^^^^^^ no implementation for `&i32 == Bar<'b, 'a>` @@ -11,7 +11,7 @@ LL | i = help: the trait `PartialEq` is implemented for `i32` error[E0277]: can't compare `&i32` with `(i32, Foo<'a, 'b>::{opaque#0})` - --> $DIR/self-referential.rs:12:31 + --> $DIR/self-referential.rs:14:31 | LL | fn foo<'a, 'b>(i: &'a i32) -> Foo<'a, 'b> { | ^^^^^^^^^^^ no implementation for `&i32 == (i32, Foo<'a, 'b>::{opaque#0})` @@ -23,7 +23,7 @@ LL | (42, i) = help: the trait `PartialEq` is implemented for `i32` error[E0277]: can't compare `&i32` with `(i32, Moo<'b, 'a>::{opaque#0})` - --> $DIR/self-referential.rs:19:31 + --> $DIR/self-referential.rs:21:31 | LL | fn moo<'a, 'b>(i: &'a i32) -> Moo<'a, 'b> { | ^^^^^^^^^^^ no implementation for `&i32 == (i32, Moo<'b, 'a>::{opaque#0})` diff --git a/tests/ui/type-alias-impl-trait/wf-in-associated-type.rs b/tests/ui/type-alias-impl-trait/wf-in-associated-type.rs index b966ca4bff0..22e2b0efd1f 100644 --- a/tests/ui/type-alias-impl-trait/wf-in-associated-type.rs +++ b/tests/ui/type-alias-impl-trait/wf-in-associated-type.rs @@ -2,7 +2,7 @@ // // revisions: pass pass_next fail // [pass] check-pass -// [pass_next] compile-flags: -Ztrait-solver=next +// [pass_next] compile-flags: -Znext-solver // [pass_next] check-pass // [fail] check-fail diff --git a/tests/ui/type/issue-94187-verbose-type-name.rs b/tests/ui/type/issue-94187-verbose-type-name.rs index 3713a32eb11..7c765d6d810 100644 --- a/tests/ui/type/issue-94187-verbose-type-name.rs +++ b/tests/ui/type/issue-94187-verbose-type-name.rs @@ -1,8 +1,8 @@ -// Check to insure that the output of `std::any::type_name` does not change based on `-Zverbose` +// Ensure the output of `std::any::type_name` does not change based on `-Zverbose-internals` // run-pass // edition: 2018 // revisions: normal verbose -// [verbose]compile-flags:-Zverbose +// [verbose]compile-flags:-Zverbose-internals --verbose use std::any::type_name; diff --git a/tests/ui/type/type-check/assignment-expected-bool.rs b/tests/ui/type/type-check/assignment-expected-bool.rs index 191939bdb70..fe8af64b43d 100644 --- a/tests/ui/type/type-check/assignment-expected-bool.rs +++ b/tests/ui/type/type-check/assignment-expected-bool.rs @@ -31,4 +31,9 @@ fn main() { let _: usize = 0 = 0; //~^ ERROR mismatched types [E0308] //~| ERROR invalid left-hand side of assignment [E0070] + + let foo = &String::new(); + let bar = ""; + if foo = bar {} + //~^ ERROR mismatched types [E0308] } diff --git a/tests/ui/type/type-check/assignment-expected-bool.stderr b/tests/ui/type/type-check/assignment-expected-bool.stderr index 56494baff6b..6c44e389a21 100644 --- a/tests/ui/type/type-check/assignment-expected-bool.stderr +++ b/tests/ui/type/type-check/assignment-expected-bool.stderr @@ -135,7 +135,18 @@ LL | let _: usize = 0 = 0; | | | expected due to this -error: aborting due to 13 previous errors +error[E0308]: mismatched types + --> $DIR/assignment-expected-bool.rs:37:8 + | +LL | if foo = bar {} + | ^^^^^^^^^ expected `bool`, found `()` + | +help: you might have meant to compare for equality + | +LL | if foo == bar {} + | + + +error: aborting due to 14 previous errors Some errors have detailed explanations: E0070, E0308. For more information about an error, try `rustc --explain E0070`. diff --git a/tests/ui/type/verbose.normal.stderr b/tests/ui/type/verbose.normal.stderr new file mode 100644 index 00000000000..6cb26403336 --- /dev/null +++ b/tests/ui/type/verbose.normal.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/verbose.rs:7:28 + | +LL | let _: Foo<u32, i32> = Foo::<i32, i32> { x: 0, y: 0 }; + | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Foo<u32, i32>`, found `Foo<i32, i32>` + | | + | expected due to this + | + = note: expected struct `Foo<u32, _>` + found struct `Foo<i32, _>` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/type/verbose.rs b/tests/ui/type/verbose.rs new file mode 100644 index 00000000000..4ebd5cdccfc --- /dev/null +++ b/tests/ui/type/verbose.rs @@ -0,0 +1,13 @@ +// revisions:verbose normal +// [verbose]compile-flags:--verbose +#![crate_type = "lib"] + +struct Foo<T, U> { x: T, y: U } +fn bar() { + let _: Foo<u32, i32> = Foo::<i32, i32> { x: 0, y: 0 }; + //~^ ERROR mismatched types + //[verbose]~| NOTE expected struct `Foo<u32, i32>` + //[normal]~| NOTE expected struct `Foo<u32, _>` + //~| NOTE expected `Foo<u32, i32>` + //~| NOTE expected due to this +} diff --git a/tests/ui/type/verbose.verbose.stderr b/tests/ui/type/verbose.verbose.stderr new file mode 100644 index 00000000000..7cc7a16cdb1 --- /dev/null +++ b/tests/ui/type/verbose.verbose.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/verbose.rs:7:28 + | +LL | let _: Foo<u32, i32> = Foo::<i32, i32> { x: 0, y: 0 }; + | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Foo<u32, i32>`, found `Foo<i32, i32>` + | | + | expected due to this + | + = note: expected struct `Foo<u32, i32>` + found struct `Foo<i32, i32>` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/issue-110052.stderr b/tests/ui/typeck/issue-110052.stderr index b25b6c0c0b7..5eb10d9a30e 100644 --- a/tests/ui/typeck/issue-110052.stderr +++ b/tests/ui/typeck/issue-110052.stderr @@ -2,7 +2,14 @@ error[E0223]: ambiguous associated type --> $DIR/issue-110052.rs:6:30 | LL | for<'iter> dyn Validator<<&'iter I>::Item>:, - | ^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<&'iter I as IntoIterator>::Item` + | ^^^^^^^^^^^^^^^^ + | +help: use fully-qualified syntax + | +LL | for<'iter> dyn Validator<<&'iter I as IntoAsyncIterator>::Item>:, + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +LL | for<'iter> dyn Validator<<&'iter I as IntoIterator>::Item>:, + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: aborting due to 1 previous error diff --git a/tests/ui/underscore-lifetime/underscore-lifetime-binders.stderr b/tests/ui/underscore-lifetime/underscore-lifetime-binders.stderr index 50401791eff..cd74d27dcb5 100644 --- a/tests/ui/underscore-lifetime/underscore-lifetime-binders.stderr +++ b/tests/ui/underscore-lifetime/underscore-lifetime-binders.stderr @@ -28,7 +28,7 @@ LL | fn meh() -> Box<dyn for<'_> Meh<'_>> | ^^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`, or if you will only have owned values | LL | fn meh() -> Box<dyn for<'_> Meh<'static>> | ~~~~~~~ diff --git a/tests/ui/unknown-unstable-lints/deny-unstable-lint-command-line.stderr b/tests/ui/unknown-unstable-lints/deny-unstable-lint-command-line.stderr index f0450aea49a..df83c103084 100644 --- a/tests/ui/unknown-unstable-lints/deny-unstable-lint-command-line.stderr +++ b/tests/ui/unknown-unstable-lints/deny-unstable-lint-command-line.stderr @@ -4,17 +4,5 @@ error: unknown lint: `test_unstable_lint` = help: add `-Zcrate-attr="feature(test_unstable_lint)"` to the command-line options to enable = note: requested on the command line with `-D unknown-lints` -error: unknown lint: `test_unstable_lint` - | - = note: the `test_unstable_lint` lint is unstable - = help: add `-Zcrate-attr="feature(test_unstable_lint)"` to the command-line options to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: unknown lint: `test_unstable_lint` - | - = note: the `test_unstable_lint` lint is unstable - = help: add `-Zcrate-attr="feature(test_unstable_lint)"` to the command-line options to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: aborting due to 3 previous errors +error: aborting due to 1 previous error diff --git a/tests/ui/unknown-unstable-lints/deny-unstable-lint-inline.rs b/tests/ui/unknown-unstable-lints/deny-unstable-lint-inline.rs index c6c60b12d83..29c6547abc1 100644 --- a/tests/ui/unknown-unstable-lints/deny-unstable-lint-inline.rs +++ b/tests/ui/unknown-unstable-lints/deny-unstable-lint-inline.rs @@ -3,7 +3,5 @@ #![deny(unknown_lints)] #![allow(test_unstable_lint)] //~^ ERROR unknown lint: `test_unstable_lint` -//~| ERROR unknown lint: `test_unstable_lint` -//~| ERROR unknown lint: `test_unstable_lint` fn main() {} diff --git a/tests/ui/unknown-unstable-lints/deny-unstable-lint-inline.stderr b/tests/ui/unknown-unstable-lints/deny-unstable-lint-inline.stderr index 20a36b28dc6..0afe3d55c98 100644 --- a/tests/ui/unknown-unstable-lints/deny-unstable-lint-inline.stderr +++ b/tests/ui/unknown-unstable-lints/deny-unstable-lint-inline.stderr @@ -12,25 +12,5 @@ note: the lint level is defined here LL | #![deny(unknown_lints)] | ^^^^^^^^^^^^^ -error: unknown lint: `test_unstable_lint` - --> $DIR/deny-unstable-lint-inline.rs:4:1 - | -LL | #![allow(test_unstable_lint)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `test_unstable_lint` lint is unstable - = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: unknown lint: `test_unstable_lint` - --> $DIR/deny-unstable-lint-inline.rs:4:1 - | -LL | #![allow(test_unstable_lint)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `test_unstable_lint` lint is unstable - = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: aborting due to 3 previous errors +error: aborting due to 1 previous error diff --git a/tests/ui/unknown-unstable-lints/warn-unknown-unstable-lint-command-line.stderr b/tests/ui/unknown-unstable-lints/warn-unknown-unstable-lint-command-line.stderr index a2deecf1caf..c133b880ebd 100644 --- a/tests/ui/unknown-unstable-lints/warn-unknown-unstable-lint-command-line.stderr +++ b/tests/ui/unknown-unstable-lints/warn-unknown-unstable-lint-command-line.stderr @@ -4,17 +4,5 @@ warning: unknown lint: `test_unstable_lint` = help: add `-Zcrate-attr="feature(test_unstable_lint)"` to the command-line options to enable = note: requested on the command line with `-W unknown-lints` -warning: unknown lint: `test_unstable_lint` - | - = note: the `test_unstable_lint` lint is unstable - = help: add `-Zcrate-attr="feature(test_unstable_lint)"` to the command-line options to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: unknown lint: `test_unstable_lint` - | - = note: the `test_unstable_lint` lint is unstable - = help: add `-Zcrate-attr="feature(test_unstable_lint)"` to the command-line options to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: 3 warnings emitted +warning: 1 warning emitted diff --git a/tests/ui/unknown-unstable-lints/warn-unknown-unstable-lint-inline.rs b/tests/ui/unknown-unstable-lints/warn-unknown-unstable-lint-inline.rs index f4247e4569e..89db84e69f6 100644 --- a/tests/ui/unknown-unstable-lints/warn-unknown-unstable-lint-inline.rs +++ b/tests/ui/unknown-unstable-lints/warn-unknown-unstable-lint-inline.rs @@ -3,7 +3,5 @@ #![warn(unknown_lints)] #![allow(test_unstable_lint)] //~^ WARNING unknown lint: `test_unstable_lint` -//~| WARNING unknown lint: `test_unstable_lint` -//~| WARNING unknown lint: `test_unstable_lint` fn main() {} diff --git a/tests/ui/unknown-unstable-lints/warn-unknown-unstable-lint-inline.stderr b/tests/ui/unknown-unstable-lints/warn-unknown-unstable-lint-inline.stderr index 12afb2e294a..48c83b49e29 100644 --- a/tests/ui/unknown-unstable-lints/warn-unknown-unstable-lint-inline.stderr +++ b/tests/ui/unknown-unstable-lints/warn-unknown-unstable-lint-inline.stderr @@ -12,25 +12,5 @@ note: the lint level is defined here LL | #![warn(unknown_lints)] | ^^^^^^^^^^^^^ -warning: unknown lint: `test_unstable_lint` - --> $DIR/warn-unknown-unstable-lint-inline.rs:4:1 - | -LL | #![allow(test_unstable_lint)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `test_unstable_lint` lint is unstable - = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: unknown lint: `test_unstable_lint` - --> $DIR/warn-unknown-unstable-lint-inline.rs:4:1 - | -LL | #![allow(test_unstable_lint)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `test_unstable_lint` lint is unstable - = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: 3 warnings emitted +warning: 1 warning emitted diff --git a/tests/ui/unpretty/flattened-format-args.stdout b/tests/ui/unpretty/flattened-format-args.stdout index a8fe8da0024..7fc5d266059 100644 --- a/tests/ui/unpretty/flattened-format-args.stdout +++ b/tests/ui/unpretty/flattened-format-args.stdout @@ -9,8 +9,7 @@ fn main() { let x = 1; // Should flatten to println!("a 123 b {x} xyz\n"): { - ::std::io::_print(<#[lang = "format_arguments"]>::new_v1(&["a 123 b ", - " xyz\n"], - &[<#[lang = "format_argument"]>::new_display(&x)])); + ::std::io::_print(format_arguments::new_v1(&["a 123 b ", + " xyz\n"], &[format_argument::new_display(&x)])); }; } diff --git a/tests/ui/unsized/issue-71659.rs b/tests/ui/unsized/issue-71659.rs index db5c2e205aa..65a867caf8f 100644 --- a/tests/ui/unsized/issue-71659.rs +++ b/tests/ui/unsized/issue-71659.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver #![feature(unsize)] diff --git a/tests/ui/unsized/issue-75899.rs b/tests/ui/unsized/issue-75899.rs index 71943103291..56c8a72bfcc 100644 --- a/tests/ui/unsized/issue-75899.rs +++ b/tests/ui/unsized/issue-75899.rs @@ -1,5 +1,5 @@ // revisions: current next -//[next] compile-flags: -Ztrait-solver=next +//[next] compile-flags: -Znext-solver // check-pass trait Trait {} diff --git a/tests/ui/where-clauses/higher-ranked-fn-type.rs b/tests/ui/where-clauses/higher-ranked-fn-type.rs index c19e75eb7bf..5d7308b6c1c 100644 --- a/tests/ui/where-clauses/higher-ranked-fn-type.rs +++ b/tests/ui/where-clauses/higher-ranked-fn-type.rs @@ -1,5 +1,5 @@ // revisions: quiet verbose -// [verbose]compile-flags: -Zverbose +// [verbose]compile-flags: -Zverbose-internals #![allow(unused_parens)] |
