diff options
Diffstat (limited to 'tests')
879 files changed, 11337 insertions, 6173 deletions
diff --git a/tests/assembly-llvm/asm/aarch64-outline-atomics.rs b/tests/assembly-llvm/asm/aarch64-outline-atomics.rs index 22599c18dcf..1177c1e68ed 100644 --- a/tests/assembly-llvm/asm/aarch64-outline-atomics.rs +++ b/tests/assembly-llvm/asm/aarch64-outline-atomics.rs @@ -8,6 +8,10 @@ use std::sync::atomic::AtomicI32; use std::sync::atomic::Ordering::*; +// Verify config on outline-atomics works (it is always enabled on aarch64-linux). +#[cfg(not(target_feature = "outline-atomics"))] +compile_error!("outline-atomics is not enabled"); + pub fn compare_exchange(a: &AtomicI32) { // On AArch64 LLVM should outline atomic operations. // CHECK: __aarch64_cas4_relax diff --git a/tests/assembly-llvm/asm/loongarch-type.rs b/tests/assembly-llvm/asm/loongarch-type.rs index c782be19f1d..95d811a6bd0 100644 --- a/tests/assembly-llvm/asm/loongarch-type.rs +++ b/tests/assembly-llvm/asm/loongarch-type.rs @@ -1,8 +1,15 @@ //@ add-core-stubs +//@ revisions: loongarch32 loongarch64 + //@ assembly-output: emit-asm -//@ compile-flags: --target loongarch64-unknown-linux-gnu + +//@[loongarch32] compile-flags: --target loongarch32-unknown-none +//@[loongarch32] needs-llvm-components: loongarch + +//@[loongarch64] compile-flags: --target loongarch64-unknown-none +//@[loongarch64] needs-llvm-components: loongarch + //@ compile-flags: -Zmerge-functions=disabled -//@ needs-llvm-components: loongarch #![feature(no_core, f16)] #![crate_type = "rlib"] @@ -22,7 +29,7 @@ extern "C" { // CHECK-LABEL: sym_fn: // CHECK: #APP // CHECK: pcalau12i $t0, %got_pc_hi20(extern_func) -// CHECK: ld.d $t0, $t0, %got_pc_lo12(extern_func) +// CHECK: ld.{{[wd]}} $t0, $t0, %got_pc_lo12(extern_func) // CHECK: #NO_APP #[no_mangle] pub unsafe fn sym_fn() { @@ -32,7 +39,7 @@ pub unsafe fn sym_fn() { // CHECK-LABEL: sym_static: // CHECK: #APP // CHECK: pcalau12i $t0, %got_pc_hi20(extern_static) -// CHECK: ld.d $t0, $t0, %got_pc_lo12(extern_static) +// CHECK: ld.{{[wd]}} $t0, $t0, %got_pc_lo12(extern_static) // CHECK: #NO_APP #[no_mangle] pub unsafe fn sym_static() { @@ -87,16 +94,18 @@ check!(reg_i32, i32, reg, "move"); // CHECK: #NO_APP check!(reg_f32, f32, reg, "move"); -// CHECK-LABEL: reg_i64: -// CHECK: #APP -// CHECK: move ${{[a-z0-9]+}}, ${{[a-z0-9]+}} -// CHECK: #NO_APP +// loongarch64-LABEL: reg_i64: +// loongarch64: #APP +// loongarch64: move ${{[a-z0-9]+}}, ${{[a-z0-9]+}} +// loongarch64: #NO_APP +#[cfg(loongarch64)] check!(reg_i64, i64, reg, "move"); -// CHECK-LABEL: reg_f64: -// CHECK: #APP -// CHECK: move ${{[a-z0-9]+}}, ${{[a-z0-9]+}} -// CHECK: #NO_APP +// loongarch64-LABEL: reg_f64: +// loongarch64: #APP +// loongarch64: move ${{[a-z0-9]+}}, ${{[a-z0-9]+}} +// loongarch64: #NO_APP +#[cfg(loongarch64)] check!(reg_f64, f64, reg, "move"); // CHECK-LABEL: reg_ptr: @@ -153,16 +162,18 @@ check_reg!(r4_i32, i32, "$r4", "move"); // CHECK: #NO_APP check_reg!(r4_f32, f32, "$r4", "move"); -// CHECK-LABEL: r4_i64: -// CHECK: #APP -// CHECK: move $a0, $a0 -// CHECK: #NO_APP +// loongarch64-LABEL: r4_i64: +// loongarch64: #APP +// loongarch64: move $a0, $a0 +// loongarch64: #NO_APP +#[cfg(loongarch64)] check_reg!(r4_i64, i64, "$r4", "move"); -// CHECK-LABEL: r4_f64: -// CHECK: #APP -// CHECK: move $a0, $a0 -// CHECK: #NO_APP +// loongarch64-LABEL: r4_f64: +// loongarch64: #APP +// loongarch64: move $a0, $a0 +// loongarch64: #NO_APP +#[cfg(loongarch64)] check_reg!(r4_f64, f64, "$r4", "move"); // CHECK-LABEL: r4_ptr: diff --git a/tests/assembly-llvm/targets/targets-elf.rs b/tests/assembly-llvm/targets/targets-elf.rs index edf16548e7d..a1d759ede2b 100644 --- a/tests/assembly-llvm/targets/targets-elf.rs +++ b/tests/assembly-llvm/targets/targets-elf.rs @@ -10,6 +10,9 @@ //@ revisions: aarch64_be_unknown_netbsd //@ [aarch64_be_unknown_netbsd] compile-flags: --target aarch64_be-unknown-netbsd //@ [aarch64_be_unknown_netbsd] needs-llvm-components: aarch64 +//@ revisions: aarch64_be_unknown_none_softfloat +//@ [aarch64_be_unknown_none_softfloat] compile-flags: --target aarch64_be-unknown-none-softfloat +//@ [aarch64_be_unknown_none_softfloat] needs-llvm-components: aarch64 //@ revisions: aarch64_kmc_solid_asp3 //@ [aarch64_kmc_solid_asp3] compile-flags: --target aarch64-kmc-solid_asp3 //@ [aarch64_kmc_solid_asp3] needs-llvm-components: aarch64 @@ -193,6 +196,9 @@ //@ revisions: armv7a_nuttx_eabihf //@ [armv7a_nuttx_eabihf] compile-flags: --target armv7a-nuttx-eabihf //@ [armv7a_nuttx_eabihf] needs-llvm-components: arm +//@ revisions: armv7a_vex_v5 +//@ [armv7a_vex_v5] compile-flags: --target armv7a-vex-v5 +//@ [armv7a_vex_v5] needs-llvm-components: arm //@ revisions: armv7r_none_eabi //@ [armv7r_none_eabi] compile-flags: --target armv7r-none-eabi //@ [armv7r_none_eabi] needs-llvm-components: arm diff --git a/tests/assembly-llvm/x86_64-bigint-helpers.rs b/tests/assembly-llvm/x86_64-bigint-helpers.rs index 58785932bc2..c5efda58fd6 100644 --- a/tests/assembly-llvm/x86_64-bigint-helpers.rs +++ b/tests/assembly-llvm/x86_64-bigint-helpers.rs @@ -2,9 +2,7 @@ //@ assembly-output: emit-asm //@ compile-flags: --crate-type=lib -Copt-level=3 -C target-cpu=x86-64-v4 //@ compile-flags: -C llvm-args=-x86-asm-syntax=intel -//@ revisions: llvm-pre-20 llvm-20 -//@ [llvm-20] min-llvm-version: 20 -//@ [llvm-pre-20] max-llvm-major-version: 19 +//@ min-llvm-version: 20 #![no_std] #![feature(bigint_helper_methods)] @@ -23,16 +21,15 @@ pub unsafe extern "sysv64" fn bigint_chain_carrying_add( n: usize, mut carry: bool, ) -> bool { - // llvm-pre-20: mov [[TEMP:r..]], qword ptr [rsi + 8*[[IND:r..]] + 8] - // llvm-pre-20: adc [[TEMP]], qword ptr [rdx + 8*[[IND]] + 8] - // llvm-pre-20: mov qword ptr [rdi + 8*[[IND]] + 8], [[TEMP]] - // llvm-pre-20: mov [[TEMP]], qword ptr [rsi + 8*[[IND]] + 16] - // llvm-pre-20: adc [[TEMP]], qword ptr [rdx + 8*[[IND]] + 16] - // llvm-pre-20: mov qword ptr [rdi + 8*[[IND]] + 16], [[TEMP]] - // llvm-20: adc [[TEMP:r..]], qword ptr [rdx + 8*[[IND:r..]]] - // llvm-20: mov qword ptr [rdi + 8*[[IND]]], [[TEMP]] - // llvm-20: mov [[TEMP]], qword ptr [rsi + 8*[[IND]] + 8] - // llvm-20: adc [[TEMP]], qword ptr [rdx + 8*[[IND]] + 8] + // Even if we emit A+B, LLVM will sometimes reorder that to B+A, so this + // test doesn't actually check which register is mov vs which is adc. + + // CHECK: mov [[TEMP1:.+]], qword ptr [{{rdx|rsi}} + 8*[[IND:.+]] + 8] + // CHECK: adc [[TEMP1]], qword ptr [{{rdx|rsi}} + 8*[[IND]] + 8] + // CHECK: mov qword ptr [rdi + 8*[[IND]] + 8], [[TEMP1]] + // CHECK: mov [[TEMP2:.+]], qword ptr [{{rdx|rsi}} + 8*[[IND]] + 16] + // CHECK: adc [[TEMP2]], qword ptr [{{rdx|rsi}} + 8*[[IND]] + 16] + // CHECK: mov qword ptr [rdi + 8*[[IND]] + 16], [[TEMP2]] for i in 0..n { (*dest.add(i), carry) = u64::carrying_add(*src1.add(i), *src2.add(i), carry); } diff --git a/tests/codegen-llvm/addr-of-mutate.rs b/tests/codegen-llvm/addr-of-mutate.rs index 14bc4b8ab28..71669065289 100644 --- a/tests/codegen-llvm/addr-of-mutate.rs +++ b/tests/codegen-llvm/addr-of-mutate.rs @@ -5,7 +5,7 @@ // Test for the absence of `readonly` on the argument when it is mutated via `&raw const`. // See <https://github.com/rust-lang/rust/issues/111502>. -// CHECK: i8 @foo(ptr noalias{{( nocapture)?}} noundef align 1{{( captures\(none\))?}} dereferenceable(128) %x) +// CHECK: i8 @foo(ptr{{( dead_on_return)?}} noalias{{( nocapture)?}} noundef align 1{{( captures\(none\))?}} dereferenceable(128) %x) #[no_mangle] pub fn foo(x: [u8; 128]) -> u8 { let ptr = core::ptr::addr_of!(x).cast_mut(); @@ -15,7 +15,7 @@ pub fn foo(x: [u8; 128]) -> u8 { x[0] } -// CHECK: i1 @second(ptr noalias{{( nocapture)?}} noundef align {{[0-9]+}}{{( captures\(none\))?}} dereferenceable({{[0-9]+}}) %a_ptr_and_b) +// CHECK: i1 @second(ptr{{( dead_on_return)?}} noalias{{( nocapture)?}} noundef align {{[0-9]+}}{{( captures\(none\))?}} dereferenceable({{[0-9]+}}) %a_ptr_and_b) #[no_mangle] pub unsafe fn second(a_ptr_and_b: (*mut (i32, bool), (i64, bool))) -> bool { let b_bool_ptr = core::ptr::addr_of!(a_ptr_and_b.1.1).cast_mut(); @@ -24,7 +24,7 @@ pub unsafe fn second(a_ptr_and_b: (*mut (i32, bool), (i64, bool))) -> bool { } // If going through a deref (and there are no other mutating accesses), then `readonly` is fine. -// CHECK: i1 @third(ptr noalias{{( nocapture)?}} noundef readonly align {{[0-9]+}}{{( captures\(none\))?}} dereferenceable({{[0-9]+}}) %a_ptr_and_b) +// CHECK: i1 @third(ptr{{( dead_on_return)?}} noalias{{( nocapture)?}} noundef readonly align {{[0-9]+}}{{( captures\(none\))?}} dereferenceable({{[0-9]+}}) %a_ptr_and_b) #[no_mangle] pub unsafe fn third(a_ptr_and_b: (*mut (i32, bool), (i64, bool))) -> bool { let b_bool_ptr = core::ptr::addr_of!((*a_ptr_and_b.0).1).cast_mut(); diff --git a/tests/codegen-llvm/align-byval-alignment-mismatch.rs b/tests/codegen-llvm/align-byval-alignment-mismatch.rs index c69fc2de9d2..8eaf2751ed7 100644 --- a/tests/codegen-llvm/align-byval-alignment-mismatch.rs +++ b/tests/codegen-llvm/align-byval-alignment-mismatch.rs @@ -55,10 +55,10 @@ extern "C" { pub unsafe fn rust_to_c_increases_alignment(x: Align1) { // i686-linux: start: // i686-linux-NEXT: [[ALLOCA:%[0-9a-z]+]] = alloca [48 x i8], align 4 - // i686-linux-NEXT: call void @llvm.lifetime.start.p0(i64 48, ptr {{.*}}[[ALLOCA]]) + // i686-linux-NEXT: call void @llvm.lifetime.start.p0({{(i64 48, )?}}ptr {{.*}}[[ALLOCA]]) // i686-linux-NEXT: call void @llvm.memcpy.{{.+}}(ptr {{.*}}align 4 {{.*}}[[ALLOCA]], ptr {{.*}}align 1 {{.*}}%x // i686-linux-NEXT: call void @extern_c_align1({{.+}} [[ALLOCA]]) - // i686-linux-NEXT: call void @llvm.lifetime.end.p0(i64 48, ptr {{.*}}[[ALLOCA]]) + // i686-linux-NEXT: call void @llvm.lifetime.end.p0({{(i64 48, )?}}ptr {{.*}}[[ALLOCA]]) // x86_64-linux: start: // x86_64-linux-NEXT: call void @extern_c_align1 diff --git a/tests/codegen-llvm/atomicptr.rs b/tests/codegen-llvm/atomicptr.rs index 4819af40ca2..ce6c4aa0d2b 100644 --- a/tests/codegen-llvm/atomicptr.rs +++ b/tests/codegen-llvm/atomicptr.rs @@ -1,5 +1,5 @@ // LLVM does not support some atomic RMW operations on pointers, so inside codegen we lower those -// to integer atomics, surrounded by casts to and from integer type. +// to integer atomics, followed by an inttoptr cast. // This test ensures that we do the round-trip correctly for AtomicPtr::fetch_byte_add, and also // ensures that we do not have such a round-trip for AtomicPtr::swap, because LLVM supports pointer // arguments to `atomicrmw xchg`. @@ -20,8 +20,8 @@ pub fn helper(_: usize) {} // CHECK-LABEL: @atomicptr_fetch_byte_add #[no_mangle] pub fn atomicptr_fetch_byte_add(a: &AtomicPtr<u8>, v: usize) -> *mut u8 { - // CHECK: %[[INTPTR:.*]] = ptrtoint ptr %{{.*}} to [[USIZE]] - // CHECK-NEXT: %[[RET:.*]] = atomicrmw add ptr %{{.*}}, [[USIZE]] %[[INTPTR]] + // CHECK: llvm.lifetime.start + // CHECK-NEXT: %[[RET:.*]] = atomicrmw add ptr %{{.*}}, [[USIZE]] %v // CHECK-NEXT: inttoptr [[USIZE]] %[[RET]] to ptr a.fetch_byte_add(v, Relaxed) } diff --git a/tests/codegen-llvm/autodiffv2.rs b/tests/codegen-llvm/autodiff/autodiffv2.rs index a40d19d3be3..85aed6a183b 100644 --- a/tests/codegen-llvm/autodiffv2.rs +++ b/tests/codegen-llvm/autodiff/autodiffv2.rs @@ -26,12 +26,13 @@ #![feature(autodiff)] -use std::autodiff::autodiff; +use std::autodiff::autodiff_forward; +// CHECK: ; #[no_mangle] //#[autodiff(d_square1, Forward, Dual, Dual)] -#[autodiff(d_square2, Forward, 4, Dualv, Dualv)] -#[autodiff(d_square3, Forward, 4, Dual, Dual)] +#[autodiff_forward(d_square2, 4, Dualv, Dualv)] +#[autodiff_forward(d_square3, 4, Dual, Dual)] fn square(x: &[f32], y: &mut [f32]) { assert!(x.len() >= 4); assert!(y.len() >= 5); diff --git a/tests/codegen-llvm/autodiff/batched.rs b/tests/codegen-llvm/autodiff/batched.rs index d27aed50e6c..306a6ed9d1f 100644 --- a/tests/codegen-llvm/autodiff/batched.rs +++ b/tests/codegen-llvm/autodiff/batched.rs @@ -17,11 +17,12 @@ use std::autodiff::autodiff_forward; #[autodiff_forward(d_square2, 4, Dual, DualOnly)] #[autodiff_forward(d_square1, 4, Dual, Dual)] #[no_mangle] +#[inline(never)] fn square(x: &f32) -> f32 { x * x } -// d_sqaure2 +// d_square2 // CHECK: define internal fastcc [4 x float] @fwddiffe4square(float %x.0.val, [4 x ptr] %"x'") // CHECK-NEXT: start: // CHECK-NEXT: %0 = extractvalue [4 x ptr] %"x'", 0 @@ -32,24 +33,20 @@ fn square(x: &f32) -> f32 { // CHECK-NEXT: %"_2'ipl2" = load float, ptr %2, align 4 // CHECK-NEXT: %3 = extractvalue [4 x ptr] %"x'", 3 // CHECK-NEXT: %"_2'ipl3" = load float, ptr %3, align 4 -// CHECK-NEXT: %4 = insertelement <4 x float> poison, float %"_2'ipl", i64 0 -// CHECK-NEXT: %5 = insertelement <4 x float> %4, float %"_2'ipl1", i64 1 -// CHECK-NEXT: %6 = insertelement <4 x float> %5, float %"_2'ipl2", i64 2 -// CHECK-NEXT: %7 = insertelement <4 x float> %6, float %"_2'ipl3", i64 3 -// CHECK-NEXT: %8 = fadd fast <4 x float> %7, %7 -// CHECK-NEXT: %9 = insertelement <4 x float> poison, float %x.0.val, i64 0 -// CHECK-NEXT: %10 = shufflevector <4 x float> %9, <4 x float> poison, <4 x i32> zeroinitializer -// CHECK-NEXT: %11 = fmul fast <4 x float> %8, %10 -// CHECK-NEXT: %12 = extractelement <4 x float> %11, i64 0 -// CHECK-NEXT: %13 = insertvalue [4 x float] undef, float %12, 0 -// CHECK-NEXT: %14 = extractelement <4 x float> %11, i64 1 -// CHECK-NEXT: %15 = insertvalue [4 x float] %13, float %14, 1 -// CHECK-NEXT: %16 = extractelement <4 x float> %11, i64 2 -// CHECK-NEXT: %17 = insertvalue [4 x float] %15, float %16, 2 -// CHECK-NEXT: %18 = extractelement <4 x float> %11, i64 3 -// CHECK-NEXT: %19 = insertvalue [4 x float] %17, float %18, 3 -// CHECK-NEXT: ret [4 x float] %19 -// CHECK-NEXT: } +// CHECK-NEXT: %4 = fmul float %"_2'ipl", 2.000000e+00 +// CHECK-NEXT: %5 = fmul fast float %4, %x.0.val +// CHECK-NEXT: %6 = insertvalue [4 x float] undef, float %5, 0 +// CHECK-NEXT: %7 = fmul float %"_2'ipl1", 2.000000e+00 +// CHECK-NEXT: %8 = fmul fast float %7, %x.0.val +// CHECK-NEXT: %9 = insertvalue [4 x float] %6, float %8, 1 +// CHECK-NEXT: %10 = fmul float %"_2'ipl2", 2.000000e+00 +// CHECK-NEXT: %11 = fmul fast float %10, %x.0.val +// CHECK-NEXT: %12 = insertvalue [4 x float] %9, float %11, 2 +// CHECK-NEXT: %13 = fmul float %"_2'ipl3", 2.000000e+00 +// CHECK-NEXT: %14 = fmul fast float %13, %x.0.val +// CHECK-NEXT: %15 = insertvalue [4 x float] %12, float %14, 3 +// CHECK-NEXT: ret [4 x float] %15 +// CHECK-NEXT: } // d_square3, the extra float is the original return value (x * x) // CHECK: define internal fastcc { float, [4 x float] } @fwddiffe4square.1(float %x.0.val, [4 x ptr] %"x'") @@ -63,26 +60,22 @@ fn square(x: &f32) -> f32 { // CHECK-NEXT: %3 = extractvalue [4 x ptr] %"x'", 3 // CHECK-NEXT: %"_2'ipl3" = load float, ptr %3, align 4 // CHECK-NEXT: %_0 = fmul float %x.0.val, %x.0.val -// CHECK-NEXT: %4 = insertelement <4 x float> poison, float %"_2'ipl", i64 0 -// CHECK-NEXT: %5 = insertelement <4 x float> %4, float %"_2'ipl1", i64 1 -// CHECK-NEXT: %6 = insertelement <4 x float> %5, float %"_2'ipl2", i64 2 -// CHECK-NEXT: %7 = insertelement <4 x float> %6, float %"_2'ipl3", i64 3 -// CHECK-NEXT: %8 = fadd fast <4 x float> %7, %7 -// CHECK-NEXT: %9 = insertelement <4 x float> poison, float %x.0.val, i64 0 -// CHECK-NEXT: %10 = shufflevector <4 x float> %9, <4 x float> poison, <4 x i32> zeroinitializer -// CHECK-NEXT: %11 = fmul fast <4 x float> %8, %10 -// CHECK-NEXT: %12 = extractelement <4 x float> %11, i64 0 -// CHECK-NEXT: %13 = insertvalue [4 x float] undef, float %12, 0 -// CHECK-NEXT: %14 = extractelement <4 x float> %11, i64 1 -// CHECK-NEXT: %15 = insertvalue [4 x float] %13, float %14, 1 -// CHECK-NEXT: %16 = extractelement <4 x float> %11, i64 2 -// CHECK-NEXT: %17 = insertvalue [4 x float] %15, float %16, 2 -// CHECK-NEXT: %18 = extractelement <4 x float> %11, i64 3 -// CHECK-NEXT: %19 = insertvalue [4 x float] %17, float %18, 3 -// CHECK-NEXT: %20 = insertvalue { float, [4 x float] } undef, float %_0, 0 -// CHECK-NEXT: %21 = insertvalue { float, [4 x float] } %20, [4 x float] %19, 1 -// CHECK-NEXT: ret { float, [4 x float] } %21 -// CHECK-NEXT: } +// CHECK-NEXT: %4 = fmul float %"_2'ipl", 2.000000e+00 +// CHECK-NEXT: %5 = fmul fast float %4, %x.0.val +// CHECK-NEXT: %6 = insertvalue [4 x float] undef, float %5, 0 +// CHECK-NEXT: %7 = fmul float %"_2'ipl1", 2.000000e+00 +// CHECK-NEXT: %8 = fmul fast float %7, %x.0.val +// CHECK-NEXT: %9 = insertvalue [4 x float] %6, float %8, 1 +// CHECK-NEXT: %10 = fmul float %"_2'ipl2", 2.000000e+00 +// CHECK-NEXT: %11 = fmul fast float %10, %x.0.val +// CHECK-NEXT: %12 = insertvalue [4 x float] %9, float %11, 2 +// CHECK-NEXT: %13 = fmul float %"_2'ipl3", 2.000000e+00 +// CHECK-NEXT: %14 = fmul fast float %13, %x.0.val +// CHECK-NEXT: %15 = insertvalue [4 x float] %12, float %14, 3 +// CHECK-NEXT: %16 = insertvalue { float, [4 x float] } undef, float %_0, 0 +// CHECK-NEXT: %17 = insertvalue { float, [4 x float] } %16, [4 x float] %15, 1 +// CHECK-NEXT: ret { float, [4 x float] } %17 +// CHECK-NEXT: } fn main() { let x = std::hint::black_box(3.0); diff --git a/tests/codegen-llvm/autodiff/generic.rs b/tests/codegen-llvm/autodiff/generic.rs index 2f674079be0..6f56460a2b6 100644 --- a/tests/codegen-llvm/autodiff/generic.rs +++ b/tests/codegen-llvm/autodiff/generic.rs @@ -6,27 +6,28 @@ use std::autodiff::autodiff_reverse; #[autodiff_reverse(d_square, Duplicated, Active)] +#[inline(never)] fn square<T: std::ops::Mul<Output = T> + Copy>(x: &T) -> T { *x * *x } -// Ensure that `d_square::<f64>` code is generated even if `square::<f64>` was never called +// Ensure that `d_square::<f32>` code is generated // // CHECK: ; generic::square -// CHECK-NEXT: ; Function Attrs: -// CHECK-NEXT: define internal {{.*}} double +// CHECK-NEXT: ; Function Attrs: {{.*}} +// CHECK-NEXT: define internal {{.*}} float // CHECK-NEXT: start: // CHECK-NOT: ret -// CHECK: fmul double +// CHECK: fmul float -// Ensure that `d_square::<f32>` code is generated +// Ensure that `d_square::<f64>` code is generated even if `square::<f64>` was never called // // CHECK: ; generic::square -// CHECK-NEXT: ; Function Attrs: {{.*}} -// CHECK-NEXT: define internal {{.*}} float +// CHECK-NEXT: ; Function Attrs: +// CHECK-NEXT: define internal {{.*}} double // CHECK-NEXT: start: // CHECK-NOT: ret -// CHECK: fmul float +// CHECK: fmul double fn main() { let xf32: f32 = std::hint::black_box(3.0); diff --git a/tests/codegen-llvm/autodiff/identical_fnc.rs b/tests/codegen-llvm/autodiff/identical_fnc.rs index 1c25b3d09ab..6066f8cb34f 100644 --- a/tests/codegen-llvm/autodiff/identical_fnc.rs +++ b/tests/codegen-llvm/autodiff/identical_fnc.rs @@ -14,25 +14,27 @@ use std::autodiff::autodiff_reverse; #[autodiff_reverse(d_square, Duplicated, Active)] +#[inline(never)] fn square(x: &f64) -> f64 { x * x } #[autodiff_reverse(d_square2, Duplicated, Active)] +#[inline(never)] fn square2(x: &f64) -> f64 { x * x } // CHECK:; identical_fnc::main // CHECK-NEXT:; Function Attrs: -// CHECK-NEXT:define internal void @_ZN13identical_fnc4main17hf4dbc69c8d2f9130E() +// CHECK-NEXT:define internal void @_ZN13identical_fnc4main17h6009e4f751bf9407E() // CHECK-NEXT:start: // CHECK-NOT:br // CHECK-NOT:ret // CHECK:; call identical_fnc::d_square -// CHECK-NEXT: call fastcc void @_ZN13identical_fnc8d_square17h4c364207a2f8e06dE(double %x.val, ptr noalias noundef nonnull align 8 dereferenceable(8) %dx1) -// CHECK-NEXT:; call identical_fnc::d_square -// CHECK-NEXT: call fastcc void @_ZN13identical_fnc8d_square17h4c364207a2f8e06dE(double %x.val, ptr noalias noundef nonnull align 8 dereferenceable(8) %dx2) +// CHECK-NEXT:call fastcc void @_ZN13identical_fnc8d_square17hcb5768e95528c35fE(double %x.val, ptr noalias noundef align 8 dereferenceable(8) %dx1) +// CHECK:; call identical_fnc::d_square +// CHECK-NEXT:call fastcc void @_ZN13identical_fnc8d_square17hcb5768e95528c35fE(double %x.val, ptr noalias noundef align 8 dereferenceable(8) %dx2) fn main() { let x = std::hint::black_box(3.0); diff --git a/tests/codegen-llvm/autodiff/inline.rs b/tests/codegen-llvm/autodiff/inline.rs deleted file mode 100644 index 65bed170207..00000000000 --- a/tests/codegen-llvm/autodiff/inline.rs +++ /dev/null @@ -1,23 +0,0 @@ -//@ compile-flags: -Zautodiff=Enable -C opt-level=3 -Clto=fat -Zautodiff=NoPostopt -//@ no-prefer-dynamic -//@ needs-enzyme - -#![feature(autodiff)] - -use std::autodiff::autodiff_reverse; - -#[autodiff_reverse(d_square, Duplicated, Active)] -fn square(x: &f64) -> f64 { - x * x -} - -// CHECK: ; inline::d_square -// CHECK-NEXT: ; Function Attrs: alwaysinline -// CHECK-NOT: noinline -// CHECK-NEXT: define internal fastcc void @_ZN6inline8d_square17h021c74e92c259cdeE -fn main() { - let x = std::hint::black_box(3.0); - let mut dx1 = std::hint::black_box(1.0); - let _ = d_square(&x, &mut dx1, 1.0); - assert_eq!(dx1, 6.0); -} diff --git a/tests/codegen-llvm/autodiff/scalar.rs b/tests/codegen-llvm/autodiff/scalar.rs index 096b4209e84..55b989f920d 100644 --- a/tests/codegen-llvm/autodiff/scalar.rs +++ b/tests/codegen-llvm/autodiff/scalar.rs @@ -7,11 +7,12 @@ use std::autodiff::autodiff_reverse; #[autodiff_reverse(d_square, Duplicated, Active)] #[no_mangle] +#[inline(never)] fn square(x: &f64) -> f64 { x * x } -// CHECK:define internal fastcc double @diffesquare(double %x.0.val, ptr nocapture nonnull align 8 %"x'" +// CHECK:define internal fastcc double @diffesquare(double %x.0.val, ptr nonnull align 8 captures(none) %"x'") // CHECK-NEXT:invertstart: // CHECK-NEXT: %_0 = fmul double %x.0.val, %x.0.val // CHECK-NEXT: %0 = fadd fast double %x.0.val, %x.0.val diff --git a/tests/codegen-llvm/autodiff/sret.rs b/tests/codegen-llvm/autodiff/sret.rs index d2fa85e3e37..dbc253ce894 100644 --- a/tests/codegen-llvm/autodiff/sret.rs +++ b/tests/codegen-llvm/autodiff/sret.rs @@ -13,30 +13,30 @@ use std::autodiff::autodiff_reverse; #[no_mangle] #[autodiff_reverse(df, Active, Active, Active)] +#[inline(never)] fn primal(x: f32, y: f32) -> f64 { (x * x * y) as f64 } -// CHECK:define internal fastcc void @_ZN4sret2df17h93be4316dd8ea006E(ptr dead_on_unwind noalias nocapture noundef nonnull writable writeonly align 8 dereferenceable(16) initializes((0, 16)) %_0, float noundef %x, float noundef %y) -// CHECK-NEXT:start: -// CHECK-NEXT: %0 = tail call fastcc { double, float, float } @diffeprimal(float %x, float %y) -// CHECK-NEXT: %.elt = extractvalue { double, float, float } %0, 0 -// CHECK-NEXT: store double %.elt, ptr %_0, align 8 -// CHECK-NEXT: %_0.repack1 = getelementptr inbounds nuw i8, ptr %_0, i64 8 -// CHECK-NEXT: %.elt2 = extractvalue { double, float, float } %0, 1 -// CHECK-NEXT: store float %.elt2, ptr %_0.repack1, align 8 -// CHECK-NEXT: %_0.repack3 = getelementptr inbounds nuw i8, ptr %_0, i64 12 -// CHECK-NEXT: %.elt4 = extractvalue { double, float, float } %0, 2 -// CHECK-NEXT: store float %.elt4, ptr %_0.repack3, align 4 -// CHECK-NEXT: ret void -// CHECK-NEXT:} +// CHECK: define internal fastcc { double, float, float } @diffeprimal(float noundef %x, float noundef %y) +// CHECK-NEXT: invertstart: +// CHECK-NEXT: %_4 = fmul float %x, %x +// CHECK-NEXT: %_3 = fmul float %_4, %y +// CHECK-NEXT: %_0 = fpext float %_3 to double +// CHECK-NEXT: %0 = fadd fast float %y, %y +// CHECK-NEXT: %1 = fmul fast float %0, %x +// CHECK-NEXT: %2 = insertvalue { double, float, float } undef, double %_0, 0 +// CHECK-NEXT: %3 = insertvalue { double, float, float } %2, float %1, 1 +// CHECK-NEXT: %4 = insertvalue { double, float, float } %3, float %_4, 2 +// CHECK-NEXT: ret { double, float, float } %4 +// CHECK-NEXT: } fn main() { let x = std::hint::black_box(3.0); let y = std::hint::black_box(2.5); let scalar = std::hint::black_box(1.0); let (r1, r2, r3) = df(x, y, scalar); - // 3*3*1.5 = 22.5 + // 3*3*2.5 = 22.5 assert_eq!(r1, 22.5); // 2*x*y = 2*3*2.5 = 15.0 assert_eq!(r2, 15.0); diff --git a/tests/codegen-llvm/autodiff/trait.rs b/tests/codegen-llvm/autodiff/trait.rs new file mode 100644 index 00000000000..701f3a9e843 --- /dev/null +++ b/tests/codegen-llvm/autodiff/trait.rs @@ -0,0 +1,30 @@ +//@ compile-flags: -Zautodiff=Enable -Zautodiff=NoPostopt -C opt-level=3 -Clto=fat +//@ no-prefer-dynamic +//@ needs-enzyme + +// Just check it does not crash for now +// CHECK: ; +#![feature(autodiff)] + +use std::autodiff::autodiff_reverse; + +struct Foo { + a: f64, +} + +trait MyTrait { + fn f(&self, x: f64) -> f64; + fn df(&self, x: f64, seed: f64) -> (f64, f64); +} + +impl MyTrait for Foo { + #[autodiff_reverse(df, Const, Active, Active)] + fn f(&self, x: f64) -> f64 { + self.a * 0.25 * (x * x - 1.0 - 2.0 * x.ln()) + } +} + +fn main() { + let foo = Foo { a: 3.0f64 }; + dbg!(foo.df(1.0, 1.0)); +} diff --git a/tests/codegen-llvm/bigint-helpers.rs b/tests/codegen-llvm/bigint-helpers.rs index 355cccb8150..ec70a3eabed 100644 --- a/tests/codegen-llvm/bigint-helpers.rs +++ b/tests/codegen-llvm/bigint-helpers.rs @@ -3,11 +3,20 @@ #![crate_type = "lib"] #![feature(bigint_helper_methods)] +// Note that there's also an assembly test for this, which is what checks for +// the `ADC` (Add with Carry) instruction on x86 now that the IR we emit uses +// the preferred instruction phrasing instead of the intrinsic. + // CHECK-LABEL: @u32_carrying_add #[no_mangle] pub fn u32_carrying_add(a: u32, b: u32, c: bool) -> (u32, bool) { - // CHECK: @llvm.uadd.with.overflow.i32 - // CHECK: @llvm.uadd.with.overflow.i32 - // CHECK: or disjoint i1 + // CHECK: %[[AB:.+]] = add i32 {{%a, %b|%b, %a}} + // CHECK: %[[O1:.+]] = icmp ult i32 %[[AB]], %a + // CHECK: %[[CEXT:.+]] = zext i1 %c to i32 + // CHECK: %[[ABC:.+]] = add i32 %[[AB]], %[[CEXT]] + // CHECK: %[[O2:.+]] = icmp ult i32 %[[ABC]], %[[AB]] + // CHECK: %[[O:.+]] = or disjoint i1 %[[O1]], %[[O2]] + // CHECK: insertvalue {{.+}}, i32 %[[ABC]], 0 + // CHECK: insertvalue {{.+}}, i1 %[[O]], 1 u32::carrying_add(a, b, c) } diff --git a/tests/codegen-llvm/call-tmps-lifetime.rs b/tests/codegen-llvm/call-tmps-lifetime.rs index 7b7b6e17bdd..0d7657ed758 100644 --- a/tests/codegen-llvm/call-tmps-lifetime.rs +++ b/tests/codegen-llvm/call-tmps-lifetime.rs @@ -16,14 +16,14 @@ use minicore::*; // CHECK-NEXT: start: // CHECK-NEXT: [[B:%.*]] = alloca // CHECK-NEXT: [[A:%.*]] = alloca -// CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 4096, ptr [[A]]) +// CHECK-NEXT: call void @llvm.lifetime.start.p0({{(i64 4096, )?}}ptr [[A]]) // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[A]], ptr align 4 {{.*}}, i32 4096, i1 false) // CHECK-NEXT: call void %h(ptr {{.*}} [[A]]) -// CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 4096, ptr [[A]]) -// CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 4096, ptr [[B]]) +// CHECK-NEXT: call void @llvm.lifetime.end.p0({{(i64 4096, )?}}ptr [[A]]) +// CHECK-NEXT: call void @llvm.lifetime.start.p0({{(i64 4096, )?}}ptr [[B]]) // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[B]], ptr align 4 {{.*}}, i32 4096, i1 false) // CHECK-NEXT: call void %h(ptr {{.*}} [[B]]) -// CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 4096, ptr [[B]]) +// CHECK-NEXT: call void @llvm.lifetime.end.p0({{(i64 4096, )?}}ptr [[B]]) #[no_mangle] pub fn const_indirect(h: extern "C" fn([u32; 1024])) { const C: [u32; 1024] = [0; 1024]; @@ -42,12 +42,12 @@ pub struct Str { // CHECK-LABEL: define void @immediate_indirect(ptr {{.*}}%s.0, i32 {{.*}}%s.1, ptr {{.*}}%g) // CHECK-NEXT: start: // CHECK-NEXT: [[A:%.*]] = alloca -// CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 8, ptr [[A]]) +// CHECK-NEXT: call void @llvm.lifetime.start.p0({{(i64 8, )?}}ptr [[A]]) // CHECK-NEXT: store ptr %s.0, ptr [[A]] // CHECK-NEXT: [[B:%.]] = getelementptr inbounds i8, ptr [[A]], i32 4 // CHECK-NEXT: store i32 %s.1, ptr [[B]] // CHECK-NEXT: call void %g(ptr {{.*}} [[A]]) -// CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 8, ptr [[A]]) +// CHECK-NEXT: call void @llvm.lifetime.end.p0({{(i64 8, )?}}ptr [[A]]) #[no_mangle] pub fn immediate_indirect(s: Str, g: extern "C" fn(Str)) { g(s); @@ -58,10 +58,10 @@ pub fn immediate_indirect(s: Str, g: extern "C" fn(Str)) { // CHECK-LABEL: define void @align_indirect(ptr{{.*}} align 1{{.*}} %a, ptr{{.*}} %fun) // CHECK-NEXT: start: // CHECK-NEXT: [[A:%.*]] = alloca [1024 x i8], align 4 -// CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 1024, ptr [[A]]) +// CHECK-NEXT: call void @llvm.lifetime.start.p0({{(i64 1024, )?}}ptr [[A]]) // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[A]], ptr align 1 %a, i32 1024, i1 false) // CHECK-NEXT: call void %fun(ptr {{.*}} [[A]]) -// CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 1024, ptr [[A]]) +// CHECK-NEXT: call void @llvm.lifetime.end.p0({{(i64 1024, )?}}ptr [[A]]) #[no_mangle] pub fn align_indirect(a: [u8; 1024], fun: extern "C" fn([u8; 1024])) { fun(a); diff --git a/tests/codegen-llvm/dead_on_return.rs b/tests/codegen-llvm/dead_on_return.rs new file mode 100644 index 00000000000..3c1940d6ba7 --- /dev/null +++ b/tests/codegen-llvm/dead_on_return.rs @@ -0,0 +1,31 @@ +//@ compile-flags: -C opt-level=3 +//@ min-llvm-version: 21 + +#![crate_type = "lib"] +#![allow(unused_assignments, unused_variables)] + +// Check that the old string is deallocated, but a new one is not initialized. +#[unsafe(no_mangle)] +pub fn test_str_new(mut s: String) { + // CHECK-LABEL: @test_str_new + // CHECK: __rust_dealloc + // CHECK-NOT: store + s = String::new(); +} + +#[unsafe(no_mangle)] +pub fn test_str_take(mut x: String) -> String { + // CHECK-LABEL: @test_str_take + // CHECK-NEXT: {{.*}}: + // CHECK-NEXT: call void @llvm.memcpy + // CHECK-NEXT: ret + core::mem::take(&mut x) +} + +#[unsafe(no_mangle)] +pub fn test_array_store(mut x: [u32; 100]) { + // CHECK-LABEL: @test_array_store + // CHECK-NEXT: {{.*}}: + // CHECK-NEXT: ret + x[0] = 1; +} diff --git a/tests/codegen-llvm/enum/enum-discriminant-eq.rs b/tests/codegen-llvm/enum/enum-discriminant-eq.rs index d599685c2e5..a1ab5e5c6e2 100644 --- a/tests/codegen-llvm/enum/enum-discriminant-eq.rs +++ b/tests/codegen-llvm/enum/enum-discriminant-eq.rs @@ -91,18 +91,23 @@ pub enum Mid<T> { pub fn mid_bool_eq_discr(a: Mid<bool>, b: Mid<bool>) -> bool { // CHECK-LABEL: @mid_bool_eq_discr( - // CHECK: %[[A_REL_DISCR:.+]] = add nsw i8 %a, -2 - // CHECK: %[[A_IS_NICHE:.+]] = icmp samesign ugt i8 %a, 1 - // CHECK: %[[A_NOT_HOLE:.+]] = icmp ne i8 %[[A_REL_DISCR]], 1 + // CHECK: %[[A_NOT_HOLE:.+]] = icmp ne i8 %a, 3 // CHECK: tail call void @llvm.assume(i1 %[[A_NOT_HOLE]]) - // CHECK: %[[A_DISCR:.+]] = select i1 %[[A_IS_NICHE]], i8 %[[A_REL_DISCR]], i8 1 + // LLVM20: %[[A_REL_DISCR:.+]] = add nsw i8 %a, -2 + // CHECK: %[[A_IS_NICHE:.+]] = icmp samesign ugt i8 %a, 1 + // LLVM20: %[[A_DISCR:.+]] = select i1 %[[A_IS_NICHE]], i8 %[[A_REL_DISCR]], i8 1 - // CHECK: %[[B_REL_DISCR:.+]] = add nsw i8 %b, -2 - // CHECK: %[[B_IS_NICHE:.+]] = icmp samesign ugt i8 %b, 1 - // CHECK: %[[B_NOT_HOLE:.+]] = icmp ne i8 %[[B_REL_DISCR]], 1 + // CHECK: %[[B_NOT_HOLE:.+]] = icmp ne i8 %b, 3 // CHECK: tail call void @llvm.assume(i1 %[[B_NOT_HOLE]]) - // CHECK: %[[B_DISCR:.+]] = select i1 %[[B_IS_NICHE]], i8 %[[B_REL_DISCR]], i8 1 + // LLVM20: %[[B_REL_DISCR:.+]] = add nsw i8 %b, -2 + // CHECK: %[[B_IS_NICHE:.+]] = icmp samesign ugt i8 %b, 1 + // LLVM20: %[[B_DISCR:.+]] = select i1 %[[B_IS_NICHE]], i8 %[[B_REL_DISCR]], i8 1 + + // LLVM21: %[[A_MOD_DISCR:.+]] = select i1 %[[A_IS_NICHE]], i8 %a, i8 3 + // LLVM21: %[[B_MOD_DISCR:.+]] = select i1 %[[B_IS_NICHE]], i8 %b, i8 3 + // LLVM20: %[[R:.+]] = icmp eq i8 %[[A_DISCR]], %[[B_DISCR]] + // LLVM21: %[[R:.+]] = icmp eq i8 %[[A_MOD_DISCR]], %[[B_MOD_DISCR]] // CHECK: ret i1 %[[R]] discriminant_value(&a) == discriminant_value(&b) } @@ -111,19 +116,23 @@ pub fn mid_bool_eq_discr(a: Mid<bool>, b: Mid<bool>) -> bool { pub fn mid_ord_eq_discr(a: Mid<Ordering>, b: Mid<Ordering>) -> bool { // CHECK-LABEL: @mid_ord_eq_discr( - // CHECK: %[[A_REL_DISCR:.+]] = add nsw i8 %a, -2 - // CHECK: %[[A_IS_NICHE:.+]] = icmp sgt i8 %a, 1 - // CHECK: %[[A_NOT_HOLE:.+]] = icmp ne i8 %[[A_REL_DISCR]], 1 + // CHECK: %[[A_NOT_HOLE:.+]] = icmp ne i8 %a, 3 // CHECK: tail call void @llvm.assume(i1 %[[A_NOT_HOLE]]) - // CHECK: %[[A_DISCR:.+]] = select i1 %[[A_IS_NICHE]], i8 %[[A_REL_DISCR]], i8 1 + // LLVM20: %[[A_REL_DISCR:.+]] = add nsw i8 %a, -2 + // CHECK: %[[A_IS_NICHE:.+]] = icmp sgt i8 %a, 1 + // LLVM20: %[[A_DISCR:.+]] = select i1 %[[A_IS_NICHE]], i8 %[[A_REL_DISCR]], i8 1 - // CHECK: %[[B_REL_DISCR:.+]] = add nsw i8 %b, -2 - // CHECK: %[[B_IS_NICHE:.+]] = icmp sgt i8 %b, 1 - // CHECK: %[[B_NOT_HOLE:.+]] = icmp ne i8 %[[B_REL_DISCR]], 1 + // CHECK: %[[B_NOT_HOLE:.+]] = icmp ne i8 %b, 3 // CHECK: tail call void @llvm.assume(i1 %[[B_NOT_HOLE]]) - // CHECK: %[[B_DISCR:.+]] = select i1 %[[B_IS_NICHE]], i8 %[[B_REL_DISCR]], i8 1 + // LLVM20: %[[B_REL_DISCR:.+]] = add nsw i8 %b, -2 + // CHECK: %[[B_IS_NICHE:.+]] = icmp sgt i8 %b, 1 + // LLVM20: %[[B_DISCR:.+]] = select i1 %[[B_IS_NICHE]], i8 %[[B_REL_DISCR]], i8 1 - // CHECK: %[[R:.+]] = icmp eq i8 %[[A_DISCR]], %[[B_DISCR]] + // LLVM21: %[[A_MOD_DISCR:.+]] = select i1 %[[A_IS_NICHE]], i8 %a, i8 3 + // LLVM21: %[[B_MOD_DISCR:.+]] = select i1 %[[B_IS_NICHE]], i8 %b, i8 3 + + // LLVM20: %[[R:.+]] = icmp eq i8 %[[A_DISCR]], %[[B_DISCR]] + // LLVM21: %[[R:.+]] = icmp eq i8 %[[A_MOD_DISCR]], %[[B_MOD_DISCR]] // CHECK: ret i1 %[[R]] discriminant_value(&a) == discriminant_value(&b) } @@ -140,16 +149,16 @@ pub fn mid_nz32_eq_discr(a: Mid<NonZero<u32>>, b: Mid<NonZero<u32>>) -> bool { pub fn mid_ac_eq_discr(a: Mid<AC>, b: Mid<AC>) -> bool { // CHECK-LABEL: @mid_ac_eq_discr( - // LLVM20: %[[A_REL_DISCR:.+]] = xor i8 %a, -128 - // CHECK: %[[A_IS_NICHE:.+]] = icmp slt i8 %a, 0 // CHECK: %[[A_NOT_HOLE:.+]] = icmp ne i8 %a, -127 // CHECK: tail call void @llvm.assume(i1 %[[A_NOT_HOLE]]) + // LLVM20: %[[A_REL_DISCR:.+]] = xor i8 %a, -128 + // CHECK: %[[A_IS_NICHE:.+]] = icmp slt i8 %a, 0 // LLVM20: %[[A_DISCR:.+]] = select i1 %[[A_IS_NICHE]], i8 %[[A_REL_DISCR]], i8 1 - // LLVM20: %[[B_REL_DISCR:.+]] = xor i8 %b, -128 - // CHECK: %[[B_IS_NICHE:.+]] = icmp slt i8 %b, 0 // CHECK: %[[B_NOT_HOLE:.+]] = icmp ne i8 %b, -127 // CHECK: tail call void @llvm.assume(i1 %[[B_NOT_HOLE]]) + // LLVM20: %[[B_REL_DISCR:.+]] = xor i8 %b, -128 + // CHECK: %[[B_IS_NICHE:.+]] = icmp slt i8 %b, 0 // LLVM20: %[[B_DISCR:.+]] = select i1 %[[B_IS_NICHE]], i8 %[[B_REL_DISCR]], i8 1 // LLVM21: %[[A_DISCR:.+]] = select i1 %[[A_IS_NICHE]], i8 %a, i8 -127 @@ -166,21 +175,25 @@ pub fn mid_ac_eq_discr(a: Mid<AC>, b: Mid<AC>) -> bool { pub fn mid_giant_eq_discr(a: Mid<Giant>, b: Mid<Giant>) -> bool { // CHECK-LABEL: @mid_giant_eq_discr( + // CHECK: %[[A_NOT_HOLE:.+]] = icmp ne i128 %a, 6 + // CHECK: tail call void @llvm.assume(i1 %[[A_NOT_HOLE]]) // CHECK: %[[A_TRUNC:.+]] = trunc nuw nsw i128 %a to i64 - // CHECK: %[[A_REL_DISCR:.+]] = add nsw i64 %[[A_TRUNC]], -5 + // LLVM20: %[[A_REL_DISCR:.+]] = add nsw i64 %[[A_TRUNC]], -5 // CHECK: %[[A_IS_NICHE:.+]] = icmp samesign ugt i128 %a, 4 - // CHECK: %[[A_NOT_HOLE:.+]] = icmp ne i64 %[[A_REL_DISCR]], 1 - // CHECK: tail call void @llvm.assume(i1 %[[A_NOT_HOLE]]) - // CHECK: %[[A_DISCR:.+]] = select i1 %[[A_IS_NICHE]], i64 %[[A_REL_DISCR]], i64 1 + // LLVM20: %[[A_DISCR:.+]] = select i1 %[[A_IS_NICHE]], i64 %[[A_REL_DISCR]], i64 1 + // CHECK: %[[B_NOT_HOLE:.+]] = icmp ne i128 %b, 6 + // CHECK: tail call void @llvm.assume(i1 %[[B_NOT_HOLE]]) // CHECK: %[[B_TRUNC:.+]] = trunc nuw nsw i128 %b to i64 - // CHECK: %[[B_REL_DISCR:.+]] = add nsw i64 %[[B_TRUNC]], -5 + // LLVM20: %[[B_REL_DISCR:.+]] = add nsw i64 %[[B_TRUNC]], -5 // CHECK: %[[B_IS_NICHE:.+]] = icmp samesign ugt i128 %b, 4 - // CHECK: %[[B_NOT_HOLE:.+]] = icmp ne i64 %[[B_REL_DISCR]], 1 - // CHECK: tail call void @llvm.assume(i1 %[[B_NOT_HOLE]]) - // CHECK: %[[B_DISCR:.+]] = select i1 %[[B_IS_NICHE]], i64 %[[B_REL_DISCR]], i64 1 + // LLVM20: %[[B_DISCR:.+]] = select i1 %[[B_IS_NICHE]], i64 %[[B_REL_DISCR]], i64 1 + + // LLVM21: %[[A_MODIFIED_TAG:.+]] = select i1 %[[A_IS_NICHE]], i64 %[[A_TRUNC]], i64 6 + // LLVM21: %[[B_MODIFIED_TAG:.+]] = select i1 %[[B_IS_NICHE]], i64 %[[B_TRUNC]], i64 6 + // LLVM21: %[[R:.+]] = icmp eq i64 %[[A_MODIFIED_TAG]], %[[B_MODIFIED_TAG]] - // CHECK: %[[R:.+]] = icmp eq i64 %[[A_DISCR]], %[[B_DISCR]] + // LLVM20: %[[R:.+]] = icmp eq i64 %[[A_DISCR]], %[[B_DISCR]] // CHECK: ret i1 %[[R]] discriminant_value(&a) == discriminant_value(&b) } diff --git a/tests/codegen-llvm/enum/enum-match.rs b/tests/codegen-llvm/enum/enum-match.rs index 57db44ec74e..091c4e9adf4 100644 --- a/tests/codegen-llvm/enum/enum-match.rs +++ b/tests/codegen-llvm/enum/enum-match.rs @@ -138,18 +138,18 @@ pub fn match3(e: Option<&u8>) -> i16 { #[derive(PartialEq)] pub enum MiddleNiche { - A, - B, - C(bool), - D, - E, + A, // tag 2 + B, // tag 3 + C(bool), // untagged + D, // tag 5 + E, // tag 6 } // CHECK-LABEL: define{{( dso_local)?}} noundef{{( range\(i8 -?[0-9]+, -?[0-9]+\))?}} i8 @match4(i8{{.+}}%0) // CHECK-NEXT: start: -// CHECK-NEXT: %[[REL_VAR:.+]] = add{{( nsw)?}} i8 %0, -2 -// CHECK-NEXT: %[[NOT_IMPOSSIBLE:.+]] = icmp ne i8 %[[REL_VAR]], 2 +// CHECK-NEXT: %[[NOT_IMPOSSIBLE:.+]] = icmp ne i8 %0, 4 // CHECK-NEXT: call void @llvm.assume(i1 %[[NOT_IMPOSSIBLE]]) +// CHECK-NEXT: %[[REL_VAR:.+]] = add{{( nsw)?}} i8 %0, -2 // CHECK-NEXT: %[[NOT_NICHE:.+]] = icmp{{( samesign)?}} ult i8 %0, 2 // CHECK-NEXT: %[[DISCR:.+]] = select i1 %[[NOT_NICHE]], i8 2, i8 %[[REL_VAR]] // CHECK-NEXT: switch i8 %[[DISCR]] @@ -443,19 +443,19 @@ pub enum HugeVariantIndex { V255(Never), V256(Never), - Possible257, - Bool258(bool), - Possible259, + Possible257, // tag 2 + Bool258(bool), // untagged + Possible259, // tag 4 } // CHECK-LABEL: define{{( dso_local)?}} noundef{{( range\(i8 [0-9]+, [0-9]+\))?}} i8 @match5(i8{{.+}}%0) // CHECK-NEXT: start: +// CHECK-NEXT: %[[NOT_IMPOSSIBLE:.+]] = icmp ne i8 %0, 3 +// CHECK-NEXT: call void @llvm.assume(i1 %[[NOT_IMPOSSIBLE]]) // CHECK-NEXT: %[[REL_VAR:.+]] = add{{( nsw)?}} i8 %0, -2 // CHECK-NEXT: %[[REL_VAR_WIDE:.+]] = zext i8 %[[REL_VAR]] to i64 // CHECK-NEXT: %[[IS_NICHE:.+]] = icmp{{( samesign)?}} ugt i8 %0, 1 // CHECK-NEXT: %[[NICHE_DISCR:.+]] = add nuw nsw i64 %[[REL_VAR_WIDE]], 257 -// CHECK-NEXT: %[[NOT_IMPOSSIBLE:.+]] = icmp ne i64 %[[NICHE_DISCR]], 258 -// CHECK-NEXT: call void @llvm.assume(i1 %[[NOT_IMPOSSIBLE]]) // CHECK-NEXT: %[[DISCR:.+]] = select i1 %[[IS_NICHE]], i64 %[[NICHE_DISCR]], i64 258 // CHECK-NEXT: switch i64 %[[DISCR]], // CHECK-NEXT: i64 257, diff --git a/tests/codegen-llvm/function-arguments.rs b/tests/codegen-llvm/function-arguments.rs index c8cd8526ae5..a3fafbe6f82 100644 --- a/tests/codegen-llvm/function-arguments.rs +++ b/tests/codegen-llvm/function-arguments.rs @@ -134,7 +134,7 @@ pub fn mutable_notunpin_borrow(_: &mut NotUnpin) {} #[no_mangle] pub fn notunpin_borrow(_: &NotUnpin) {} -// CHECK: @indirect_struct(ptr noalias{{( nocapture)?}} noundef readonly align 4{{( captures\(none\))?}} dereferenceable(32) %_1) +// CHECK: @indirect_struct(ptr{{( dead_on_return)?}} noalias{{( nocapture)?}} noundef readonly align 4{{( captures\(none\))?}} dereferenceable(32) %_1) #[no_mangle] pub fn indirect_struct(_: S) {} diff --git a/tests/codegen-llvm/gdb_debug_script_load.rs b/tests/codegen-llvm/gdb_debug_script_load.rs index 90f2be41cf2..3e92eba10b1 100644 --- a/tests/codegen-llvm/gdb_debug_script_load.rs +++ b/tests/codegen-llvm/gdb_debug_script_load.rs @@ -9,8 +9,6 @@ #![feature(lang_items)] #![no_std] -// CHECK: @llvm.used = {{.+}} @__rustc_debug_gdb_scripts_section - #[panic_handler] fn panic_handler(_: &core::panic::PanicInfo) -> ! { loop {} @@ -24,7 +22,7 @@ extern "C" fn rust_eh_personality() { // Needs rustc to generate `main` as that's where the magic load is inserted. // IOW, we cannot write this test with `#![no_main]`. // CHECK-LABEL: @main -// CHECK: load volatile i8, {{.+}} @__rustc_debug_gdb_scripts_section +// CHECK: load volatile i8, {{.+}} @__rustc_debug_gdb_scripts_section__ #[lang = "start"] fn lang_start<T: 'static>( diff --git a/tests/codegen-llvm/intrinsics/transmute-simd.rs b/tests/codegen-llvm/intrinsics/transmute-simd.rs index e34b27e1333..92af16945ab 100644 --- a/tests/codegen-llvm/intrinsics/transmute-simd.rs +++ b/tests/codegen-llvm/intrinsics/transmute-simd.rs @@ -97,10 +97,10 @@ pub extern "C" fn float_ptr_same_lanes(v: f64x2) -> PtrX2 { // CHECK-NOT: alloca // CHECK: %[[TEMP:.+]] = alloca [16 x i8] // CHECK-NOT: alloca - // CHECK: call void @llvm.lifetime.start.p0(i64 16, ptr %[[TEMP]]) + // CHECK: call void @llvm.lifetime.start.p0({{(i64 16, )?}}ptr %[[TEMP]]) // CHECK: store <2 x double> %v, ptr %[[TEMP]] // CHECK: %[[RET:.+]] = load <2 x ptr>, ptr %[[TEMP]] - // CHECK: call void @llvm.lifetime.end.p0(i64 16, ptr %[[TEMP]]) + // CHECK: call void @llvm.lifetime.end.p0({{(i64 16, )?}}ptr %[[TEMP]]) // CHECK: ret <2 x ptr> %[[RET]] unsafe { transmute(v) } } @@ -111,10 +111,10 @@ pub extern "C" fn ptr_float_same_lanes(v: PtrX2) -> f64x2 { // CHECK-NOT: alloca // CHECK: %[[TEMP:.+]] = alloca [16 x i8] // CHECK-NOT: alloca - // CHECK: call void @llvm.lifetime.start.p0(i64 16, ptr %[[TEMP]]) + // CHECK: call void @llvm.lifetime.start.p0({{(i64 16, )?}}ptr %[[TEMP]]) // CHECK: store <2 x ptr> %v, ptr %[[TEMP]] // CHECK: %[[RET:.+]] = load <2 x double>, ptr %[[TEMP]] - // CHECK: call void @llvm.lifetime.end.p0(i64 16, ptr %[[TEMP]]) + // CHECK: call void @llvm.lifetime.end.p0({{(i64 16, )?}}ptr %[[TEMP]]) // CHECK: ret <2 x double> %[[RET]] unsafe { transmute(v) } } @@ -125,10 +125,10 @@ pub extern "C" fn int_ptr_same_lanes(v: i64x2) -> PtrX2 { // CHECK-NOT: alloca // CHECK: %[[TEMP:.+]] = alloca [16 x i8] // CHECK-NOT: alloca - // CHECK: call void @llvm.lifetime.start.p0(i64 16, ptr %[[TEMP]]) + // CHECK: call void @llvm.lifetime.start.p0({{(i64 16, )?}}ptr %[[TEMP]]) // CHECK: store <2 x i64> %v, ptr %[[TEMP]] // CHECK: %[[RET:.+]] = load <2 x ptr>, ptr %[[TEMP]] - // CHECK: call void @llvm.lifetime.end.p0(i64 16, ptr %[[TEMP]]) + // CHECK: call void @llvm.lifetime.end.p0({{(i64 16, )?}}ptr %[[TEMP]]) // CHECK: ret <2 x ptr> %[[RET]] unsafe { transmute(v) } } @@ -139,10 +139,10 @@ pub extern "C" fn ptr_int_same_lanes(v: PtrX2) -> i64x2 { // CHECK-NOT: alloca // CHECK: %[[TEMP:.+]] = alloca [16 x i8] // CHECK-NOT: alloca - // CHECK: call void @llvm.lifetime.start.p0(i64 16, ptr %[[TEMP]]) + // CHECK: call void @llvm.lifetime.start.p0({{(i64 16, )?}}ptr %[[TEMP]]) // CHECK: store <2 x ptr> %v, ptr %[[TEMP]] // CHECK: %[[RET:.+]] = load <2 x i64>, ptr %[[TEMP]] - // CHECK: call void @llvm.lifetime.end.p0(i64 16, ptr %[[TEMP]]) + // CHECK: call void @llvm.lifetime.end.p0({{(i64 16, )?}}ptr %[[TEMP]]) // CHECK: ret <2 x i64> %[[RET]] unsafe { transmute(v) } } @@ -153,10 +153,10 @@ pub extern "C" fn float_ptr_widen(v: f32x4) -> PtrX2 { // CHECK-NOT: alloca // CHECK: %[[TEMP:.+]] = alloca [16 x i8] // CHECK-NOT: alloca - // CHECK: call void @llvm.lifetime.start.p0(i64 16, ptr %[[TEMP]]) + // CHECK: call void @llvm.lifetime.start.p0({{(i64 16, )?}}ptr %[[TEMP]]) // CHECK: store <4 x float> %v, ptr %[[TEMP]] // CHECK: %[[RET:.+]] = load <2 x ptr>, ptr %[[TEMP]] - // CHECK: call void @llvm.lifetime.end.p0(i64 16, ptr %[[TEMP]]) + // CHECK: call void @llvm.lifetime.end.p0({{(i64 16, )?}}ptr %[[TEMP]]) // CHECK: ret <2 x ptr> %[[RET]] unsafe { transmute(v) } } @@ -167,10 +167,10 @@ pub extern "C" fn int_ptr_widen(v: i32x4) -> PtrX2 { // CHECK-NOT: alloca // CHECK: %[[TEMP:.+]] = alloca [16 x i8] // CHECK-NOT: alloca - // CHECK: call void @llvm.lifetime.start.p0(i64 16, ptr %[[TEMP]]) + // CHECK: call void @llvm.lifetime.start.p0({{(i64 16, )?}}ptr %[[TEMP]]) // CHECK: store <4 x i32> %v, ptr %[[TEMP]] // CHECK: %[[RET:.+]] = load <2 x ptr>, ptr %[[TEMP]] - // CHECK: call void @llvm.lifetime.end.p0(i64 16, ptr %[[TEMP]]) + // CHECK: call void @llvm.lifetime.end.p0({{(i64 16, )?}}ptr %[[TEMP]]) // CHECK: ret <2 x ptr> %[[RET]] unsafe { transmute(v) } } diff --git a/tests/codegen-llvm/intrinsics/transmute.rs b/tests/codegen-llvm/intrinsics/transmute.rs index 91cff38773d..e327c100d7d 100644 --- a/tests/codegen-llvm/intrinsics/transmute.rs +++ b/tests/codegen-llvm/intrinsics/transmute.rs @@ -192,12 +192,12 @@ pub unsafe fn check_byte_from_bool(x: bool) -> u8 { #[no_mangle] pub unsafe fn check_to_pair(x: u64) -> Option<i32> { // CHECK: %[[TEMP:.+]] = alloca [8 x i8], align 8 - // CHECK: call void @llvm.lifetime.start.p0(i64 8, ptr %[[TEMP]]) + // CHECK: call void @llvm.lifetime.start.p0({{(i64 8, )?}}ptr %[[TEMP]]) // CHECK: store i64 %x, ptr %[[TEMP]], align 8 // CHECK: %[[PAIR0:.+]] = load i32, ptr %[[TEMP]], align 8 // CHECK: %[[PAIR1P:.+]] = getelementptr inbounds i8, ptr %[[TEMP]], i64 4 // CHECK: %[[PAIR1:.+]] = load i32, ptr %[[PAIR1P]], align 4 - // CHECK: call void @llvm.lifetime.end.p0(i64 8, ptr %[[TEMP]]) + // CHECK: call void @llvm.lifetime.end.p0({{(i64 8, )?}}ptr %[[TEMP]]) // CHECK: insertvalue {{.+}}, i32 %[[PAIR0]], 0 // CHECK: insertvalue {{.+}}, i32 %[[PAIR1]], 1 transmute(x) @@ -207,12 +207,12 @@ pub unsafe fn check_to_pair(x: u64) -> Option<i32> { #[no_mangle] pub unsafe fn check_from_pair(x: Option<i32>) -> u64 { // CHECK: %[[TEMP:.+]] = alloca [8 x i8], align 8 - // CHECK: call void @llvm.lifetime.start.p0(i64 8, ptr %[[TEMP]]) + // CHECK: call void @llvm.lifetime.start.p0({{(i64 8, )?}}ptr %[[TEMP]]) // CHECK: store i32 %x.0, ptr %[[TEMP]], align 8 // CHECK: %[[PAIR1P:.+]] = getelementptr inbounds i8, ptr %[[TEMP]], i64 4 // CHECK: store i32 %x.1, ptr %[[PAIR1P]], align 4 // CHECK: %[[R:.+]] = load i64, ptr %[[TEMP]], align 8 - // CHECK: call void @llvm.lifetime.end.p0(i64 8, ptr %[[TEMP]]) + // CHECK: call void @llvm.lifetime.end.p0({{(i64 8, )?}}ptr %[[TEMP]]) // CHECK: ret i64 %[[R]] transmute(x) } diff --git a/tests/codegen-llvm/issues/issue-105386-ub-in-debuginfo.rs b/tests/codegen-llvm/issues/issue-105386-ub-in-debuginfo.rs index 848aa910b58..95e70bf5678 100644 --- a/tests/codegen-llvm/issues/issue-105386-ub-in-debuginfo.rs +++ b/tests/codegen-llvm/issues/issue-105386-ub-in-debuginfo.rs @@ -19,6 +19,6 @@ pub fn outer_function(x: S, y: S) -> usize { // CHECK: [[spill:%.*]] = alloca // CHECK-NOT: [[ptr_tmp:%.*]] = getelementptr inbounds i8, ptr [[spill]] // CHECK-NOT: [[load:%.*]] = load ptr, ptr -// CHECK: call void @llvm.lifetime.start{{.*}}({{.*}}, ptr [[spill]]) +// CHECK: call void @llvm.lifetime.start{{.*}}({{(.*, )?}}ptr [[spill]]) // CHECK: [[inner:%.*]] = getelementptr inbounds i8, ptr [[spill]] // CHECK: call void @llvm.memcpy{{.*}}(ptr {{align .*}} [[inner]], ptr {{align .*}} %x diff --git a/tests/codegen-llvm/issues/saturating-sub-index-139759.rs b/tests/codegen-llvm/issues/saturating-sub-index-139759.rs new file mode 100644 index 00000000000..eac2f4d306b --- /dev/null +++ b/tests/codegen-llvm/issues/saturating-sub-index-139759.rs @@ -0,0 +1,19 @@ +// Test that calculating an index with saturating subtraction from an in-bounds +// index doesn't generate another bounds check. + +//@ compile-flags: -Copt-level=3 +//@ min-llvm-version: 21 + +#![crate_type = "lib"] + +// CHECK-LABEL: @bounds_check_is_elided +#[no_mangle] +pub fn bounds_check_is_elided(s: &[i32], index: usize) -> i32 { + // CHECK-NOT: panic_bounds_check + if index < s.len() { + let lower_bound = index.saturating_sub(1); + s[lower_bound] + } else { + -1 + } +} diff --git a/tests/codegen-llvm/lifetime_start_end.rs b/tests/codegen-llvm/lifetime_start_end.rs index 0639e7640aa..2df5acf54df 100644 --- a/tests/codegen-llvm/lifetime_start_end.rs +++ b/tests/codegen-llvm/lifetime_start_end.rs @@ -8,27 +8,27 @@ pub fn test() { let a = 0u8; &a; // keep variable in an alloca - // CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, ptr %a) + // CHECK: call void @llvm.lifetime.start{{.*}}({{(i[0-9 ]+, )?}}ptr %a) { let b = &Some(a); &b; // keep variable in an alloca - // CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, {{.*}}) + // CHECK: call void @llvm.lifetime.start{{.*}}({{(i[0-9 ]+, )?}}{{.*}}) - // CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, {{.*}}) + // CHECK: call void @llvm.lifetime.start{{.*}}({{(i[0-9 ]+, )?}}{{.*}}) - // CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, {{.*}}) + // CHECK: call void @llvm.lifetime.end{{.*}}({{(i[0-9 ]+, )?}}{{.*}}) - // CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, {{.*}}) + // CHECK: call void @llvm.lifetime.end{{.*}}({{(i[0-9 ]+, )?}}{{.*}}) } let c = 1u8; &c; // keep variable in an alloca - // CHECK: call void @llvm.lifetime.start{{.*}}(i{{[0-9 ]+}}, ptr %c) + // CHECK: call void @llvm.lifetime.start{{.*}}({{(i[0-9 ]+, )?}}ptr %c) - // CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, ptr %c) + // CHECK: call void @llvm.lifetime.end{{.*}}({{(i[0-9 ]+, )?}}ptr %c) - // CHECK: call void @llvm.lifetime.end{{.*}}(i{{[0-9 ]+}}, ptr %a) + // CHECK: call void @llvm.lifetime.end{{.*}}({{(i[0-9 ]+, )?}}ptr %a) } diff --git a/tests/codegen-llvm/loongarch-abi/loongarch64-lp64d-abi.rs b/tests/codegen-llvm/loongarch-abi/loongarch64-lp64d-abi.rs index 93c8d60930b..4666342a16a 100644 --- a/tests/codegen-llvm/loongarch-abi/loongarch64-lp64d-abi.rs +++ b/tests/codegen-llvm/loongarch-abi/loongarch64-lp64d-abi.rs @@ -256,7 +256,7 @@ pub struct IntDoubleInt { c: i32, } -// CHECK: define void @f_int_double_int_s_arg(ptr noalias{{( nocapture)?}} noundef align 8{{( captures\(none\))?}} dereferenceable(24) %a) +// CHECK: define void @f_int_double_int_s_arg(ptr{{( dead_on_return)?}} noalias{{( nocapture)?}} noundef align 8{{( captures\(none\))?}} dereferenceable(24) %a) #[no_mangle] pub extern "C" fn f_int_double_int_s_arg(a: IntDoubleInt) {} diff --git a/tests/codegen-llvm/sanitizer/cfi/external_weak_symbols.rs b/tests/codegen-llvm/sanitizer/cfi/external_weak_symbols.rs index 00e9b5029af..b3cb6dfdd37 100644 --- a/tests/codegen-llvm/sanitizer/cfi/external_weak_symbols.rs +++ b/tests/codegen-llvm/sanitizer/cfi/external_weak_symbols.rs @@ -10,7 +10,7 @@ unsafe extern "C" { #[linkage = "extern_weak"] static FOO: Option<unsafe extern "C" fn(f64) -> ()>; } -// CHECK: @_rust_extern_with_linkage_FOO = internal global ptr @FOO +// CHECK: @_rust_extern_with_linkage_{{.*}}_FOO = internal global ptr @FOO fn main() { unsafe { diff --git a/tests/codegen-llvm/uninhabited-transparent-return-abi.rs b/tests/codegen-llvm/uninhabited-transparent-return-abi.rs index face1577c3f..83d9a7a32ab 100644 --- a/tests/codegen-llvm/uninhabited-transparent-return-abi.rs +++ b/tests/codegen-llvm/uninhabited-transparent-return-abi.rs @@ -23,7 +23,7 @@ extern "Rust" { #[no_mangle] pub fn test_uninhabited_ret_by_ref() { // CHECK: %_1 = alloca [24 x i8], align {{8|4}} - // CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %_1) + // CHECK-NEXT: call void @llvm.lifetime.start.p0({{(i64 24, )?}}ptr nonnull %_1) // CHECK-NEXT: call void @opaque({{.*}} sret([24 x i8]) {{.*}} %_1) #2 // CHECK-NEXT: unreachable unsafe { @@ -35,7 +35,7 @@ pub fn test_uninhabited_ret_by_ref() { #[no_mangle] pub fn test_uninhabited_ret_by_ref_with_arg(rsi: u32) { // CHECK: %_2 = alloca [24 x i8], align {{8|4}} - // CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %_2) + // CHECK-NEXT: call void @llvm.lifetime.start.p0({{(i64 24, )?}}ptr nonnull %_2) // CHECK-NEXT: call void @opaque_with_arg({{.*}} sret([24 x i8]) {{.*}} %_2, i32 noundef %rsi) #2 // CHECK-NEXT: unreachable unsafe { diff --git a/tests/coverage/mcdc/condition-limit.cov-map b/tests/coverage/mcdc/condition-limit.cov-map deleted file mode 100644 index ffee97cfbc5..00000000000 --- a/tests/coverage/mcdc/condition-limit.cov-map +++ /dev/null @@ -1,58 +0,0 @@ -Function name: condition_limit::accept_7_conditions -Raw bytes (192): 0x[01, 01, 08, 01, 05, 05, 09, 09, 0d, 0d, 11, 11, 15, 15, 19, 19, 1d, 01, 1d, 1b, 01, 06, 01, 00, 2c, 01, 01, 0a, 00, 0b, 01, 00, 0d, 00, 0e, 01, 00, 10, 00, 11, 01, 00, 13, 00, 14, 01, 00, 16, 00, 17, 01, 00, 19, 00, 1a, 01, 00, 1c, 00, 1d, 01, 00, 21, 00, 29, 01, 01, 08, 00, 09, 28, 08, 07, 00, 08, 00, 27, 30, 05, 02, 01, 07, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 09, 06, 07, 06, 00, 00, 0d, 00, 0e, 09, 00, 12, 00, 13, 30, 0d, 0a, 06, 05, 00, 00, 12, 00, 13, 0d, 00, 17, 00, 18, 30, 11, 0e, 05, 04, 00, 00, 17, 00, 18, 11, 00, 1c, 00, 1d, 30, 15, 12, 04, 03, 00, 00, 1c, 00, 1d, 15, 00, 21, 00, 22, 30, 19, 16, 03, 02, 00, 00, 21, 00, 22, 19, 00, 26, 00, 27, 30, 1d, 1a, 02, 00, 00, 00, 26, 00, 27, 1d, 00, 28, 02, 06, 1e, 02, 05, 00, 06, 01, 01, 01, 00, 02] -Number of files: 1 -- file 0 => $DIR/condition-limit.rs -Number of expressions: 8 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Counter(2) -- expression 2 operands: lhs = Counter(2), rhs = Counter(3) -- expression 3 operands: lhs = Counter(3), rhs = Counter(4) -- expression 4 operands: lhs = Counter(4), rhs = Counter(5) -- expression 5 operands: lhs = Counter(5), rhs = Counter(6) -- expression 6 operands: lhs = Counter(6), rhs = Counter(7) -- expression 7 operands: lhs = Counter(0), rhs = Counter(7) -Number of file 0 mappings: 27 -- Code(Counter(0)) at (prev + 6, 1) to (start + 0, 44) -- Code(Counter(0)) at (prev + 1, 10) to (start + 0, 11) -- Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14) -- Code(Counter(0)) at (prev + 0, 16) to (start + 0, 17) -- Code(Counter(0)) at (prev + 0, 19) to (start + 0, 20) -- Code(Counter(0)) at (prev + 0, 22) to (start + 0, 23) -- Code(Counter(0)) at (prev + 0, 25) to (start + 0, 26) -- Code(Counter(0)) at (prev + 0, 28) to (start + 0, 29) -- Code(Counter(0)) at (prev + 0, 33) to (start + 0, 41) -- Code(Counter(0)) at (prev + 1, 8) to (start + 0, 9) -- MCDCDecision { bitmap_idx: 8, conditions_num: 7 } at (prev + 0, 8) to (start + 0, 39) -- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 7, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9) - true = c1 - false = (c0 - c1) -- Code(Counter(1)) at (prev + 0, 13) to (start + 0, 14) -- MCDCBranch { true: Counter(2), false: Expression(1, Sub), condition_id: 7, true_next_id: 6, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 14) - true = c2 - false = (c1 - c2) -- Code(Counter(2)) at (prev + 0, 18) to (start + 0, 19) -- MCDCBranch { true: Counter(3), false: Expression(2, Sub), condition_id: 6, true_next_id: 5, false_next_id: 0 } at (prev + 0, 18) to (start + 0, 19) - true = c3 - false = (c2 - c3) -- Code(Counter(3)) at (prev + 0, 23) to (start + 0, 24) -- MCDCBranch { true: Counter(4), false: Expression(3, Sub), condition_id: 5, true_next_id: 4, false_next_id: 0 } at (prev + 0, 23) to (start + 0, 24) - true = c4 - false = (c3 - c4) -- Code(Counter(4)) at (prev + 0, 28) to (start + 0, 29) -- MCDCBranch { true: Counter(5), false: Expression(4, Sub), condition_id: 4, true_next_id: 3, false_next_id: 0 } at (prev + 0, 28) to (start + 0, 29) - true = c5 - false = (c4 - c5) -- Code(Counter(5)) at (prev + 0, 33) to (start + 0, 34) -- MCDCBranch { true: Counter(6), false: Expression(5, Sub), condition_id: 3, true_next_id: 2, false_next_id: 0 } at (prev + 0, 33) to (start + 0, 34) - true = c6 - false = (c5 - c6) -- Code(Counter(6)) at (prev + 0, 38) to (start + 0, 39) -- MCDCBranch { true: Counter(7), false: Expression(6, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 38) to (start + 0, 39) - true = c7 - false = (c6 - c7) -- Code(Counter(7)) at (prev + 0, 40) to (start + 2, 6) -- Code(Expression(7, Sub)) at (prev + 2, 5) to (start + 0, 6) - = (c0 - c7) -- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) -Highest counter ID seen: c7 - diff --git a/tests/coverage/mcdc/condition-limit.coverage b/tests/coverage/mcdc/condition-limit.coverage deleted file mode 100644 index 04ccd6497c3..00000000000 --- a/tests/coverage/mcdc/condition-limit.coverage +++ /dev/null @@ -1,55 +0,0 @@ - LL| |#![feature(coverage_attribute)] - LL| |//@ edition: 2021 - LL| |//@ compile-flags: -Zcoverage-options=mcdc - LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc - LL| | - LL| 2|fn accept_7_conditions(bool_arr: [bool; 7]) { - LL| 2| let [a, b, c, d, e, f, g] = bool_arr; - LL| 2| if a && b && c && d && e && f && g { - ^1 ^1 ^1 ^1 ^1 ^1 - ------------------ - | Branch (LL:8): [True: 1, False: 1] - | Branch (LL:13): [True: 1, False: 0] - | Branch (LL:18): [True: 1, False: 0] - | Branch (LL:23): [True: 1, False: 0] - | Branch (LL:28): [True: 1, False: 0] - | Branch (LL:33): [True: 1, False: 0] - | Branch (LL:38): [True: 1, False: 0] - ------------------ - |---> MC/DC Decision Region (LL:8) to (LL:39) - | - | Number of Conditions: 7 - | Condition C1 --> (LL:8) - | Condition C2 --> (LL:13) - | Condition C3 --> (LL:18) - | Condition C4 --> (LL:23) - | Condition C5 --> (LL:28) - | Condition C6 --> (LL:33) - | Condition C7 --> (LL:38) - | - | Executed MC/DC Test Vectors: - | - | C1, C2, C3, C4, C5, C6, C7 Result - | 1 { F, -, -, -, -, -, - = F } - | 2 { T, T, T, T, T, T, T = T } - | - | C1-Pair: covered: (1,2) - | C2-Pair: not covered - | C3-Pair: not covered - | C4-Pair: not covered - | C5-Pair: not covered - | C6-Pair: not covered - | C7-Pair: not covered - | MC/DC Coverage for Decision: 14.29% - | - ------------------ - LL| 1| core::hint::black_box("hello"); - LL| 1| } - LL| 2|} - LL| | - LL| |#[coverage(off)] - LL| |fn main() { - LL| | accept_7_conditions([false; 7]); - LL| | accept_7_conditions([true; 7]); - LL| |} - diff --git a/tests/coverage/mcdc/condition-limit.rs b/tests/coverage/mcdc/condition-limit.rs deleted file mode 100644 index 867636cdaed..00000000000 --- a/tests/coverage/mcdc/condition-limit.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![feature(coverage_attribute)] -//@ edition: 2021 -//@ compile-flags: -Zcoverage-options=mcdc -//@ llvm-cov-flags: --show-branches=count --show-mcdc - -fn accept_7_conditions(bool_arr: [bool; 7]) { - let [a, b, c, d, e, f, g] = bool_arr; - if a && b && c && d && e && f && g { - core::hint::black_box("hello"); - } -} - -#[coverage(off)] -fn main() { - accept_7_conditions([false; 7]); - accept_7_conditions([true; 7]); -} diff --git a/tests/coverage/mcdc/if.cov-map b/tests/coverage/mcdc/if.cov-map deleted file mode 100644 index dac1eb4c94b..00000000000 --- a/tests/coverage/mcdc/if.cov-map +++ /dev/null @@ -1,223 +0,0 @@ -Function name: if::mcdc_check_a -Raw bytes (67): 0x[01, 01, 03, 01, 05, 05, 09, 01, 09, 09, 01, 0e, 01, 00, 22, 01, 01, 08, 00, 09, 28, 03, 02, 00, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 09, 06, 02, 00, 00, 00, 0d, 00, 0e, 09, 00, 0f, 02, 06, 0a, 02, 0c, 02, 06, 01, 03, 01, 00, 02] -Number of files: 1 -- file 0 => $DIR/if.rs -Number of expressions: 3 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Counter(2) -- expression 2 operands: lhs = Counter(0), rhs = Counter(2) -Number of file 0 mappings: 9 -- Code(Counter(0)) at (prev + 14, 1) to (start + 0, 34) -- Code(Counter(0)) at (prev + 1, 8) to (start + 0, 9) -- MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 0, 8) to (start + 0, 14) -- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9) - true = c1 - false = (c0 - c1) -- Code(Counter(1)) at (prev + 0, 13) to (start + 0, 14) -- MCDCBranch { true: Counter(2), false: Expression(1, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 14) - true = c2 - false = (c1 - c2) -- Code(Counter(2)) at (prev + 0, 15) to (start + 2, 6) -- Code(Expression(2, Sub)) at (prev + 2, 12) to (start + 2, 6) - = (c0 - c2) -- Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2) -Highest counter ID seen: c2 - -Function name: if::mcdc_check_b -Raw bytes (67): 0x[01, 01, 03, 01, 05, 05, 09, 01, 09, 09, 01, 16, 01, 00, 22, 01, 01, 08, 00, 09, 28, 03, 02, 00, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 09, 06, 02, 00, 00, 00, 0d, 00, 0e, 09, 00, 0f, 02, 06, 0a, 02, 0c, 02, 06, 01, 03, 01, 00, 02] -Number of files: 1 -- file 0 => $DIR/if.rs -Number of expressions: 3 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Counter(2) -- expression 2 operands: lhs = Counter(0), rhs = Counter(2) -Number of file 0 mappings: 9 -- Code(Counter(0)) at (prev + 22, 1) to (start + 0, 34) -- Code(Counter(0)) at (prev + 1, 8) to (start + 0, 9) -- MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 0, 8) to (start + 0, 14) -- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9) - true = c1 - false = (c0 - c1) -- Code(Counter(1)) at (prev + 0, 13) to (start + 0, 14) -- MCDCBranch { true: Counter(2), false: Expression(1, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 14) - true = c2 - false = (c1 - c2) -- Code(Counter(2)) at (prev + 0, 15) to (start + 2, 6) -- Code(Expression(2, Sub)) at (prev + 2, 12) to (start + 2, 6) - = (c0 - c2) -- Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2) -Highest counter ID seen: c2 - -Function name: if::mcdc_check_both -Raw bytes (67): 0x[01, 01, 03, 01, 05, 05, 09, 01, 09, 09, 01, 1e, 01, 00, 25, 01, 01, 08, 00, 09, 28, 03, 02, 00, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 09, 06, 02, 00, 00, 00, 0d, 00, 0e, 09, 00, 0f, 02, 06, 0a, 02, 0c, 02, 06, 01, 03, 01, 00, 02] -Number of files: 1 -- file 0 => $DIR/if.rs -Number of expressions: 3 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Counter(2) -- expression 2 operands: lhs = Counter(0), rhs = Counter(2) -Number of file 0 mappings: 9 -- Code(Counter(0)) at (prev + 30, 1) to (start + 0, 37) -- Code(Counter(0)) at (prev + 1, 8) to (start + 0, 9) -- MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 0, 8) to (start + 0, 14) -- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9) - true = c1 - false = (c0 - c1) -- Code(Counter(1)) at (prev + 0, 13) to (start + 0, 14) -- MCDCBranch { true: Counter(2), false: Expression(1, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 14) - true = c2 - false = (c1 - c2) -- Code(Counter(2)) at (prev + 0, 15) to (start + 2, 6) -- Code(Expression(2, Sub)) at (prev + 2, 12) to (start + 2, 6) - = (c0 - c2) -- Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2) -Highest counter ID seen: c2 - -Function name: if::mcdc_check_neither -Raw bytes (67): 0x[01, 01, 03, 01, 05, 05, 09, 01, 09, 09, 01, 06, 01, 00, 28, 01, 01, 08, 00, 09, 28, 03, 02, 00, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 09, 06, 02, 00, 00, 00, 0d, 00, 0e, 09, 00, 0f, 02, 06, 0a, 02, 0c, 02, 06, 01, 03, 01, 00, 02] -Number of files: 1 -- file 0 => $DIR/if.rs -Number of expressions: 3 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Counter(2) -- expression 2 operands: lhs = Counter(0), rhs = Counter(2) -Number of file 0 mappings: 9 -- Code(Counter(0)) at (prev + 6, 1) to (start + 0, 40) -- Code(Counter(0)) at (prev + 1, 8) to (start + 0, 9) -- MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 0, 8) to (start + 0, 14) -- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9) - true = c1 - false = (c0 - c1) -- Code(Counter(1)) at (prev + 0, 13) to (start + 0, 14) -- MCDCBranch { true: Counter(2), false: Expression(1, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 14) - true = c2 - false = (c1 - c2) -- Code(Counter(2)) at (prev + 0, 15) to (start + 2, 6) -- Code(Expression(2, Sub)) at (prev + 2, 12) to (start + 2, 6) - = (c0 - c2) -- Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2) -Highest counter ID seen: c2 - -Function name: if::mcdc_check_not_tree_decision -Raw bytes (90): 0x[01, 01, 07, 01, 05, 01, 17, 05, 09, 05, 09, 17, 0d, 05, 09, 01, 0d, 0b, 01, 30, 01, 00, 3b, 28, 05, 03, 03, 08, 00, 15, 01, 00, 09, 00, 0a, 30, 05, 02, 01, 02, 03, 00, 09, 00, 0a, 02, 00, 0e, 00, 0f, 30, 09, 06, 03, 02, 00, 00, 0e, 00, 0f, 17, 00, 14, 00, 15, 30, 0d, 12, 02, 00, 00, 00, 14, 00, 15, 0d, 00, 16, 02, 06, 1a, 02, 0c, 02, 06, 01, 03, 01, 00, 02] -Number of files: 1 -- file 0 => $DIR/if.rs -Number of expressions: 7 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(0), rhs = Expression(5, Add) -- expression 2 operands: lhs = Counter(1), rhs = Counter(2) -- expression 3 operands: lhs = Counter(1), rhs = Counter(2) -- expression 4 operands: lhs = Expression(5, Add), rhs = Counter(3) -- expression 5 operands: lhs = Counter(1), rhs = Counter(2) -- expression 6 operands: lhs = Counter(0), rhs = Counter(3) -Number of file 0 mappings: 11 -- Code(Counter(0)) at (prev + 48, 1) to (start + 0, 59) -- MCDCDecision { bitmap_idx: 5, conditions_num: 3 } at (prev + 3, 8) to (start + 0, 21) -- Code(Counter(0)) at (prev + 0, 9) to (start + 0, 10) -- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 3 } at (prev + 0, 9) to (start + 0, 10) - true = c1 - false = (c0 - c1) -- Code(Expression(0, Sub)) at (prev + 0, 14) to (start + 0, 15) - = (c0 - c1) -- MCDCBranch { true: Counter(2), false: Expression(1, Sub), condition_id: 3, true_next_id: 2, false_next_id: 0 } at (prev + 0, 14) to (start + 0, 15) - true = c2 - false = (c0 - (c1 + c2)) -- Code(Expression(5, Add)) at (prev + 0, 20) to (start + 0, 21) - = (c1 + c2) -- MCDCBranch { true: Counter(3), false: Expression(4, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 20) to (start + 0, 21) - true = c3 - false = ((c1 + c2) - c3) -- Code(Counter(3)) at (prev + 0, 22) to (start + 2, 6) -- Code(Expression(6, Sub)) at (prev + 2, 12) to (start + 2, 6) - = (c0 - c3) -- Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2) -Highest counter ID seen: c3 - -Function name: if::mcdc_check_tree_decision -Raw bytes (92): 0x[01, 01, 08, 01, 05, 05, 09, 05, 09, 05, 1f, 09, 0d, 09, 0d, 01, 1f, 09, 0d, 0b, 01, 26, 01, 00, 37, 01, 03, 08, 00, 09, 28, 04, 03, 00, 08, 00, 15, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0e, 00, 0f, 30, 09, 0a, 02, 00, 03, 00, 0e, 00, 0f, 0a, 00, 13, 00, 14, 30, 0d, 0e, 03, 00, 00, 00, 13, 00, 14, 1f, 00, 16, 02, 06, 1a, 02, 0c, 02, 06, 01, 03, 01, 00, 02] -Number of files: 1 -- file 0 => $DIR/if.rs -Number of expressions: 8 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Counter(2) -- expression 2 operands: lhs = Counter(1), rhs = Counter(2) -- expression 3 operands: lhs = Counter(1), rhs = Expression(7, Add) -- expression 4 operands: lhs = Counter(2), rhs = Counter(3) -- expression 5 operands: lhs = Counter(2), rhs = Counter(3) -- expression 6 operands: lhs = Counter(0), rhs = Expression(7, Add) -- expression 7 operands: lhs = Counter(2), rhs = Counter(3) -Number of file 0 mappings: 11 -- Code(Counter(0)) at (prev + 38, 1) to (start + 0, 55) -- Code(Counter(0)) at (prev + 3, 8) to (start + 0, 9) -- MCDCDecision { bitmap_idx: 4, conditions_num: 3 } at (prev + 0, 8) to (start + 0, 21) -- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9) - true = c1 - false = (c0 - c1) -- Code(Counter(1)) at (prev + 0, 14) to (start + 0, 15) -- MCDCBranch { true: Counter(2), false: Expression(2, Sub), condition_id: 2, true_next_id: 0, false_next_id: 3 } at (prev + 0, 14) to (start + 0, 15) - true = c2 - false = (c1 - c2) -- Code(Expression(2, Sub)) at (prev + 0, 19) to (start + 0, 20) - = (c1 - c2) -- MCDCBranch { true: Counter(3), false: Expression(3, Sub), condition_id: 3, true_next_id: 0, false_next_id: 0 } at (prev + 0, 19) to (start + 0, 20) - true = c3 - false = (c1 - (c2 + c3)) -- Code(Expression(7, Add)) at (prev + 0, 22) to (start + 2, 6) - = (c2 + c3) -- Code(Expression(6, Sub)) at (prev + 2, 12) to (start + 2, 6) - = (c0 - (c2 + c3)) -- Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2) -Highest counter ID seen: c3 - -Function name: if::mcdc_nested_if -Raw bytes (139): 0x[01, 01, 0d, 01, 05, 01, 33, 05, 09, 05, 09, 05, 09, 05, 09, 33, 0d, 05, 09, 0d, 11, 33, 11, 05, 09, 01, 33, 05, 09, 11, 01, 3a, 01, 00, 2d, 01, 01, 08, 00, 09, 28, 03, 02, 00, 08, 00, 0e, 30, 05, 02, 01, 00, 02, 00, 08, 00, 09, 02, 00, 0d, 00, 0e, 30, 09, 2e, 02, 00, 00, 00, 0d, 00, 0e, 33, 01, 09, 00, 0c, 33, 00, 0d, 00, 15, 33, 01, 0c, 00, 0d, 28, 06, 02, 00, 0c, 00, 12, 30, 0d, 1a, 01, 02, 00, 00, 0c, 00, 0d, 0d, 00, 11, 00, 12, 30, 11, 22, 02, 00, 00, 00, 11, 00, 12, 11, 00, 13, 02, 0a, 26, 02, 09, 00, 0a, 2e, 01, 0c, 02, 06, 01, 03, 01, 00, 02] -Number of files: 1 -- file 0 => $DIR/if.rs -Number of expressions: 13 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(0), rhs = Expression(12, Add) -- expression 2 operands: lhs = Counter(1), rhs = Counter(2) -- expression 3 operands: lhs = Counter(1), rhs = Counter(2) -- expression 4 operands: lhs = Counter(1), rhs = Counter(2) -- expression 5 operands: lhs = Counter(1), rhs = Counter(2) -- expression 6 operands: lhs = Expression(12, Add), rhs = Counter(3) -- expression 7 operands: lhs = Counter(1), rhs = Counter(2) -- expression 8 operands: lhs = Counter(3), rhs = Counter(4) -- expression 9 operands: lhs = Expression(12, Add), rhs = Counter(4) -- expression 10 operands: lhs = Counter(1), rhs = Counter(2) -- expression 11 operands: lhs = Counter(0), rhs = Expression(12, Add) -- expression 12 operands: lhs = Counter(1), rhs = Counter(2) -Number of file 0 mappings: 17 -- Code(Counter(0)) at (prev + 58, 1) to (start + 0, 45) -- Code(Counter(0)) at (prev + 1, 8) to (start + 0, 9) -- MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 0, 8) to (start + 0, 14) -- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 0, false_next_id: 2 } at (prev + 0, 8) to (start + 0, 9) - true = c1 - false = (c0 - c1) -- Code(Expression(0, Sub)) at (prev + 0, 13) to (start + 0, 14) - = (c0 - c1) -- MCDCBranch { true: Counter(2), false: Expression(11, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 14) - true = c2 - false = (c0 - (c1 + c2)) -- Code(Expression(12, Add)) at (prev + 1, 9) to (start + 0, 12) - = (c1 + c2) -- Code(Expression(12, Add)) at (prev + 0, 13) to (start + 0, 21) - = (c1 + c2) -- Code(Expression(12, Add)) at (prev + 1, 12) to (start + 0, 13) - = (c1 + c2) -- MCDCDecision { bitmap_idx: 6, conditions_num: 2 } at (prev + 0, 12) to (start + 0, 18) -- MCDCBranch { true: Counter(3), false: Expression(6, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 12) to (start + 0, 13) - true = c3 - false = ((c1 + c2) - c3) -- Code(Counter(3)) at (prev + 0, 17) to (start + 0, 18) -- MCDCBranch { true: Counter(4), false: Expression(8, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 17) to (start + 0, 18) - true = c4 - false = (c3 - c4) -- Code(Counter(4)) at (prev + 0, 19) to (start + 2, 10) -- Code(Expression(9, Sub)) at (prev + 2, 9) to (start + 0, 10) - = ((c1 + c2) - c4) -- Code(Expression(11, Sub)) at (prev + 1, 12) to (start + 2, 6) - = (c0 - (c1 + c2)) -- Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2) -Highest counter ID seen: c4 - diff --git a/tests/coverage/mcdc/if.coverage b/tests/coverage/mcdc/if.coverage deleted file mode 100644 index fda5525c472..00000000000 --- a/tests/coverage/mcdc/if.coverage +++ /dev/null @@ -1,287 +0,0 @@ - LL| |#![feature(coverage_attribute)] - LL| |//@ edition: 2021 - LL| |//@ compile-flags: -Zcoverage-options=mcdc - LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc - LL| | - LL| 2|fn mcdc_check_neither(a: bool, b: bool) { - LL| 2| if a && b { - ^0 - ------------------ - | Branch (LL:8): [True: 0, False: 2] - | Branch (LL:13): [True: 0, False: 0] - ------------------ - |---> MC/DC Decision Region (LL:8) to (LL:14) - | - | Number of Conditions: 2 - | Condition C1 --> (LL:8) - | Condition C2 --> (LL:13) - | - | Executed MC/DC Test Vectors: - | - | C1, C2 Result - | 1 { F, - = F } - | - | C1-Pair: not covered - | C2-Pair: not covered - | MC/DC Coverage for Decision: 0.00% - | - ------------------ - LL| 0| say("a and b"); - LL| 2| } else { - LL| 2| say("not both"); - LL| 2| } - LL| 2|} - LL| | - LL| 2|fn mcdc_check_a(a: bool, b: bool) { - LL| 2| if a && b { - ^1 - ------------------ - | Branch (LL:8): [True: 1, False: 1] - | Branch (LL:13): [True: 1, False: 0] - ------------------ - |---> MC/DC Decision Region (LL:8) to (LL:14) - | - | Number of Conditions: 2 - | Condition C1 --> (LL:8) - | Condition C2 --> (LL:13) - | - | Executed MC/DC Test Vectors: - | - | C1, C2 Result - | 1 { F, - = F } - | 2 { T, T = T } - | - | C1-Pair: covered: (1,2) - | C2-Pair: not covered - | MC/DC Coverage for Decision: 50.00% - | - ------------------ - LL| 1| say("a and b"); - LL| 1| } else { - LL| 1| say("not both"); - LL| 1| } - LL| 2|} - LL| | - LL| 2|fn mcdc_check_b(a: bool, b: bool) { - LL| 2| if a && b { - ------------------ - | Branch (LL:8): [True: 2, False: 0] - | Branch (LL:13): [True: 1, False: 1] - ------------------ - |---> MC/DC Decision Region (LL:8) to (LL:14) - | - | Number of Conditions: 2 - | Condition C1 --> (LL:8) - | Condition C2 --> (LL:13) - | - | Executed MC/DC Test Vectors: - | - | C1, C2 Result - | 1 { T, F = F } - | 2 { T, T = T } - | - | C1-Pair: not covered - | C2-Pair: covered: (1,2) - | MC/DC Coverage for Decision: 50.00% - | - ------------------ - LL| 1| say("a and b"); - LL| 1| } else { - LL| 1| say("not both"); - LL| 1| } - LL| 2|} - LL| | - LL| 3|fn mcdc_check_both(a: bool, b: bool) { - LL| 3| if a && b { - ^2 - ------------------ - | Branch (LL:8): [True: 2, False: 1] - | Branch (LL:13): [True: 1, False: 1] - ------------------ - |---> MC/DC Decision Region (LL:8) to (LL:14) - | - | Number of Conditions: 2 - | Condition C1 --> (LL:8) - | Condition C2 --> (LL:13) - | - | Executed MC/DC Test Vectors: - | - | C1, C2 Result - | 1 { F, - = F } - | 2 { T, F = F } - | 3 { T, T = T } - | - | C1-Pair: covered: (1,3) - | C2-Pair: covered: (2,3) - | MC/DC Coverage for Decision: 100.00% - | - ------------------ - LL| 1| say("a and b"); - LL| 2| } else { - LL| 2| say("not both"); - LL| 2| } - LL| 3|} - LL| | - LL| 4|fn mcdc_check_tree_decision(a: bool, b: bool, c: bool) { - LL| | // This expression is intentionally written in a way - LL| | // where 100% branch coverage indicates 100% mcdc coverage. - LL| 4| if a && (b || c) { - ^3 ^2 - ------------------ - | Branch (LL:8): [True: 3, False: 1] - | Branch (LL:14): [True: 1, False: 2] - | Branch (LL:19): [True: 1, False: 1] - ------------------ - |---> MC/DC Decision Region (LL:8) to (LL:21) - | - | Number of Conditions: 3 - | Condition C1 --> (LL:8) - | Condition C2 --> (LL:14) - | Condition C3 --> (LL:19) - | - | Executed MC/DC Test Vectors: - | - | C1, C2, C3 Result - | 1 { F, -, - = F } - | 2 { T, F, F = F } - | 3 { T, F, T = T } - | 4 { T, T, - = T } - | - | C1-Pair: covered: (1,3) - | C2-Pair: covered: (2,4) - | C3-Pair: covered: (2,3) - | MC/DC Coverage for Decision: 100.00% - | - ------------------ - LL| 2| say("pass"); - LL| 2| } else { - LL| 2| say("reject"); - LL| 2| } - LL| 4|} - LL| | - LL| 4|fn mcdc_check_not_tree_decision(a: bool, b: bool, c: bool) { - LL| | // Contradict to `mcdc_check_tree_decision`, - LL| | // 100% branch coverage of this expression does not indicate 100% mcdc coverage. - LL| 4| if (a || b) && c { - ^1 - ------------------ - | Branch (LL:9): [True: 3, False: 1] - | Branch (LL:14): [True: 1, False: 0] - | Branch (LL:20): [True: 2, False: 2] - ------------------ - |---> MC/DC Decision Region (LL:8) to (LL:21) - | - | Number of Conditions: 3 - | Condition C1 --> (LL:9) - | Condition C2 --> (LL:14) - | Condition C3 --> (LL:20) - | - | Executed MC/DC Test Vectors: - | - | C1, C2, C3 Result - | 1 { T, -, F = F } - | 2 { F, T, T = T } - | 3 { T, -, T = T } - | - | C1-Pair: not covered - | C2-Pair: not covered - | C3-Pair: covered: (1,3) - | MC/DC Coverage for Decision: 33.33% - | - ------------------ - LL| 2| say("pass"); - LL| 2| } else { - LL| 2| say("reject"); - LL| 2| } - LL| 4|} - LL| | - LL| 3|fn mcdc_nested_if(a: bool, b: bool, c: bool) { - LL| 3| if a || b { - ^0 - ------------------ - | Branch (LL:8): [True: 3, False: 0] - | Branch (LL:13): [True: 0, False: 0] - ------------------ - |---> MC/DC Decision Region (LL:8) to (LL:14) - | - | Number of Conditions: 2 - | Condition C1 --> (LL:8) - | Condition C2 --> (LL:13) - | - | Executed MC/DC Test Vectors: - | - | C1, C2 Result - | 1 { T, - = T } - | - | C1-Pair: not covered - | C2-Pair: not covered - | MC/DC Coverage for Decision: 0.00% - | - ------------------ - LL| 3| say("a or b"); - LL| 3| if b && c { - ^2 - ------------------ - | Branch (LL:12): [True: 2, False: 1] - | Branch (LL:17): [True: 1, False: 1] - ------------------ - |---> MC/DC Decision Region (LL:12) to (LL:18) - | - | Number of Conditions: 2 - | Condition C1 --> (LL:12) - | Condition C2 --> (LL:17) - | - | Executed MC/DC Test Vectors: - | - | C1, C2 Result - | 1 { F, - = F } - | 2 { T, F = F } - | 3 { T, T = T } - | - | C1-Pair: covered: (1,3) - | C2-Pair: covered: (2,3) - | MC/DC Coverage for Decision: 100.00% - | - ------------------ - LL| 1| say("b and c"); - LL| 2| } - LL| 0| } else { - LL| 0| say("neither a nor b"); - LL| 0| } - LL| 3|} - LL| | - LL| |#[coverage(off)] - LL| |fn main() { - LL| | mcdc_check_neither(false, false); - LL| | mcdc_check_neither(false, true); - LL| | - LL| | mcdc_check_a(true, true); - LL| | mcdc_check_a(false, true); - LL| | - LL| | mcdc_check_b(true, true); - LL| | mcdc_check_b(true, false); - LL| | - LL| | mcdc_check_both(false, true); - LL| | mcdc_check_both(true, true); - LL| | mcdc_check_both(true, false); - LL| | - LL| | mcdc_check_tree_decision(false, true, true); - LL| | mcdc_check_tree_decision(true, true, false); - LL| | mcdc_check_tree_decision(true, false, false); - LL| | mcdc_check_tree_decision(true, false, true); - LL| | - LL| | mcdc_check_not_tree_decision(false, true, true); - LL| | mcdc_check_not_tree_decision(true, true, false); - LL| | mcdc_check_not_tree_decision(true, false, false); - LL| | mcdc_check_not_tree_decision(true, false, true); - LL| | - LL| | mcdc_nested_if(true, false, true); - LL| | mcdc_nested_if(true, true, true); - LL| | mcdc_nested_if(true, true, false); - LL| |} - LL| | - LL| |#[coverage(off)] - LL| |fn say(message: &str) { - LL| | core::hint::black_box(message); - LL| |} - diff --git a/tests/coverage/mcdc/if.rs b/tests/coverage/mcdc/if.rs deleted file mode 100644 index c4675f5d167..00000000000 --- a/tests/coverage/mcdc/if.rs +++ /dev/null @@ -1,102 +0,0 @@ -#![feature(coverage_attribute)] -//@ edition: 2021 -//@ compile-flags: -Zcoverage-options=mcdc -//@ llvm-cov-flags: --show-branches=count --show-mcdc - -fn mcdc_check_neither(a: bool, b: bool) { - if a && b { - say("a and b"); - } else { - say("not both"); - } -} - -fn mcdc_check_a(a: bool, b: bool) { - if a && b { - say("a and b"); - } else { - say("not both"); - } -} - -fn mcdc_check_b(a: bool, b: bool) { - if a && b { - say("a and b"); - } else { - say("not both"); - } -} - -fn mcdc_check_both(a: bool, b: bool) { - if a && b { - say("a and b"); - } else { - say("not both"); - } -} - -fn mcdc_check_tree_decision(a: bool, b: bool, c: bool) { - // This expression is intentionally written in a way - // where 100% branch coverage indicates 100% mcdc coverage. - if a && (b || c) { - say("pass"); - } else { - say("reject"); - } -} - -fn mcdc_check_not_tree_decision(a: bool, b: bool, c: bool) { - // Contradict to `mcdc_check_tree_decision`, - // 100% branch coverage of this expression does not indicate 100% mcdc coverage. - if (a || b) && c { - say("pass"); - } else { - say("reject"); - } -} - -fn mcdc_nested_if(a: bool, b: bool, c: bool) { - if a || b { - say("a or b"); - if b && c { - say("b and c"); - } - } else { - say("neither a nor b"); - } -} - -#[coverage(off)] -fn main() { - mcdc_check_neither(false, false); - mcdc_check_neither(false, true); - - mcdc_check_a(true, true); - mcdc_check_a(false, true); - - mcdc_check_b(true, true); - mcdc_check_b(true, false); - - mcdc_check_both(false, true); - mcdc_check_both(true, true); - mcdc_check_both(true, false); - - mcdc_check_tree_decision(false, true, true); - mcdc_check_tree_decision(true, true, false); - mcdc_check_tree_decision(true, false, false); - mcdc_check_tree_decision(true, false, true); - - mcdc_check_not_tree_decision(false, true, true); - mcdc_check_not_tree_decision(true, true, false); - mcdc_check_not_tree_decision(true, false, false); - mcdc_check_not_tree_decision(true, false, true); - - mcdc_nested_if(true, false, true); - mcdc_nested_if(true, true, true); - mcdc_nested_if(true, true, false); -} - -#[coverage(off)] -fn say(message: &str) { - core::hint::black_box(message); -} diff --git a/tests/coverage/mcdc/inlined_expressions.cov-map b/tests/coverage/mcdc/inlined_expressions.cov-map deleted file mode 100644 index d05ef368ba4..00000000000 --- a/tests/coverage/mcdc/inlined_expressions.cov-map +++ /dev/null @@ -1,21 +0,0 @@ -Function name: inlined_expressions::inlined_instance -Raw bytes (55): 0x[01, 01, 02, 01, 05, 05, 09, 07, 01, 07, 01, 00, 2e, 01, 01, 05, 00, 06, 28, 03, 02, 00, 05, 00, 0b, 30, 05, 02, 01, 02, 00, 00, 05, 00, 06, 05, 00, 0a, 00, 0b, 30, 09, 06, 02, 00, 00, 00, 0a, 00, 0b, 01, 01, 01, 00, 02] -Number of files: 1 -- file 0 => $DIR/inlined_expressions.rs -Number of expressions: 2 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Counter(2) -Number of file 0 mappings: 7 -- Code(Counter(0)) at (prev + 7, 1) to (start + 0, 46) -- Code(Counter(0)) at (prev + 1, 5) to (start + 0, 6) -- MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 0, 5) to (start + 0, 11) -- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 5) to (start + 0, 6) - true = c1 - false = (c0 - c1) -- Code(Counter(1)) at (prev + 0, 10) to (start + 0, 11) -- MCDCBranch { true: Counter(2), false: Expression(1, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 10) to (start + 0, 11) - true = c2 - false = (c1 - c2) -- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) -Highest counter ID seen: c2 - diff --git a/tests/coverage/mcdc/inlined_expressions.coverage b/tests/coverage/mcdc/inlined_expressions.coverage deleted file mode 100644 index cfe398995e4..00000000000 --- a/tests/coverage/mcdc/inlined_expressions.coverage +++ /dev/null @@ -1,40 +0,0 @@ - LL| |#![feature(coverage_attribute)] - LL| |//@ edition: 2021 - LL| |//@ compile-flags: -Zcoverage-options=mcdc -Copt-level=z -Cllvm-args=--inline-threshold=0 - LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc - LL| | - LL| |#[inline(always)] - LL| 3|fn inlined_instance(a: bool, b: bool) -> bool { - LL| 3| a && b - ^2 - ------------------ - | Branch (LL:5): [True: 2, False: 1] - | Branch (LL:10): [True: 1, False: 1] - ------------------ - |---> MC/DC Decision Region (LL:5) to (LL:11) - | - | Number of Conditions: 2 - | Condition C1 --> (LL:5) - | Condition C2 --> (LL:10) - | - | Executed MC/DC Test Vectors: - | - | C1, C2 Result - | 1 { F, - = F } - | 2 { T, F = F } - | 3 { T, T = T } - | - | C1-Pair: covered: (1,3) - | C2-Pair: covered: (2,3) - | MC/DC Coverage for Decision: 100.00% - | - ------------------ - LL| 3|} - LL| | - LL| |#[coverage(off)] - LL| |fn main() { - LL| | let _ = inlined_instance(true, false); - LL| | let _ = inlined_instance(false, true); - LL| | let _ = inlined_instance(true, true); - LL| |} - diff --git a/tests/coverage/mcdc/inlined_expressions.rs b/tests/coverage/mcdc/inlined_expressions.rs deleted file mode 100644 index 15d4260f6e2..00000000000 --- a/tests/coverage/mcdc/inlined_expressions.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![feature(coverage_attribute)] -//@ edition: 2021 -//@ compile-flags: -Zcoverage-options=mcdc -Copt-level=z -Cllvm-args=--inline-threshold=0 -//@ llvm-cov-flags: --show-branches=count --show-mcdc - -#[inline(always)] -fn inlined_instance(a: bool, b: bool) -> bool { - a && b -} - -#[coverage(off)] -fn main() { - let _ = inlined_instance(true, false); - let _ = inlined_instance(false, true); - let _ = inlined_instance(true, true); -} diff --git a/tests/coverage/mcdc/nested_if.cov-map b/tests/coverage/mcdc/nested_if.cov-map deleted file mode 100644 index 853cdf2c576..00000000000 --- a/tests/coverage/mcdc/nested_if.cov-map +++ /dev/null @@ -1,200 +0,0 @@ -Function name: nested_if::doubly_nested_if_in_condition -Raw bytes (175): 0x[01, 01, 0f, 01, 05, 05, 11, 05, 09, 05, 37, 09, 0d, 05, 09, 05, 1f, 09, 15, 15, 19, 05, 2b, 09, 19, 09, 0d, 05, 37, 09, 0d, 01, 11, 15, 01, 0e, 01, 00, 45, 01, 01, 08, 00, 09, 28, 09, 02, 00, 08, 00, 4e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 11, 06, 02, 00, 00, 00, 0d, 00, 4e, 05, 00, 10, 00, 11, 28, 06, 02, 00, 10, 00, 36, 30, 09, 16, 01, 00, 02, 00, 10, 00, 11, 30, 0d, 32, 02, 00, 00, 00, 15, 00, 36, 16, 00, 18, 00, 19, 28, 03, 02, 00, 18, 00, 1e, 30, 15, 1a, 01, 02, 00, 00, 18, 00, 19, 15, 00, 1d, 00, 1e, 30, 19, 22, 02, 00, 00, 00, 1d, 00, 1e, 19, 00, 21, 00, 25, 26, 00, 2f, 00, 34, 37, 00, 39, 00, 3e, 32, 00, 48, 00, 4c, 11, 00, 4f, 02, 06, 3a, 02, 0c, 02, 06, 01, 03, 01, 00, 02] -Number of files: 1 -- file 0 => $DIR/nested_if.rs -Number of expressions: 15 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Counter(4) -- expression 2 operands: lhs = Counter(1), rhs = Counter(2) -- expression 3 operands: lhs = Counter(1), rhs = Expression(13, Add) -- expression 4 operands: lhs = Counter(2), rhs = Counter(3) -- expression 5 operands: lhs = Counter(1), rhs = Counter(2) -- expression 6 operands: lhs = Counter(1), rhs = Expression(7, Add) -- expression 7 operands: lhs = Counter(2), rhs = Counter(5) -- expression 8 operands: lhs = Counter(5), rhs = Counter(6) -- expression 9 operands: lhs = Counter(1), rhs = Expression(10, Add) -- expression 10 operands: lhs = Counter(2), rhs = Counter(6) -- expression 11 operands: lhs = Counter(2), rhs = Counter(3) -- expression 12 operands: lhs = Counter(1), rhs = Expression(13, Add) -- expression 13 operands: lhs = Counter(2), rhs = Counter(3) -- expression 14 operands: lhs = Counter(0), rhs = Counter(4) -Number of file 0 mappings: 21 -- Code(Counter(0)) at (prev + 14, 1) to (start + 0, 69) -- Code(Counter(0)) at (prev + 1, 8) to (start + 0, 9) -- MCDCDecision { bitmap_idx: 9, conditions_num: 2 } at (prev + 0, 8) to (start + 0, 78) -- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9) - true = c1 - false = (c0 - c1) -- MCDCBranch { true: Counter(4), false: Expression(1, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 78) - true = c4 - false = (c1 - c4) -- Code(Counter(1)) at (prev + 0, 16) to (start + 0, 17) -- MCDCDecision { bitmap_idx: 6, conditions_num: 2 } at (prev + 0, 16) to (start + 0, 54) -- MCDCBranch { true: Counter(2), false: Expression(5, Sub), condition_id: 1, true_next_id: 0, false_next_id: 2 } at (prev + 0, 16) to (start + 0, 17) - true = c2 - false = (c1 - c2) -- MCDCBranch { true: Counter(3), false: Expression(12, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 21) to (start + 0, 54) - true = c3 - false = (c1 - (c2 + c3)) -- Code(Expression(5, Sub)) at (prev + 0, 24) to (start + 0, 25) - = (c1 - c2) -- MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 0, 24) to (start + 0, 30) -- MCDCBranch { true: Counter(5), false: Expression(6, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 24) to (start + 0, 25) - true = c5 - false = (c1 - (c2 + c5)) -- Code(Counter(5)) at (prev + 0, 29) to (start + 0, 30) -- MCDCBranch { true: Counter(6), false: Expression(8, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 29) to (start + 0, 30) - true = c6 - false = (c5 - c6) -- Code(Counter(6)) at (prev + 0, 33) to (start + 0, 37) -- Code(Expression(9, Sub)) at (prev + 0, 47) to (start + 0, 52) - = (c1 - (c2 + c6)) -- Code(Expression(13, Add)) at (prev + 0, 57) to (start + 0, 62) - = (c2 + c3) -- Code(Expression(12, Sub)) at (prev + 0, 72) to (start + 0, 76) - = (c1 - (c2 + c3)) -- Code(Counter(4)) at (prev + 0, 79) to (start + 2, 6) -- Code(Expression(14, Sub)) at (prev + 2, 12) to (start + 2, 6) - = (c0 - c4) -- Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2) -Highest counter ID seen: c6 - -Function name: nested_if::nested_if_in_condition -Raw bytes (123): 0x[01, 01, 0a, 01, 05, 05, 11, 05, 09, 05, 09, 05, 23, 09, 0d, 09, 0d, 05, 23, 09, 0d, 01, 11, 0f, 01, 06, 01, 00, 35, 01, 01, 08, 00, 09, 28, 06, 02, 00, 08, 00, 2e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 11, 06, 02, 00, 00, 00, 0d, 00, 2e, 05, 00, 10, 00, 11, 28, 03, 02, 00, 10, 00, 16, 30, 09, 0e, 01, 00, 02, 00, 10, 00, 11, 0e, 00, 15, 00, 16, 30, 0d, 1e, 02, 00, 00, 00, 15, 00, 16, 23, 00, 19, 00, 1d, 1e, 00, 27, 00, 2c, 11, 00, 2f, 02, 06, 26, 02, 0c, 02, 06, 01, 03, 01, 00, 02] -Number of files: 1 -- file 0 => $DIR/nested_if.rs -Number of expressions: 10 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Counter(4) -- expression 2 operands: lhs = Counter(1), rhs = Counter(2) -- expression 3 operands: lhs = Counter(1), rhs = Counter(2) -- expression 4 operands: lhs = Counter(1), rhs = Expression(8, Add) -- expression 5 operands: lhs = Counter(2), rhs = Counter(3) -- expression 6 operands: lhs = Counter(2), rhs = Counter(3) -- expression 7 operands: lhs = Counter(1), rhs = Expression(8, Add) -- expression 8 operands: lhs = Counter(2), rhs = Counter(3) -- expression 9 operands: lhs = Counter(0), rhs = Counter(4) -Number of file 0 mappings: 15 -- Code(Counter(0)) at (prev + 6, 1) to (start + 0, 53) -- Code(Counter(0)) at (prev + 1, 8) to (start + 0, 9) -- MCDCDecision { bitmap_idx: 6, conditions_num: 2 } at (prev + 0, 8) to (start + 0, 46) -- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9) - true = c1 - false = (c0 - c1) -- MCDCBranch { true: Counter(4), false: Expression(1, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 46) - true = c4 - false = (c1 - c4) -- Code(Counter(1)) at (prev + 0, 16) to (start + 0, 17) -- MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 0, 16) to (start + 0, 22) -- MCDCBranch { true: Counter(2), false: Expression(3, Sub), condition_id: 1, true_next_id: 0, false_next_id: 2 } at (prev + 0, 16) to (start + 0, 17) - true = c2 - false = (c1 - c2) -- Code(Expression(3, Sub)) at (prev + 0, 21) to (start + 0, 22) - = (c1 - c2) -- MCDCBranch { true: Counter(3), false: Expression(7, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 21) to (start + 0, 22) - true = c3 - false = (c1 - (c2 + c3)) -- Code(Expression(8, Add)) at (prev + 0, 25) to (start + 0, 29) - = (c2 + c3) -- Code(Expression(7, Sub)) at (prev + 0, 39) to (start + 0, 44) - = (c1 - (c2 + c3)) -- Code(Counter(4)) at (prev + 0, 47) to (start + 2, 6) -- Code(Expression(9, Sub)) at (prev + 2, 12) to (start + 2, 6) - = (c0 - c4) -- Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2) -Highest counter ID seen: c4 - -Function name: nested_if::nested_in_then_block_in_condition -Raw bytes (175): 0x[01, 01, 0f, 01, 05, 05, 19, 05, 09, 05, 09, 05, 37, 09, 0d, 09, 0d, 37, 11, 09, 0d, 11, 15, 37, 15, 09, 0d, 05, 37, 09, 0d, 01, 19, 15, 01, 21, 01, 00, 52, 01, 01, 08, 00, 09, 28, 09, 02, 00, 08, 00, 4b, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 19, 06, 02, 00, 00, 00, 0d, 00, 4b, 05, 00, 10, 00, 11, 28, 03, 02, 00, 10, 00, 16, 30, 09, 0e, 01, 00, 02, 00, 10, 00, 11, 0e, 00, 15, 00, 16, 30, 0d, 32, 02, 00, 00, 00, 15, 00, 16, 37, 00, 1c, 00, 1d, 28, 06, 02, 00, 1c, 00, 22, 30, 11, 1e, 01, 02, 00, 00, 1c, 00, 1d, 11, 00, 21, 00, 22, 30, 15, 26, 02, 00, 00, 00, 21, 00, 22, 15, 00, 25, 00, 29, 2a, 00, 33, 00, 38, 32, 00, 44, 00, 49, 19, 00, 4c, 02, 06, 3a, 02, 0c, 02, 06, 01, 03, 01, 00, 02] -Number of files: 1 -- file 0 => $DIR/nested_if.rs -Number of expressions: 15 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Counter(6) -- expression 2 operands: lhs = Counter(1), rhs = Counter(2) -- expression 3 operands: lhs = Counter(1), rhs = Counter(2) -- expression 4 operands: lhs = Counter(1), rhs = Expression(13, Add) -- expression 5 operands: lhs = Counter(2), rhs = Counter(3) -- expression 6 operands: lhs = Counter(2), rhs = Counter(3) -- expression 7 operands: lhs = Expression(13, Add), rhs = Counter(4) -- expression 8 operands: lhs = Counter(2), rhs = Counter(3) -- expression 9 operands: lhs = Counter(4), rhs = Counter(5) -- expression 10 operands: lhs = Expression(13, Add), rhs = Counter(5) -- expression 11 operands: lhs = Counter(2), rhs = Counter(3) -- expression 12 operands: lhs = Counter(1), rhs = Expression(13, Add) -- expression 13 operands: lhs = Counter(2), rhs = Counter(3) -- expression 14 operands: lhs = Counter(0), rhs = Counter(6) -Number of file 0 mappings: 21 -- Code(Counter(0)) at (prev + 33, 1) to (start + 0, 82) -- Code(Counter(0)) at (prev + 1, 8) to (start + 0, 9) -- MCDCDecision { bitmap_idx: 9, conditions_num: 2 } at (prev + 0, 8) to (start + 0, 75) -- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9) - true = c1 - false = (c0 - c1) -- MCDCBranch { true: Counter(6), false: Expression(1, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 75) - true = c6 - false = (c1 - c6) -- Code(Counter(1)) at (prev + 0, 16) to (start + 0, 17) -- MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 0, 16) to (start + 0, 22) -- MCDCBranch { true: Counter(2), false: Expression(3, Sub), condition_id: 1, true_next_id: 0, false_next_id: 2 } at (prev + 0, 16) to (start + 0, 17) - true = c2 - false = (c1 - c2) -- Code(Expression(3, Sub)) at (prev + 0, 21) to (start + 0, 22) - = (c1 - c2) -- MCDCBranch { true: Counter(3), false: Expression(12, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 21) to (start + 0, 22) - true = c3 - false = (c1 - (c2 + c3)) -- Code(Expression(13, Add)) at (prev + 0, 28) to (start + 0, 29) - = (c2 + c3) -- MCDCDecision { bitmap_idx: 6, conditions_num: 2 } at (prev + 0, 28) to (start + 0, 34) -- MCDCBranch { true: Counter(4), false: Expression(7, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 28) to (start + 0, 29) - true = c4 - false = ((c2 + c3) - c4) -- Code(Counter(4)) at (prev + 0, 33) to (start + 0, 34) -- MCDCBranch { true: Counter(5), false: Expression(9, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 33) to (start + 0, 34) - true = c5 - false = (c4 - c5) -- Code(Counter(5)) at (prev + 0, 37) to (start + 0, 41) -- Code(Expression(10, Sub)) at (prev + 0, 51) to (start + 0, 56) - = ((c2 + c3) - c5) -- Code(Expression(12, Sub)) at (prev + 0, 68) to (start + 0, 73) - = (c1 - (c2 + c3)) -- Code(Counter(6)) at (prev + 0, 76) to (start + 2, 6) -- Code(Expression(14, Sub)) at (prev + 2, 12) to (start + 2, 6) - = (c0 - c6) -- Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2) -Highest counter ID seen: c6 - -Function name: nested_if::nested_single_condition_decision -Raw bytes (88): 0x[01, 01, 05, 01, 05, 05, 0d, 05, 09, 05, 09, 01, 0d, 0c, 01, 16, 01, 00, 36, 01, 04, 08, 00, 09, 28, 03, 02, 00, 08, 00, 29, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 0d, 06, 02, 00, 00, 00, 0d, 00, 29, 05, 00, 10, 00, 11, 20, 09, 0e, 00, 10, 00, 11, 09, 00, 14, 00, 19, 0e, 00, 23, 00, 27, 0d, 00, 2a, 02, 06, 12, 02, 0c, 02, 06, 01, 03, 01, 00, 02] -Number of files: 1 -- file 0 => $DIR/nested_if.rs -Number of expressions: 5 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Counter(3) -- expression 2 operands: lhs = Counter(1), rhs = Counter(2) -- expression 3 operands: lhs = Counter(1), rhs = Counter(2) -- expression 4 operands: lhs = Counter(0), rhs = Counter(3) -Number of file 0 mappings: 12 -- Code(Counter(0)) at (prev + 22, 1) to (start + 0, 54) -- Code(Counter(0)) at (prev + 4, 8) to (start + 0, 9) -- MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 0, 8) to (start + 0, 41) -- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9) - true = c1 - false = (c0 - c1) -- MCDCBranch { true: Counter(3), false: Expression(1, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 41) - true = c3 - false = (c1 - c3) -- Code(Counter(1)) at (prev + 0, 16) to (start + 0, 17) -- Branch { true: Counter(2), false: Expression(3, Sub) } at (prev + 0, 16) to (start + 0, 17) - true = c2 - false = (c1 - c2) -- Code(Counter(2)) at (prev + 0, 20) to (start + 0, 25) -- Code(Expression(3, Sub)) at (prev + 0, 35) to (start + 0, 39) - = (c1 - c2) -- Code(Counter(3)) at (prev + 0, 42) to (start + 2, 6) -- Code(Expression(4, Sub)) at (prev + 2, 12) to (start + 2, 6) - = (c0 - c3) -- Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2) -Highest counter ID seen: c3 - diff --git a/tests/coverage/mcdc/nested_if.coverage b/tests/coverage/mcdc/nested_if.coverage deleted file mode 100644 index 8b5179b34fe..00000000000 --- a/tests/coverage/mcdc/nested_if.coverage +++ /dev/null @@ -1,257 +0,0 @@ - LL| |#![feature(coverage_attribute)] - LL| |//@ edition: 2021 - LL| |//@ compile-flags: -Zcoverage-options=mcdc - LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc - LL| | - LL| 4|fn nested_if_in_condition(a: bool, b: bool, c: bool) { - LL| 4| if a && if b || c { true } else { false } { - ^3 ^2 ^2 ^1 - ------------------ - | Branch (LL:8): [True: 3, False: 1] - | Branch (LL:13): [True: 2, False: 1] - | Branch (LL:16): [True: 1, False: 2] - | Branch (LL:21): [True: 1, False: 1] - ------------------ - |---> MC/DC Decision Region (LL:8) to (LL:46) - | - | Number of Conditions: 2 - | Condition C1 --> (LL:8) - | Condition C2 --> (LL:13) - | - | Executed MC/DC Test Vectors: - | - | C1, C2 Result - | 1 { F, - = F } - | 2 { T, F = F } - | 3 { T, T = T } - | - | C1-Pair: covered: (1,3) - | C2-Pair: covered: (2,3) - | MC/DC Coverage for Decision: 100.00% - | - |---> MC/DC Decision Region (LL:16) to (LL:22) - | - | Number of Conditions: 2 - | Condition C1 --> (LL:16) - | Condition C2 --> (LL:21) - | - | Executed MC/DC Test Vectors: - | - | C1, C2 Result - | 1 { F, F = F } - | 2 { F, T = T } - | 3 { T, - = T } - | - | C1-Pair: covered: (1,3) - | C2-Pair: covered: (1,2) - | MC/DC Coverage for Decision: 100.00% - | - ------------------ - LL| 2| say("yes"); - LL| 2| } else { - LL| 2| say("no"); - LL| 2| } - LL| 4|} - LL| | - LL| 4|fn doubly_nested_if_in_condition(a: bool, b: bool, c: bool, d: bool) { - LL| 4| if a && if b || if c && d { true } else { false } { false } else { true } { - ^3 ^2 ^1 ^1 ^1 ^2 ^1 - ------------------ - | Branch (LL:8): [True: 3, False: 1] - | Branch (LL:13): [True: 1, False: 2] - | Branch (LL:16): [True: 1, False: 2] - | Branch (LL:21): [True: 1, False: 1] - | Branch (LL:24): [True: 1, False: 1] - | Branch (LL:29): [True: 1, False: 0] - ------------------ - |---> MC/DC Decision Region (LL:8) to (LL:78) - | - | Number of Conditions: 2 - | Condition C1 --> (LL:8) - | Condition C2 --> (LL:13) - | - | Executed MC/DC Test Vectors: - | - | C1, C2 Result - | 1 { F, - = F } - | 2 { T, F = F } - | 3 { T, T = T } - | - | C1-Pair: covered: (1,3) - | C2-Pair: covered: (2,3) - | MC/DC Coverage for Decision: 100.00% - | - |---> MC/DC Decision Region (LL:16) to (LL:54) - | - | Number of Conditions: 2 - | Condition C1 --> (LL:16) - | Condition C2 --> (LL:21) - | - | Executed MC/DC Test Vectors: - | - | C1, C2 Result - | 1 { F, F = F } - | 2 { F, T = T } - | 3 { T, - = T } - | - | C1-Pair: covered: (1,3) - | C2-Pair: covered: (1,2) - | MC/DC Coverage for Decision: 100.00% - | - |---> MC/DC Decision Region (LL:24) to (LL:30) - | - | Number of Conditions: 2 - | Condition C1 --> (LL:24) - | Condition C2 --> (LL:29) - | - | Executed MC/DC Test Vectors: - | - | C1, C2 Result - | 1 { F, - = F } - | 2 { T, T = T } - | - | C1-Pair: covered: (1,2) - | C2-Pair: not covered - | MC/DC Coverage for Decision: 50.00% - | - ------------------ - LL| 1| say("yes"); - LL| 3| } else { - LL| 3| say("no"); - LL| 3| } - LL| 4|} - LL| | - LL| 3|fn nested_single_condition_decision(a: bool, b: bool) { - LL| | // Decision with only 1 decision should not be instrumented by MCDC because - LL| | // branch-coverage is equivalent to MCDC coverage in this case, and we don't - LL| | // want to waste bitmap space for this. - LL| 3| if a && if b { false } else { true } { - ^2 ^1 ^1 - ------------------ - | Branch (LL:8): [True: 2, False: 1] - | Branch (LL:13): [True: 1, False: 1] - | Branch (LL:16): [True: 1, False: 1] - ------------------ - |---> MC/DC Decision Region (LL:8) to (LL:41) - | - | Number of Conditions: 2 - | Condition C1 --> (LL:8) - | Condition C2 --> (LL:13) - | - | Executed MC/DC Test Vectors: - | - | C1, C2 Result - | 1 { F, - = F } - | 2 { T, F = F } - | 3 { T, T = T } - | - | C1-Pair: covered: (1,3) - | C2-Pair: covered: (2,3) - | MC/DC Coverage for Decision: 100.00% - | - ------------------ - LL| 1| say("yes"); - LL| 2| } else { - LL| 2| say("no"); - LL| 2| } - LL| 3|} - LL| | - LL| 7|fn nested_in_then_block_in_condition(a: bool, b: bool, c: bool, d: bool, e: bool) { - LL| 7| if a && if b || c { if d && e { true } else { false } } else { false } { - ^6 ^5 ^5 ^2 ^1 ^4 ^1 - ------------------ - | Branch (LL:8): [True: 6, False: 1] - | Branch (LL:13): [True: 1, False: 5] - | Branch (LL:16): [True: 1, False: 5] - | Branch (LL:21): [True: 4, False: 1] - | Branch (LL:28): [True: 2, False: 3] - | Branch (LL:33): [True: 1, False: 1] - ------------------ - |---> MC/DC Decision Region (LL:8) to (LL:75) - | - | Number of Conditions: 2 - | Condition C1 --> (LL:8) - | Condition C2 --> (LL:13) - | - | Executed MC/DC Test Vectors: - | - | C1, C2 Result - | 1 { F, - = F } - | 2 { T, F = F } - | 3 { T, T = T } - | - | C1-Pair: covered: (1,3) - | C2-Pair: covered: (2,3) - | MC/DC Coverage for Decision: 100.00% - | - |---> MC/DC Decision Region (LL:16) to (LL:22) - | - | Number of Conditions: 2 - | Condition C1 --> (LL:16) - | Condition C2 --> (LL:21) - | - | Executed MC/DC Test Vectors: - | - | C1, C2 Result - | 1 { F, F = F } - | 2 { F, T = T } - | 3 { T, - = T } - | - | C1-Pair: covered: (1,3) - | C2-Pair: covered: (1,2) - | MC/DC Coverage for Decision: 100.00% - | - |---> MC/DC Decision Region (LL:28) to (LL:34) - | - | Number of Conditions: 2 - | Condition C1 --> (LL:28) - | Condition C2 --> (LL:33) - | - | Executed MC/DC Test Vectors: - | - | C1, C2 Result - | 1 { F, - = F } - | 2 { T, F = F } - | 3 { T, T = T } - | - | C1-Pair: covered: (1,3) - | C2-Pair: covered: (2,3) - | MC/DC Coverage for Decision: 100.00% - | - ------------------ - LL| 1| say("yes"); - LL| 6| } else { - LL| 6| say("no"); - LL| 6| } - LL| 7|} - LL| | - LL| |#[coverage(off)] - LL| |fn main() { - LL| | nested_if_in_condition(true, false, false); - LL| | nested_if_in_condition(true, true, true); - LL| | nested_if_in_condition(true, false, true); - LL| | nested_if_in_condition(false, true, true); - LL| | - LL| | doubly_nested_if_in_condition(true, false, false, true); - LL| | doubly_nested_if_in_condition(true, true, true, true); - LL| | doubly_nested_if_in_condition(true, false, true, true); - LL| | doubly_nested_if_in_condition(false, true, true, true); - LL| | - LL| | nested_single_condition_decision(true, true); - LL| | nested_single_condition_decision(true, false); - LL| | nested_single_condition_decision(false, false); - LL| | - LL| | nested_in_then_block_in_condition(false, false, false, false, false); - LL| | nested_in_then_block_in_condition(true, false, false, false, false); - LL| | nested_in_then_block_in_condition(true, true, false, false, false); - LL| | nested_in_then_block_in_condition(true, false, true, false, false); - LL| | nested_in_then_block_in_condition(true, false, true, true, false); - LL| | nested_in_then_block_in_condition(true, false, true, false, true); - LL| | nested_in_then_block_in_condition(true, false, true, true, true); - LL| |} - LL| | - LL| |#[coverage(off)] - LL| |fn say(message: &str) { - LL| | core::hint::black_box(message); - LL| |} - diff --git a/tests/coverage/mcdc/nested_if.rs b/tests/coverage/mcdc/nested_if.rs deleted file mode 100644 index db02aece33c..00000000000 --- a/tests/coverage/mcdc/nested_if.rs +++ /dev/null @@ -1,69 +0,0 @@ -#![feature(coverage_attribute)] -//@ edition: 2021 -//@ compile-flags: -Zcoverage-options=mcdc -//@ llvm-cov-flags: --show-branches=count --show-mcdc - -fn nested_if_in_condition(a: bool, b: bool, c: bool) { - if a && if b || c { true } else { false } { - say("yes"); - } else { - say("no"); - } -} - -fn doubly_nested_if_in_condition(a: bool, b: bool, c: bool, d: bool) { - if a && if b || if c && d { true } else { false } { false } else { true } { - say("yes"); - } else { - say("no"); - } -} - -fn nested_single_condition_decision(a: bool, b: bool) { - // Decision with only 1 decision should not be instrumented by MCDC because - // branch-coverage is equivalent to MCDC coverage in this case, and we don't - // want to waste bitmap space for this. - if a && if b { false } else { true } { - say("yes"); - } else { - say("no"); - } -} - -fn nested_in_then_block_in_condition(a: bool, b: bool, c: bool, d: bool, e: bool) { - if a && if b || c { if d && e { true } else { false } } else { false } { - say("yes"); - } else { - say("no"); - } -} - -#[coverage(off)] -fn main() { - nested_if_in_condition(true, false, false); - nested_if_in_condition(true, true, true); - nested_if_in_condition(true, false, true); - nested_if_in_condition(false, true, true); - - doubly_nested_if_in_condition(true, false, false, true); - doubly_nested_if_in_condition(true, true, true, true); - doubly_nested_if_in_condition(true, false, true, true); - doubly_nested_if_in_condition(false, true, true, true); - - nested_single_condition_decision(true, true); - nested_single_condition_decision(true, false); - nested_single_condition_decision(false, false); - - nested_in_then_block_in_condition(false, false, false, false, false); - nested_in_then_block_in_condition(true, false, false, false, false); - nested_in_then_block_in_condition(true, true, false, false, false); - nested_in_then_block_in_condition(true, false, true, false, false); - nested_in_then_block_in_condition(true, false, true, true, false); - nested_in_then_block_in_condition(true, false, true, false, true); - nested_in_then_block_in_condition(true, false, true, true, true); -} - -#[coverage(off)] -fn say(message: &str) { - core::hint::black_box(message); -} diff --git a/tests/coverage/mcdc/non_control_flow.cov-map b/tests/coverage/mcdc/non_control_flow.cov-map deleted file mode 100644 index f06bc2ed816..00000000000 --- a/tests/coverage/mcdc/non_control_flow.cov-map +++ /dev/null @@ -1,186 +0,0 @@ -Function name: non_control_flow::assign_3 -Raw bytes (89): 0x[01, 01, 04, 01, 05, 01, 0b, 05, 09, 09, 0d, 0c, 01, 15, 01, 00, 27, 01, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 04, 03, 00, 0d, 00, 18, 30, 05, 02, 01, 00, 02, 00, 0d, 00, 0e, 02, 00, 12, 00, 13, 30, 09, 06, 02, 03, 00, 00, 12, 00, 13, 09, 00, 17, 00, 18, 30, 0d, 0e, 03, 00, 00, 00, 17, 00, 18, 01, 01, 05, 00, 0e, 01, 00, 0f, 00, 10, 01, 01, 01, 00, 02] -Number of files: 1 -- file 0 => $DIR/non_control_flow.rs -Number of expressions: 4 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(0), rhs = Expression(2, Add) -- expression 2 operands: lhs = Counter(1), rhs = Counter(2) -- expression 3 operands: lhs = Counter(2), rhs = Counter(3) -Number of file 0 mappings: 12 -- Code(Counter(0)) at (prev + 21, 1) to (start + 0, 39) -- Code(Counter(0)) at (prev + 1, 9) to (start + 0, 10) -- Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14) -- MCDCDecision { bitmap_idx: 4, conditions_num: 3 } at (prev + 0, 13) to (start + 0, 24) -- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 0, false_next_id: 2 } at (prev + 0, 13) to (start + 0, 14) - true = c1 - false = (c0 - c1) -- Code(Expression(0, Sub)) at (prev + 0, 18) to (start + 0, 19) - = (c0 - c1) -- MCDCBranch { true: Counter(2), false: Expression(1, Sub), condition_id: 2, true_next_id: 3, false_next_id: 0 } at (prev + 0, 18) to (start + 0, 19) - true = c2 - false = (c0 - (c1 + c2)) -- Code(Counter(2)) at (prev + 0, 23) to (start + 0, 24) -- MCDCBranch { true: Counter(3), false: Expression(3, Sub), condition_id: 3, true_next_id: 0, false_next_id: 0 } at (prev + 0, 23) to (start + 0, 24) - true = c3 - false = (c2 - c3) -- Code(Counter(0)) at (prev + 1, 5) to (start + 0, 14) -- Code(Counter(0)) at (prev + 0, 15) to (start + 0, 16) -- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) -Highest counter ID seen: c3 - -Function name: non_control_flow::assign_3_bis -Raw bytes (91): 0x[01, 01, 05, 01, 05, 05, 09, 01, 09, 01, 13, 09, 0d, 0c, 01, 1a, 01, 00, 2b, 01, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 05, 03, 00, 0d, 00, 18, 30, 05, 02, 01, 03, 02, 00, 0d, 00, 0e, 05, 00, 12, 00, 13, 30, 09, 06, 03, 00, 02, 00, 12, 00, 13, 0a, 00, 17, 00, 18, 30, 0d, 0e, 02, 00, 00, 00, 17, 00, 18, 01, 01, 05, 00, 0e, 01, 00, 0f, 00, 10, 01, 01, 01, 00, 02] -Number of files: 1 -- file 0 => $DIR/non_control_flow.rs -Number of expressions: 5 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Counter(2) -- expression 2 operands: lhs = Counter(0), rhs = Counter(2) -- expression 3 operands: lhs = Counter(0), rhs = Expression(4, Add) -- expression 4 operands: lhs = Counter(2), rhs = Counter(3) -Number of file 0 mappings: 12 -- Code(Counter(0)) at (prev + 26, 1) to (start + 0, 43) -- Code(Counter(0)) at (prev + 1, 9) to (start + 0, 10) -- Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14) -- MCDCDecision { bitmap_idx: 5, conditions_num: 3 } at (prev + 0, 13) to (start + 0, 24) -- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 3, false_next_id: 2 } at (prev + 0, 13) to (start + 0, 14) - true = c1 - false = (c0 - c1) -- Code(Counter(1)) at (prev + 0, 18) to (start + 0, 19) -- MCDCBranch { true: Counter(2), false: Expression(1, Sub), condition_id: 3, true_next_id: 0, false_next_id: 2 } at (prev + 0, 18) to (start + 0, 19) - true = c2 - false = (c1 - c2) -- Code(Expression(2, Sub)) at (prev + 0, 23) to (start + 0, 24) - = (c0 - c2) -- MCDCBranch { true: Counter(3), false: Expression(3, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 23) to (start + 0, 24) - true = c3 - false = (c0 - (c2 + c3)) -- Code(Counter(0)) at (prev + 1, 5) to (start + 0, 14) -- Code(Counter(0)) at (prev + 0, 15) to (start + 0, 16) -- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) -Highest counter ID seen: c3 - -Function name: non_control_flow::assign_and -Raw bytes (70): 0x[01, 01, 02, 01, 05, 05, 09, 0a, 01, 0b, 01, 00, 20, 01, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 03, 02, 00, 0d, 00, 13, 30, 05, 02, 01, 02, 00, 00, 0d, 00, 0e, 05, 00, 12, 00, 13, 30, 09, 06, 02, 00, 00, 00, 12, 00, 13, 01, 01, 05, 00, 0e, 01, 00, 0f, 00, 10, 01, 01, 01, 00, 02] -Number of files: 1 -- file 0 => $DIR/non_control_flow.rs -Number of expressions: 2 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Counter(2) -Number of file 0 mappings: 10 -- Code(Counter(0)) at (prev + 11, 1) to (start + 0, 32) -- Code(Counter(0)) at (prev + 1, 9) to (start + 0, 10) -- Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14) -- MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 0, 13) to (start + 0, 19) -- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 14) - true = c1 - false = (c0 - c1) -- Code(Counter(1)) at (prev + 0, 18) to (start + 0, 19) -- MCDCBranch { true: Counter(2), false: Expression(1, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 18) to (start + 0, 19) - true = c2 - false = (c1 - c2) -- Code(Counter(0)) at (prev + 1, 5) to (start + 0, 14) -- Code(Counter(0)) at (prev + 0, 15) to (start + 0, 16) -- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) -Highest counter ID seen: c2 - -Function name: non_control_flow::assign_or -Raw bytes (72): 0x[01, 01, 03, 01, 05, 01, 0b, 05, 09, 0a, 01, 10, 01, 00, 1f, 01, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 03, 02, 00, 0d, 00, 13, 30, 05, 02, 01, 00, 02, 00, 0d, 00, 0e, 02, 00, 12, 00, 13, 30, 09, 06, 02, 00, 00, 00, 12, 00, 13, 01, 01, 05, 00, 0e, 01, 00, 0f, 00, 10, 01, 01, 01, 00, 02] -Number of files: 1 -- file 0 => $DIR/non_control_flow.rs -Number of expressions: 3 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(0), rhs = Expression(2, Add) -- expression 2 operands: lhs = Counter(1), rhs = Counter(2) -Number of file 0 mappings: 10 -- Code(Counter(0)) at (prev + 16, 1) to (start + 0, 31) -- Code(Counter(0)) at (prev + 1, 9) to (start + 0, 10) -- Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14) -- MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 0, 13) to (start + 0, 19) -- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 0, false_next_id: 2 } at (prev + 0, 13) to (start + 0, 14) - true = c1 - false = (c0 - c1) -- Code(Expression(0, Sub)) at (prev + 0, 18) to (start + 0, 19) - = (c0 - c1) -- MCDCBranch { true: Counter(2), false: Expression(1, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 18) to (start + 0, 19) - true = c2 - false = (c0 - (c1 + c2)) -- Code(Counter(0)) at (prev + 1, 5) to (start + 0, 14) -- Code(Counter(0)) at (prev + 0, 15) to (start + 0, 16) -- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) -Highest counter ID seen: c2 - -Function name: non_control_flow::foo -Raw bytes (24): 0x[01, 01, 00, 04, 01, 24, 01, 00, 18, 01, 01, 05, 00, 0e, 01, 00, 0f, 00, 10, 01, 01, 01, 00, 02] -Number of files: 1 -- file 0 => $DIR/non_control_flow.rs -Number of expressions: 0 -Number of file 0 mappings: 4 -- Code(Counter(0)) at (prev + 36, 1) to (start + 0, 24) -- Code(Counter(0)) at (prev + 1, 5) to (start + 0, 14) -- Code(Counter(0)) at (prev + 0, 15) to (start + 0, 16) -- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) -Highest counter ID seen: c0 - -Function name: non_control_flow::func_call -Raw bytes (60): 0x[01, 01, 02, 01, 05, 05, 09, 08, 01, 28, 01, 00, 1f, 01, 01, 05, 00, 08, 01, 00, 09, 00, 0a, 28, 03, 02, 00, 09, 00, 0f, 30, 05, 02, 01, 02, 00, 00, 09, 00, 0a, 05, 00, 0e, 00, 0f, 30, 09, 06, 02, 00, 00, 00, 0e, 00, 0f, 01, 01, 01, 00, 02] -Number of files: 1 -- file 0 => $DIR/non_control_flow.rs -Number of expressions: 2 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Counter(2) -Number of file 0 mappings: 8 -- Code(Counter(0)) at (prev + 40, 1) to (start + 0, 31) -- Code(Counter(0)) at (prev + 1, 5) to (start + 0, 8) -- Code(Counter(0)) at (prev + 0, 9) to (start + 0, 10) -- MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 0, 9) to (start + 0, 15) -- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 9) to (start + 0, 10) - true = c1 - false = (c0 - c1) -- Code(Counter(1)) at (prev + 0, 14) to (start + 0, 15) -- MCDCBranch { true: Counter(2), false: Expression(1, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 14) to (start + 0, 15) - true = c2 - false = (c1 - c2) -- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) -Highest counter ID seen: c2 - -Function name: non_control_flow::right_comb_tree -Raw bytes (121): 0x[01, 01, 05, 01, 05, 05, 09, 09, 0d, 0d, 11, 11, 15, 10, 01, 1f, 01, 00, 40, 01, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 06, 05, 00, 0d, 00, 2a, 30, 05, 02, 01, 02, 00, 00, 0d, 00, 0e, 05, 00, 13, 00, 14, 30, 09, 06, 02, 03, 00, 00, 13, 00, 14, 09, 00, 19, 00, 1a, 30, 0d, 0a, 03, 04, 00, 00, 19, 00, 1a, 0d, 00, 1f, 00, 20, 30, 11, 0e, 04, 05, 00, 00, 1f, 00, 20, 11, 00, 24, 00, 27, 30, 15, 12, 05, 00, 00, 00, 24, 00, 27, 01, 01, 05, 00, 0e, 01, 00, 0f, 00, 10, 01, 01, 01, 00, 02] -Number of files: 1 -- file 0 => $DIR/non_control_flow.rs -Number of expressions: 5 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Counter(2) -- expression 2 operands: lhs = Counter(2), rhs = Counter(3) -- expression 3 operands: lhs = Counter(3), rhs = Counter(4) -- expression 4 operands: lhs = Counter(4), rhs = Counter(5) -Number of file 0 mappings: 16 -- Code(Counter(0)) at (prev + 31, 1) to (start + 0, 64) -- Code(Counter(0)) at (prev + 1, 9) to (start + 0, 10) -- Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14) -- MCDCDecision { bitmap_idx: 6, conditions_num: 5 } at (prev + 0, 13) to (start + 0, 42) -- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 14) - true = c1 - false = (c0 - c1) -- Code(Counter(1)) at (prev + 0, 19) to (start + 0, 20) -- MCDCBranch { true: Counter(2), false: Expression(1, Sub), condition_id: 2, true_next_id: 3, false_next_id: 0 } at (prev + 0, 19) to (start + 0, 20) - true = c2 - false = (c1 - c2) -- Code(Counter(2)) at (prev + 0, 25) to (start + 0, 26) -- MCDCBranch { true: Counter(3), false: Expression(2, Sub), condition_id: 3, true_next_id: 4, false_next_id: 0 } at (prev + 0, 25) to (start + 0, 26) - true = c3 - false = (c2 - c3) -- Code(Counter(3)) at (prev + 0, 31) to (start + 0, 32) -- MCDCBranch { true: Counter(4), false: Expression(3, Sub), condition_id: 4, true_next_id: 5, false_next_id: 0 } at (prev + 0, 31) to (start + 0, 32) - true = c4 - false = (c3 - c4) -- Code(Counter(4)) at (prev + 0, 36) to (start + 0, 39) -- MCDCBranch { true: Counter(5), false: Expression(4, Sub), condition_id: 5, true_next_id: 0, false_next_id: 0 } at (prev + 0, 36) to (start + 0, 39) - true = c5 - false = (c4 - c5) -- Code(Counter(0)) at (prev + 1, 5) to (start + 0, 14) -- Code(Counter(0)) at (prev + 0, 15) to (start + 0, 16) -- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) -Highest counter ID seen: c5 - diff --git a/tests/coverage/mcdc/non_control_flow.coverage b/tests/coverage/mcdc/non_control_flow.coverage deleted file mode 100644 index 419d40bb6f9..00000000000 --- a/tests/coverage/mcdc/non_control_flow.coverage +++ /dev/null @@ -1,224 +0,0 @@ - LL| |#![feature(coverage_attribute)] - LL| |//@ edition: 2021 - LL| |//@ compile-flags: -Zcoverage-options=mcdc - LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc - LL| | - LL| |// This test ensures that boolean expressions that are not inside control flow - LL| |// decisions are correctly instrumented. - LL| | - LL| |use core::hint::black_box; - LL| | - LL| 3|fn assign_and(a: bool, b: bool) { - LL| 3| let x = a && b; - ^2 - ------------------ - | Branch (LL:13): [True: 2, False: 1] - | Branch (LL:18): [True: 1, False: 1] - ------------------ - |---> MC/DC Decision Region (LL:13) to (LL:19) - | - | Number of Conditions: 2 - | Condition C1 --> (LL:13) - | Condition C2 --> (LL:18) - | - | Executed MC/DC Test Vectors: - | - | C1, C2 Result - | 1 { F, - = F } - | 2 { T, F = F } - | 3 { T, T = T } - | - | C1-Pair: covered: (1,3) - | C2-Pair: covered: (2,3) - | MC/DC Coverage for Decision: 100.00% - | - ------------------ - LL| 3| black_box(x); - LL| 3|} - LL| | - LL| 3|fn assign_or(a: bool, b: bool) { - LL| 3| let x = a || b; - ^1 - ------------------ - | Branch (LL:13): [True: 2, False: 1] - | Branch (LL:18): [True: 0, False: 1] - ------------------ - |---> MC/DC Decision Region (LL:13) to (LL:19) - | - | Number of Conditions: 2 - | Condition C1 --> (LL:13) - | Condition C2 --> (LL:18) - | - | Executed MC/DC Test Vectors: - | - | C1, C2 Result - | 1 { F, F = F } - | 2 { T, - = T } - | - | C1-Pair: covered: (1,2) - | C2-Pair: not covered - | MC/DC Coverage for Decision: 50.00% - | - ------------------ - LL| 3| black_box(x); - LL| 3|} - LL| | - LL| 4|fn assign_3(a: bool, b: bool, c: bool) { - LL| 4| let x = a || b && c; - ^2 ^1 - ------------------ - | Branch (LL:13): [True: 2, False: 2] - | Branch (LL:18): [True: 1, False: 1] - | Branch (LL:23): [True: 1, False: 0] - ------------------ - |---> MC/DC Decision Region (LL:13) to (LL:24) - | - | Number of Conditions: 3 - | Condition C1 --> (LL:13) - | Condition C2 --> (LL:18) - | Condition C3 --> (LL:23) - | - | Executed MC/DC Test Vectors: - | - | C1, C2, C3 Result - | 1 { F, F, - = F } - | 2 { F, T, T = T } - | 3 { T, -, - = T } - | - | C1-Pair: covered: (1,3) - | C2-Pair: covered: (1,2) - | C3-Pair: not covered - | MC/DC Coverage for Decision: 66.67% - | - ------------------ - LL| 4| black_box(x); - LL| 4|} - LL| | - LL| 4|fn assign_3_bis(a: bool, b: bool, c: bool) { - LL| 4| let x = a && b || c; - ^2 ^3 - ------------------ - | Branch (LL:13): [True: 2, False: 2] - | Branch (LL:18): [True: 1, False: 1] - | Branch (LL:23): [True: 2, False: 1] - ------------------ - |---> MC/DC Decision Region (LL:13) to (LL:24) - | - | Number of Conditions: 3 - | Condition C1 --> (LL:13) - | Condition C2 --> (LL:18) - | Condition C3 --> (LL:23) - | - | Executed MC/DC Test Vectors: - | - | C1, C2, C3 Result - | 1 { T, F, F = F } - | 2 { F, -, T = T } - | 3 { T, T, - = T } - | - | C1-Pair: not covered - | C2-Pair: covered: (1,3) - | C3-Pair: not covered - | MC/DC Coverage for Decision: 33.33% - | - ------------------ - LL| 4| black_box(x); - LL| 4|} - LL| | - LL| 3|fn right_comb_tree(a: bool, b: bool, c: bool, d: bool, e: bool) { - LL| 3| let x = a && (b && (c && (d && (e)))); - ^2 ^1 ^1 ^1 - ------------------ - | Branch (LL:13): [True: 2, False: 1] - | Branch (LL:19): [True: 1, False: 1] - | Branch (LL:25): [True: 1, False: 0] - | Branch (LL:31): [True: 1, False: 0] - | Branch (LL:36): [True: 1, False: 0] - ------------------ - |---> MC/DC Decision Region (LL:13) to (LL:42) - | - | Number of Conditions: 5 - | Condition C1 --> (LL:13) - | Condition C2 --> (LL:19) - | Condition C3 --> (LL:25) - | Condition C4 --> (LL:31) - | Condition C5 --> (LL:36) - | - | Executed MC/DC Test Vectors: - | - | C1, C2, C3, C4, C5 Result - | 1 { F, -, -, -, - = F } - | 2 { T, F, -, -, - = F } - | 3 { T, T, T, T, T = T } - | - | C1-Pair: covered: (1,3) - | C2-Pair: covered: (2,3) - | C3-Pair: not covered - | C4-Pair: not covered - | C5-Pair: not covered - | MC/DC Coverage for Decision: 40.00% - | - ------------------ - LL| 3| black_box(x); - LL| 3|} - LL| | - LL| 3|fn foo(a: bool) -> bool { - LL| 3| black_box(a) - LL| 3|} - LL| | - LL| 3|fn func_call(a: bool, b: bool) { - LL| 3| foo(a && b); - ^2 - ------------------ - | Branch (LL:9): [True: 2, False: 1] - | Branch (LL:14): [True: 1, False: 1] - ------------------ - |---> MC/DC Decision Region (LL:9) to (LL:15) - | - | Number of Conditions: 2 - | Condition C1 --> (LL:9) - | Condition C2 --> (LL:14) - | - | Executed MC/DC Test Vectors: - | - | C1, C2 Result - | 1 { F, - = F } - | 2 { T, F = F } - | 3 { T, T = T } - | - | C1-Pair: covered: (1,3) - | C2-Pair: covered: (2,3) - | MC/DC Coverage for Decision: 100.00% - | - ------------------ - LL| 3|} - LL| | - LL| |#[coverage(off)] - LL| |fn main() { - LL| | assign_and(true, false); - LL| | assign_and(true, true); - LL| | assign_and(false, false); - LL| | - LL| | assign_or(true, false); - LL| | assign_or(true, true); - LL| | assign_or(false, false); - LL| | - LL| | assign_3(true, false, false); - LL| | assign_3(true, true, false); - LL| | assign_3(false, false, true); - LL| | assign_3(false, true, true); - LL| | - LL| | assign_3_bis(true, false, false); - LL| | assign_3_bis(true, true, false); - LL| | assign_3_bis(false, false, true); - LL| | assign_3_bis(false, true, true); - LL| | - LL| | right_comb_tree(false, false, false, true, true); - LL| | right_comb_tree(true, false, false, true, true); - LL| | right_comb_tree(true, true, true, true, true); - LL| | - LL| | func_call(true, false); - LL| | func_call(true, true); - LL| | func_call(false, false); - LL| |} - diff --git a/tests/coverage/mcdc/non_control_flow.rs b/tests/coverage/mcdc/non_control_flow.rs deleted file mode 100644 index 863bb8a5756..00000000000 --- a/tests/coverage/mcdc/non_control_flow.rs +++ /dev/null @@ -1,71 +0,0 @@ -#![feature(coverage_attribute)] -//@ edition: 2021 -//@ compile-flags: -Zcoverage-options=mcdc -//@ llvm-cov-flags: --show-branches=count --show-mcdc - -// This test ensures that boolean expressions that are not inside control flow -// decisions are correctly instrumented. - -use core::hint::black_box; - -fn assign_and(a: bool, b: bool) { - let x = a && b; - black_box(x); -} - -fn assign_or(a: bool, b: bool) { - let x = a || b; - black_box(x); -} - -fn assign_3(a: bool, b: bool, c: bool) { - let x = a || b && c; - black_box(x); -} - -fn assign_3_bis(a: bool, b: bool, c: bool) { - let x = a && b || c; - black_box(x); -} - -fn right_comb_tree(a: bool, b: bool, c: bool, d: bool, e: bool) { - let x = a && (b && (c && (d && (e)))); - black_box(x); -} - -fn foo(a: bool) -> bool { - black_box(a) -} - -fn func_call(a: bool, b: bool) { - foo(a && b); -} - -#[coverage(off)] -fn main() { - assign_and(true, false); - assign_and(true, true); - assign_and(false, false); - - assign_or(true, false); - assign_or(true, true); - assign_or(false, false); - - assign_3(true, false, false); - assign_3(true, true, false); - assign_3(false, false, true); - assign_3(false, true, true); - - assign_3_bis(true, false, false); - assign_3_bis(true, true, false); - assign_3_bis(false, false, true); - assign_3_bis(false, true, true); - - right_comb_tree(false, false, false, true, true); - right_comb_tree(true, false, false, true, true); - right_comb_tree(true, true, true, true, true); - - func_call(true, false); - func_call(true, true); - func_call(false, false); -} diff --git a/tests/crashes/135528.rs b/tests/crashes/135528.rs deleted file mode 100644 index 171550e209e..00000000000 --- a/tests/crashes/135528.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ known-bug: #135528 -//@ compile-flags: -Zvalidate-mir -Zinline-mir=yes -#![feature(type_alias_impl_trait)] -type Tait = impl Copy; - -fn set(x: &isize) -> isize { - *x -} - -#[define_opaque(Tait)] -fn d(x: Tait) { - set(x); -} - -#[define_opaque(Tait)] -fn other_define() -> Tait { - () -} - -fn main() {} diff --git a/tests/crashes/135646.rs b/tests/crashes/135646.rs deleted file mode 100644 index 841ea5b81b4..00000000000 --- a/tests/crashes/135646.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ known-bug: #135646 -//@ compile-flags: -Zpolonius=next -//@ edition: 2024 - -fn main() { - &{ [1, 2, 3][4] }; -} diff --git a/tests/crashes/138510.rs b/tests/crashes/138510.rs deleted file mode 100644 index f429e8bb33b..00000000000 --- a/tests/crashes/138510.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ known-bug: #138510 -fn main() -where - #[repr()] - _: Sized, -{ -} diff --git a/tests/crashes/144293-indirect-ops-llvm.rs b/tests/crashes/144293-indirect-ops-llvm.rs new file mode 100644 index 00000000000..490a0116d7d --- /dev/null +++ b/tests/crashes/144293-indirect-ops-llvm.rs @@ -0,0 +1,42 @@ +//@ known-bug: #144293 +// Same as recursion-etc but eggs LLVM emission into giving indirect arguments. +#![expect(incomplete_features)] +#![feature(explicit_tail_calls)] + +use std::hint::black_box; + +struct U64Wrapper { + pub x: u64, + pub arbitrary: String, +} + +fn count(curr: U64Wrapper, top: U64Wrapper) -> U64Wrapper { + if black_box(curr.x) >= top.x { + curr + } else { + become count( + U64Wrapper { + x: curr.x + 1, + arbitrary: curr.arbitrary, + }, + top, + ) + } +} + +fn main() { + println!( + "{}", + count( + U64Wrapper { + x: 0, + arbitrary: "hello!".into() + }, + black_box(U64Wrapper { + x: 1000000, + arbitrary: "goodbye!".into() + }) + ) + .x + ); +} diff --git a/tests/debuginfo/embedded-visualizer.rs b/tests/debuginfo/embedded-visualizer.rs index 12d87be7c66..cbd8691394d 100644 --- a/tests/debuginfo/embedded-visualizer.rs +++ b/tests/debuginfo/embedded-visualizer.rs @@ -1,8 +1,6 @@ //@ compile-flags:-g //@ ignore-lldb //@ ignore-windows-gnu: #128981 -//@ ignore-musl: linker too old in CI -//@ ignore-i586-unknown-linux-gnu: linker too old in CI // === CDB TESTS ================================================================================== diff --git a/tests/mir-opt/building/issue_101867.main.built.after.mir b/tests/mir-opt/building/issue_101867.main.built.after.mir index e59b23fdd20..8a36c901eed 100644 --- a/tests/mir-opt/building/issue_101867.main.built.after.mir +++ b/tests/mir-opt/building/issue_101867.main.built.after.mir @@ -24,7 +24,6 @@ fn main() -> () { _1 = Option::<u8>::Some(const 1_u8); FakeRead(ForLet(None), _1); AscribeUserType(_1, o, UserTypeProjection { base: UserType(1), projs: [] }); - StorageLive(_5); PlaceMention(_1); _6 = discriminant(_1); switchInt(move _6) -> [1: bb4, otherwise: bb3]; @@ -55,6 +54,7 @@ fn main() -> () { } bb6: { + StorageLive(_5); _5 = copy ((_1 as Some).0: u8); _0 = const (); StorageDead(_5); @@ -63,7 +63,6 @@ fn main() -> () { } bb7: { - StorageDead(_5); goto -> bb1; } diff --git a/tests/mir-opt/building/user_type_annotations.let_else.built.after.mir b/tests/mir-opt/building/user_type_annotations.let_else.built.after.mir index 6369dbec750..3d26fe24ac9 100644 --- a/tests/mir-opt/building/user_type_annotations.let_else.built.after.mir +++ b/tests/mir-opt/building/user_type_annotations.let_else.built.after.mir @@ -21,9 +21,6 @@ fn let_else() -> () { } bb0: { - StorageLive(_2); - StorageLive(_3); - StorageLive(_4); StorageLive(_5); StorageLive(_6); StorageLive(_7); @@ -51,16 +48,19 @@ fn let_else() -> () { bb4: { AscribeUserType(_5, +, UserTypeProjection { base: UserType(1), projs: [] }); + StorageLive(_2); _2 = copy (_5.0: u32); + StorageLive(_3); _3 = copy (_5.1: u64); + StorageLive(_4); _4 = copy (_5.2: &char); StorageDead(_7); StorageDead(_5); _0 = const (); - StorageDead(_8); StorageDead(_4); StorageDead(_3); StorageDead(_2); + StorageDead(_8); return; } @@ -68,9 +68,6 @@ fn let_else() -> () { StorageDead(_7); StorageDead(_5); StorageDead(_8); - StorageDead(_4); - StorageDead(_3); - StorageDead(_2); goto -> bb1; } diff --git a/tests/mir-opt/gvn.dereference_indexing.GVN.panic-abort.diff b/tests/mir-opt/gvn.dereference_indexing.GVN.panic-abort.diff new file mode 100644 index 00000000000..9bdcc2f108a --- /dev/null +++ b/tests/mir-opt/gvn.dereference_indexing.GVN.panic-abort.diff @@ -0,0 +1,59 @@ +- // MIR for `dereference_indexing` before GVN ++ // MIR for `dereference_indexing` after GVN + + fn dereference_indexing(_1: [u8; 2], _2: usize) -> () { + debug array => _1; + debug index => _2; + let mut _0: (); + let _3: &u8; + let _4: usize; + let mut _5: usize; + let _6: usize; + let mut _7: bool; + let _8: (); + let mut _9: u8; + scope 1 { + debug a => _3; + } + scope 2 { + debug i => _4; + } + + bb0: { + StorageLive(_3); +- StorageLive(_4); ++ nop; + StorageLive(_5); + _5 = copy _2; +- _4 = Add(move _5, const 1_usize); ++ _4 = Add(copy _2, const 1_usize); + StorageDead(_5); + StorageLive(_6); + _6 = copy _4; +- _7 = Lt(copy _6, const 2_usize); +- assert(move _7, "index out of bounds: the length is {} but the index is {}", const 2_usize, copy _6) -> [success: bb1, unwind unreachable]; ++ _7 = Lt(copy _4, const 2_usize); ++ assert(move _7, "index out of bounds: the length is {} but the index is {}", const 2_usize, copy _4) -> [success: bb1, unwind unreachable]; + } + + bb1: { +- _3 = &_1[_6]; +- StorageDead(_4); ++ _3 = &_1[_4]; ++ nop; + StorageLive(_8); + StorageLive(_9); + _9 = copy (*_3); + _8 = opaque::<u8>(move _9) -> [return: bb2, unwind unreachable]; + } + + bb2: { + StorageDead(_9); + StorageDead(_8); + _0 = const (); + StorageDead(_6); + StorageDead(_3); + return; + } + } + diff --git a/tests/mir-opt/gvn.dereference_indexing.GVN.panic-unwind.diff b/tests/mir-opt/gvn.dereference_indexing.GVN.panic-unwind.diff new file mode 100644 index 00000000000..f38bc51adc4 --- /dev/null +++ b/tests/mir-opt/gvn.dereference_indexing.GVN.panic-unwind.diff @@ -0,0 +1,59 @@ +- // MIR for `dereference_indexing` before GVN ++ // MIR for `dereference_indexing` after GVN + + fn dereference_indexing(_1: [u8; 2], _2: usize) -> () { + debug array => _1; + debug index => _2; + let mut _0: (); + let _3: &u8; + let _4: usize; + let mut _5: usize; + let _6: usize; + let mut _7: bool; + let _8: (); + let mut _9: u8; + scope 1 { + debug a => _3; + } + scope 2 { + debug i => _4; + } + + bb0: { + StorageLive(_3); +- StorageLive(_4); ++ nop; + StorageLive(_5); + _5 = copy _2; +- _4 = Add(move _5, const 1_usize); ++ _4 = Add(copy _2, const 1_usize); + StorageDead(_5); + StorageLive(_6); + _6 = copy _4; +- _7 = Lt(copy _6, const 2_usize); +- assert(move _7, "index out of bounds: the length is {} but the index is {}", const 2_usize, copy _6) -> [success: bb1, unwind continue]; ++ _7 = Lt(copy _4, const 2_usize); ++ assert(move _7, "index out of bounds: the length is {} but the index is {}", const 2_usize, copy _4) -> [success: bb1, unwind continue]; + } + + bb1: { +- _3 = &_1[_6]; +- StorageDead(_4); ++ _3 = &_1[_4]; ++ nop; + StorageLive(_8); + StorageLive(_9); + _9 = copy (*_3); + _8 = opaque::<u8>(move _9) -> [return: bb2, unwind continue]; + } + + bb2: { + StorageDead(_9); + StorageDead(_8); + _0 = const (); + StorageDead(_6); + StorageDead(_3); + return; + } + } + diff --git a/tests/mir-opt/gvn.rs b/tests/mir-opt/gvn.rs index 407980fd0fd..98f94fbf0b1 100644 --- a/tests/mir-opt/gvn.rs +++ b/tests/mir-opt/gvn.rs @@ -1052,6 +1052,26 @@ fn remove_casts_must_change_both_sides(mut_a: &*mut u8, mut_b: *mut u8) -> bool } } +/// Verify that we do not references to non-existing locals when dereferencing projections. +fn dereference_indexing(array: [u8; 2], index: usize) { + // CHECK-LABEL: fn dereference_indexing( + // CHECK: debug a => [[a:_.*]]; + // CHECK: debug i => [[i:_.*]]; + + let a = { + // CHECK: [[i]] = Add(copy _2, const 1_usize); + let i = index + 1; + // CHECK: [[a]] = &_1[[[i]]]; + &array[i] + }; + + // CHECK-NOT: [{{.*}}] + // CHECK: [[tmp:_.*]] = copy (*[[a]]); + // CHECK: opaque::<u8>(move [[tmp]]) + opaque(*a); +} + +// CHECK-LABEL: fn main( fn main() { subexpression_elimination(2, 4, 5); wrap_unwrap(5); @@ -1079,6 +1099,7 @@ fn main() { slice_const_length(&[1]); meta_of_ref_to_slice(&42); slice_from_raw_parts_as_ptr(&123, 456); + dereference_indexing([129, 14], 5); } #[inline(never)] @@ -1138,3 +1159,4 @@ enum Never {} // EMIT_MIR gvn.cast_pointer_then_transmute.GVN.diff // EMIT_MIR gvn.transmute_then_cast_pointer.GVN.diff // EMIT_MIR gvn.remove_casts_must_change_both_sides.GVN.diff +// EMIT_MIR gvn.dereference_indexing.GVN.diff diff --git a/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff b/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff index b3eb3e1f8b9..484bc7dad12 100644 --- a/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff +++ b/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff @@ -85,11 +85,11 @@ _8 = &(_2.2: std::string::String); - _3 = &fake shallow (_2.0: bool); - _4 = &fake shallow (_2.1: bool); - StorageLive(_12); - StorageLive(_13); - _13 = copy _1; -- switchInt(move _13) -> [0: bb16, otherwise: bb15]; -+ switchInt(move _13) -> [0: bb13, otherwise: bb12]; + StorageLive(_9); + StorageLive(_10); + _10 = copy _1; +- switchInt(move _10) -> [0: bb12, otherwise: bb11]; ++ switchInt(move _10) -> [0: bb9, otherwise: bb8]; } - bb9: { @@ -100,11 +100,11 @@ _8 = &(_2.2: std::string::String); - _3 = &fake shallow (_2.0: bool); - _4 = &fake shallow (_2.1: bool); - StorageLive(_9); - StorageLive(_10); - _10 = copy _1; -- switchInt(move _10) -> [0: bb12, otherwise: bb11]; -+ switchInt(move _10) -> [0: bb9, otherwise: bb8]; + StorageLive(_12); + StorageLive(_13); + _13 = copy _1; +- switchInt(move _13) -> [0: bb16, otherwise: bb15]; ++ switchInt(move _13) -> [0: bb13, otherwise: bb12]; } - bb10: { @@ -139,7 +139,7 @@ - FakeRead(ForGuardBinding, _6); - FakeRead(ForGuardBinding, _8); StorageLive(_5); - _5 = copy (_2.1: bool); + _5 = copy (_2.0: bool); StorageLive(_7); _7 = move (_2.2: std::string::String); - goto -> bb10; @@ -152,8 +152,8 @@ StorageDead(_9); StorageDead(_8); StorageDead(_6); -- falseEdge -> [real: bb1, imaginary: bb1]; -+ goto -> bb1; +- falseEdge -> [real: bb3, imaginary: bb3]; ++ goto -> bb2; } - bb15: { @@ -181,7 +181,7 @@ - FakeRead(ForGuardBinding, _6); - FakeRead(ForGuardBinding, _8); StorageLive(_5); - _5 = copy (_2.0: bool); + _5 = copy (_2.1: bool); StorageLive(_7); _7 = move (_2.2: std::string::String); - goto -> bb10; @@ -194,8 +194,8 @@ StorageDead(_12); StorageDead(_8); StorageDead(_6); -- falseEdge -> [real: bb3, imaginary: bb3]; -+ goto -> bb2; +- falseEdge -> [real: bb1, imaginary: bb1]; ++ goto -> bb1; } - bb19: { diff --git a/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff b/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff index b3eb3e1f8b9..484bc7dad12 100644 --- a/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff +++ b/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff @@ -85,11 +85,11 @@ _8 = &(_2.2: std::string::String); - _3 = &fake shallow (_2.0: bool); - _4 = &fake shallow (_2.1: bool); - StorageLive(_12); - StorageLive(_13); - _13 = copy _1; -- switchInt(move _13) -> [0: bb16, otherwise: bb15]; -+ switchInt(move _13) -> [0: bb13, otherwise: bb12]; + StorageLive(_9); + StorageLive(_10); + _10 = copy _1; +- switchInt(move _10) -> [0: bb12, otherwise: bb11]; ++ switchInt(move _10) -> [0: bb9, otherwise: bb8]; } - bb9: { @@ -100,11 +100,11 @@ _8 = &(_2.2: std::string::String); - _3 = &fake shallow (_2.0: bool); - _4 = &fake shallow (_2.1: bool); - StorageLive(_9); - StorageLive(_10); - _10 = copy _1; -- switchInt(move _10) -> [0: bb12, otherwise: bb11]; -+ switchInt(move _10) -> [0: bb9, otherwise: bb8]; + StorageLive(_12); + StorageLive(_13); + _13 = copy _1; +- switchInt(move _13) -> [0: bb16, otherwise: bb15]; ++ switchInt(move _13) -> [0: bb13, otherwise: bb12]; } - bb10: { @@ -139,7 +139,7 @@ - FakeRead(ForGuardBinding, _6); - FakeRead(ForGuardBinding, _8); StorageLive(_5); - _5 = copy (_2.1: bool); + _5 = copy (_2.0: bool); StorageLive(_7); _7 = move (_2.2: std::string::String); - goto -> bb10; @@ -152,8 +152,8 @@ StorageDead(_9); StorageDead(_8); StorageDead(_6); -- falseEdge -> [real: bb1, imaginary: bb1]; -+ goto -> bb1; +- falseEdge -> [real: bb3, imaginary: bb3]; ++ goto -> bb2; } - bb15: { @@ -181,7 +181,7 @@ - FakeRead(ForGuardBinding, _6); - FakeRead(ForGuardBinding, _8); StorageLive(_5); - _5 = copy (_2.0: bool); + _5 = copy (_2.1: bool); StorageLive(_7); _7 = move (_2.2: std::string::String); - goto -> bb10; @@ -194,8 +194,8 @@ StorageDead(_12); StorageDead(_8); StorageDead(_6); -- falseEdge -> [real: bb3, imaginary: bb3]; -+ goto -> bb2; +- falseEdge -> [real: bb1, imaginary: bb1]; ++ goto -> bb1; } - bb19: { diff --git a/tests/mir-opt/remove_unneeded_drop_in_place.rs b/tests/mir-opt/remove_unneeded_drop_in_place.rs new file mode 100644 index 00000000000..470c6499d16 --- /dev/null +++ b/tests/mir-opt/remove_unneeded_drop_in_place.rs @@ -0,0 +1,17 @@ +//@ test-mir-pass: RemoveUnneededDrops +//@ needs-unwind +//@ compile-flags: -Z mir-opt-level=1 + +// EMIT_MIR remove_unneeded_drop_in_place.slice_in_place.RemoveUnneededDrops.diff +unsafe fn slice_in_place(ptr: *mut [char]) { + // CHECK-LABEL: fn slice_in_place(_1: *mut [char]) + // CHECK: bb0: { + // CHECK-NEXT: return; + // CHECK-NEXT: } + std::ptr::drop_in_place(ptr) +} + +fn main() { + let mut a = ['o', 'k']; + unsafe { slice_in_place(&raw mut a) }; +} diff --git a/tests/mir-opt/remove_unneeded_drop_in_place.slice_in_place.RemoveUnneededDrops.diff b/tests/mir-opt/remove_unneeded_drop_in_place.slice_in_place.RemoveUnneededDrops.diff new file mode 100644 index 00000000000..4d70e7151c3 --- /dev/null +++ b/tests/mir-opt/remove_unneeded_drop_in_place.slice_in_place.RemoveUnneededDrops.diff @@ -0,0 +1,20 @@ +- // MIR for `slice_in_place` before RemoveUnneededDrops ++ // MIR for `slice_in_place` after RemoveUnneededDrops + + fn slice_in_place(_1: *mut [char]) -> () { + debug ptr => _1; + let mut _0: (); + let mut _2: *mut [char]; + + bb0: { + StorageLive(_2); + _2 = copy _1; +- _0 = drop_in_place::<[char]>(move _2) -> [return: bb1, unwind continue]; +- } +- +- bb1: { + StorageDead(_2); + return; + } + } + diff --git a/tests/pretty/autodiff/autodiff_forward.pp b/tests/pretty/autodiff/autodiff_forward.pp index a2525abc832..6eddb5669c7 100644 --- a/tests/pretty/autodiff/autodiff_forward.pp +++ b/tests/pretty/autodiff/autodiff_forward.pp @@ -3,10 +3,10 @@ //@ needs-enzyme #![feature(autodiff)] -#[prelude_import] -use ::std::prelude::rust_2015::*; #[macro_use] extern crate std; +#[prelude_import] +use ::std::prelude::rust_2015::*; //@ pretty-mode:expanded //@ pretty-compare-only //@ pp-exact:autodiff_forward.pp @@ -16,7 +16,6 @@ extern crate std; use std::autodiff::{autodiff_forward, autodiff_reverse}; #[rustc_autodiff] -#[inline(never)] pub fn f1(x: &[f64], y: f64) -> f64 { @@ -36,163 +35,96 @@ pub fn f1(x: &[f64], y: f64) -> f64 { ::core::panicking::panic("not implemented") } #[rustc_autodiff(Forward, 1, Dual, Const, Dual)] -#[inline(never)] pub fn df1(x: &[f64], bx_0: &[f64], y: f64) -> (f64, f64) { - unsafe { asm!("NOP", options(pure, nomem)); }; - ::core::hint::black_box(f1(x, y)); - ::core::hint::black_box((bx_0,)); - ::core::hint::black_box(<(f64, f64)>::default()) + ::core::intrinsics::autodiff(f1::<>, df1::<>, (x, bx_0, y)) } #[rustc_autodiff] -#[inline(never)] pub fn f2(x: &[f64], y: f64) -> f64 { ::core::panicking::panic("not implemented") } #[rustc_autodiff(Forward, 1, Dual, Const, Const)] -#[inline(never)] pub fn df2(x: &[f64], bx_0: &[f64], y: f64) -> f64 { - unsafe { asm!("NOP", options(pure, nomem)); }; - ::core::hint::black_box(f2(x, y)); - ::core::hint::black_box((bx_0,)); - ::core::hint::black_box(f2(x, y)) + ::core::intrinsics::autodiff(f2::<>, df2::<>, (x, bx_0, y)) } #[rustc_autodiff] -#[inline(never)] pub fn f3(x: &[f64], y: f64) -> f64 { ::core::panicking::panic("not implemented") } #[rustc_autodiff(Forward, 1, Dual, Const, Const)] -#[inline(never)] pub fn df3(x: &[f64], bx_0: &[f64], y: f64) -> f64 { - unsafe { asm!("NOP", options(pure, nomem)); }; - ::core::hint::black_box(f3(x, y)); - ::core::hint::black_box((bx_0,)); - ::core::hint::black_box(f3(x, y)) + ::core::intrinsics::autodiff(f3::<>, df3::<>, (x, bx_0, y)) } #[rustc_autodiff] -#[inline(never)] pub fn f4() {} #[rustc_autodiff(Forward, 1, None)] -#[inline(never)] -pub fn df4() -> () { - unsafe { asm!("NOP", options(pure, nomem)); }; - ::core::hint::black_box(f4()); - ::core::hint::black_box(()); -} +pub fn df4() -> () { ::core::intrinsics::autodiff(f4::<>, df4::<>, ()) } #[rustc_autodiff] -#[inline(never)] pub fn f5(x: &[f64], y: f64) -> f64 { ::core::panicking::panic("not implemented") } #[rustc_autodiff(Forward, 1, Const, Dual, Const)] -#[inline(never)] pub fn df5_y(x: &[f64], y: f64, by_0: f64) -> f64 { - unsafe { asm!("NOP", options(pure, nomem)); }; - ::core::hint::black_box(f5(x, y)); - ::core::hint::black_box((by_0,)); - ::core::hint::black_box(f5(x, y)) + ::core::intrinsics::autodiff(f5::<>, df5_y::<>, (x, y, by_0)) } #[rustc_autodiff(Forward, 1, Dual, Const, Const)] -#[inline(never)] pub fn df5_x(x: &[f64], bx_0: &[f64], y: f64) -> f64 { - unsafe { asm!("NOP", options(pure, nomem)); }; - ::core::hint::black_box(f5(x, y)); - ::core::hint::black_box((bx_0,)); - ::core::hint::black_box(f5(x, y)) + ::core::intrinsics::autodiff(f5::<>, df5_x::<>, (x, bx_0, y)) } #[rustc_autodiff(Reverse, 1, Duplicated, Const, Active)] -#[inline(never)] pub fn df5_rev(x: &[f64], dx_0: &mut [f64], y: f64, dret: f64) -> f64 { - unsafe { asm!("NOP", options(pure, nomem)); }; - ::core::hint::black_box(f5(x, y)); - ::core::hint::black_box((dx_0, dret)); - ::core::hint::black_box(f5(x, y)) + ::core::intrinsics::autodiff(f5::<>, df5_rev::<>, (x, dx_0, y, dret)) } struct DoesNotImplDefault; #[rustc_autodiff] -#[inline(never)] pub fn f6() -> DoesNotImplDefault { ::core::panicking::panic("not implemented") } #[rustc_autodiff(Forward, 1, Const)] -#[inline(never)] pub fn df6() -> DoesNotImplDefault { - unsafe { asm!("NOP", options(pure, nomem)); }; - ::core::hint::black_box(f6()); - ::core::hint::black_box(()); - ::core::hint::black_box(f6()) + ::core::intrinsics::autodiff(f6::<>, df6::<>, ()) } #[rustc_autodiff] -#[inline(never)] pub fn f7(x: f32) -> () {} #[rustc_autodiff(Forward, 1, Const, None)] -#[inline(never)] pub fn df7(x: f32) -> () { - unsafe { asm!("NOP", options(pure, nomem)); }; - ::core::hint::black_box(f7(x)); - ::core::hint::black_box(()); + ::core::intrinsics::autodiff(f7::<>, df7::<>, (x,)) } #[no_mangle] #[rustc_autodiff] -#[inline(never)] fn f8(x: &f32) -> f32 { ::core::panicking::panic("not implemented") } #[rustc_autodiff(Forward, 4, Dual, Dual)] -#[inline(never)] fn f8_3(x: &f32, bx_0: &f32, bx_1: &f32, bx_2: &f32, bx_3: &f32) -> [f32; 5usize] { - unsafe { asm!("NOP", options(pure, nomem)); }; - ::core::hint::black_box(f8(x)); - ::core::hint::black_box((bx_0, bx_1, bx_2, bx_3)); - ::core::hint::black_box(<[f32; 5usize]>::default()) + ::core::intrinsics::autodiff(f8::<>, f8_3::<>, + (x, bx_0, bx_1, bx_2, bx_3)) } #[rustc_autodiff(Forward, 4, Dual, DualOnly)] -#[inline(never)] fn f8_2(x: &f32, bx_0: &f32, bx_1: &f32, bx_2: &f32, bx_3: &f32) -> [f32; 4usize] { - unsafe { asm!("NOP", options(pure, nomem)); }; - ::core::hint::black_box(f8(x)); - ::core::hint::black_box((bx_0, bx_1, bx_2, bx_3)); - ::core::hint::black_box(<[f32; 4usize]>::default()) + ::core::intrinsics::autodiff(f8::<>, f8_2::<>, + (x, bx_0, bx_1, bx_2, bx_3)) } #[rustc_autodiff(Forward, 1, Dual, DualOnly)] -#[inline(never)] fn f8_1(x: &f32, bx_0: &f32) -> f32 { - unsafe { asm!("NOP", options(pure, nomem)); }; - ::core::hint::black_box(f8(x)); - ::core::hint::black_box((bx_0,)); - ::core::hint::black_box(<f32>::default()) + ::core::intrinsics::autodiff(f8::<>, f8_1::<>, (x, bx_0)) } pub fn f9() { #[rustc_autodiff] - #[inline(never)] fn inner(x: f32) -> f32 { x * x } #[rustc_autodiff(Forward, 1, Dual, Dual)] - #[inline(never)] fn d_inner_2(x: f32, bx_0: f32) -> (f32, f32) { - unsafe { asm!("NOP", options(pure, nomem)); }; - ::core::hint::black_box(inner(x)); - ::core::hint::black_box((bx_0,)); - ::core::hint::black_box(<(f32, f32)>::default()) + ::core::intrinsics::autodiff(inner::<>, d_inner_2::<>, (x, bx_0)) } #[rustc_autodiff(Forward, 1, Dual, DualOnly)] - #[inline(never)] fn d_inner_1(x: f32, bx_0: f32) -> f32 { - unsafe { asm!("NOP", options(pure, nomem)); }; - ::core::hint::black_box(inner(x)); - ::core::hint::black_box((bx_0,)); - ::core::hint::black_box(<f32>::default()) + ::core::intrinsics::autodiff(inner::<>, d_inner_1::<>, (x, bx_0)) } } #[rustc_autodiff] -#[inline(never)] pub fn f10<T: std::ops::Mul<Output = T> + Copy>(x: &T) -> T { *x * *x } #[rustc_autodiff(Reverse, 1, Duplicated, Active)] -#[inline(never)] pub fn d_square<T: std::ops::Mul<Output = T> + Copy>(x: &T, dx_0: &mut T, dret: T) -> T { - unsafe { asm!("NOP", options(pure, nomem)); }; - ::core::hint::black_box(f10::<T>(x)); - ::core::hint::black_box((dx_0, dret)); - ::core::hint::black_box(f10::<T>(x)) + ::core::intrinsics::autodiff(f10::<T>, d_square::<T>, (x, dx_0, dret)) } fn main() {} diff --git a/tests/pretty/autodiff/autodiff_reverse.pp b/tests/pretty/autodiff/autodiff_reverse.pp index e67c3443dde..8f598b865c7 100644 --- a/tests/pretty/autodiff/autodiff_reverse.pp +++ b/tests/pretty/autodiff/autodiff_reverse.pp @@ -3,10 +3,10 @@ //@ needs-enzyme #![feature(autodiff)] -#[prelude_import] -use ::std::prelude::rust_2015::*; #[macro_use] extern crate std; +#[prelude_import] +use ::std::prelude::rust_2015::*; //@ pretty-mode:expanded //@ pretty-compare-only //@ pp-exact:autodiff_reverse.pp @@ -16,7 +16,6 @@ extern crate std; use std::autodiff::autodiff_reverse; #[rustc_autodiff] -#[inline(never)] pub fn f1(x: &[f64], y: f64) -> f64 { // Not the most interesting derivative, but who are we to judge @@ -29,58 +28,33 @@ pub fn f1(x: &[f64], y: f64) -> f64 { ::core::panicking::panic("not implemented") } #[rustc_autodiff(Reverse, 1, Duplicated, Const, Active)] -#[inline(never)] pub fn df1(x: &[f64], dx_0: &mut [f64], y: f64, dret: f64) -> f64 { - unsafe { asm!("NOP", options(pure, nomem)); }; - ::core::hint::black_box(f1(x, y)); - ::core::hint::black_box((dx_0, dret)); - ::core::hint::black_box(f1(x, y)) + ::core::intrinsics::autodiff(f1::<>, df1::<>, (x, dx_0, y, dret)) } #[rustc_autodiff] -#[inline(never)] pub fn f2() {} #[rustc_autodiff(Reverse, 1, None)] -#[inline(never)] -pub fn df2() { - unsafe { asm!("NOP", options(pure, nomem)); }; - ::core::hint::black_box(f2()); - ::core::hint::black_box(()); -} +pub fn df2() { ::core::intrinsics::autodiff(f2::<>, df2::<>, ()) } #[rustc_autodiff] -#[inline(never)] pub fn f3(x: &[f64], y: f64) -> f64 { ::core::panicking::panic("not implemented") } #[rustc_autodiff(Reverse, 1, Duplicated, Const, Active)] -#[inline(never)] pub fn df3(x: &[f64], dx_0: &mut [f64], y: f64, dret: f64) -> f64 { - unsafe { asm!("NOP", options(pure, nomem)); }; - ::core::hint::black_box(f3(x, y)); - ::core::hint::black_box((dx_0, dret)); - ::core::hint::black_box(f3(x, y)) + ::core::intrinsics::autodiff(f3::<>, df3::<>, (x, dx_0, y, dret)) } enum Foo { Reverse, } use Foo::Reverse; #[rustc_autodiff] -#[inline(never)] pub fn f4(x: f32) { ::core::panicking::panic("not implemented") } #[rustc_autodiff(Reverse, 1, Const, None)] -#[inline(never)] -pub fn df4(x: f32) { - unsafe { asm!("NOP", options(pure, nomem)); }; - ::core::hint::black_box(f4(x)); - ::core::hint::black_box(()); -} +pub fn df4(x: f32) { ::core::intrinsics::autodiff(f4::<>, df4::<>, (x,)) } #[rustc_autodiff] -#[inline(never)] pub fn f5(x: *const f32, y: &f32) { ::core::panicking::panic("not implemented") } #[rustc_autodiff(Reverse, 1, DuplicatedOnly, Duplicated, None)] -#[inline(never)] pub unsafe fn df5(x: *const f32, dx_0: *mut f32, y: &f32, dy_0: &mut f32) { - unsafe { asm!("NOP", options(pure, nomem)); }; - ::core::hint::black_box(f5(x, y)); - ::core::hint::black_box((dx_0, dy_0)); + ::core::intrinsics::autodiff(f5::<>, df5::<>, (x, dx_0, y, dy_0)) } fn main() {} diff --git a/tests/pretty/autodiff/autodiff_reverse.rs b/tests/pretty/autodiff/autodiff_reverse.rs index d37e5e3eb4c..c50b81d7780 100644 --- a/tests/pretty/autodiff/autodiff_reverse.rs +++ b/tests/pretty/autodiff/autodiff_reverse.rs @@ -23,7 +23,9 @@ pub fn f3(x: &[f64], y: f64) -> f64 { unimplemented!() } -enum Foo { Reverse } +enum Foo { + Reverse, +} use Foo::Reverse; // What happens if we already have Reverse in type (enum variant decl) and value (enum variant // constructor) namespace? > It's expected to work normally. diff --git a/tests/pretty/autodiff/inherent_impl.pp b/tests/pretty/autodiff/inherent_impl.pp index d18061b2dbd..36a9222640a 100644 --- a/tests/pretty/autodiff/inherent_impl.pp +++ b/tests/pretty/autodiff/inherent_impl.pp @@ -3,10 +3,10 @@ //@ needs-enzyme #![feature(autodiff)] -#[prelude_import] -use ::std::prelude::rust_2015::*; #[macro_use] extern crate std; +#[prelude_import] +use ::std::prelude::rust_2015::*; //@ pretty-mode:expanded //@ pretty-compare-only //@ pp-exact:inherent_impl.pp @@ -26,16 +26,12 @@ trait MyTrait { impl MyTrait for Foo { #[rustc_autodiff] - #[inline(never)] fn f(&self, x: f64) -> f64 { self.a * 0.25 * (x * x - 1.0 - 2.0 * x.ln()) } #[rustc_autodiff(Reverse, 1, Const, Active, Active)] - #[inline(never)] fn df(&self, x: f64, dret: f64) -> (f64, f64) { - unsafe { asm!("NOP", options(pure, nomem)); }; - ::core::hint::black_box(self.f(x)); - ::core::hint::black_box((dret,)); - ::core::hint::black_box((self.f(x), f64::default())) + ::core::intrinsics::autodiff(Self::f::<>, Self::df::<>, + (self, x, dret)) } } diff --git a/tests/run-make/atomic-lock-free/atomic_lock_free.rs b/tests/run-make/atomic-lock-free/atomic_lock_free.rs index f5c3b360ee8..92ffd111ce8 100644 --- a/tests/run-make/atomic-lock-free/atomic_lock_free.rs +++ b/tests/run-make/atomic-lock-free/atomic_lock_free.rs @@ -14,7 +14,7 @@ pub enum AtomicOrdering { } #[rustc_intrinsic] -unsafe fn atomic_xadd<T, const ORD: AtomicOrdering>(dst: *mut T, src: T) -> T; +unsafe fn atomic_xadd<T, U, const ORD: AtomicOrdering>(dst: *mut T, src: U) -> T; #[lang = "pointee_sized"] pub trait PointeeSized {} @@ -35,51 +35,62 @@ impl<T: ?Sized> Copy for *mut T {} impl ConstParamTy for AtomicOrdering {} #[cfg(target_has_atomic = "8")] +#[unsafe(no_mangle)] // let's make sure we actually generate a symbol to check pub unsafe fn atomic_u8(x: *mut u8) { - atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1); - atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1); + atomic_xadd::<_, _, { AtomicOrdering::SeqCst }>(x, 1u8); } #[cfg(target_has_atomic = "8")] +#[unsafe(no_mangle)] pub unsafe fn atomic_i8(x: *mut i8) { - atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1); + atomic_xadd::<_, _, { AtomicOrdering::SeqCst }>(x, 1i8); } #[cfg(target_has_atomic = "16")] +#[unsafe(no_mangle)] pub unsafe fn atomic_u16(x: *mut u16) { - atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1); + atomic_xadd::<_, _, { AtomicOrdering::SeqCst }>(x, 1u16); } #[cfg(target_has_atomic = "16")] +#[unsafe(no_mangle)] pub unsafe fn atomic_i16(x: *mut i16) { - atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1); + atomic_xadd::<_, _, { AtomicOrdering::SeqCst }>(x, 1i16); } #[cfg(target_has_atomic = "32")] +#[unsafe(no_mangle)] pub unsafe fn atomic_u32(x: *mut u32) { - atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1); + atomic_xadd::<_, _, { AtomicOrdering::SeqCst }>(x, 1u32); } #[cfg(target_has_atomic = "32")] +#[unsafe(no_mangle)] pub unsafe fn atomic_i32(x: *mut i32) { - atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1); + atomic_xadd::<_, _, { AtomicOrdering::SeqCst }>(x, 1i32); } #[cfg(target_has_atomic = "64")] +#[unsafe(no_mangle)] pub unsafe fn atomic_u64(x: *mut u64) { - atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1); + atomic_xadd::<_, _, { AtomicOrdering::SeqCst }>(x, 1u64); } #[cfg(target_has_atomic = "64")] +#[unsafe(no_mangle)] pub unsafe fn atomic_i64(x: *mut i64) { - atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1); + atomic_xadd::<_, _, { AtomicOrdering::SeqCst }>(x, 1i64); } #[cfg(target_has_atomic = "128")] +#[unsafe(no_mangle)] pub unsafe fn atomic_u128(x: *mut u128) { - atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1); + atomic_xadd::<_, _, { AtomicOrdering::SeqCst }>(x, 1u128); } #[cfg(target_has_atomic = "128")] +#[unsafe(no_mangle)] pub unsafe fn atomic_i128(x: *mut i128) { - atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1); + atomic_xadd::<_, _, { AtomicOrdering::SeqCst }>(x, 1i128); } #[cfg(target_has_atomic = "ptr")] +#[unsafe(no_mangle)] pub unsafe fn atomic_usize(x: *mut usize) { - atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1); + atomic_xadd::<_, _, { AtomicOrdering::SeqCst }>(x, 1usize); } #[cfg(target_has_atomic = "ptr")] +#[unsafe(no_mangle)] pub unsafe fn atomic_isize(x: *mut isize) { - atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1); + atomic_xadd::<_, _, { AtomicOrdering::SeqCst }>(x, 1isize); } diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-disabled.stderr b/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-disabled.stderr index 464208f989e..895558f3b0f 100644 --- a/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-disabled.stderr +++ b/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-disabled.stderr @@ -1,20 +1,20 @@ error: `[const]` is not allowed here --> const-super-trait.rs:7:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^ | note: this trait is not `const`, so it cannot have `[const]` trait bounds --> const-super-trait.rs:7:1 | -LL | trait Bar: ~const Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0658]: const trait impls are experimental --> const-super-trait.rs:7:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^ | = note: see issue #143874 <https://github.com/rust-lang/rust/issues/143874> for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable @@ -23,8 +23,8 @@ LL | trait Bar: ~const Foo {} error[E0658]: const trait impls are experimental --> const-super-trait.rs:9:17 | -LL | const fn foo<T: ~const Bar>(x: &T) { - | ^^^^^^ +LL | const fn foo<T: [const] Bar>(x: &T) { + | ^^^^^^^ | = note: see issue #143874 <https://github.com/rust-lang/rust/issues/143874> for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable @@ -33,8 +33,8 @@ LL | const fn foo<T: ~const Bar>(x: &T) { error: `[const]` can only be applied to `const` traits --> const-super-trait.rs:7:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `const` to allow it to have `const` implementations | @@ -44,12 +44,12 @@ LL | #[const_trait] trait Foo { error: `[const]` can only be applied to `const` traits --> const-super-trait.rs:9:17 | -LL | const fn foo<T: ~const Bar>(x: &T) { - | ^^^^^^ can't be applied to `Bar` +LL | const fn foo<T: [const] Bar>(x: &T) { + | ^^^^^^^ can't be applied to `Bar` | help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: ~const Foo {} +LL | #[const_trait] trait Bar: [const] Foo {} | ++++++++++++++ error[E0015]: cannot call non-const method `<T as Foo>::a` in constant functions diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr b/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr index 569e559186f..821ab6fa57c 100644 --- a/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr +++ b/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr @@ -1,20 +1,20 @@ error: `[const]` is not allowed here --> const-super-trait.rs:7:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^ | note: this trait is not `const`, so it cannot have `[const]` trait bounds --> const-super-trait.rs:7:1 | -LL | trait Bar: ~const Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` can only be applied to `const` traits --> const-super-trait.rs:7:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | help: mark `Foo` as `const` to allow it to have `const` implementations | @@ -24,12 +24,12 @@ LL | #[const_trait] trait Foo { error: `[const]` can only be applied to `const` traits --> const-super-trait.rs:9:17 | -LL | const fn foo<T: ~const Bar>(x: &T) { - | ^^^^^^ can't be applied to `Bar` +LL | const fn foo<T: [const] Bar>(x: &T) { + | ^^^^^^^ can't be applied to `Bar` | help: mark `Bar` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: ~const Foo {} +LL | #[const_trait] trait Bar: [const] Foo {} | ++++++++++++++ error[E0015]: cannot call non-const method `<T as Foo>::a` in constant functions diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-disabled.stderr b/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-disabled.stderr index 694e06fb6ea..b39be78e438 100644 --- a/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-disabled.stderr +++ b/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-disabled.stderr @@ -1,36 +1,36 @@ error: `[const]` is not allowed here --> const-super-trait.rs:7:12 | -7 | trait Bar: ~const Foo {} - | ^^^^^^ +7 | trait Bar: [const] Foo {} + | ^^^^^^^ | note: this trait is not `const`, so it cannot have `[const]` trait bounds --> const-super-trait.rs:7:1 | -7 | trait Bar: ~const Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ +7 | trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0658]: const trait impls are experimental --> const-super-trait.rs:7:12 | -7 | trait Bar: ~const Foo {} - | ^^^^^^ +7 | trait Bar: [const] Foo {} + | ^^^^^^^ | = note: see issue #143874 <https://github.com/rust-lang/rust/issues/143874> for more information error[E0658]: const trait impls are experimental --> const-super-trait.rs:9:17 | -9 | const fn foo<T: ~const Bar>(x: &T) { - | ^^^^^^ +9 | const fn foo<T: [const] Bar>(x: &T) { + | ^^^^^^^ | = note: see issue #143874 <https://github.com/rust-lang/rust/issues/143874> for more information error: `[const]` can only be applied to `const` traits --> const-super-trait.rs:7:12 | -7 | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +7 | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | note: `Foo` can't be used with `[const]` because it isn't `const` --> const-super-trait.rs:3:1 @@ -41,14 +41,14 @@ note: `Foo` can't be used with `[const]` because it isn't `const` error: `[const]` can only be applied to `const` traits --> const-super-trait.rs:9:17 | -9 | const fn foo<T: ~const Bar>(x: &T) { - | ^^^^^^ can't be applied to `Bar` +9 | const fn foo<T: [const] Bar>(x: &T) { + | ^^^^^^^ can't be applied to `Bar` | note: `Bar` can't be used with `[const]` because it isn't `const` --> const-super-trait.rs:7:1 | -7 | trait Bar: ~const Foo {} - | ^^^^^^^^^^^^^^^^^^^^^ +7 | trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0015]: cannot call non-const method `<T as Foo>::a` in constant functions --> const-super-trait.rs:10:7 diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-enabled.stderr b/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-enabled.stderr index 2109f0deb72..30ee5cf6f4b 100644 --- a/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-enabled.stderr +++ b/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-enabled.stderr @@ -1,14 +1,14 @@ error: `[const]` is not allowed here --> const-super-trait.rs:7:12 | -7 | trait Bar: ~const Foo {} - | ^^^^^^ +7 | trait Bar: [const] Foo {} + | ^^^^^^^ | note: this trait is not `const`, so it cannot have `[const]` trait bounds --> const-super-trait.rs:7:1 | -7 | trait Bar: ~const Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ +7 | trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0554]: `#![feature]` may not be used on the NIGHTLY release channel --> const-super-trait.rs:1:30 @@ -19,8 +19,8 @@ error[E0554]: `#![feature]` may not be used on the NIGHTLY release channel error: `[const]` can only be applied to `const` traits --> const-super-trait.rs:7:12 | -7 | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +7 | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | note: `Foo` can't be used with `[const]` because it isn't `const` --> const-super-trait.rs:3:1 @@ -31,14 +31,14 @@ note: `Foo` can't be used with `[const]` because it isn't `const` error: `[const]` can only be applied to `const` traits --> const-super-trait.rs:9:17 | -9 | const fn foo<T: ~const Bar>(x: &T) { - | ^^^^^^ can't be applied to `Bar` +9 | const fn foo<T: [const] Bar>(x: &T) { + | ^^^^^^^ can't be applied to `Bar` | note: `Bar` can't be used with `[const]` because it isn't `const` --> const-super-trait.rs:7:1 | -7 | trait Bar: ~const Foo {} - | ^^^^^^^^^^^^^^^^^^^^^ +7 | trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0015]: cannot call non-const method `<T as Foo>::a` in constant functions --> const-super-trait.rs:10:7 diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait.rs b/tests/run-make/const-trait-stable-toolchain/const-super-trait.rs index b2ee96d79f7..2371dfc0e6d 100644 --- a/tests/run-make/const-trait-stable-toolchain/const-super-trait.rs +++ b/tests/run-make/const-trait-stable-toolchain/const-super-trait.rs @@ -4,9 +4,9 @@ trait Foo { fn a(&self); } -trait Bar: ~const Foo {} +trait Bar: [const] Foo {} -const fn foo<T: ~const Bar>(x: &T) { +const fn foo<T: [const] Bar>(x: &T) { x.a(); } diff --git a/tests/run-make/libtest-json/output-default.json b/tests/run-make/libtest-json/output-default.json index a6a8a9f3b47..5371715d17c 100644 --- a/tests/run-make/libtest-json/output-default.json +++ b/tests/run-make/libtest-json/output-default.json @@ -2,7 +2,7 @@ { "type": "test", "event": "started", "name": "a" } { "type": "test", "name": "a", "event": "ok" } { "type": "test", "event": "started", "name": "b" } -{ "type": "test", "name": "b", "event": "failed", "stdout": "\nthread 'b' panicked at f.rs:9:5:\nassertion failed: false\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" } +{ "type": "test", "name": "b", "event": "failed", "stdout": "\nthread 'b' ($TID) panicked at f.rs:9:5:\nassertion failed: false\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" } { "type": "test", "event": "started", "name": "c" } { "type": "test", "name": "c", "event": "ok" } { "type": "test", "event": "started", "name": "d" } diff --git a/tests/run-make/libtest-json/output-stdout-success.json b/tests/run-make/libtest-json/output-stdout-success.json index a6c36e746b3..5caadcf56cf 100644 --- a/tests/run-make/libtest-json/output-stdout-success.json +++ b/tests/run-make/libtest-json/output-stdout-success.json @@ -2,9 +2,9 @@ { "type": "test", "event": "started", "name": "a" } { "type": "test", "name": "a", "event": "ok", "stdout": "print from successful test\n" } { "type": "test", "event": "started", "name": "b" } -{ "type": "test", "name": "b", "event": "failed", "stdout": "\nthread 'b' panicked at f.rs:9:5:\nassertion failed: false\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" } +{ "type": "test", "name": "b", "event": "failed", "stdout": "\nthread 'b' ($TID) panicked at f.rs:9:5:\nassertion failed: false\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" } { "type": "test", "event": "started", "name": "c" } -{ "type": "test", "name": "c", "event": "ok", "stdout": "\nthread 'c' panicked at f.rs:15:5:\nassertion failed: false\n" } +{ "type": "test", "name": "c", "event": "ok", "stdout": "\nthread 'c' ($TID) panicked at f.rs:15:5:\nassertion failed: false\n" } { "type": "test", "event": "started", "name": "d" } { "type": "test", "name": "d", "event": "ignored", "message": "msg" } { "type": "suite", "event": "failed", "passed": 2, "failed": 1, "ignored": 1, "measured": 0, "filtered_out": 0, "exec_time": "$EXEC_TIME" } diff --git a/tests/run-make/libtest-json/rmake.rs b/tests/run-make/libtest-json/rmake.rs index c31f4a79b64..034ba6246f1 100644 --- a/tests/run-make/libtest-json/rmake.rs +++ b/tests/run-make/libtest-json/rmake.rs @@ -38,5 +38,6 @@ fn run_tests(extra_args: &[&str], expected_file: &str) { .expected_file(expected_file) .actual_text("stdout", test_stdout) .normalize(r#"(?<prefix>"exec_time": )[0-9.]+"#, r#"${prefix}"$$EXEC_TIME""#) + .normalize(r"thread '(?P<name>.*?)' \(\d+\) panicked", "thread '$name' ($$TID) panicked") .run(); } diff --git a/tests/run-make/libtest-junit/output-default.xml b/tests/run-make/libtest-junit/output-default.xml index aa1b8c855aa..2467d8d940a 100644 --- a/tests/run-make/libtest-junit/output-default.xml +++ b/tests/run-make/libtest-junit/output-default.xml @@ -1 +1 @@ -<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="1" tests="4" skipped="1" ><testcase classname="unknown" name="a" time="$TIME"/><testcase classname="unknown" name="b" time="$TIME"><failure type="assert"/><system-out><![CDATA[print from failing test]]>

<![CDATA[thread 'b' panicked at f.rs:10:5:]]>
<![CDATA[assertion failed: false]]>
<![CDATA[note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace]]>
<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="c" time="$TIME"/><system-out/><system-err/></testsuite></testsuites> +<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="1" tests="4" skipped="1" ><testcase classname="unknown" name="a" time="$TIME"/><testcase classname="unknown" name="b" time="$TIME"><failure type="assert"/><system-out><![CDATA[print from failing test]]>

<![CDATA[thread 'b' ($TID) panicked at f.rs:10:5:]]>
<![CDATA[assertion failed: false]]>
<![CDATA[note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace]]>
<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="c" time="$TIME"/><system-out/><system-err/></testsuite></testsuites> diff --git a/tests/run-make/libtest-junit/output-stdout-success.xml b/tests/run-make/libtest-junit/output-stdout-success.xml index 2592ec7efb1..6bf1d7008a4 100644 --- a/tests/run-make/libtest-junit/output-stdout-success.xml +++ b/tests/run-make/libtest-junit/output-stdout-success.xml @@ -1 +1 @@ -<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="1" tests="4" skipped="1" ><testcase classname="unknown" name="a" time="$TIME"><system-out><![CDATA[print from successful test]]>
<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="b" time="$TIME"><failure type="assert"/><system-out><![CDATA[print from failing test]]>

<![CDATA[thread 'b' panicked at f.rs:10:5:]]>
<![CDATA[assertion failed: false]]>
<![CDATA[note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace]]>
<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="c" time="$TIME"><system-out><![CDATA[]]>
<![CDATA[thread 'c' panicked at f.rs:16:5:]]>
<![CDATA[assertion failed: false]]>
<![CDATA[]]></system-out></testcase><system-out/><system-err/></testsuite></testsuites> +<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="1" tests="4" skipped="1" ><testcase classname="unknown" name="a" time="$TIME"><system-out><![CDATA[print from successful test]]>
<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="b" time="$TIME"><failure type="assert"/><system-out><![CDATA[print from failing test]]>

<![CDATA[thread 'b' ($TID) panicked at f.rs:10:5:]]>
<![CDATA[assertion failed: false]]>
<![CDATA[note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace]]>
<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="c" time="$TIME"><system-out><![CDATA[]]>
<![CDATA[thread 'c' ($TID) panicked at f.rs:16:5:]]>
<![CDATA[assertion failed: false]]>
<![CDATA[]]></system-out></testcase><system-out/><system-err/></testsuite></testsuites> diff --git a/tests/run-make/libtest-junit/rmake.rs b/tests/run-make/libtest-junit/rmake.rs index 5917660b6c7..6961be21513 100644 --- a/tests/run-make/libtest-junit/rmake.rs +++ b/tests/run-make/libtest-junit/rmake.rs @@ -27,5 +27,6 @@ fn run_tests(extra_args: &[&str], expected_file: &str) { .expected_file(expected_file) .actual_text("stdout", test_stdout) .normalize(r#"\btime="[0-9.]+""#, r#"time="$$TIME""#) + .normalize(r"thread '(?P<name>.*?)' \(\d+\) panicked", "thread '$name' ($$TID) panicked") .run(); } diff --git a/tests/run-make/link-under-xcode/foo.rs b/tests/run-make/link-under-xcode/foo.rs new file mode 100644 index 00000000000..f328e4d9d04 --- /dev/null +++ b/tests/run-make/link-under-xcode/foo.rs @@ -0,0 +1 @@ +fn main() {} diff --git a/tests/run-make/link-under-xcode/rmake.rs b/tests/run-make/link-under-xcode/rmake.rs new file mode 100644 index 00000000000..c9394feb000 --- /dev/null +++ b/tests/run-make/link-under-xcode/rmake.rs @@ -0,0 +1,32 @@ +//! Test that linking works under an environment similar to what Xcode sets up. +//! +//! Regression test for https://github.com/rust-lang/rust/issues/80817. + +//@ only-apple + +use run_make_support::{cmd, rustc, target}; + +fn main() { + // Fetch toolchain `/usr/bin` directory. Usually: + // /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin + let clang_bin = cmd("xcrun").arg("--find").arg("clang").run().stdout_utf8(); + let toolchain_bin = clang_bin.trim().strip_suffix("/clang").unwrap(); + + // Put toolchain directory at the front of PATH. + let path = format!("{}:{}", toolchain_bin, std::env::var("PATH").unwrap()); + + // Check that compiling and linking still works. + // + // Removing `SDKROOT` is necessary for the test to excercise what we want, since bootstrap runs + // under `/usr/bin/python3`, which will set SDKROOT for us. + rustc().target(target()).env_remove("SDKROOT").env("PATH", &path).input("foo.rs").run(); + + // Also check linking directly with the system linker. + rustc() + .target(target()) + .env_remove("SDKROOT") + .env("PATH", &path) + .input("foo.rs") + .arg("-Clinker-flavor=ld") + .run(); +} diff --git a/tests/run-make/lto-long-filenames/main.rs b/tests/run-make/lto-long-filenames/main.rs new file mode 100644 index 00000000000..daedff5c05f --- /dev/null +++ b/tests/run-make/lto-long-filenames/main.rs @@ -0,0 +1,7 @@ +// This file has very long lines, but there is no way to avoid it as we are testing +// long crate names. so: +// ignore-tidy-linelength + +extern crate generated_large_large_large_large_large_large_large_large_large_large_large_large_large_large_large_large_large_crate_name; + +fn main() {} diff --git a/tests/run-make/lto-long-filenames/rmake.rs b/tests/run-make/lto-long-filenames/rmake.rs new file mode 100644 index 00000000000..9e0ba63e9f5 --- /dev/null +++ b/tests/run-make/lto-long-filenames/rmake.rs @@ -0,0 +1,32 @@ +// This file has very long lines, but there is no way to avoid it as we are testing +// long crate names. so: +// ignore-tidy-linelength + +// A variant of the smoke test to check that link time optimization +// (LTO) is accepted by the compiler, and that +// passing its various flags still results in successful compilation, even for very long crate names. +// See https://github.com/rust-lang/rust/issues/49914 + +//@ ignore-cross-compile + +use std::fs; + +use run_make_support::{rfs, rustc}; + +// This test make sure we don't get such following error: +// error: could not write output to generated_large_large_large_large_large_large_large_large_large_large_large_large_large_large_large_large_large_crate_name.generated_large_large_large_large_large_large_large_large_large_large_large_large_large_large_large_large_large_crate_name.9384edb61bfd127c-cgu.0.rcgu.o: File name too long +// as reported in issue #49914 +fn main() { + let lto_flags = ["-Clto", "-Clto=yes", "-Clto=off", "-Clto=thin", "-Clto=fat"]; + let aux_file = "generated_large_large_large_large_large_large_large_large_large_large_large_large_large_large_large_large_large_crate_name.rs"; + // The auxiliary file is used to test long crate names. + // The file name is intentionally long to test the handling of long filenames. + // We don't commit it to avoid issues with Windows paths which have known limitations for the full path length. + // Posix usually only have a limit for the length of the file name. + rfs::write(aux_file, "#![crate_type = \"rlib\"]\n"); + + for flag in lto_flags { + rustc().input(aux_file).arg(flag).run(); + rustc().input("main.rs").arg(flag).run(); + } +} diff --git a/tests/run-make/msvc-wholearchive/rmake.rs b/tests/run-make/msvc-wholearchive/rmake.rs index 98586fd8cc8..aec9391a420 100644 --- a/tests/run-make/msvc-wholearchive/rmake.rs +++ b/tests/run-make/msvc-wholearchive/rmake.rs @@ -7,7 +7,7 @@ use std::path::PathBuf; -use run_make_support::{cc, cmd, env_var, extra_c_flags, rustc}; +use run_make_support::{cc, cmd, env_var, extra_linker_flags, rustc}; fn main() { // Build the staticlib @@ -31,7 +31,7 @@ fn main() { // Otherwise the actual test failure may be caused by something else. cmd(&linker) .args(["c.obj", "./static.lib", "-dll", "-def:dll.def", "-out:dll.dll"]) - .args(extra_c_flags()) + .args(extra_linker_flags()) .run(); // FIXME(@ChrisDenton): this doesn't currently work with llvm's lld-link for other reasons. @@ -46,7 +46,7 @@ fn main() { "-def:dll.def", "-out:dll_whole_archive.dll", ]) - .args(extra_c_flags()) + .args(extra_linker_flags()) .run(); } } diff --git a/tests/run-make/pgo-branch-weights/rmake.rs b/tests/run-make/pgo-branch-weights/rmake.rs index 1893248e307..e74eabc1875 100644 --- a/tests/run-make/pgo-branch-weights/rmake.rs +++ b/tests/run-make/pgo-branch-weights/rmake.rs @@ -17,15 +17,21 @@ use run_make_support::{llvm_filecheck, llvm_profdata, rfs, run_with_args, rustc} fn main() { let path_prof_data_dir = Path::new("prof_data_dir"); let path_merged_profdata = path_prof_data_dir.join("merged.profdata"); - rustc().input("opaque.rs").run(); + rustc().input("opaque.rs").codegen_source_order().run(); rfs::create_dir_all(&path_prof_data_dir); rustc() .input("interesting.rs") .profile_generate(&path_prof_data_dir) .opt() .codegen_units(1) + .codegen_source_order() + .run(); + rustc() + .input("main.rs") + .profile_generate(&path_prof_data_dir) + .opt() + .codegen_source_order() .run(); - rustc().input("main.rs").profile_generate(&path_prof_data_dir).opt().run(); run_with_args("main", &["aaaaaaaaaaaa2bbbbbbbbbbbb2bbbbbbbbbbbbbbbbcc"]); llvm_profdata().merge().output(&path_merged_profdata).input(path_prof_data_dir).run(); rustc() @@ -34,6 +40,7 @@ fn main() { .opt() .codegen_units(1) .emit("llvm-ir") + .codegen_source_order() .run(); llvm_filecheck() .patterns("filecheck-patterns.txt") diff --git a/tests/run-make/pgo-indirect-call-promotion/rmake.rs b/tests/run-make/pgo-indirect-call-promotion/rmake.rs index ce9754f13b9..ee09141912b 100644 --- a/tests/run-make/pgo-indirect-call-promotion/rmake.rs +++ b/tests/run-make/pgo-indirect-call-promotion/rmake.rs @@ -14,11 +14,17 @@ use run_make_support::{llvm_filecheck, llvm_profdata, rfs, run, rustc}; fn main() { // We don't compile `opaque` with either optimizations or instrumentation. - rustc().input("opaque.rs").run(); + rustc().input("opaque.rs").codegen_source_order().run(); // Compile the test program with instrumentation rfs::create_dir("prof_data_dir"); - rustc().input("interesting.rs").profile_generate("prof_data_dir").opt().codegen_units(1).run(); - rustc().input("main.rs").profile_generate("prof_data_dir").opt().run(); + rustc() + .input("interesting.rs") + .profile_generate("prof_data_dir") + .opt() + .codegen_units(1) + .codegen_source_order() + .run(); + rustc().input("main.rs").profile_generate("prof_data_dir").opt().codegen_source_order().run(); // The argument below generates to the expected branch weights run("main"); llvm_profdata().merge().output("prof_data_dir/merged.profdata").input("prof_data_dir").run(); @@ -28,6 +34,7 @@ fn main() { .opt() .codegen_units(1) .emit("llvm-ir") + .codegen_source_order() .run(); llvm_filecheck() .patterns("filecheck-patterns.txt") diff --git a/tests/run-make/pgo-use/rmake.rs b/tests/run-make/pgo-use/rmake.rs index c09a82353b9..137b0b859a0 100644 --- a/tests/run-make/pgo-use/rmake.rs +++ b/tests/run-make/pgo-use/rmake.rs @@ -22,6 +22,7 @@ fn main() { .opt_level("2") .codegen_units(1) .arg("-Cllvm-args=-disable-preinline") + .codegen_source_order() .profile_generate(cwd()) .input("main.rs") .run(); @@ -40,6 +41,7 @@ fn main() { .arg("-Cllvm-args=-disable-preinline") .profile_use("merged.profdata") .emit("llvm-ir") + .codegen_source_order() .input("main.rs") .run(); // Check that the generate IR contains some things that we expect. diff --git a/tests/run-make/raw-dylib-link-ordinal/exporter.def b/tests/run-make/raw-dylib-link-ordinal/exporter.def index 5d87c580a54..0544e9f1803 100644 --- a/tests/run-make/raw-dylib-link-ordinal/exporter.def +++ b/tests/run-make/raw-dylib-link-ordinal/exporter.def @@ -1,5 +1,5 @@ LIBRARY exporter EXPORTS exported_function @13 NONAME - exported_variable @5 NONAME + exported_variable @5 NONAME DATA print_exported_variable @9 NONAME diff --git a/tests/run-make/raw-dylib-link-ordinal/rmake.rs b/tests/run-make/raw-dylib-link-ordinal/rmake.rs index 43274b9765b..b9254b16753 100644 --- a/tests/run-make/raw-dylib-link-ordinal/rmake.rs +++ b/tests/run-make/raw-dylib-link-ordinal/rmake.rs @@ -11,7 +11,7 @@ //@ only-windows -use run_make_support::{cc, diff, is_windows_msvc, run, rustc}; +use run_make_support::{cc, diff, extra_c_flags, is_windows_msvc, run, rustc}; // NOTE: build_native_dynamic lib is not used, as the special `def` files // must be passed to the CC compiler. @@ -24,6 +24,7 @@ fn main() { cc().input("exporter.obj") .arg("exporter.def") .args(&["-link", "-dll", "-noimplib", "-out:exporter.dll"]) + .args(extra_c_flags()) .run(); } else { cc().arg("-v").arg("-c").out_exe("exporter.obj").input("exporter.c").run(); diff --git a/tests/run-make/symbols-all-mangled/rmake.rs b/tests/run-make/symbols-all-mangled/rmake.rs index e30bef98580..2cf57975800 100644 --- a/tests/run-make/symbols-all-mangled/rmake.rs +++ b/tests/run-make/symbols-all-mangled/rmake.rs @@ -35,7 +35,13 @@ fn symbols_check_archive(path: &str) { continue; // All compiler-builtins symbols must remain unmangled } - if symbol_ok_everywhere(name) { + if name.contains("rust_eh_personality") { + continue; // Unfortunately LLVM doesn't allow us to mangle this symbol + } + + if name.contains(".llvm.") { + // Starting in LLVM 21 we get various implementation-detail functions which + // contain .llvm. that are not a problem. continue; } @@ -65,7 +71,13 @@ fn symbols_check(path: &str) { continue; } - if symbol_ok_everywhere(name) { + if name.contains("rust_eh_personality") { + continue; // Unfortunately LLVM doesn't allow us to mangle this symbol + } + + if name.contains(".llvm.") { + // Starting in LLVM 21 we get various implementation-detail functions which + // contain .llvm. that are not a problem. continue; } @@ -76,22 +88,3 @@ fn symbols_check(path: &str) { fn strip_underscore_if_apple(symbol: &str) -> &str { if cfg!(target_vendor = "apple") { symbol.strip_prefix("_").unwrap() } else { symbol } } - -fn symbol_ok_everywhere(name: &str) -> bool { - if name.contains("rust_eh_personality") { - return true; // Unfortunately LLVM doesn't allow us to mangle this symbol - } - - if name.contains(".llvm.") { - // Starting in LLVM 21 we get various implementation-detail functions which - // contain .llvm. that are not a problem. - return true; - } - - if name.starts_with("__rustc_debug_gdb_scripts_section") { - // These symbols are fine; they're made unique by the crate ID. - return true; - } - - return false; -} diff --git a/tests/run-make/wasm-panic-small/rmake.rs b/tests/run-make/wasm-panic-small/rmake.rs index e69fbac9635..ea0b6faf037 100644 --- a/tests/run-make/wasm-panic-small/rmake.rs +++ b/tests/run-make/wasm-panic-small/rmake.rs @@ -24,5 +24,5 @@ fn test(cfg: &str) { let bytes = rfs::read("foo.wasm"); println!("{}", bytes.len()); - assert!(bytes.len() < 40_000); + assert!(bytes.len() < 40_000, "bytes len was: {}", bytes.len()); } diff --git a/tests/run-make/wasm-unexpected-features/foo.rs b/tests/run-make/wasm-unexpected-features/foo.rs new file mode 100644 index 00000000000..5c7aa2d6190 --- /dev/null +++ b/tests/run-make/wasm-unexpected-features/foo.rs @@ -0,0 +1,43 @@ +#![no_core] +#![crate_type = "cdylib"] +#![feature(no_core, lang_items, allocator_internals, rustc_attrs)] +#![needs_allocator] +#![allow(internal_features)] + +#[rustc_std_internal_symbol] +unsafe fn __rust_alloc(_size: usize, _align: usize) -> *mut u8 { + 0 as *mut u8 +} + +unsafe extern "Rust" { + #[rustc_std_internal_symbol] + fn __rust_alloc_error_handler(size: usize, align: usize) -> !; +} + +#[used] +static mut BUF: [u8; 1024] = [0; 1024]; + +#[unsafe(no_mangle)] +extern "C" fn init() { + unsafe { + __rust_alloc_error_handler(0, 0); + } +} + +mod minicore { + #[lang = "pointee_sized"] + pub trait PointeeSized {} + + #[lang = "meta_sized"] + pub trait MetaSized: PointeeSized {} + + #[lang = "sized"] + pub trait Sized: MetaSized {} + + #[lang = "copy"] + pub trait Copy {} + impl Copy for u8 {} + + #[lang = "drop_in_place"] + fn drop_in_place<T>(_: *mut T) {} +} diff --git a/tests/run-make/wasm-unexpected-features/rmake.rs b/tests/run-make/wasm-unexpected-features/rmake.rs new file mode 100644 index 00000000000..416b5ef4caa --- /dev/null +++ b/tests/run-make/wasm-unexpected-features/rmake.rs @@ -0,0 +1,26 @@ +//@ only-wasm32-wasip1 + +use std::path::Path; + +use run_make_support::{rfs, rustc, wasmparser}; + +fn main() { + rustc() + .input("foo.rs") + .target("wasm32-wasip1") + .target_cpu("mvp") + .opt_level("z") + .lto("fat") + .linker_plugin_lto("on") + .link_arg("--import-memory") + .run(); + verify_features(Path::new("foo.wasm")); +} + +fn verify_features(path: &Path) { + eprintln!("verify {path:?}"); + let file = rfs::read(&path); + + let mut validator = wasmparser::Validator::new_with_features(wasmparser::WasmFeatures::WASM1); + validator.validate_all(&file).unwrap(); +} diff --git a/tests/rustdoc-js-std/core-transmute.js b/tests/rustdoc-js-std/core-transmute.js index 8c9910a32d7..b15f398902c 100644 --- a/tests/rustdoc-js-std/core-transmute.js +++ b/tests/rustdoc-js-std/core-transmute.js @@ -3,9 +3,9 @@ const EXPECTED = [ { 'query': 'generic:T -> generic:U', 'others': [ + { 'path': 'core::mem', 'name': 'transmute' }, { 'path': 'core::intrinsics::simd', 'name': 'simd_as' }, { 'path': 'core::intrinsics::simd', 'name': 'simd_cast' }, - { 'path': 'core::mem', 'name': 'transmute' }, ], }, ]; diff --git a/tests/rustdoc-js-std/transmute-fail.js b/tests/rustdoc-js-std/transmute-fail.js index ddfb2761948..459e8dc3f00 100644 --- a/tests/rustdoc-js-std/transmute-fail.js +++ b/tests/rustdoc-js-std/transmute-fail.js @@ -6,9 +6,9 @@ const EXPECTED = [ // should-fail tag and the search query below: 'query': 'generic:T -> generic:T', 'others': [ + { 'path': 'std::mem', 'name': 'transmute' }, { 'path': 'std::intrinsics::simd', 'name': 'simd_as' }, { 'path': 'std::intrinsics::simd', 'name': 'simd_cast' }, - { 'path': 'std::mem', 'name': 'transmute' }, ], }, ]; diff --git a/tests/rustdoc-js-std/transmute.js b/tests/rustdoc-js-std/transmute.js index f52e0ab1436..a85b02e2994 100644 --- a/tests/rustdoc-js-std/transmute.js +++ b/tests/rustdoc-js-std/transmute.js @@ -5,9 +5,9 @@ const EXPECTED = [ // should-fail tag and the search query below: 'query': 'generic:T -> generic:U', 'others': [ + { 'path': 'std::mem', 'name': 'transmute' }, { 'path': 'std::intrinsics::simd', 'name': 'simd_as' }, { 'path': 'std::intrinsics::simd', 'name': 'simd_cast' }, - { 'path': 'std::mem', 'name': 'transmute' }, ], }, ]; diff --git a/tests/rustdoc-js/doc-alias-after-other-items.js b/tests/rustdoc-js/doc-alias-after-other-items.js new file mode 100644 index 00000000000..5b22ef67698 --- /dev/null +++ b/tests/rustdoc-js/doc-alias-after-other-items.js @@ -0,0 +1,38 @@ +// exact-check + +// Checking that doc aliases are always listed after items with equivalent matching. + +const EXPECTED = [ + { + 'query': 'coo', + 'others': [ + { + 'path': 'doc_alias_after_other_items', + 'name': 'Foo', + 'href': '../doc_alias_after_other_items/struct.Foo.html', + }, + { + 'path': 'doc_alias_after_other_items', + 'name': 'bar', + 'alias': 'Boo', + 'is_alias': true + }, + ], + }, + { + 'query': '"confiture"', + 'others': [ + { + 'path': 'doc_alias_after_other_items', + 'name': 'Confiture', + 'href': '../doc_alias_after_other_items/struct.Confiture.html', + }, + { + 'path': 'doc_alias_after_other_items', + 'name': 'this_is_a_long_name', + 'alias': 'Confiture', + 'is_alias': true + }, + ], + }, +]; diff --git a/tests/rustdoc-js/doc-alias-after-other-items.rs b/tests/rustdoc-js/doc-alias-after-other-items.rs new file mode 100644 index 00000000000..2ed555c8e2f --- /dev/null +++ b/tests/rustdoc-js/doc-alias-after-other-items.rs @@ -0,0 +1,9 @@ +pub struct Foo; + +#[doc(alias = "Boo")] +pub fn bar() {} + +pub struct Confiture; + +#[doc(alias = "Confiture")] +pub fn this_is_a_long_name() {} diff --git a/tests/rustdoc-js/sort-stability.js b/tests/rustdoc-js/sort-stability.js new file mode 100644 index 00000000000..8c095619a08 --- /dev/null +++ b/tests/rustdoc-js/sort-stability.js @@ -0,0 +1,9 @@ +const EXPECTED = [ + { + 'query': 'foo', + 'others': [ + {"path": "sort_stability::old", "name": "foo"}, + {"path": "sort_stability::new", "name": "foo"}, + ], + }, +]; diff --git a/tests/rustdoc-js/sort-stability.rs b/tests/rustdoc-js/sort-stability.rs new file mode 100644 index 00000000000..68662bb3aab --- /dev/null +++ b/tests/rustdoc-js/sort-stability.rs @@ -0,0 +1,16 @@ +#![feature(staged_api)] +#![stable(feature = "foo_lib", since = "1.0.0")] + +#[stable(feature = "old_foo", since = "1.0.1")] +pub mod old { + /// Old, stable foo + #[stable(feature = "old_foo", since = "1.0.1")] + pub fn foo() {} +} + +#[unstable(feature = "new_foo", issue = "none")] +pub mod new { + /// New, unstable foo + #[unstable(feature = "new_foo", issue = "none")] + pub fn foo() {} +} diff --git a/tests/rustdoc-ui/check-doc-alias-attr-location.stderr b/tests/rustdoc-ui/check-doc-alias-attr-location.stderr index 9d3ce5e63ef..85c9516236c 100644 --- a/tests/rustdoc-ui/check-doc-alias-attr-location.stderr +++ b/tests/rustdoc-ui/check-doc-alias-attr-location.stderr @@ -4,13 +4,13 @@ error: `#[doc(alias = "...")]` isn't allowed on foreign module LL | #[doc(alias = "foo")] | ^^^^^^^^^^^^^ -error: `#[doc(alias = "...")]` isn't allowed on inherent implementation block +error: `#[doc(alias = "...")]` isn't allowed on implementation block --> $DIR/check-doc-alias-attr-location.rs:10:7 | LL | #[doc(alias = "bar")] | ^^^^^^^^^^^^^ -error: `#[doc(alias = "...")]` isn't allowed on trait implementation block +error: `#[doc(alias = "...")]` isn't allowed on implementation block --> $DIR/check-doc-alias-attr-location.rs:16:7 | LL | #[doc(alias = "foobar")] diff --git a/tests/rustdoc-ui/doctest/edition-2024-error-output.stdout b/tests/rustdoc-ui/doctest/edition-2024-error-output.stdout index ab6aca239af..c8acbe4eda7 100644 --- a/tests/rustdoc-ui/doctest/edition-2024-error-output.stdout +++ b/tests/rustdoc-ui/doctest/edition-2024-error-output.stdout @@ -9,7 +9,7 @@ Test executable failed (exit status: 101). stderr: -thread 'main' panicked at $TMP:6:1: +thread 'main' ($TID) panicked at $TMP:6:1: assertion `left == right` failed left: 4 right: 5 diff --git a/tests/rustdoc-ui/doctest/failed-doctest-output-windows.stdout b/tests/rustdoc-ui/doctest/failed-doctest-output-windows.stdout index 7aa965d543b..12a59d435fe 100644 --- a/tests/rustdoc-ui/doctest/failed-doctest-output-windows.stdout +++ b/tests/rustdoc-ui/doctest/failed-doctest-output-windows.stdout @@ -27,7 +27,7 @@ stderr: stderr 1 stderr 2 -thread 'main' panicked at $DIR/failed-doctest-output-windows.rs:7:1: +thread 'main' ($TID) panicked at $DIR/failed-doctest-output-windows.rs:7:1: oh no note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/rustdoc-ui/doctest/failed-doctest-output.stdout b/tests/rustdoc-ui/doctest/failed-doctest-output.stdout index a333f341ce5..3dbb2179b8f 100644 --- a/tests/rustdoc-ui/doctest/failed-doctest-output.stdout +++ b/tests/rustdoc-ui/doctest/failed-doctest-output.stdout @@ -27,7 +27,7 @@ stderr: stderr 1 stderr 2 -thread 'main' panicked at $DIR/failed-doctest-output.rs:7:1: +thread 'main' ($TID) panicked at $DIR/failed-doctest-output.rs:7:1: oh no note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/rustdoc-ui/doctest/stdout-and-stderr.stdout b/tests/rustdoc-ui/doctest/stdout-and-stderr.stdout index a35a4d7c3cb..dfdcd7759d5 100644 --- a/tests/rustdoc-ui/doctest/stdout-and-stderr.stdout +++ b/tests/rustdoc-ui/doctest/stdout-and-stderr.stdout @@ -14,7 +14,7 @@ stdout: stderr: -thread 'main' panicked at $TMP:7:1: +thread 'main' ($TID) panicked at $TMP:7:1: assertion `left == right` failed left: "doc" right: "test" @@ -26,7 +26,7 @@ Test executable failed (exit status: 101). stderr: -thread 'main' panicked at $TMP:15:1: +thread 'main' ($TID) panicked at $TMP:15:1: assertion `left == right` failed left: "doc" right: "test" diff --git a/tests/rustdoc-ui/intra-doc/github-flavored-admonitions.rs b/tests/rustdoc-ui/intra-doc/github-flavored-admonitions.rs new file mode 100644 index 00000000000..d5fa72eb993 --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/github-flavored-admonitions.rs @@ -0,0 +1,6 @@ +// regression test for https://github.com/rust-lang/rust/issues/141866 +//@ check-pass +#![deny(rustdoc::broken_intra_doc_links)] + +//! > [!NOTE] +//! > This should not cause any warnings diff --git a/tests/rustdoc-ui/remap-path-prefix-failed-doctest-output.stdout b/tests/rustdoc-ui/remap-path-prefix-failed-doctest-output.stdout index 87d1e772b80..08f7a4ddd3a 100644 --- a/tests/rustdoc-ui/remap-path-prefix-failed-doctest-output.stdout +++ b/tests/rustdoc-ui/remap-path-prefix-failed-doctest-output.stdout @@ -9,7 +9,7 @@ Test executable failed (exit status: 101). stderr: -thread 'main' panicked at remapped_path/remap-path-prefix-failed-doctest-output.rs:3:1: +thread 'main' ($TID) panicked at remapped_path/remap-path-prefix-failed-doctest-output.rs:3:1: oh no note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/rustdoc/enum/enum-variant-value.rs b/tests/rustdoc/enum/enum-variant-value.rs index 1670de8a24f..9cc85dfe10d 100644 --- a/tests/rustdoc/enum/enum-variant-value.rs +++ b/tests/rustdoc/enum/enum-variant-value.rs @@ -189,3 +189,25 @@ pub use bar::P; //@ has - '//*[@id="variant.A"]/h3' 'A(u32)' //@ matches - '//*[@id="variant.B"]/h3' '^B$' pub use bar::Q; + +// Ensure signed implicit discriminants are rendered correctly after a negative explicit value. +//@ has 'foo/enum.R.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A = -2,' +//@ has - '//*[@class="rust item-decl"]/code' 'B = -1,' +//@ matches - '//*[@id="variant.A"]/h3' '^A = -2$' +//@ matches - '//*[@id="variant.B"]/h3' '^B = -1$' +pub enum R { + A = -2, + B, +} + +// Also check that incrementing -1 yields 0 for the next implicit variant. +//@ has 'foo/enum.S.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A = -1,' +//@ has - '//*[@class="rust item-decl"]/code' 'B = 0,' +//@ matches - '//*[@id="variant.A"]/h3' '^A = -1$' +//@ matches - '//*[@id="variant.B"]/h3' '^B = 0$' +pub enum S { + A = -1, + B, +} diff --git a/tests/rustdoc/footnote-reference-ids.rs b/tests/rustdoc/footnote-reference-ids.rs new file mode 100644 index 00000000000..ffa04e1d767 --- /dev/null +++ b/tests/rustdoc/footnote-reference-ids.rs @@ -0,0 +1,23 @@ +// This test ensures that multiple references to a single footnote and +// corresponding back links work as expected. + +#![crate_name = "foo"] + +//@ has 'foo/index.html' +//@ has - '//*[@class="docblock"]/p/sup[@id="fnref1"]/a[@href="#fn1"]' '1' +//@ has - '//*[@class="docblock"]/p/sup[@id="fnref2"]/a[@href="#fn2"]' '2' +//@ has - '//*[@class="docblock"]/p/sup[@id="fnref2-2"]/a[@href="#fn2"]' '2' +//@ has - '//li[@id="fn1"]/p' 'meow' +//@ has - '//li[@id="fn1"]/p/a[@href="#fnref1"]' '↩' +//@ has - '//li[@id="fn2"]/p' 'uwu' +//@ has - '//li[@id="fn2"]/p/a[@href="#fnref2"]/sup' '1' +//@ has - '//li[@id="fn2"]/p/sup/a[@href="#fnref2-2"]' '2' + +//! # Footnote, references and back links +//! +//! Single: [^a]. +//! +//! Double: [^b] [^b]. +//! +//! [^a]: meow +//! [^b]: uwu diff --git a/tests/rustdoc/footnote-reference-in-footnote-def.rs b/tests/rustdoc/footnote-reference-in-footnote-def.rs index db3f9a59ef8..504d0bdb8f7 100644 --- a/tests/rustdoc/footnote-reference-in-footnote-def.rs +++ b/tests/rustdoc/footnote-reference-in-footnote-def.rs @@ -9,7 +9,7 @@ //@ has - '//li[@id="fn1"]/p/sup[@id="fnref2"]/a[@href="#fn2"]' '2' //@ has - '//li[@id="fn1"]//a[@href="#fn2"]' '2' //@ has - '//li[@id="fn2"]/p' 'uwu' -//@ has - '//li[@id="fn2"]/p/sup[@id="fnref1"]/a[@href="#fn1"]' '1' +//@ has - '//li[@id="fn2"]/p/sup[@id="fnref1-2"]/a[@href="#fn1"]' '1' //@ has - '//li[@id="fn2"]//a[@href="#fn1"]' '1' //! # footnote-hell diff --git a/tests/ui-fulldeps/auxiliary/parser.rs b/tests/ui-fulldeps/auxiliary/parser.rs index 8a370512460..6726969350d 100644 --- a/tests/ui-fulldeps/auxiliary/parser.rs +++ b/tests/ui-fulldeps/auxiliary/parser.rs @@ -10,7 +10,6 @@ extern crate rustc_span; use rustc_ast::ast::{AttrKind, Attribute, DUMMY_NODE_ID, Expr}; use rustc_ast::mut_visit::{self, MutVisitor}; use rustc_ast::node_id::NodeId; -use rustc_ast::ptr::P; use rustc_ast::token::{self, Token}; use rustc_ast::tokenstream::{AttrTokenStream, AttrTokenTree, LazyAttrTokenStream}; use rustc_errors::Diag; @@ -19,7 +18,7 @@ use rustc_session::parse::ParseSess; use rustc_span::{AttrId, DUMMY_SP, FileName, Span}; use std::sync::Arc; -pub fn parse_expr(psess: &ParseSess, source_code: &str) -> Option<P<Expr>> { +pub fn parse_expr(psess: &ParseSess, source_code: &str) -> Option<Box<Expr>> { let parser = rustc_parse::unwrap_or_emit_fatal(rustc_parse::new_parser_from_source_str( psess, FileName::anon_source_code(source_code), diff --git a/tests/ui-fulldeps/pprust-expr-roundtrip.rs b/tests/ui-fulldeps/pprust-expr-roundtrip.rs index 8bca20852ad..08ded2aee53 100644 --- a/tests/ui-fulldeps/pprust-expr-roundtrip.rs +++ b/tests/ui-fulldeps/pprust-expr-roundtrip.rs @@ -35,7 +35,6 @@ extern crate rustc_driver; use parser::parse_expr; use rustc_ast::mut_visit::MutVisitor; -use rustc_ast::ptr::P; use rustc_ast::*; use rustc_ast_pretty::pprust; use rustc_session::parse::ParseSess; @@ -45,11 +44,11 @@ use rustc_span::DUMMY_SP; use thin_vec::{thin_vec, ThinVec}; // Helper functions for building exprs -fn expr(kind: ExprKind) -> P<Expr> { - P(Expr { id: DUMMY_NODE_ID, kind, span: DUMMY_SP, attrs: AttrVec::new(), tokens: None }) +fn expr(kind: ExprKind) -> Box<Expr> { + Box::new(Expr { id: DUMMY_NODE_ID, kind, span: DUMMY_SP, attrs: AttrVec::new(), tokens: None }) } -fn make_x() -> P<Expr> { +fn make_x() -> Box<Expr> { let seg = PathSegment::from_ident(Ident::from_str("x")); let path = Path { segments: thin_vec![seg], span: DUMMY_SP, tokens: None }; expr(ExprKind::Path(None, path)) @@ -58,7 +57,7 @@ fn make_x() -> P<Expr> { /// Iterate over exprs of depth up to `depth`. The goal is to explore all "interesting" /// combinations of expression nesting. For example, we explore combinations using `if`, but not /// `while` or `match`, since those should print and parse in much the same way as `if`. -fn iter_exprs(depth: usize, f: &mut dyn FnMut(P<Expr>)) { +fn iter_exprs(depth: usize, f: &mut dyn FnMut(Box<Expr>)) { if depth == 0 { f(make_x()); return; @@ -108,7 +107,7 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P<Expr>)) { iter_exprs(depth - 1, &mut |e| g(ExprKind::Unary(UnOp::Deref, e))); } 9 => { - let block = P(Block { + let block = Box::new(Block { stmts: ThinVec::new(), id: DUMMY_NODE_ID, rules: BlockCheckMode::Default, @@ -118,7 +117,10 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P<Expr>)) { iter_exprs(depth - 1, &mut |e| g(ExprKind::If(e, block.clone(), None))); } 10 => { - let decl = P(FnDecl { inputs: thin_vec![], output: FnRetTy::Default(DUMMY_SP) }); + let decl = Box::new(FnDecl { + inputs: thin_vec![], + output: FnRetTy::Default(DUMMY_SP), + }); iter_exprs(depth - 1, &mut |e| { g(ExprKind::Closure(Box::new(Closure { binder: ClosureBinder::NotPresent, @@ -159,7 +161,7 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P<Expr>)) { } 16 => { let path = Path::from_ident(Ident::from_str("S")); - g(ExprKind::Struct(P(StructExpr { + g(ExprKind::Struct(Box::new(StructExpr { qself: None, path, fields: thin_vec![], @@ -170,8 +172,12 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P<Expr>)) { iter_exprs(depth - 1, &mut |e| g(ExprKind::Try(e))); } 18 => { - let pat = - P(Pat { id: DUMMY_NODE_ID, kind: PatKind::Wild, span: DUMMY_SP, tokens: None }); + let pat = Box::new(Pat { + id: DUMMY_NODE_ID, + kind: PatKind::Wild, + span: DUMMY_SP, + tokens: None, + }); iter_exprs(depth - 1, &mut |e| { g(ExprKind::Let(pat.clone(), e, DUMMY_SP, Recovered::No)) }) @@ -204,7 +210,7 @@ impl MutVisitor for AddParens { mut_visit::walk_expr(self, e); let expr = std::mem::replace(e, Expr::dummy()); - e.kind = ExprKind::Paren(P(expr)); + e.kind = ExprKind::Paren(Box::new(expr)); } } diff --git a/tests/ui/abi/interrupt-invalid-signature.avr.stderr b/tests/ui/abi/interrupt-invalid-signature.avr.stderr new file mode 100644 index 00000000000..91f5ca2022e --- /dev/null +++ b/tests/ui/abi/interrupt-invalid-signature.avr.stderr @@ -0,0 +1,28 @@ +error: invalid signature for `extern "avr-interrupt"` function + --> $DIR/interrupt-invalid-signature.rs:44:35 + | +LL | extern "avr-interrupt" fn avr_arg(_byte: u8) {} + | ^^^^^^^^^ + | + = note: functions with the "avr-interrupt" ABI cannot have any parameters or return type +help: remove the parameters and return type + | +LL - extern "avr-interrupt" fn avr_arg(_byte: u8) {} +LL + extern "avr-interrupt" fn avr_arg() {} + | + +error: invalid signature for `extern "avr-interrupt"` function + --> $DIR/interrupt-invalid-signature.rs:59:40 + | +LL | extern "avr-interrupt" fn avr_ret() -> u8 { + | ^^ + | + = note: functions with the "avr-interrupt" ABI cannot have any parameters or return type +help: remove the parameters and return type + | +LL - extern "avr-interrupt" fn avr_ret() -> u8 { +LL + extern "avr-interrupt" fn avr_ret() { + | + +error: aborting due to 2 previous errors + diff --git a/tests/ui/abi/interrupt-invalid-signature.i686.stderr b/tests/ui/abi/interrupt-invalid-signature.i686.stderr new file mode 100644 index 00000000000..86f2e097c37 --- /dev/null +++ b/tests/ui/abi/interrupt-invalid-signature.i686.stderr @@ -0,0 +1,15 @@ +error: invalid signature for `extern "x86-interrupt"` function + --> $DIR/interrupt-invalid-signature.rs:83:40 + | +LL | extern "x86-interrupt" fn x86_ret() -> u8 { + | ^^ + | + = note: functions with the "x86-interrupt" ABI cannot have a return type +help: remove the return type + --> $DIR/interrupt-invalid-signature.rs:83:40 + | +LL | extern "x86-interrupt" fn x86_ret() -> u8 { + | ^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/abi/interrupt-invalid-signature.msp430.stderr b/tests/ui/abi/interrupt-invalid-signature.msp430.stderr new file mode 100644 index 00000000000..38479f93de5 --- /dev/null +++ b/tests/ui/abi/interrupt-invalid-signature.msp430.stderr @@ -0,0 +1,28 @@ +error: invalid signature for `extern "msp430-interrupt"` function + --> $DIR/interrupt-invalid-signature.rs:40:41 + | +LL | extern "msp430-interrupt" fn msp430_arg(_byte: u8) {} + | ^^^^^^^^^ + | + = note: functions with the "msp430-interrupt" ABI cannot have any parameters or return type +help: remove the parameters and return type + | +LL - extern "msp430-interrupt" fn msp430_arg(_byte: u8) {} +LL + extern "msp430-interrupt" fn msp430_arg() {} + | + +error: invalid signature for `extern "msp430-interrupt"` function + --> $DIR/interrupt-invalid-signature.rs:65:46 + | +LL | extern "msp430-interrupt" fn msp430_ret() -> u8 { + | ^^ + | + = note: functions with the "msp430-interrupt" ABI cannot have any parameters or return type +help: remove the parameters and return type + | +LL - extern "msp430-interrupt" fn msp430_ret() -> u8 { +LL + extern "msp430-interrupt" fn msp430_ret() { + | + +error: aborting due to 2 previous errors + diff --git a/tests/ui/abi/interrupt-invalid-signature.riscv32.stderr b/tests/ui/abi/interrupt-invalid-signature.riscv32.stderr new file mode 100644 index 00000000000..d632b17ab83 --- /dev/null +++ b/tests/ui/abi/interrupt-invalid-signature.riscv32.stderr @@ -0,0 +1,54 @@ +error: invalid signature for `extern "riscv-interrupt-m"` function + --> $DIR/interrupt-invalid-signature.rs:48:43 + | +LL | extern "riscv-interrupt-m" fn riscv_m_arg(_byte: u8) {} + | ^^^^^^^^^ + | + = note: functions with the "riscv-interrupt-m" ABI cannot have any parameters or return type +help: remove the parameters and return type + | +LL - extern "riscv-interrupt-m" fn riscv_m_arg(_byte: u8) {} +LL + extern "riscv-interrupt-m" fn riscv_m_arg() {} + | + +error: invalid signature for `extern "riscv-interrupt-s"` function + --> $DIR/interrupt-invalid-signature.rs:52:43 + | +LL | extern "riscv-interrupt-s" fn riscv_s_arg(_byte: u8) {} + | ^^^^^^^^^ + | + = note: functions with the "riscv-interrupt-s" ABI cannot have any parameters or return type +help: remove the parameters and return type + | +LL - extern "riscv-interrupt-s" fn riscv_s_arg(_byte: u8) {} +LL + extern "riscv-interrupt-s" fn riscv_s_arg() {} + | + +error: invalid signature for `extern "riscv-interrupt-m"` function + --> $DIR/interrupt-invalid-signature.rs:71:48 + | +LL | extern "riscv-interrupt-m" fn riscv_m_ret() -> u8 { + | ^^ + | + = note: functions with the "riscv-interrupt-m" ABI cannot have any parameters or return type +help: remove the parameters and return type + | +LL - extern "riscv-interrupt-m" fn riscv_m_ret() -> u8 { +LL + extern "riscv-interrupt-m" fn riscv_m_ret() { + | + +error: invalid signature for `extern "riscv-interrupt-s"` function + --> $DIR/interrupt-invalid-signature.rs:77:48 + | +LL | extern "riscv-interrupt-s" fn riscv_s_ret() -> u8 { + | ^^ + | + = note: functions with the "riscv-interrupt-s" ABI cannot have any parameters or return type +help: remove the parameters and return type + | +LL - extern "riscv-interrupt-s" fn riscv_s_ret() -> u8 { +LL + extern "riscv-interrupt-s" fn riscv_s_ret() { + | + +error: aborting due to 4 previous errors + diff --git a/tests/ui/abi/interrupt-invalid-signature.riscv64.stderr b/tests/ui/abi/interrupt-invalid-signature.riscv64.stderr new file mode 100644 index 00000000000..d632b17ab83 --- /dev/null +++ b/tests/ui/abi/interrupt-invalid-signature.riscv64.stderr @@ -0,0 +1,54 @@ +error: invalid signature for `extern "riscv-interrupt-m"` function + --> $DIR/interrupt-invalid-signature.rs:48:43 + | +LL | extern "riscv-interrupt-m" fn riscv_m_arg(_byte: u8) {} + | ^^^^^^^^^ + | + = note: functions with the "riscv-interrupt-m" ABI cannot have any parameters or return type +help: remove the parameters and return type + | +LL - extern "riscv-interrupt-m" fn riscv_m_arg(_byte: u8) {} +LL + extern "riscv-interrupt-m" fn riscv_m_arg() {} + | + +error: invalid signature for `extern "riscv-interrupt-s"` function + --> $DIR/interrupt-invalid-signature.rs:52:43 + | +LL | extern "riscv-interrupt-s" fn riscv_s_arg(_byte: u8) {} + | ^^^^^^^^^ + | + = note: functions with the "riscv-interrupt-s" ABI cannot have any parameters or return type +help: remove the parameters and return type + | +LL - extern "riscv-interrupt-s" fn riscv_s_arg(_byte: u8) {} +LL + extern "riscv-interrupt-s" fn riscv_s_arg() {} + | + +error: invalid signature for `extern "riscv-interrupt-m"` function + --> $DIR/interrupt-invalid-signature.rs:71:48 + | +LL | extern "riscv-interrupt-m" fn riscv_m_ret() -> u8 { + | ^^ + | + = note: functions with the "riscv-interrupt-m" ABI cannot have any parameters or return type +help: remove the parameters and return type + | +LL - extern "riscv-interrupt-m" fn riscv_m_ret() -> u8 { +LL + extern "riscv-interrupt-m" fn riscv_m_ret() { + | + +error: invalid signature for `extern "riscv-interrupt-s"` function + --> $DIR/interrupt-invalid-signature.rs:77:48 + | +LL | extern "riscv-interrupt-s" fn riscv_s_ret() -> u8 { + | ^^ + | + = note: functions with the "riscv-interrupt-s" ABI cannot have any parameters or return type +help: remove the parameters and return type + | +LL - extern "riscv-interrupt-s" fn riscv_s_ret() -> u8 { +LL + extern "riscv-interrupt-s" fn riscv_s_ret() { + | + +error: aborting due to 4 previous errors + diff --git a/tests/ui/abi/interrupt-invalid-signature.rs b/tests/ui/abi/interrupt-invalid-signature.rs new file mode 100644 index 00000000000..e389285b069 --- /dev/null +++ b/tests/ui/abi/interrupt-invalid-signature.rs @@ -0,0 +1,110 @@ +/*! Tests interrupt ABIs have a constricted signature + +Most interrupt ABIs share a similar restriction in terms of not allowing most signatures. +Specifically, they generally cannot have arguments or return types. +So we test that they error in essentially all of the same places. +A notable and interesting exception is x86. + +This test uses `cfg` because it is not testing whether these ABIs work on the platform. +*/ +//@ add-core-stubs +//@ revisions: x64 i686 riscv32 riscv64 avr msp430 +// +//@ [x64] needs-llvm-components: x86 +//@ [x64] compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=rlib +//@ [i686] needs-llvm-components: x86 +//@ [i686] compile-flags: --target=i686-unknown-linux-gnu --crate-type=rlib +//@ [riscv32] needs-llvm-components: riscv +//@ [riscv32] compile-flags: --target=riscv32i-unknown-none-elf --crate-type=rlib +//@ [riscv64] needs-llvm-components: riscv +//@ [riscv64] compile-flags: --target=riscv64gc-unknown-none-elf --crate-type=rlib +//@ [avr] needs-llvm-components: avr +//@ [avr] compile-flags: --target=avr-none -C target-cpu=atmega328p --crate-type=rlib +//@ [msp430] needs-llvm-components: msp430 +//@ [msp430] compile-flags: --target=msp430-none-elf --crate-type=rlib +#![no_core] +#![feature( + no_core, + abi_msp430_interrupt, + abi_avr_interrupt, + abi_x86_interrupt, + abi_riscv_interrupt +)] + +extern crate minicore; +use minicore::*; + +/* most extern "interrupt" definitions should not accept args */ + +#[cfg(msp430)] +extern "msp430-interrupt" fn msp430_arg(_byte: u8) {} +//[msp430]~^ ERROR invalid signature + +#[cfg(avr)] +extern "avr-interrupt" fn avr_arg(_byte: u8) {} +//[avr]~^ ERROR invalid signature + +#[cfg(any(riscv32,riscv64))] +extern "riscv-interrupt-m" fn riscv_m_arg(_byte: u8) {} +//[riscv32,riscv64]~^ ERROR invalid signature + +#[cfg(any(riscv32,riscv64))] +extern "riscv-interrupt-s" fn riscv_s_arg(_byte: u8) {} +//[riscv32,riscv64]~^ ERROR invalid signature + + +/* all extern "interrupt" definitions should not return non-1ZST values */ + +#[cfg(avr)] +extern "avr-interrupt" fn avr_ret() -> u8 { + //[avr]~^ ERROR invalid signature + 1 +} + +#[cfg(msp430)] +extern "msp430-interrupt" fn msp430_ret() -> u8 { + //[msp430]~^ ERROR invalid signature + 1 +} + +#[cfg(any(riscv32,riscv64))] +extern "riscv-interrupt-m" fn riscv_m_ret() -> u8 { + //[riscv32,riscv64]~^ ERROR invalid signature + 1 +} + +#[cfg(any(riscv32,riscv64))] +extern "riscv-interrupt-s" fn riscv_s_ret() -> u8 { + //[riscv32,riscv64]~^ ERROR invalid signature + 1 +} + +#[cfg(any(x64,i686))] +extern "x86-interrupt" fn x86_ret() -> u8 { + //[x64,i686]~^ ERROR invalid signature + 1 +} + + + +/* extern "interrupt" fnptrs with invalid signatures */ + +#[cfg(avr)] +fn avr_ptr(_f: extern "avr-interrupt" fn(u8) -> u8) { +} + +#[cfg(msp430)] +fn msp430_ptr(_f: extern "msp430-interrupt" fn(u8) -> u8) { +} + +#[cfg(any(riscv32,riscv64))] +fn riscv_m_ptr(_f: extern "riscv-interrupt-m" fn(u8) -> u8) { +} + +#[cfg(any(riscv32,riscv64))] +fn riscv_s_ptr(_f: extern "riscv-interrupt-s" fn(u8) -> u8) { +} + +#[cfg(any(x64,i686))] +fn x86_ptr(_f: extern "x86-interrupt" fn() -> u8) { +} diff --git a/tests/ui/abi/interrupt-invalid-signature.x64.stderr b/tests/ui/abi/interrupt-invalid-signature.x64.stderr new file mode 100644 index 00000000000..86f2e097c37 --- /dev/null +++ b/tests/ui/abi/interrupt-invalid-signature.x64.stderr @@ -0,0 +1,15 @@ +error: invalid signature for `extern "x86-interrupt"` function + --> $DIR/interrupt-invalid-signature.rs:83:40 + | +LL | extern "x86-interrupt" fn x86_ret() -> u8 { + | ^^ + | + = note: functions with the "x86-interrupt" ABI cannot have a return type +help: remove the return type + --> $DIR/interrupt-invalid-signature.rs:83:40 + | +LL | extern "x86-interrupt" fn x86_ret() -> u8 { + | ^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/abi/interrupt-returns-never-or-unit.rs b/tests/ui/abi/interrupt-returns-never-or-unit.rs new file mode 100644 index 00000000000..8e224229a0b --- /dev/null +++ b/tests/ui/abi/interrupt-returns-never-or-unit.rs @@ -0,0 +1,110 @@ +/*! Tests interrupt ABIs can return ! + +Most interrupt ABIs share a similar restriction in terms of not allowing most signatures, +but it makes sense to allow them to return ! because they could indeed be divergent. + +This test uses `cfg` because it is not testing whether these ABIs work on the platform. +*/ +//@ add-core-stubs +//@ revisions: x64 i686 riscv32 riscv64 avr msp430 +//@ build-pass +// +//@ [x64] needs-llvm-components: x86 +//@ [x64] compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=rlib +//@ [i686] needs-llvm-components: x86 +//@ [i686] compile-flags: --target=i686-unknown-linux-gnu --crate-type=rlib +//@ [riscv32] needs-llvm-components: riscv +//@ [riscv32] compile-flags: --target=riscv32i-unknown-none-elf --crate-type=rlib +//@ [riscv64] needs-llvm-components: riscv +//@ [riscv64] compile-flags: --target=riscv64gc-unknown-none-elf --crate-type=rlib +//@ [avr] needs-llvm-components: avr +//@ [avr] compile-flags: --target=avr-none -C target-cpu=atmega328p --crate-type=rlib +//@ [msp430] needs-llvm-components: msp430 +//@ [msp430] compile-flags: --target=msp430-none-elf --crate-type=rlib +#![no_core] +#![feature( + no_core, + abi_msp430_interrupt, + abi_avr_interrupt, + abi_x86_interrupt, + abi_riscv_interrupt +)] + +extern crate minicore; +use minicore::*; + +/* interrupts can return never */ + +#[cfg(avr)] +extern "avr-interrupt" fn avr_ret_never() -> ! { + loop {} +} + +#[cfg(msp430)] +extern "msp430-interrupt" fn msp430_ret_never() -> ! { + loop {} +} + +#[cfg(any(riscv32,riscv64))] +extern "riscv-interrupt-m" fn riscv_m_ret_never() -> ! { + loop {} +} + +#[cfg(any(riscv32,riscv64))] +extern "riscv-interrupt-s" fn riscv_s_ret_never() -> ! { + loop {} +} + +#[cfg(any(x64,i686))] +extern "x86-interrupt" fn x86_ret_never() -> ! { + loop {} +} + +/* interrupts can return explicit () */ + +#[cfg(avr)] +extern "avr-interrupt" fn avr_ret_unit() -> () { + () +} + +#[cfg(msp430)] +extern "msp430-interrupt" fn msp430_ret_unit() -> () { + () +} + +#[cfg(any(riscv32,riscv64))] +extern "riscv-interrupt-m" fn riscv_m_ret_unit() -> () { + () +} + +#[cfg(any(riscv32,riscv64))] +extern "riscv-interrupt-s" fn riscv_s_ret_unit() -> () { + () +} + +#[cfg(any(x64,i686))] +extern "x86-interrupt" fn x86_ret_unit() -> () { + () +} + +/* extern "interrupt" fnptrs can return ! too */ + +#[cfg(avr)] +fn avr_ptr(_f: extern "avr-interrupt" fn() -> !) { +} + +#[cfg(msp430)] +fn msp430_ptr(_f: extern "msp430-interrupt" fn() -> !) { +} + +#[cfg(any(riscv32,riscv64))] +fn riscv_m_ptr(_f: extern "riscv-interrupt-m" fn() -> !) { +} + +#[cfg(any(riscv32,riscv64))] +fn riscv_s_ptr(_f: extern "riscv-interrupt-s" fn() -> !) { +} + +#[cfg(any(x64,i686))] +fn x86_ptr(_f: extern "x86-interrupt" fn() -> !) { +} diff --git a/tests/ui/alloc-error/alloc-error-handler-bad-signature-1.stderr b/tests/ui/alloc-error/alloc-error-handler-bad-signature-1.stderr index 15314fac37b..aad45c422e2 100644 --- a/tests/ui/alloc-error/alloc-error-handler-bad-signature-1.stderr +++ b/tests/ui/alloc-error/alloc-error-handler-bad-signature-1.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/alloc-error-handler-bad-signature-1.rs:10:1 | LL | #[alloc_error_handler] - | ---------------------- in this procedural macro expansion + | ---------------------- in this attribute macro expansion LL | // fn oom( LL | || info: &Layout, LL | || ) -> () @@ -23,7 +23,7 @@ error[E0308]: mismatched types --> $DIR/alloc-error-handler-bad-signature-1.rs:10:1 | LL | #[alloc_error_handler] - | ---------------------- in this procedural macro expansion + | ---------------------- in this attribute macro expansion LL | // fn oom( LL | || info: &Layout, LL | || ) -> () diff --git a/tests/ui/alloc-error/alloc-error-handler-bad-signature-2.stderr b/tests/ui/alloc-error/alloc-error-handler-bad-signature-2.stderr index 2ab42638411..581d1947419 100644 --- a/tests/ui/alloc-error/alloc-error-handler-bad-signature-2.stderr +++ b/tests/ui/alloc-error/alloc-error-handler-bad-signature-2.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/alloc-error-handler-bad-signature-2.rs:10:1 | LL | #[alloc_error_handler] - | ---------------------- in this procedural macro expansion + | ---------------------- in this attribute macro expansion LL | // fn oom( LL | || info: Layout, LL | || ) { @@ -31,7 +31,7 @@ error[E0308]: mismatched types --> $DIR/alloc-error-handler-bad-signature-2.rs:10:1 | LL | #[alloc_error_handler] - | ---------------------- in this procedural macro expansion + | ---------------------- in this attribute macro expansion LL | // fn oom( LL | || info: Layout, LL | || ) { diff --git a/tests/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr b/tests/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr index 3a410174f54..91147df71eb 100644 --- a/tests/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr +++ b/tests/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr @@ -2,7 +2,7 @@ error[E0061]: this function takes 0 arguments but 1 argument was supplied --> $DIR/alloc-error-handler-bad-signature-3.rs:10:1 | LL | #[alloc_error_handler] - | ---------------------- in this procedural macro expansion + | ---------------------- in this attribute macro expansion LL | fn oom() -> ! { | _-^^^^^^^^^^^^ LL | | loop {} diff --git a/tests/ui/allocator/not-an-allocator.stderr b/tests/ui/allocator/not-an-allocator.stderr index 079bf9334eb..f33a698ed78 100644 --- a/tests/ui/allocator/not-an-allocator.stderr +++ b/tests/ui/allocator/not-an-allocator.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied --> $DIR/not-an-allocator.rs:2:11 | LL | #[global_allocator] - | ------------------- in this procedural macro expansion + | ------------------- in this attribute macro expansion LL | static A: usize = 0; | ^^^^^ the trait `GlobalAlloc` is not implemented for `usize` | @@ -12,7 +12,7 @@ error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied --> $DIR/not-an-allocator.rs:2:11 | LL | #[global_allocator] - | ------------------- in this procedural macro expansion + | ------------------- in this attribute macro expansion LL | static A: usize = 0; | ^^^^^ the trait `GlobalAlloc` is not implemented for `usize` | @@ -23,7 +23,7 @@ error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied --> $DIR/not-an-allocator.rs:2:11 | LL | #[global_allocator] - | ------------------- in this procedural macro expansion + | ------------------- in this attribute macro expansion LL | static A: usize = 0; | ^^^^^ the trait `GlobalAlloc` is not implemented for `usize` | @@ -34,7 +34,7 @@ error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied --> $DIR/not-an-allocator.rs:2:11 | LL | #[global_allocator] - | ------------------- in this procedural macro expansion + | ------------------- in this attribute macro expansion LL | static A: usize = 0; | ^^^^^ the trait `GlobalAlloc` is not implemented for `usize` | diff --git a/tests/ui/allocator/two-allocators.stderr b/tests/ui/allocator/two-allocators.stderr index 5308232a20b..1a9a5910eec 100644 --- a/tests/ui/allocator/two-allocators.stderr +++ b/tests/ui/allocator/two-allocators.stderr @@ -4,7 +4,7 @@ error: cannot define multiple global allocators LL | static A: System = System; | -------------------------- previous global allocator defined here LL | #[global_allocator] - | ------------------- in this procedural macro expansion + | ------------------- in this attribute macro expansion LL | static B: System = System; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot define a new global allocator diff --git a/tests/ui/argument-suggestions/issue-100478.stderr b/tests/ui/argument-suggestions/issue-100478.stderr index 8889a0ab5df..81dbff2f000 100644 --- a/tests/ui/argument-suggestions/issue-100478.stderr +++ b/tests/ui/argument-suggestions/issue-100478.stderr @@ -75,12 +75,16 @@ LL | fn foo(p1: T1, p2: Arc<T2>, p3: T3, p4: Arc<T4>, p5: T5, p6: T6, p7: T7, p8 | ^^^ ----------- help: provide the argument | -LL - foo( -LL - -LL - p1, //p2, -LL - p3, p4, p5, p6, p7, p8, -LL - ); -LL + foo(p1, /* Arc<T2> */, p3, p4, p5, p6, p7, p8); +LL ~ foo( +LL + p1, +LL + /* Arc<T2> */, +LL + p3, +LL + p4, +LL + p5, +LL + p6, +LL + p7, +LL + p8, +LL ~ ); | error: aborting due to 4 previous errors diff --git a/tests/ui/asm/loongarch/bad-reg.loongarch32_ilp32d.stderr b/tests/ui/asm/loongarch/bad-reg.loongarch32_ilp32d.stderr new file mode 100644 index 00000000000..8742d4bd82c --- /dev/null +++ b/tests/ui/asm/loongarch/bad-reg.loongarch32_ilp32d.stderr @@ -0,0 +1,38 @@ +error: invalid register `$r0`: constant zero cannot be used as an operand for inline asm + --> $DIR/bad-reg.rs:27:18 + | +LL | asm!("", out("$r0") _); + | ^^^^^^^^^^^^ + +error: invalid register `$tp`: reserved for TLS + --> $DIR/bad-reg.rs:29:18 + | +LL | asm!("", out("$tp") _); + | ^^^^^^^^^^^^ + +error: invalid register `$sp`: the stack pointer cannot be used as an operand for inline asm + --> $DIR/bad-reg.rs:31:18 + | +LL | asm!("", out("$sp") _); + | ^^^^^^^^^^^^ + +error: invalid register `$r21`: reserved by the ABI + --> $DIR/bad-reg.rs:33:18 + | +LL | asm!("", out("$r21") _); + | ^^^^^^^^^^^^^ + +error: invalid register `$fp`: the frame pointer cannot be used as an operand for inline asm + --> $DIR/bad-reg.rs:35:18 + | +LL | asm!("", out("$fp") _); + | ^^^^^^^^^^^^ + +error: invalid register `$r31`: $r31 is used internally by LLVM and cannot be used as an operand for inline asm + --> $DIR/bad-reg.rs:37:18 + | +LL | asm!("", out("$r31") _); + | ^^^^^^^^^^^^^ + +error: aborting due to 6 previous errors + diff --git a/tests/ui/asm/loongarch/bad-reg.loongarch32_ilp32s.stderr b/tests/ui/asm/loongarch/bad-reg.loongarch32_ilp32s.stderr new file mode 100644 index 00000000000..e6cb6e40c70 --- /dev/null +++ b/tests/ui/asm/loongarch/bad-reg.loongarch32_ilp32s.stderr @@ -0,0 +1,62 @@ +error: invalid register `$r0`: constant zero cannot be used as an operand for inline asm + --> $DIR/bad-reg.rs:27:18 + | +LL | asm!("", out("$r0") _); + | ^^^^^^^^^^^^ + +error: invalid register `$tp`: reserved for TLS + --> $DIR/bad-reg.rs:29:18 + | +LL | asm!("", out("$tp") _); + | ^^^^^^^^^^^^ + +error: invalid register `$sp`: the stack pointer cannot be used as an operand for inline asm + --> $DIR/bad-reg.rs:31:18 + | +LL | asm!("", out("$sp") _); + | ^^^^^^^^^^^^ + +error: invalid register `$r21`: reserved by the ABI + --> $DIR/bad-reg.rs:33:18 + | +LL | asm!("", out("$r21") _); + | ^^^^^^^^^^^^^ + +error: invalid register `$fp`: the frame pointer cannot be used as an operand for inline asm + --> $DIR/bad-reg.rs:35:18 + | +LL | asm!("", out("$fp") _); + | ^^^^^^^^^^^^ + +error: invalid register `$r31`: $r31 is used internally by LLVM and cannot be used as an operand for inline asm + --> $DIR/bad-reg.rs:37:18 + | +LL | asm!("", out("$r31") _); + | ^^^^^^^^^^^^^ + +error: register class `freg` requires at least one of the following target features: d, f + --> $DIR/bad-reg.rs:41:26 + | +LL | asm!("/* {} */", in(freg) f); + | ^^^^^^^^^^ + +error: register class `freg` requires at least one of the following target features: d, f + --> $DIR/bad-reg.rs:43:26 + | +LL | asm!("/* {} */", out(freg) _); + | ^^^^^^^^^^^ + +error: register class `freg` requires at least one of the following target features: d, f + --> $DIR/bad-reg.rs:45:26 + | +LL | asm!("/* {} */", in(freg) d); + | ^^^^^^^^^^ + +error: register class `freg` requires at least one of the following target features: d, f + --> $DIR/bad-reg.rs:47:26 + | +LL | asm!("/* {} */", out(freg) d); + | ^^^^^^^^^^^ + +error: aborting due to 10 previous errors + diff --git a/tests/ui/asm/loongarch/bad-reg.loongarch64_lp64d.stderr b/tests/ui/asm/loongarch/bad-reg.loongarch64_lp64d.stderr index 0e544119650..8742d4bd82c 100644 --- a/tests/ui/asm/loongarch/bad-reg.loongarch64_lp64d.stderr +++ b/tests/ui/asm/loongarch/bad-reg.loongarch64_lp64d.stderr @@ -1,35 +1,35 @@ error: invalid register `$r0`: constant zero cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:22:18 + --> $DIR/bad-reg.rs:27:18 | LL | asm!("", out("$r0") _); | ^^^^^^^^^^^^ error: invalid register `$tp`: reserved for TLS - --> $DIR/bad-reg.rs:24:18 + --> $DIR/bad-reg.rs:29:18 | LL | asm!("", out("$tp") _); | ^^^^^^^^^^^^ error: invalid register `$sp`: the stack pointer cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:26:18 + --> $DIR/bad-reg.rs:31:18 | LL | asm!("", out("$sp") _); | ^^^^^^^^^^^^ error: invalid register `$r21`: reserved by the ABI - --> $DIR/bad-reg.rs:28:18 + --> $DIR/bad-reg.rs:33:18 | LL | asm!("", out("$r21") _); | ^^^^^^^^^^^^^ error: invalid register `$fp`: the frame pointer cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:30:18 + --> $DIR/bad-reg.rs:35:18 | LL | asm!("", out("$fp") _); | ^^^^^^^^^^^^ error: invalid register `$r31`: $r31 is used internally by LLVM and cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:32:18 + --> $DIR/bad-reg.rs:37:18 | LL | asm!("", out("$r31") _); | ^^^^^^^^^^^^^ diff --git a/tests/ui/asm/loongarch/bad-reg.loongarch64_lp64s.stderr b/tests/ui/asm/loongarch/bad-reg.loongarch64_lp64s.stderr index 6d0410dc6a1..e6cb6e40c70 100644 --- a/tests/ui/asm/loongarch/bad-reg.loongarch64_lp64s.stderr +++ b/tests/ui/asm/loongarch/bad-reg.loongarch64_lp64s.stderr @@ -1,59 +1,59 @@ error: invalid register `$r0`: constant zero cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:22:18 + --> $DIR/bad-reg.rs:27:18 | LL | asm!("", out("$r0") _); | ^^^^^^^^^^^^ error: invalid register `$tp`: reserved for TLS - --> $DIR/bad-reg.rs:24:18 + --> $DIR/bad-reg.rs:29:18 | LL | asm!("", out("$tp") _); | ^^^^^^^^^^^^ error: invalid register `$sp`: the stack pointer cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:26:18 + --> $DIR/bad-reg.rs:31:18 | LL | asm!("", out("$sp") _); | ^^^^^^^^^^^^ error: invalid register `$r21`: reserved by the ABI - --> $DIR/bad-reg.rs:28:18 + --> $DIR/bad-reg.rs:33:18 | LL | asm!("", out("$r21") _); | ^^^^^^^^^^^^^ error: invalid register `$fp`: the frame pointer cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:30:18 + --> $DIR/bad-reg.rs:35:18 | LL | asm!("", out("$fp") _); | ^^^^^^^^^^^^ error: invalid register `$r31`: $r31 is used internally by LLVM and cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:32:18 + --> $DIR/bad-reg.rs:37:18 | LL | asm!("", out("$r31") _); | ^^^^^^^^^^^^^ error: register class `freg` requires at least one of the following target features: d, f - --> $DIR/bad-reg.rs:36:26 + --> $DIR/bad-reg.rs:41:26 | LL | asm!("/* {} */", in(freg) f); | ^^^^^^^^^^ error: register class `freg` requires at least one of the following target features: d, f - --> $DIR/bad-reg.rs:38:26 + --> $DIR/bad-reg.rs:43:26 | LL | asm!("/* {} */", out(freg) _); | ^^^^^^^^^^^ error: register class `freg` requires at least one of the following target features: d, f - --> $DIR/bad-reg.rs:40:26 + --> $DIR/bad-reg.rs:45:26 | LL | asm!("/* {} */", in(freg) d); | ^^^^^^^^^^ error: register class `freg` requires at least one of the following target features: d, f - --> $DIR/bad-reg.rs:42:26 + --> $DIR/bad-reg.rs:47:26 | LL | asm!("/* {} */", out(freg) d); | ^^^^^^^^^^^ diff --git a/tests/ui/asm/loongarch/bad-reg.rs b/tests/ui/asm/loongarch/bad-reg.rs index 685b460bc92..0d3eba07f14 100644 --- a/tests/ui/asm/loongarch/bad-reg.rs +++ b/tests/ui/asm/loongarch/bad-reg.rs @@ -1,6 +1,11 @@ //@ add-core-stubs //@ needs-asm-support -//@ revisions: loongarch64_lp64d loongarch64_lp64s +//@ revisions: loongarch32_ilp32d loongarch32_ilp32s loongarch64_lp64d loongarch64_lp64s +//@ min-llvm-version: 20 +//@[loongarch32_ilp32d] compile-flags: --target loongarch32-unknown-none +//@[loongarch32_ilp32d] needs-llvm-components: loongarch +//@[loongarch32_ilp32s] compile-flags: --target loongarch32-unknown-none-softfloat +//@[loongarch32_ilp32s] needs-llvm-components: loongarch //@[loongarch64_lp64d] compile-flags: --target loongarch64-unknown-linux-gnu //@[loongarch64_lp64d] needs-llvm-components: loongarch //@[loongarch64_lp64s] compile-flags: --target loongarch64-unknown-none-softfloat @@ -34,12 +39,12 @@ fn f() { asm!("", out("$f0") _); // ok asm!("/* {} */", in(freg) f); - //[loongarch64_lp64s]~^ ERROR register class `freg` requires at least one of the following target features: d, f + //[loongarch32_ilp32s,loongarch64_lp64s]~^ ERROR register class `freg` requires at least one of the following target features: d, f asm!("/* {} */", out(freg) _); - //[loongarch64_lp64s]~^ ERROR register class `freg` requires at least one of the following target features: d, f + //[loongarch32_ilp32s,loongarch64_lp64s]~^ ERROR register class `freg` requires at least one of the following target features: d, f asm!("/* {} */", in(freg) d); - //[loongarch64_lp64s]~^ ERROR register class `freg` requires at least one of the following target features: d, f + //[loongarch32_ilp32s,loongarch64_lp64s]~^ ERROR register class `freg` requires at least one of the following target features: d, f asm!("/* {} */", out(freg) d); - //[loongarch64_lp64s]~^ ERROR register class `freg` requires at least one of the following target features: d, f + //[loongarch32_ilp32s,loongarch64_lp64s]~^ ERROR register class `freg` requires at least one of the following target features: d, f } } diff --git a/tests/ui/asm/naked-invalid-attr.rs b/tests/ui/asm/naked-invalid-attr.rs index 6ac9cb9e3a9..c9e0949abfb 100644 --- a/tests/ui/asm/naked-invalid-attr.rs +++ b/tests/ui/asm/naked-invalid-attr.rs @@ -1,25 +1,25 @@ // Checks that the #[unsafe(naked)] attribute can be placed on function definitions only. // //@ needs-asm-support -#![unsafe(naked)] //~ ERROR should be applied to a function definition +#![unsafe(naked)] //~ ERROR attribute cannot be used on use std::arch::naked_asm; extern "C" { - #[unsafe(naked)] //~ ERROR should be applied to a function definition + #[unsafe(naked)] //~ ERROR attribute cannot be used on fn f(); } -#[unsafe(naked)] //~ ERROR should be applied to a function definition +#[unsafe(naked)] //~ ERROR attribute cannot be used on #[repr(C)] struct S { - #[unsafe(naked)] //~ ERROR should be applied to a function definition + #[unsafe(naked)] //~ ERROR attribute cannot be used on a: u32, b: u32, } trait Invoke { - #[unsafe(naked)] //~ ERROR should be applied to a function definition + #[unsafe(naked)] //~ ERROR attribute cannot be used on extern "C" fn invoke(&self); } @@ -48,7 +48,7 @@ impl S { } fn main() { - #[unsafe(naked)] //~ ERROR should be applied to a function definition + #[unsafe(naked)] //~ ERROR attribute cannot be used on || {}; } diff --git a/tests/ui/asm/naked-invalid-attr.stderr b/tests/ui/asm/naked-invalid-attr.stderr index 2571c8fa989..936a36cd92e 100644 --- a/tests/ui/asm/naked-invalid-attr.stderr +++ b/tests/ui/asm/naked-invalid-attr.stderr @@ -4,65 +4,62 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `a` LL | #[::a] | ^ use of unresolved module or unlinked crate `a` -error[E0736]: attribute incompatible with `#[unsafe(naked)]` - --> $DIR/naked-invalid-attr.rs:56:3 +error: `#[naked]` attribute cannot be used on crates + --> $DIR/naked-invalid-attr.rs:4:1 | -LL | #[::a] - | ^^^ the `::a` attribute is incompatible with `#[unsafe(naked)]` -... -LL | #[unsafe(naked)] - | ---------------- function marked with `#[unsafe(naked)]` here - -error: attribute should be applied to a function definition - --> $DIR/naked-invalid-attr.rs:13:1 +LL | #![unsafe(naked)] + | ^^^^^^^^^^^^^^^^^ | -LL | #[unsafe(naked)] - | ^^^^^^^^^^^^^^^^ -LL | #[repr(C)] -LL | / struct S { -LL | | #[unsafe(naked)] -LL | | a: u32, -LL | | b: u32, -LL | | } - | |_- not a function definition + = help: `#[naked]` can only be applied to functions -error: attribute should be applied to a function definition - --> $DIR/naked-invalid-attr.rs:16:5 +error: `#[naked]` attribute cannot be used on foreign functions + --> $DIR/naked-invalid-attr.rs:9:5 | LL | #[unsafe(naked)] | ^^^^^^^^^^^^^^^^ -LL | a: u32, - | ------ not a function definition + | + = help: `#[naked]` can be applied to methods, functions -error: attribute should be applied to a function definition - --> $DIR/naked-invalid-attr.rs:51:5 +error: `#[naked]` attribute cannot be used on structs + --> $DIR/naked-invalid-attr.rs:13:1 + | +LL | #[unsafe(naked)] + | ^^^^^^^^^^^^^^^^ + | + = help: `#[naked]` can only be applied to functions + +error: `#[naked]` attribute cannot be used on struct fields + --> $DIR/naked-invalid-attr.rs:16:5 | LL | #[unsafe(naked)] | ^^^^^^^^^^^^^^^^ -LL | || {}; - | ----- not a function definition + | + = help: `#[naked]` can only be applied to functions -error: attribute should be applied to a function definition +error: `#[naked]` attribute cannot be used on required trait methods --> $DIR/naked-invalid-attr.rs:22:5 | LL | #[unsafe(naked)] | ^^^^^^^^^^^^^^^^ -LL | extern "C" fn invoke(&self); - | ---------------------------- not a function definition + | + = help: `#[naked]` can be applied to functions, inherent methods, provided trait methods, trait methods in impl blocks -error: attribute should be applied to a function definition - --> $DIR/naked-invalid-attr.rs:9:5 +error: `#[naked]` attribute cannot be used on closures + --> $DIR/naked-invalid-attr.rs:51:5 | LL | #[unsafe(naked)] | ^^^^^^^^^^^^^^^^ -LL | fn f(); - | ------- not a function definition + | + = help: `#[naked]` can be applied to methods, functions -error: attribute should be applied to a function definition - --> $DIR/naked-invalid-attr.rs:4:1 +error[E0736]: attribute incompatible with `#[unsafe(naked)]` + --> $DIR/naked-invalid-attr.rs:56:3 | -LL | #![unsafe(naked)] - | ^^^^^^^^^^^^^^^^^ cannot be applied to crates +LL | #[::a] + | ^^^ the `::a` attribute is incompatible with `#[unsafe(naked)]` +... +LL | #[unsafe(naked)] + | ---------------- function marked with `#[unsafe(naked)]` here error: aborting due to 8 previous errors diff --git a/tests/ui/asm/s390x/bad-reg.rs b/tests/ui/asm/s390x/bad-reg.rs index 56b2d709372..eb9138755e7 100644 --- a/tests/ui/asm/s390x/bad-reg.rs +++ b/tests/ui/asm/s390x/bad-reg.rs @@ -1,7 +1,7 @@ //@ add-core-stubs //@ needs-asm-support //@ revisions: s390x s390x_vector s390x_vector_stable -//@[s390x] compile-flags: --target s390x-unknown-linux-gnu +//@[s390x] compile-flags: --target s390x-unknown-linux-gnu -C target-feature=-vector //@[s390x] needs-llvm-components: systemz //@[s390x_vector] compile-flags: --target s390x-unknown-linux-gnu -C target-feature=+vector //@[s390x_vector] needs-llvm-components: systemz diff --git a/tests/ui/issues/issue-23442.rs b/tests/ui/associated-types/unioned-keys-with-associated-type-23442.rs index 883c5bb511a..89a2d0177a3 100644 --- a/tests/ui/issues/issue-23442.rs +++ b/tests/ui/associated-types/unioned-keys-with-associated-type-23442.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/23442 //@ check-pass #![allow(dead_code)] use std::marker::PhantomData; diff --git a/tests/ui/async-await/drop-live-upvar-2.may_not_dangle.stderr b/tests/ui/async-await/drop-live-upvar-2.may_not_dangle.stderr new file mode 100644 index 00000000000..34f6ba79246 --- /dev/null +++ b/tests/ui/async-await/drop-live-upvar-2.may_not_dangle.stderr @@ -0,0 +1,18 @@ +error[E0597]: `y` does not live long enough + --> $DIR/drop-live-upvar-2.rs:31:26 + | +LL | let y = (); + | - binding `y` declared here +LL | drop_me = Droppy(&y); + | ^^ borrowed value does not live long enough +... +LL | } + | - `y` dropped here while still borrowed +LL | } + | - borrow might be used here, when `fut` is dropped and runs the destructor for coroutine + | + = note: values in a scope are dropped in the opposite order they are defined + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/tests/ui/async-await/drop-live-upvar-2.rs b/tests/ui/async-await/drop-live-upvar-2.rs new file mode 100644 index 00000000000..605db4c8f76 --- /dev/null +++ b/tests/ui/async-await/drop-live-upvar-2.rs @@ -0,0 +1,37 @@ +//@ revisions: may_dangle may_not_dangle +//@[may_dangle] check-pass +//@ edition: 2018 + +// Ensure that if a coroutine's interior has no drop types then we don't require the upvars to +// be *use-live*, but instead require them to be *drop-live*. In this case, `Droppy<&'?0 ()>` +// does not require that `'?0` is live for drops since the parameter is `#[may_dangle]` in +// the may_dangle revision, but not in the may_not_dangle revision. + +#![feature(dropck_eyepatch)] + +struct Droppy<T>(T); + +#[cfg(may_dangle)] +unsafe impl<#[may_dangle] T> Drop for Droppy<T> { + fn drop(&mut self) { + // This does not use `T` of course. + } +} + +#[cfg(may_not_dangle)] +impl<T> Drop for Droppy<T> { + fn drop(&mut self) {} +} + +fn main() { + let drop_me; + let fut; + { + let y = (); + drop_me = Droppy(&y); + //[may_not_dangle]~^ ERROR `y` does not live long enough + fut = async { + std::mem::drop(drop_me); + }; + } +} diff --git a/tests/ui/async-await/drop-live-upvar.rs b/tests/ui/async-await/drop-live-upvar.rs new file mode 100644 index 00000000000..8e881f729b9 --- /dev/null +++ b/tests/ui/async-await/drop-live-upvar.rs @@ -0,0 +1,23 @@ +//@ edition: 2018 +// Regression test for <https://github.com/rust-lang/rust/issues/144155>. + +struct NeedsDrop<'a>(&'a Vec<i32>); + +async fn await_point() {} + +impl Drop for NeedsDrop<'_> { + fn drop(&mut self) {} +} + +fn foo() { + let v = vec![1, 2, 3]; + let x = NeedsDrop(&v); + let c = async { + std::future::ready(()).await; + drop(x); + }; + drop(v); + //~^ ERROR cannot move out of `v` because it is borrowed +} + +fn main() {} diff --git a/tests/ui/async-await/drop-live-upvar.stderr b/tests/ui/async-await/drop-live-upvar.stderr new file mode 100644 index 00000000000..f804484536b --- /dev/null +++ b/tests/ui/async-await/drop-live-upvar.stderr @@ -0,0 +1,22 @@ +error[E0505]: cannot move out of `v` because it is borrowed + --> $DIR/drop-live-upvar.rs:19:10 + | +LL | let v = vec![1, 2, 3]; + | - binding `v` declared here +LL | let x = NeedsDrop(&v); + | -- borrow of `v` occurs here +... +LL | drop(v); + | ^ move out of `v` occurs here +LL | +LL | } + | - borrow might be used here, when `c` is dropped and runs the destructor for coroutine + | +help: consider cloning the value if the performance cost is acceptable + | +LL | let x = NeedsDrop(&v.clone()); + | ++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0505`. diff --git a/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-completion.rs b/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-completion.rs index a8b05a4befa..ed99614914a 100644 --- a/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-completion.rs +++ b/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-completion.rs @@ -2,7 +2,7 @@ // be talking about `async fn`s instead. //@ run-fail -//@ error-pattern: thread 'main' panicked +//@ regex-error-pattern: thread 'main'.*panicked //@ error-pattern: `async fn` resumed after completion //@ edition:2018 diff --git a/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-panic.rs b/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-panic.rs index 94366e66263..881fafb010f 100644 --- a/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-panic.rs +++ b/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-panic.rs @@ -3,7 +3,7 @@ //@ run-fail //@ needs-unwind -//@ error-pattern: thread 'main' panicked +//@ regex-error-pattern: thread 'main'.*panicked //@ error-pattern: `async fn` resumed after panicking //@ edition:2018 diff --git a/tests/ui/async-await/recursive-async-auto-trait-overflow.rs b/tests/ui/async-await/recursive-async-auto-trait-overflow.rs new file mode 100644 index 00000000000..716600ce472 --- /dev/null +++ b/tests/ui/async-await/recursive-async-auto-trait-overflow.rs @@ -0,0 +1,14 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/145151>. + +//@ edition: 2024 +//@ check-pass + +async fn process<'a>() { + Box::pin(process()).await; +} + +fn require_send(_: impl Send) {} + +fn main() { + require_send(process()); +} diff --git a/tests/ui/attributes/attrs-on-params.rs b/tests/ui/attributes/attrs-on-params.rs index 158a4500bde..c8e9810327c 100644 --- a/tests/ui/attributes/attrs-on-params.rs +++ b/tests/ui/attributes/attrs-on-params.rs @@ -1,7 +1,7 @@ // This checks that incorrect params on function parameters are caught fn function(#[inline] param: u32) { - //~^ ERROR attribute should be applied to function or closure + //~^ ERROR attribute cannot be used on //~| ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes } diff --git a/tests/ui/attributes/attrs-on-params.stderr b/tests/ui/attributes/attrs-on-params.stderr index 306e862cb58..91f87a954c5 100644 --- a/tests/ui/attributes/attrs-on-params.stderr +++ b/tests/ui/attributes/attrs-on-params.stderr @@ -4,14 +4,13 @@ error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed LL | fn function(#[inline] param: u32) { | ^^^^^^^^^ -error[E0518]: attribute should be applied to function or closure +error: `#[inline]` attribute cannot be used on function params --> $DIR/attrs-on-params.rs:3:13 | LL | fn function(#[inline] param: u32) { - | ^^^^^^^^^----------- - | | - | not a function or closure + | ^^^^^^^^^ + | + = help: `#[inline]` can only be applied to functions error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0518`. diff --git a/tests/ui/attributes/auxiliary/derive_macro_with_helper.rs b/tests/ui/attributes/auxiliary/derive_macro_with_helper.rs new file mode 100644 index 00000000000..128af50ce36 --- /dev/null +++ b/tests/ui/attributes/auxiliary/derive_macro_with_helper.rs @@ -0,0 +1,8 @@ +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(Derive, attributes(arg))] +pub fn derive(_: TokenStream) -> TokenStream { + TokenStream::new() +} diff --git a/tests/ui/attributes/check-builtin-attr-ice.rs b/tests/ui/attributes/check-builtin-attr-ice.rs index 7745849acd0..811210e2cca 100644 --- a/tests/ui/attributes/check-builtin-attr-ice.rs +++ b/tests/ui/attributes/check-builtin-attr-ice.rs @@ -44,12 +44,10 @@ struct Foo { #[should_panic::skip] //~^ ERROR failed to resolve - //~| ERROR `#[should_panic::skip]` only has an effect on functions pub field: u8, #[should_panic::a::b::c] //~^ ERROR failed to resolve - //~| ERROR `#[should_panic::a::b::c]` only has an effect on functions pub field2: u8, } diff --git a/tests/ui/attributes/check-builtin-attr-ice.stderr b/tests/ui/attributes/check-builtin-attr-ice.stderr index 4f26f71efb7..07bbe01898a 100644 --- a/tests/ui/attributes/check-builtin-attr-ice.stderr +++ b/tests/ui/attributes/check-builtin-attr-ice.stderr @@ -5,35 +5,17 @@ LL | #[should_panic::skip] | ^^^^^^^^^^^^ use of unresolved module or unlinked crate `should_panic` error[E0433]: failed to resolve: use of unresolved module or unlinked crate `should_panic` - --> $DIR/check-builtin-attr-ice.rs:50:7 + --> $DIR/check-builtin-attr-ice.rs:49:7 | LL | #[should_panic::a::b::c] | ^^^^^^^^^^^^ use of unresolved module or unlinked crate `should_panic` error[E0433]: failed to resolve: use of unresolved module or unlinked crate `deny` - --> $DIR/check-builtin-attr-ice.rs:59:7 + --> $DIR/check-builtin-attr-ice.rs:57:7 | LL | #[deny::skip] | ^^^^ use of unresolved module or unlinked crate `deny` -error: `#[should_panic::skip]` only has an effect on functions - --> $DIR/check-builtin-attr-ice.rs:45:5 - | -LL | #[should_panic::skip] - | ^^^^^^^^^^^^^^^^^^^^^ - | -note: the lint level is defined here - --> $DIR/check-builtin-attr-ice.rs:42:9 - | -LL | #![deny(unused_attributes)] - | ^^^^^^^^^^^^^^^^^ - -error: `#[should_panic::a::b::c]` only has an effect on functions - --> $DIR/check-builtin-attr-ice.rs:50:5 - | -LL | #[should_panic::a::b::c] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 5 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/attributes/cold-attribute-application-54044.rs b/tests/ui/attributes/cold-attribute-application-54044.rs index 2e644b91c07..cf027ac02b0 100644 --- a/tests/ui/attributes/cold-attribute-application-54044.rs +++ b/tests/ui/attributes/cold-attribute-application-54044.rs @@ -2,13 +2,13 @@ #![deny(unused_attributes)] //~ NOTE lint level is defined here #[cold] -//~^ ERROR attribute should be applied to a function -//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -struct Foo; //~ NOTE not a function +//~^ ERROR attribute cannot be used on +//~| WARN previously accepted +struct Foo; fn main() { #[cold] - //~^ ERROR attribute should be applied to a function - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - 5; //~ NOTE not a function + //~^ ERROR attribute cannot be used on + //~| WARN previously accepted + 5; } diff --git a/tests/ui/attributes/cold-attribute-application-54044.stderr b/tests/ui/attributes/cold-attribute-application-54044.stderr index efdf5e0de52..367686f02cb 100644 --- a/tests/ui/attributes/cold-attribute-application-54044.stderr +++ b/tests/ui/attributes/cold-attribute-application-54044.stderr @@ -1,29 +1,25 @@ -error: attribute should be applied to a function definition +error: `#[cold]` attribute cannot be used on structs --> $DIR/cold-attribute-application-54044.rs:4:1 | LL | #[cold] | ^^^^^^^ -... -LL | struct Foo; - | ----------- not a function definition | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[cold]` can only be applied to functions note: the lint level is defined here --> $DIR/cold-attribute-application-54044.rs:2:9 | LL | #![deny(unused_attributes)] | ^^^^^^^^^^^^^^^^^ -error: attribute should be applied to a function definition +error: `#[cold]` attribute cannot be used on expressions --> $DIR/cold-attribute-application-54044.rs:10:5 | LL | #[cold] | ^^^^^^^ -... -LL | 5; - | - not a function definition | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[cold]` can only be applied to functions error: aborting due to 2 previous errors diff --git a/tests/ui/attributes/crate-name-macro-call.stderr b/tests/ui/attributes/crate-name-macro-call.stderr index ab562b41a31..56827aa11a4 100644 --- a/tests/ui/attributes/crate-name-macro-call.stderr +++ b/tests/ui/attributes/crate-name-macro-call.stderr @@ -3,6 +3,8 @@ error: malformed `crate_name` attribute input | LL | #![crate_name = concat!("my", "crate")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![crate_name = "name"]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/crates-and-source-files.html#the-crate_name-attribute> error: aborting due to 1 previous error diff --git a/tests/ui/attributes/crate-type-delimited.stderr b/tests/ui/attributes/crate-type-delimited.stderr index 0bbbe07b198..7f080f74838 100644 --- a/tests/ui/attributes/crate-type-delimited.stderr +++ b/tests/ui/attributes/crate-type-delimited.stderr @@ -2,7 +2,24 @@ error: malformed `crate_type` attribute input --> $DIR/crate-type-delimited.rs:2:1 | LL | #![crate_type(lib)] - | ^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![crate_type = "bin|lib|..."]` + | ^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html> +help: the following are the possible correct uses + | +LL - #![crate_type(lib)] +LL + #![crate_type = "bin"] + | +LL - #![crate_type(lib)] +LL + #![crate_type = "cdylib"] + | +LL - #![crate_type(lib)] +LL + #![crate_type = "dylib"] + | +LL - #![crate_type(lib)] +LL + #![crate_type = "lib"] + | + = and 4 other candidates error: aborting due to 1 previous error diff --git a/tests/ui/attributes/crate-type-empty.stderr b/tests/ui/attributes/crate-type-empty.stderr index b9279d961ee..f50bb33d6bb 100644 --- a/tests/ui/attributes/crate-type-empty.stderr +++ b/tests/ui/attributes/crate-type-empty.stderr @@ -2,7 +2,20 @@ error: malformed `crate_type` attribute input --> $DIR/crate-type-empty.rs:2:1 | LL | #![crate_type] - | ^^^^^^^^^^^^^^ help: must be of the form: `#![crate_type = "bin|lib|..."]` + | ^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html> +help: the following are the possible correct uses + | +LL | #![crate_type = "bin"] + | +++++++ +LL | #![crate_type = "cdylib"] + | ++++++++++ +LL | #![crate_type = "dylib"] + | +++++++++ +LL | #![crate_type = "lib"] + | +++++++ + = and 4 other candidates error: aborting due to 1 previous error diff --git a/tests/ui/attributes/crate-type-macro-call.stderr b/tests/ui/attributes/crate-type-macro-call.stderr index 6ccc3edf885..97938f7af24 100644 --- a/tests/ui/attributes/crate-type-macro-call.stderr +++ b/tests/ui/attributes/crate-type-macro-call.stderr @@ -2,7 +2,24 @@ error: malformed `crate_type` attribute input --> $DIR/crate-type-macro-call.rs:1:1 | LL | #![crate_type = foo!()] - | ^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![crate_type = "bin|lib|..."]` + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html> +help: the following are the possible correct uses + | +LL - #![crate_type = foo!()] +LL + #![crate_type = "bin"] + | +LL - #![crate_type = foo!()] +LL + #![crate_type = "cdylib"] + | +LL - #![crate_type = foo!()] +LL + #![crate_type = "dylib"] + | +LL - #![crate_type = foo!()] +LL + #![crate_type = "lib"] + | + = and 4 other candidates error: aborting due to 1 previous error diff --git a/tests/ui/attributes/empty-repr.rs b/tests/ui/attributes/empty-repr.rs new file mode 100644 index 00000000000..e6ba1baf031 --- /dev/null +++ b/tests/ui/attributes/empty-repr.rs @@ -0,0 +1,14 @@ +// Regression test for https://github.com/rust-lang/rust/issues/138510 + +#![feature(where_clause_attrs)] +#![deny(unused_attributes)] + +fn main() { +} + +fn test() where +#[repr()] +//~^ ERROR unused attribute +(): Sized { + +} diff --git a/tests/ui/attributes/empty-repr.stderr b/tests/ui/attributes/empty-repr.stderr new file mode 100644 index 00000000000..92901fa170c --- /dev/null +++ b/tests/ui/attributes/empty-repr.stderr @@ -0,0 +1,14 @@ +error: unused attribute + --> $DIR/empty-repr.rs:10:1 + | +LL | #[repr()] + | ^^^^^^^^^ help: remove this attribute + | +note: the lint level is defined here + --> $DIR/empty-repr.rs:4:9 + | +LL | #![deny(unused_attributes)] + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/attributes/helper-attr-interpolated-non-lit-arg.rs b/tests/ui/attributes/helper-attr-interpolated-non-lit-arg.rs new file mode 100644 index 00000000000..17c9ad1bd48 --- /dev/null +++ b/tests/ui/attributes/helper-attr-interpolated-non-lit-arg.rs @@ -0,0 +1,20 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/140612>. +//@ proc-macro: derive_macro_with_helper.rs +//@ edition: 2018 +//@ check-pass + +macro_rules! expand { + ($text:expr) => { + #[derive(derive_macro_with_helper::Derive)] + // This inert attr is completely valid because it follows the grammar + // `#` `[` SimplePath DelimitedTokenStream `]`. + // However, we used to incorrectly delay a bug here and ICE when trying to parse `$text` as + // the inside of a "meta item list" which may only begin with literals or paths. + #[arg($text)] + pub struct Foo; + }; +} + +expand!(1 + 1); + +fn main() {} diff --git a/tests/ui/attributes/inline-attribute-enum-variant-error.rs b/tests/ui/attributes/inline-attribute-enum-variant-error.rs index 305b285d2a4..fd2cd49be16 100644 --- a/tests/ui/attributes/inline-attribute-enum-variant-error.rs +++ b/tests/ui/attributes/inline-attribute-enum-variant-error.rs @@ -2,7 +2,7 @@ enum Foo { #[inline] - //~^ ERROR attribute should be applied + //~^ ERROR attribute cannot be used on Variant, } diff --git a/tests/ui/attributes/inline-attribute-enum-variant-error.stderr b/tests/ui/attributes/inline-attribute-enum-variant-error.stderr index a4564d8f722..03954388c2e 100644 --- a/tests/ui/attributes/inline-attribute-enum-variant-error.stderr +++ b/tests/ui/attributes/inline-attribute-enum-variant-error.stderr @@ -1,12 +1,10 @@ -error[E0518]: attribute should be applied to function or closure +error: `#[inline]` attribute cannot be used on enum variants --> $DIR/inline-attribute-enum-variant-error.rs:4:5 | LL | #[inline] | ^^^^^^^^^ -LL | -LL | Variant, - | ------- not a function or closure + | + = help: `#[inline]` can only be applied to functions error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0518`. diff --git a/tests/ui/attributes/inline/attr-usage-inline.rs b/tests/ui/attributes/inline/attr-usage-inline.rs index d8ca0fce163..8217b9834ff 100644 --- a/tests/ui/attributes/inline/attr-usage-inline.rs +++ b/tests/ui/attributes/inline/attr-usage-inline.rs @@ -4,7 +4,7 @@ #[inline] fn f() {} -#[inline] //~ ERROR: attribute should be applied to function or closure +#[inline] //~ ERROR: attribute cannot be used on struct S; struct I { diff --git a/tests/ui/attributes/inline/attr-usage-inline.stderr b/tests/ui/attributes/inline/attr-usage-inline.stderr index 2123438032c..9fca17d90ca 100644 --- a/tests/ui/attributes/inline/attr-usage-inline.stderr +++ b/tests/ui/attributes/inline/attr-usage-inline.stderr @@ -1,10 +1,10 @@ -error[E0518]: attribute should be applied to function or closure +error: `#[inline]` attribute cannot be used on structs --> $DIR/attr-usage-inline.rs:7:1 | LL | #[inline] | ^^^^^^^^^ -LL | struct S; - | --------- not a function or closure + | + = help: `#[inline]` can only be applied to functions error[E0518]: attribute should be applied to function or closure --> $DIR/attr-usage-inline.rs:21:1 diff --git a/tests/ui/attributes/invalid-macro-use.rs b/tests/ui/attributes/invalid-macro-use.rs index cfb13fd183c..52e4608303f 100644 --- a/tests/ui/attributes/invalid-macro-use.rs +++ b/tests/ui/attributes/invalid-macro-use.rs @@ -8,21 +8,25 @@ extern crate std as s1; #[macro_use(5)] //~^ ERROR malformed `macro_use` attribute input //~| NOTE expected a valid identifier here +//~| NOTE for more information, visit extern crate std as s2; #[macro_use(a = "b")] //~^ ERROR malformed `macro_use` attribute input //~| NOTE didn't expect any arguments here +//~| NOTE for more information, visit extern crate std as s3; #[macro_use(a(b))] //~^ ERROR malformed `macro_use` attribute input //~| NOTE didn't expect any arguments here +//~| NOTE for more information, visit extern crate std as s4; #[macro_use(a::b)] //~^ ERROR malformed `macro_use` attribute input //~| NOTE expected a valid identifier here +//~| NOTE for more information, visit extern crate std as s5; #[macro_use(a)] diff --git a/tests/ui/attributes/invalid-macro-use.stderr b/tests/ui/attributes/invalid-macro-use.stderr index 4f5db5c558a..ff3ed6196d3 100644 --- a/tests/ui/attributes/invalid-macro-use.stderr +++ b/tests/ui/attributes/invalid-macro-use.stderr @@ -1,11 +1,11 @@ error[E0469]: imported macro not found - --> $DIR/invalid-macro-use.rs:47:13 + --> $DIR/invalid-macro-use.rs:51:13 | LL | #[macro_use(a)] | ^ error[E0469]: imported macro not found - --> $DIR/invalid-macro-use.rs:49:13 + --> $DIR/invalid-macro-use.rs:53:13 | LL | #[macro_use(b)] | ^ @@ -24,6 +24,7 @@ LL | #[macro_use(5)] | | | expected a valid identifier here | + = note: for more information, visit <https://doc.rust-lang.org/reference/macros-by-example.html#the-macro_use-attribute> help: try changing it to one of the following valid forms of the attribute | LL - #[macro_use(5)] @@ -34,13 +35,14 @@ LL + #[macro_use] | error[E0565]: malformed `macro_use` attribute input - --> $DIR/invalid-macro-use.rs:13:1 + --> $DIR/invalid-macro-use.rs:14:1 | LL | #[macro_use(a = "b")] | ^^^^^^^^^^^^^^-----^^ | | | didn't expect any arguments here | + = note: for more information, visit <https://doc.rust-lang.org/reference/macros-by-example.html#the-macro_use-attribute> help: try changing it to one of the following valid forms of the attribute | LL - #[macro_use(a = "b")] @@ -51,13 +53,14 @@ LL + #[macro_use] | error[E0565]: malformed `macro_use` attribute input - --> $DIR/invalid-macro-use.rs:18:1 + --> $DIR/invalid-macro-use.rs:20:1 | LL | #[macro_use(a(b))] | ^^^^^^^^^^^^^---^^ | | | didn't expect any arguments here | + = note: for more information, visit <https://doc.rust-lang.org/reference/macros-by-example.html#the-macro_use-attribute> help: try changing it to one of the following valid forms of the attribute | LL - #[macro_use(a(b))] @@ -68,13 +71,14 @@ LL + #[macro_use] | error[E0539]: malformed `macro_use` attribute input - --> $DIR/invalid-macro-use.rs:23:1 + --> $DIR/invalid-macro-use.rs:26:1 | LL | #[macro_use(a::b)] | ^^^^^^^^^^^^----^^ | | | expected a valid identifier here | + = note: for more information, visit <https://doc.rust-lang.org/reference/macros-by-example.html#the-macro_use-attribute> help: try changing it to one of the following valid forms of the attribute | LL - #[macro_use(a::b)] @@ -85,13 +89,13 @@ LL + #[macro_use] | error: unused attribute - --> $DIR/invalid-macro-use.rs:28:1 + --> $DIR/invalid-macro-use.rs:32:1 | LL | #[macro_use(a)] | ^^^^^^^^^^^^^^^ help: remove this attribute | note: attribute also specified here - --> $DIR/invalid-macro-use.rs:30:1 + --> $DIR/invalid-macro-use.rs:34:1 | LL | #[macro_use] | ^^^^^^^^^^^^ @@ -102,25 +106,25 @@ LL | #![deny(unused_attributes)] | ^^^^^^^^^^^^^^^^^ error: unused attribute - --> $DIR/invalid-macro-use.rs:36:1 + --> $DIR/invalid-macro-use.rs:40:1 | LL | #[macro_use(a)] | ^^^^^^^^^^^^^^^ help: remove this attribute | note: attribute also specified here - --> $DIR/invalid-macro-use.rs:34:1 + --> $DIR/invalid-macro-use.rs:38:1 | LL | #[macro_use] | ^^^^^^^^^^^^ error: unused attribute - --> $DIR/invalid-macro-use.rs:42:1 + --> $DIR/invalid-macro-use.rs:46:1 | LL | #[macro_use] | ^^^^^^^^^^^^ help: remove this attribute | note: attribute also specified here - --> $DIR/invalid-macro-use.rs:40:1 + --> $DIR/invalid-macro-use.rs:44:1 | LL | #[macro_use] | ^^^^^^^^^^^^ diff --git a/tests/ui/attributes/invalid-reprs.stderr b/tests/ui/attributes/invalid-reprs.stderr index 415b969b244..72aaff92bd0 100644 --- a/tests/ui/attributes/invalid-reprs.stderr +++ b/tests/ui/attributes/invalid-reprs.stderr @@ -26,6 +26,7 @@ LL | let y = #[repr(uwu(4))] | ^^^^^^ | = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` + = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html?highlight=repr#representations> error: aborting due to 3 previous errors diff --git a/tests/ui/attributes/issue-105594-invalid-attr-validation.rs b/tests/ui/attributes/issue-105594-invalid-attr-validation.rs index cb196471fd7..f9e01cd1507 100644 --- a/tests/ui/attributes/issue-105594-invalid-attr-validation.rs +++ b/tests/ui/attributes/issue-105594-invalid-attr-validation.rs @@ -3,5 +3,5 @@ fn main() {} -#[track_caller] //~ ERROR attribute should be applied to a function +#[track_caller] //~ ERROR attribute cannot be used on static _A: () = (); diff --git a/tests/ui/attributes/issue-105594-invalid-attr-validation.stderr b/tests/ui/attributes/issue-105594-invalid-attr-validation.stderr index 1248967c47b..337d3808d28 100644 --- a/tests/ui/attributes/issue-105594-invalid-attr-validation.stderr +++ b/tests/ui/attributes/issue-105594-invalid-attr-validation.stderr @@ -1,11 +1,10 @@ -error[E0739]: attribute should be applied to a function definition +error: `#[track_caller]` attribute cannot be used on statics --> $DIR/issue-105594-invalid-attr-validation.rs:6:1 | LL | #[track_caller] | ^^^^^^^^^^^^^^^ -LL | static _A: () = (); - | ------------------- not a function definition + | + = help: `#[track_caller]` can only be applied to functions error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0739`. diff --git a/tests/ui/attributes/key-value-expansion-scope.rs b/tests/ui/attributes/key-value-expansion-scope.rs index 49a59502377..6688d698f9e 100644 --- a/tests/ui/attributes/key-value-expansion-scope.rs +++ b/tests/ui/attributes/key-value-expansion-scope.rs @@ -1,7 +1,7 @@ -#![doc = in_root!()] //~ WARN cannot find macro `in_root` +#![doc = in_root!()] //~ ERROR cannot find macro `in_root` //~| WARN this was previously accepted by the compiler #![doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope -#![doc = in_mod_escape!()] //~ WARN cannot find macro `in_mod_escape` +#![doc = in_mod_escape!()] //~ ERROR cannot find macro `in_mod_escape` //~| WARN this was previously accepted by the compiler #![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope @@ -18,10 +18,10 @@ fn before() { macro_rules! in_root { () => { "" } } -#[doc = in_mod!()] //~ WARN cannot find macro `in_mod` +#[doc = in_mod!()] //~ ERROR cannot find macro `in_mod` //~| WARN this was previously accepted by the compiler mod macros_stay { - #![doc = in_mod!()] //~ WARN cannot find macro `in_mod` + #![doc = in_mod!()] //~ ERROR cannot find macro `in_mod` //~| WARN this was previously accepted by the compiler macro_rules! in_mod { () => { "" } } @@ -33,10 +33,10 @@ mod macros_stay { } #[macro_use] -#[doc = in_mod_escape!()] //~ WARN cannot find macro `in_mod_escape` +#[doc = in_mod_escape!()] //~ ERROR cannot find macro `in_mod_escape` //~| WARN this was previously accepted by the compiler mod macros_escape { - #![doc = in_mod_escape!()] //~ WARN cannot find macro `in_mod_escape` + #![doc = in_mod_escape!()] //~ ERROR cannot find macro `in_mod_escape` //~| WARN this was previously accepted by the compiler macro_rules! in_mod_escape { () => { "" } } diff --git a/tests/ui/attributes/key-value-expansion-scope.stderr b/tests/ui/attributes/key-value-expansion-scope.stderr index 91a602e57d9..29b48ca4ce6 100644 --- a/tests/ui/attributes/key-value-expansion-scope.stderr +++ b/tests/ui/attributes/key-value-expansion-scope.stderr @@ -126,7 +126,7 @@ LL | #![doc = in_block!()] | = help: have you added the `#[macro_use]` on the module/import? -warning: cannot find macro `in_root` in the current scope when looking from the crate root +error: cannot find macro `in_root` in the current scope when looking from the crate root --> $DIR/key-value-expansion-scope.rs:1:10 | LL | #![doc = in_root!()] @@ -135,9 +135,9 @@ LL | #![doc = in_root!()] = 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 #124535 <https://github.com/rust-lang/rust/issues/124535> = help: import `macro_rules` with `use` to make it callable above its definition - = note: `#[warn(out_of_scope_macro_calls)]` on by default + = note: `#[deny(out_of_scope_macro_calls)]` on by default -warning: cannot find macro `in_mod_escape` in the current scope when looking from the crate root +error: cannot find macro `in_mod_escape` in the current scope when looking from the crate root --> $DIR/key-value-expansion-scope.rs:4:10 | LL | #![doc = in_mod_escape!()] @@ -147,7 +147,7 @@ LL | #![doc = in_mod_escape!()] = note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535> = help: import `macro_rules` with `use` to make it callable above its definition -warning: cannot find macro `in_mod` in the current scope when looking from module `macros_stay` +error: cannot find macro `in_mod` in the current scope when looking from module `macros_stay` --> $DIR/key-value-expansion-scope.rs:21:9 | LL | #[doc = in_mod!()] @@ -157,7 +157,7 @@ LL | #[doc = in_mod!()] = note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535> = help: import `macro_rules` with `use` to make it callable above its definition -warning: cannot find macro `in_mod` in the current scope when looking from module `macros_stay` +error: cannot find macro `in_mod` in the current scope when looking from module `macros_stay` --> $DIR/key-value-expansion-scope.rs:24:14 | LL | #![doc = in_mod!()] @@ -167,7 +167,7 @@ LL | #![doc = in_mod!()] = note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535> = help: import `macro_rules` with `use` to make it callable above its definition -warning: cannot find macro `in_mod_escape` in the current scope when looking from module `macros_escape` +error: cannot find macro `in_mod_escape` in the current scope when looking from module `macros_escape` --> $DIR/key-value-expansion-scope.rs:36:9 | LL | #[doc = in_mod_escape!()] @@ -177,7 +177,7 @@ LL | #[doc = in_mod_escape!()] = note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535> = help: import `macro_rules` with `use` to make it callable above its definition -warning: cannot find macro `in_mod_escape` in the current scope when looking from module `macros_escape` +error: cannot find macro `in_mod_escape` in the current scope when looking from module `macros_escape` --> $DIR/key-value-expansion-scope.rs:39:14 | LL | #![doc = in_mod_escape!()] @@ -187,5 +187,77 @@ LL | #![doc = in_mod_escape!()] = note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535> = help: import `macro_rules` with `use` to make it callable above its definition -error: aborting due to 16 previous errors; 6 warnings emitted +error: aborting due to 22 previous errors + +Future incompatibility report: Future breakage diagnostic: +error: cannot find macro `in_root` in the current scope when looking from the crate root + --> $DIR/key-value-expansion-scope.rs:1:10 + | +LL | #![doc = in_root!()] + | ^^^^^^^ not found from the crate root + | + = 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 #124535 <https://github.com/rust-lang/rust/issues/124535> + = help: import `macro_rules` with `use` to make it callable above its definition + = note: `#[deny(out_of_scope_macro_calls)]` on by default + +Future breakage diagnostic: +error: cannot find macro `in_mod_escape` in the current scope when looking from the crate root + --> $DIR/key-value-expansion-scope.rs:4:10 + | +LL | #![doc = in_mod_escape!()] + | ^^^^^^^^^^^^^ not found from the crate root + | + = 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 #124535 <https://github.com/rust-lang/rust/issues/124535> + = help: import `macro_rules` with `use` to make it callable above its definition + = note: `#[deny(out_of_scope_macro_calls)]` on by default + +Future breakage diagnostic: +error: cannot find macro `in_mod` in the current scope when looking from module `macros_stay` + --> $DIR/key-value-expansion-scope.rs:21:9 + | +LL | #[doc = in_mod!()] + | ^^^^^^ not found from module `macros_stay` + | + = 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 #124535 <https://github.com/rust-lang/rust/issues/124535> + = help: import `macro_rules` with `use` to make it callable above its definition + = note: `#[deny(out_of_scope_macro_calls)]` on by default + +Future breakage diagnostic: +error: cannot find macro `in_mod` in the current scope when looking from module `macros_stay` + --> $DIR/key-value-expansion-scope.rs:24:14 + | +LL | #![doc = in_mod!()] + | ^^^^^^ not found from module `macros_stay` + | + = 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 #124535 <https://github.com/rust-lang/rust/issues/124535> + = help: import `macro_rules` with `use` to make it callable above its definition + = note: `#[deny(out_of_scope_macro_calls)]` on by default + +Future breakage diagnostic: +error: cannot find macro `in_mod_escape` in the current scope when looking from module `macros_escape` + --> $DIR/key-value-expansion-scope.rs:36:9 + | +LL | #[doc = in_mod_escape!()] + | ^^^^^^^^^^^^^ not found from module `macros_escape` + | + = 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 #124535 <https://github.com/rust-lang/rust/issues/124535> + = help: import `macro_rules` with `use` to make it callable above its definition + = note: `#[deny(out_of_scope_macro_calls)]` on by default + +Future breakage diagnostic: +error: cannot find macro `in_mod_escape` in the current scope when looking from module `macros_escape` + --> $DIR/key-value-expansion-scope.rs:39:14 + | +LL | #![doc = in_mod_escape!()] + | ^^^^^^^^^^^^^ not found from module `macros_escape` + | + = 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 #124535 <https://github.com/rust-lang/rust/issues/124535> + = help: import `macro_rules` with `use` to make it callable above its definition + = note: `#[deny(out_of_scope_macro_calls)]` on by default diff --git a/tests/ui/attributes/linkage.rs b/tests/ui/attributes/linkage.rs index 0d5ce699fa8..932bfa88fc5 100644 --- a/tests/ui/attributes/linkage.rs +++ b/tests/ui/attributes/linkage.rs @@ -3,16 +3,16 @@ #![deny(unused_attributes)] #![allow(dead_code)] -#[linkage = "weak"] //~ ERROR attribute should be applied to a function or static +#[linkage = "weak"] //~ ERROR attribute cannot be used on type InvalidTy = (); -#[linkage = "weak"] //~ ERROR attribute should be applied to a function or static +#[linkage = "weak"] //~ ERROR attribute cannot be used on mod invalid_module {} -#[linkage = "weak"] //~ ERROR attribute should be applied to a function or static +#[linkage = "weak"] //~ ERROR attribute cannot be used on struct F; -#[linkage = "weak"] //~ ERROR attribute should be applied to a function or static +#[linkage = "weak"] //~ ERROR attribute cannot be used on impl F { #[linkage = "weak"] fn valid(&self) {} @@ -24,7 +24,7 @@ fn f() { { 1 }; - //~^^^^ ERROR attribute should be applied to a function or static + //~^^^^ ERROR attribute cannot be used on } extern "C" { @@ -38,5 +38,5 @@ extern "C" { fn main() { let _ = #[linkage = "weak"] (|| 1); - //~^^ ERROR attribute should be applied to a function or static + //~^^ ERROR attribute cannot be used on } diff --git a/tests/ui/attributes/linkage.stderr b/tests/ui/attributes/linkage.stderr index d5595529f40..2e7ff0e7936 100644 --- a/tests/ui/attributes/linkage.stderr +++ b/tests/ui/attributes/linkage.stderr @@ -1,55 +1,50 @@ -error: attribute should be applied to a function or static +error: `#[linkage]` attribute cannot be used on type aliases --> $DIR/linkage.rs:6:1 | LL | #[linkage = "weak"] | ^^^^^^^^^^^^^^^^^^^ -LL | type InvalidTy = (); - | -------------------- not a function definition or static + | + = help: `#[linkage]` can be applied to functions, statics, foreign statics -error: attribute should be applied to a function or static +error: `#[linkage]` attribute cannot be used on modules --> $DIR/linkage.rs:9:1 | LL | #[linkage = "weak"] | ^^^^^^^^^^^^^^^^^^^ -LL | mod invalid_module {} - | --------------------- not a function definition or static + | + = help: `#[linkage]` can be applied to functions, statics, foreign statics -error: attribute should be applied to a function or static +error: `#[linkage]` attribute cannot be used on structs --> $DIR/linkage.rs:12:1 | LL | #[linkage = "weak"] | ^^^^^^^^^^^^^^^^^^^ -LL | struct F; - | --------- not a function definition or static + | + = help: `#[linkage]` can be applied to functions, statics, foreign statics -error: attribute should be applied to a function or static +error: `#[linkage]` attribute cannot be used on inherent impl blocks --> $DIR/linkage.rs:15:1 | -LL | #[linkage = "weak"] - | ^^^^^^^^^^^^^^^^^^^ -LL | / impl F { -LL | | #[linkage = "weak"] -LL | | fn valid(&self) {} -LL | | } - | |_- not a function definition or static +LL | #[linkage = "weak"] + | ^^^^^^^^^^^^^^^^^^^ + | + = help: `#[linkage]` can be applied to functions, statics, foreign statics -error: attribute should be applied to a function or static +error: `#[linkage]` attribute cannot be used on expressions --> $DIR/linkage.rs:23:5 | -LL | #[linkage = "weak"] - | ^^^^^^^^^^^^^^^^^^^ -LL | / { -LL | | 1 -LL | | }; - | |_____- not a function definition or static +LL | #[linkage = "weak"] + | ^^^^^^^^^^^^^^^^^^^ + | + = help: `#[linkage]` can be applied to functions, statics, foreign statics -error: attribute should be applied to a function or static +error: `#[linkage]` attribute cannot be used on closures --> $DIR/linkage.rs:39:13 | LL | let _ = #[linkage = "weak"] | ^^^^^^^^^^^^^^^^^^^ -LL | (|| 1); - | ------ not a function definition or static + | + = help: `#[linkage]` can be applied to methods, functions, statics, foreign statics, foreign functions error: aborting due to 6 previous errors diff --git a/tests/ui/attributes/lint_on_root.rs b/tests/ui/attributes/lint_on_root.rs index 93d47bf0d71..bafdb46883f 100644 --- a/tests/ui/attributes/lint_on_root.rs +++ b/tests/ui/attributes/lint_on_root.rs @@ -1,7 +1,8 @@ // NOTE: this used to panic in debug builds (by a sanity assertion) // and not emit any lint on release builds. See https://github.com/rust-lang/rust/issues/142891. #![inline = ""] -//~^ ERROR valid forms for the attribute are `#[inline(always|never)]` and `#[inline]` +//~^ ERROR: valid forms for the attribute are `#[inline(always)]`, `#[inline(never)]`, and `#[inline]` [ill_formed_attribute_input] //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +//~| ERROR attribute cannot be used on fn main() {} diff --git a/tests/ui/attributes/lint_on_root.stderr b/tests/ui/attributes/lint_on_root.stderr index aaa46e6f54b..9d8d1495c1b 100644 --- a/tests/ui/attributes/lint_on_root.stderr +++ b/tests/ui/attributes/lint_on_root.stderr @@ -1,4 +1,12 @@ -error: valid forms for the attribute are `#[inline(always|never)]` and `#[inline]` +error: `#[inline]` attribute cannot be used on crates + --> $DIR/lint_on_root.rs:3:1 + | +LL | #![inline = ""] + | ^^^^^^^^^^^^^^^ + | + = help: `#[inline]` can only be applied to functions + +error: valid forms for the attribute are `#[inline(always)]`, `#[inline(never)]`, and `#[inline]` --> $DIR/lint_on_root.rs:3:1 | LL | #![inline = ""] @@ -8,5 +16,16 @@ LL | #![inline = ""] = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> = note: `#[deny(ill_formed_attribute_input)]` on by default -error: aborting due to 1 previous error +error: aborting due to 2 previous errors + +Future incompatibility report: Future breakage diagnostic: +error: valid forms for the attribute are `#[inline(always)]`, `#[inline(never)]`, and `#[inline]` + --> $DIR/lint_on_root.rs:3:1 + | +LL | #![inline = ""] + | ^^^^^^^^^^^^^^^ + | + = 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 #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: `#[deny(ill_formed_attribute_input)]` on by default diff --git a/tests/ui/attributes/malformed-attrs.rs b/tests/ui/attributes/malformed-attrs.rs index 0d5bf69d548..3293f75fba9 100644 --- a/tests/ui/attributes/malformed-attrs.rs +++ b/tests/ui/attributes/malformed-attrs.rs @@ -35,6 +35,7 @@ //~^ ERROR `allow_internal_unstable` expects a list of feature names #[rustc_confusables] //~^ ERROR malformed +//~| ERROR attribute cannot be used on #[deprecated = 5] //~^ ERROR malformed #[doc] @@ -42,9 +43,10 @@ //~| WARN this was previously accepted by the compiler #[rustc_macro_transparency] //~^ ERROR malformed +//~| ERROR attribute cannot be used on #[repr] //~^ ERROR malformed -//~| ERROR is not supported on function items +//~| ERROR is not supported on functions #[rustc_as_ptr = 5] //~^ ERROR malformed #[inline = 5] @@ -68,6 +70,7 @@ //~^ ERROR malformed #[used()] //~^ ERROR malformed +//~| ERROR attribute cannot be used on #[crate_name] //~^ ERROR malformed #[doc] @@ -78,7 +81,7 @@ #[export_stable = 1] //~^ ERROR malformed #[link] -//~^ ERROR attribute must be of the form +//~^ ERROR valid forms for the attribute are //~| WARN this was previously accepted by the compiler #[link_name] //~^ ERROR malformed diff --git a/tests/ui/attributes/malformed-attrs.stderr b/tests/ui/attributes/malformed-attrs.stderr index e8ae4715398..9c31765149b 100644 --- a/tests/ui/attributes/malformed-attrs.stderr +++ b/tests/ui/attributes/malformed-attrs.stderr @@ -1,14 +1,16 @@ error[E0539]: malformed `cfg` attribute input - --> $DIR/malformed-attrs.rs:99:1 + --> $DIR/malformed-attrs.rs:102:1 | LL | #[cfg] | ^^^^^^ | | | expected this to be a list | help: must be of the form: `#[cfg(predicate)]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute> error: malformed `cfg_attr` attribute input - --> $DIR/malformed-attrs.rs:101:1 + --> $DIR/malformed-attrs.rs:104:1 | LL | #[cfg_attr] | ^^^^^^^^^^^ @@ -20,7 +22,7 @@ LL | #[cfg_attr(condition, attribute, other_attribute, ...)] | ++++++++++++++++++++++++++++++++++++++++++++ error[E0463]: can't find crate for `wloop` - --> $DIR/malformed-attrs.rs:208:1 + --> $DIR/malformed-attrs.rs:211:1 | LL | extern crate wloop; | ^^^^^^^^^^^^^^^^^^^ can't find crate @@ -29,34 +31,46 @@ error: malformed `windows_subsystem` attribute input --> $DIR/malformed-attrs.rs:26:1 | LL | #![windows_subsystem] - | ^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![windows_subsystem = "windows|console"]` + | ^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/reference/runtime.html#the-windows_subsystem-attribute> +help: the following are the possible correct uses + | +LL | #![windows_subsystem = "console"] + | +++++++++++ +LL | #![windows_subsystem = "windows"] + | +++++++++++ error: malformed `crate_name` attribute input - --> $DIR/malformed-attrs.rs:71:1 + --> $DIR/malformed-attrs.rs:74:1 | LL | #[crate_name] | ^^^^^^^^^^^^^ help: must be of the form: `#[crate_name = "name"]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/crates-and-source-files.html#the-crate_name-attribute> error: malformed `no_sanitize` attribute input - --> $DIR/malformed-attrs.rs:89:1 + --> $DIR/malformed-attrs.rs:92:1 | LL | #[no_sanitize] | ^^^^^^^^^^^^^^ help: must be of the form: `#[no_sanitize(address, kcfi, memory, thread)]` error: malformed `instruction_set` attribute input - --> $DIR/malformed-attrs.rs:103:1 + --> $DIR/malformed-attrs.rs:106:1 | LL | #[instruction_set] | ^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[instruction_set(set)]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/codegen.html#the-instruction_set-attribute> error: malformed `patchable_function_entry` attribute input - --> $DIR/malformed-attrs.rs:105:1 + --> $DIR/malformed-attrs.rs:108:1 | LL | #[patchable_function_entry] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[patchable_function_entry(prefix_nops = m, entry_nops = n)]` error: malformed `must_not_suspend` attribute input - --> $DIR/malformed-attrs.rs:129:1 + --> $DIR/malformed-attrs.rs:132:1 | LL | #[must_not_suspend()] | ^^^^^^^^^^^^^^^^^^^^^ @@ -71,71 +85,120 @@ LL + #[must_not_suspend] | error: malformed `cfi_encoding` attribute input - --> $DIR/malformed-attrs.rs:131:1 + --> $DIR/malformed-attrs.rs:134:1 | LL | #[cfi_encoding] | ^^^^^^^^^^^^^^^ help: must be of the form: `#[cfi_encoding = "encoding"]` -error: malformed `linkage` attribute input - --> $DIR/malformed-attrs.rs:170:5 - | -LL | #[linkage] - | ^^^^^^^^^^ help: must be of the form: `#[linkage = "external|internal|..."]` - error: malformed `allow` attribute input - --> $DIR/malformed-attrs.rs:175:1 + --> $DIR/malformed-attrs.rs:178:1 | LL | #[allow] - | ^^^^^^^^ help: must be of the form: `#[allow(lint1, lint2, ..., /*opt*/ reason = "...")]` + | ^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/diagnostics.html#lint-check-attributes> +help: the following are the possible correct uses + | +LL | #[allow(lint1)] + | +++++++ +LL | #[allow(lint1, lint2, ...)] + | +++++++++++++++++++ +LL | #[allow(lint1, lint2, lint3, reason = "...")] + | +++++++++++++++++++++++++++++++++++++ error: malformed `expect` attribute input - --> $DIR/malformed-attrs.rs:177:1 + --> $DIR/malformed-attrs.rs:180:1 | LL | #[expect] - | ^^^^^^^^^ help: must be of the form: `#[expect(lint1, lint2, ..., /*opt*/ reason = "...")]` + | ^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/diagnostics.html#lint-check-attributes> +help: the following are the possible correct uses + | +LL | #[expect(lint1)] + | +++++++ +LL | #[expect(lint1, lint2, ...)] + | +++++++++++++++++++ +LL | #[expect(lint1, lint2, lint3, reason = "...")] + | +++++++++++++++++++++++++++++++++++++ error: malformed `warn` attribute input - --> $DIR/malformed-attrs.rs:179:1 + --> $DIR/malformed-attrs.rs:182:1 | LL | #[warn] - | ^^^^^^^ help: must be of the form: `#[warn(lint1, lint2, ..., /*opt*/ reason = "...")]` + | ^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/diagnostics.html#lint-check-attributes> +help: the following are the possible correct uses + | +LL | #[warn(lint1)] + | +++++++ +LL | #[warn(lint1, lint2, ...)] + | +++++++++++++++++++ +LL | #[warn(lint1, lint2, lint3, reason = "...")] + | +++++++++++++++++++++++++++++++++++++ error: malformed `deny` attribute input - --> $DIR/malformed-attrs.rs:181:1 + --> $DIR/malformed-attrs.rs:184:1 | LL | #[deny] - | ^^^^^^^ help: must be of the form: `#[deny(lint1, lint2, ..., /*opt*/ reason = "...")]` + | ^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/diagnostics.html#lint-check-attributes> +help: the following are the possible correct uses + | +LL | #[deny(lint1)] + | +++++++ +LL | #[deny(lint1, lint2, ...)] + | +++++++++++++++++++ +LL | #[deny(lint1, lint2, lint3, reason = "...")] + | +++++++++++++++++++++++++++++++++++++ error: malformed `forbid` attribute input - --> $DIR/malformed-attrs.rs:183:1 + --> $DIR/malformed-attrs.rs:186:1 | LL | #[forbid] - | ^^^^^^^^^ help: must be of the form: `#[forbid(lint1, lint2, ..., /*opt*/ reason = "...")]` + | ^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/diagnostics.html#lint-check-attributes> +help: the following are the possible correct uses + | +LL | #[forbid(lint1)] + | +++++++ +LL | #[forbid(lint1, lint2, ...)] + | +++++++++++++++++++ +LL | #[forbid(lint1, lint2, lint3, reason = "...")] + | +++++++++++++++++++++++++++++++++++++ error: malformed `debugger_visualizer` attribute input - --> $DIR/malformed-attrs.rs:185:1 + --> $DIR/malformed-attrs.rs:188:1 | LL | #[debugger_visualizer] | ^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[debugger_visualizer(natvis_file = "...", gdb_script_file = "...")]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/debugger.html#the-debugger_visualizer-attribute> error: malformed `thread_local` attribute input - --> $DIR/malformed-attrs.rs:200:1 + --> $DIR/malformed-attrs.rs:203:1 | LL | #[thread_local()] | ^^^^^^^^^^^^^^^^^ help: must be of the form: `#[thread_local]` error: malformed `no_link` attribute input - --> $DIR/malformed-attrs.rs:204:1 + --> $DIR/malformed-attrs.rs:207:1 | LL | #[no_link()] | ^^^^^^^^^^^^ help: must be of the form: `#[no_link]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/extern-crates.html#the-no_link-attribute> error: malformed `macro_export` attribute input - --> $DIR/malformed-attrs.rs:211:1 + --> $DIR/malformed-attrs.rs:214:1 | LL | #[macro_export = 18] | ^^^^^^^^^^^^^^^^^^^^ | + = note: for more information, visit <https://doc.rust-lang.org/reference/macros-by-example.html#path-based-scope> help: the following are the possible correct uses | LL - #[macro_export = 18] @@ -145,32 +208,26 @@ LL - #[macro_export = 18] LL + #[macro_export] | -error: malformed `allow_internal_unsafe` attribute input - --> $DIR/malformed-attrs.rs:213:1 - | -LL | #[allow_internal_unsafe = 1] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[allow_internal_unsafe]` - error: the `#[proc_macro]` attribute is only usable with crates of the `proc-macro` crate type - --> $DIR/malformed-attrs.rs:96:1 + --> $DIR/malformed-attrs.rs:99:1 | LL | #[proc_macro = 18] | ^^^^^^^^^^^^^^^^^^ error: the `#[proc_macro_attribute]` attribute is only usable with crates of the `proc-macro` crate type - --> $DIR/malformed-attrs.rs:113:1 + --> $DIR/malformed-attrs.rs:116:1 | LL | #[proc_macro_attribute = 19] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` crate type - --> $DIR/malformed-attrs.rs:120:1 + --> $DIR/malformed-attrs.rs:123:1 | LL | #[proc_macro_derive] | ^^^^^^^^^^^^^^^^^^^^ error[E0658]: allow_internal_unsafe side-steps the unsafe_code lint - --> $DIR/malformed-attrs.rs:213:1 + --> $DIR/malformed-attrs.rs:216:1 | LL | #[allow_internal_unsafe = 1] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -178,36 +235,39 @@ LL | #[allow_internal_unsafe = 1] = help: add `#![feature(allow_internal_unsafe)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: valid forms for the attribute are `#[doc(hidden|inline|...)]` and `#[doc = "string"]` - --> $DIR/malformed-attrs.rs:40:1 +error: valid forms for the attribute are `#[doc(hidden)]`, `#[doc(inline)]`, and `#[doc = "string"]` + --> $DIR/malformed-attrs.rs:41:1 | LL | #[doc] | ^^^^^^ | = 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 #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: for more information, visit <https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html> = note: `#[deny(ill_formed_attribute_input)]` on by default -error: valid forms for the attribute are `#[doc(hidden|inline|...)]` and `#[doc = "string"]` - --> $DIR/malformed-attrs.rs:73:1 +error: valid forms for the attribute are `#[doc(hidden)]`, `#[doc(inline)]`, and `#[doc = "string"]` + --> $DIR/malformed-attrs.rs:76:1 | LL | #[doc] | ^^^^^^ | = 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 #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: for more information, visit <https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html> -error: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ wasm_import_module = "...", /*opt*/ import_name_type = "decorated|noprefix|undecorated")]` - --> $DIR/malformed-attrs.rs:80:1 +error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]` + --> $DIR/malformed-attrs.rs:83:1 | LL | #[link] | ^^^^^^^ | = 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 #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> error: invalid argument - --> $DIR/malformed-attrs.rs:185:1 + --> $DIR/malformed-attrs.rs:188:1 | LL | #[debugger_visualizer] | ^^^^^^^^^^^^^^^^^^^^^^ @@ -243,8 +303,16 @@ LL | #[rustc_confusables] | expected this to be a list | help: must be of the form: `#[rustc_confusables("name1", "name2", ...)]` +error: `#[rustc_confusables]` attribute cannot be used on functions + --> $DIR/malformed-attrs.rs:36:1 + | +LL | #[rustc_confusables] + | ^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[rustc_confusables]` can only be applied to inherent methods + error[E0539]: malformed `deprecated` attribute input - --> $DIR/malformed-attrs.rs:38:1 + --> $DIR/malformed-attrs.rs:39:1 | LL | #[deprecated = 5] | ^^^^^^^^^^^^^^^-^ @@ -257,29 +325,60 @@ LL - #[deprecated = 5] LL + #[deprecated = "reason"] | LL - #[deprecated = 5] -LL + #[deprecated(/*opt*/ since = "version", /*opt*/ note = "reason")] +LL + #[deprecated(note = "reason")] + | +LL - #[deprecated = 5] +LL + #[deprecated(since = "version")] | LL - #[deprecated = 5] -LL + #[deprecated] +LL + #[deprecated(since = "version", note = "reason")] | + = and 1 other candidate error[E0539]: malformed `rustc_macro_transparency` attribute input - --> $DIR/malformed-attrs.rs:43:1 + --> $DIR/malformed-attrs.rs:44:1 + | +LL | #[rustc_macro_transparency] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try changing it to one of the following valid forms of the attribute + | +LL | #[rustc_macro_transparency = "opaque"] + | ++++++++++ +LL | #[rustc_macro_transparency = "semitransparent"] + | +++++++++++++++++++ +LL | #[rustc_macro_transparency = "transparent"] + | +++++++++++++++ + +error: `#[rustc_macro_transparency]` attribute cannot be used on functions + --> $DIR/malformed-attrs.rs:44:1 | LL | #[rustc_macro_transparency] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_macro_transparency = "transparent|semitransparent|opaque"]` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[rustc_macro_transparency]` can only be applied to macro defs error[E0539]: malformed `repr` attribute input - --> $DIR/malformed-attrs.rs:45:1 + --> $DIR/malformed-attrs.rs:47:1 | LL | #[repr] - | ^^^^^^^ - | | - | expected this to be a list - | help: must be of the form: `#[repr(C | Rust | align(...) | packed(...) | <integer type> | transparent)]` + | ^^^^^^^ expected this to be a list + | + = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations> +help: try changing it to one of the following valid forms of the attribute + | +LL | #[repr(<integer type>)] + | ++++++++++++++++ +LL | #[repr(C)] + | +++ +LL | #[repr(Rust)] + | ++++++ +LL | #[repr(align(...))] + | ++++++++++++ + = and 2 other candidates error[E0565]: malformed `rustc_as_ptr` attribute input - --> $DIR/malformed-attrs.rs:48:1 + --> $DIR/malformed-attrs.rs:50:1 | LL | #[rustc_as_ptr = 5] | ^^^^^^^^^^^^^^^---^ @@ -288,7 +387,7 @@ LL | #[rustc_as_ptr = 5] | help: must be of the form: `#[rustc_as_ptr]` error[E0539]: malformed `rustc_align` attribute input - --> $DIR/malformed-attrs.rs:53:1 + --> $DIR/malformed-attrs.rs:55:1 | LL | #[rustc_align] | ^^^^^^^^^^^^^^ @@ -297,16 +396,22 @@ LL | #[rustc_align] | help: must be of the form: `#[rustc_align(<alignment in bytes>)]` error[E0539]: malformed `optimize` attribute input - --> $DIR/malformed-attrs.rs:55:1 + --> $DIR/malformed-attrs.rs:57:1 | LL | #[optimize] - | ^^^^^^^^^^^ - | | - | expected this to be a list - | help: must be of the form: `#[optimize(size|speed|none)]` + | ^^^^^^^^^^^ expected this to be a list + | +help: try changing it to one of the following valid forms of the attribute + | +LL | #[optimize(none)] + | ++++++ +LL | #[optimize(size)] + | ++++++ +LL | #[optimize(speed)] + | +++++++ error[E0565]: malformed `cold` attribute input - --> $DIR/malformed-attrs.rs:57:1 + --> $DIR/malformed-attrs.rs:59:1 | LL | #[cold = 1] | ^^^^^^^---^ @@ -315,13 +420,13 @@ LL | #[cold = 1] | help: must be of the form: `#[cold]` error: valid forms for the attribute are `#[must_use = "reason"]` and `#[must_use]` - --> $DIR/malformed-attrs.rs:59:1 + --> $DIR/malformed-attrs.rs:61:1 | LL | #[must_use()] | ^^^^^^^^^^^^^ error[E0565]: malformed `no_mangle` attribute input - --> $DIR/malformed-attrs.rs:61:1 + --> $DIR/malformed-attrs.rs:63:1 | LL | #[no_mangle = 1] | ^^^^^^^^^^^^---^ @@ -330,7 +435,7 @@ LL | #[no_mangle = 1] | help: must be of the form: `#[no_mangle]` error[E0565]: malformed `naked` attribute input - --> $DIR/malformed-attrs.rs:63:1 + --> $DIR/malformed-attrs.rs:65:1 | LL | #[unsafe(naked())] | ^^^^^^^^^^^^^^--^^ @@ -339,7 +444,7 @@ LL | #[unsafe(naked())] | help: must be of the form: `#[naked]` error[E0565]: malformed `track_caller` attribute input - --> $DIR/malformed-attrs.rs:65:1 + --> $DIR/malformed-attrs.rs:67:1 | LL | #[track_caller()] | ^^^^^^^^^^^^^^--^ @@ -348,13 +453,13 @@ LL | #[track_caller()] | help: must be of the form: `#[track_caller]` error[E0539]: malformed `export_name` attribute input - --> $DIR/malformed-attrs.rs:67:1 + --> $DIR/malformed-attrs.rs:69:1 | LL | #[export_name()] | ^^^^^^^^^^^^^^^^ help: must be of the form: `#[export_name = "name"]` error[E0805]: malformed `used` attribute input - --> $DIR/malformed-attrs.rs:69:1 + --> $DIR/malformed-attrs.rs:71:1 | LL | #[used()] | ^^^^^^--^ @@ -363,14 +468,24 @@ LL | #[used()] | help: try changing it to one of the following valid forms of the attribute | -LL | #[used(compiler|linker)] - | +++++++++++++++ +LL | #[used(compiler)] + | ++++++++ +LL | #[used(linker)] + | ++++++ LL - #[used()] LL + #[used] | +error: `#[used]` attribute cannot be used on functions + --> $DIR/malformed-attrs.rs:71:1 + | +LL | #[used()] + | ^^^^^^^^^ + | + = help: `#[used]` can only be applied to statics + error[E0539]: malformed `target_feature` attribute input - --> $DIR/malformed-attrs.rs:76:1 + --> $DIR/malformed-attrs.rs:79:1 | LL | #[target_feature] | ^^^^^^^^^^^^^^^^^ @@ -379,7 +494,7 @@ LL | #[target_feature] | help: must be of the form: `#[target_feature(enable = "feat1, feat2")]` error[E0565]: malformed `export_stable` attribute input - --> $DIR/malformed-attrs.rs:78:1 + --> $DIR/malformed-attrs.rs:81:1 | LL | #[export_stable = 1] | ^^^^^^^^^^^^^^^^---^ @@ -388,19 +503,23 @@ LL | #[export_stable = 1] | help: must be of the form: `#[export_stable]` error[E0539]: malformed `link_name` attribute input - --> $DIR/malformed-attrs.rs:83:1 + --> $DIR/malformed-attrs.rs:86:1 | LL | #[link_name] | ^^^^^^^^^^^^ help: must be of the form: `#[link_name = "name"]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link_name-attribute> error[E0539]: malformed `link_section` attribute input - --> $DIR/malformed-attrs.rs:85:1 + --> $DIR/malformed-attrs.rs:88:1 | LL | #[link_section] | ^^^^^^^^^^^^^^^ help: must be of the form: `#[link_section = "name"]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/abi.html#the-link_section-attribute> error[E0539]: malformed `coverage` attribute input - --> $DIR/malformed-attrs.rs:87:1 + --> $DIR/malformed-attrs.rs:90:1 | LL | #[coverage] | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument @@ -413,7 +532,7 @@ LL | #[coverage(on)] | ++++ error[E0565]: malformed `no_implicit_prelude` attribute input - --> $DIR/malformed-attrs.rs:94:1 + --> $DIR/malformed-attrs.rs:97:1 | LL | #[no_implicit_prelude = 23] | ^^^^^^^^^^^^^^^^^^^^^^----^ @@ -422,7 +541,7 @@ LL | #[no_implicit_prelude = 23] | help: must be of the form: `#[no_implicit_prelude]` error[E0565]: malformed `proc_macro` attribute input - --> $DIR/malformed-attrs.rs:96:1 + --> $DIR/malformed-attrs.rs:99:1 | LL | #[proc_macro = 18] | ^^^^^^^^^^^^^----^ @@ -431,7 +550,7 @@ LL | #[proc_macro = 18] | help: must be of the form: `#[proc_macro]` error[E0565]: malformed `coroutine` attribute input - --> $DIR/malformed-attrs.rs:108:5 + --> $DIR/malformed-attrs.rs:111:5 | LL | #[coroutine = 63] || {} | ^^^^^^^^^^^^----^ @@ -440,7 +559,7 @@ LL | #[coroutine = 63] || {} | help: must be of the form: `#[coroutine]` error[E0565]: malformed `proc_macro_attribute` attribute input - --> $DIR/malformed-attrs.rs:113:1 + --> $DIR/malformed-attrs.rs:116:1 | LL | #[proc_macro_attribute = 19] | ^^^^^^^^^^^^^^^^^^^^^^^----^ @@ -449,13 +568,14 @@ LL | #[proc_macro_attribute = 19] | help: must be of the form: `#[proc_macro_attribute]` error[E0539]: malformed `must_use` attribute input - --> $DIR/malformed-attrs.rs:116:1 + --> $DIR/malformed-attrs.rs:119:1 | LL | #[must_use = 1] | ^^^^^^^^^^^^^-^ | | | expected a string literal here | + = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-must_use-attribute> help: try changing it to one of the following valid forms of the attribute | LL - #[must_use = 1] @@ -466,16 +586,21 @@ LL + #[must_use] | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/malformed-attrs.rs:120:1 + --> $DIR/malformed-attrs.rs:123:1 | LL | #[proc_macro_derive] - | ^^^^^^^^^^^^^^^^^^^^ - | | - | expected this to be a list - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | ^^^^^^^^^^^^^^^^^^^^ expected this to be a list + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL | #[proc_macro_derive(TraitName)] + | +++++++++++ +LL | #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | ++++++++++++++++++++++++++++++++++++++++++ error[E0539]: malformed `rustc_layout_scalar_valid_range_start` attribute input - --> $DIR/malformed-attrs.rs:125:1 + --> $DIR/malformed-attrs.rs:128:1 | LL | #[rustc_layout_scalar_valid_range_start] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -484,7 +609,7 @@ LL | #[rustc_layout_scalar_valid_range_start] | help: must be of the form: `#[rustc_layout_scalar_valid_range_start(start)]` error[E0539]: malformed `rustc_layout_scalar_valid_range_end` attribute input - --> $DIR/malformed-attrs.rs:127:1 + --> $DIR/malformed-attrs.rs:130:1 | LL | #[rustc_layout_scalar_valid_range_end] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -493,7 +618,7 @@ LL | #[rustc_layout_scalar_valid_range_end] | help: must be of the form: `#[rustc_layout_scalar_valid_range_end(end)]` error[E0565]: malformed `marker` attribute input - --> $DIR/malformed-attrs.rs:152:1 + --> $DIR/malformed-attrs.rs:155:1 | LL | #[marker = 3] | ^^^^^^^^^---^ @@ -502,7 +627,7 @@ LL | #[marker = 3] | help: must be of the form: `#[marker]` error[E0565]: malformed `fundamental` attribute input - --> $DIR/malformed-attrs.rs:154:1 + --> $DIR/malformed-attrs.rs:157:1 | LL | #[fundamental()] | ^^^^^^^^^^^^^--^ @@ -511,7 +636,7 @@ LL | #[fundamental()] | help: must be of the form: `#[fundamental]` error[E0565]: malformed `ffi_pure` attribute input - --> $DIR/malformed-attrs.rs:162:5 + --> $DIR/malformed-attrs.rs:165:5 | LL | #[unsafe(ffi_pure = 1)] | ^^^^^^^^^^^^^^^^^^---^^ @@ -520,16 +645,18 @@ LL | #[unsafe(ffi_pure = 1)] | help: must be of the form: `#[ffi_pure]` error[E0539]: malformed `link_ordinal` attribute input - --> $DIR/malformed-attrs.rs:164:5 + --> $DIR/malformed-attrs.rs:167:5 | LL | #[link_ordinal] | ^^^^^^^^^^^^^^^ | | | expected this to be a list | help: must be of the form: `#[link_ordinal(ordinal)]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link_ordinal-attribute> error[E0565]: malformed `ffi_const` attribute input - --> $DIR/malformed-attrs.rs:168:5 + --> $DIR/malformed-attrs.rs:171:5 | LL | #[unsafe(ffi_const = 1)] | ^^^^^^^^^^^^^^^^^^^---^^ @@ -537,8 +664,26 @@ LL | #[unsafe(ffi_const = 1)] | | didn't expect any arguments here | help: must be of the form: `#[ffi_const]` +error[E0539]: malformed `linkage` attribute input + --> $DIR/malformed-attrs.rs:173:5 + | +LL | #[linkage] + | ^^^^^^^^^^ expected this to be of the form `linkage = "..."` + | +help: try changing it to one of the following valid forms of the attribute + | +LL | #[linkage = "available_externally"] + | ++++++++++++++++++++++++ +LL | #[linkage = "common"] + | ++++++++++ +LL | #[linkage = "extern_weak"] + | +++++++++++++++ +LL | #[linkage = "external"] + | ++++++++++++ + = and 5 other candidates + error[E0565]: malformed `automatically_derived` attribute input - --> $DIR/malformed-attrs.rs:188:1 + --> $DIR/malformed-attrs.rs:191:1 | LL | #[automatically_derived = 18] | ^^^^^^^^^^^^^^^^^^^^^^^^----^ @@ -547,7 +692,7 @@ LL | #[automatically_derived = 18] | help: must be of the form: `#[automatically_derived]` error[E0565]: malformed `non_exhaustive` attribute input - --> $DIR/malformed-attrs.rs:194:1 + --> $DIR/malformed-attrs.rs:197:1 | LL | #[non_exhaustive = 1] | ^^^^^^^^^^^^^^^^^---^ @@ -556,13 +701,22 @@ LL | #[non_exhaustive = 1] | help: must be of the form: `#[non_exhaustive]` error: valid forms for the attribute are `#[macro_use(name1, name2, ...)]` and `#[macro_use]` - --> $DIR/malformed-attrs.rs:206:1 + --> $DIR/malformed-attrs.rs:209:1 | LL | #[macro_use = 1] | ^^^^^^^^^^^^^^^^ +error[E0565]: malformed `allow_internal_unsafe` attribute input + --> $DIR/malformed-attrs.rs:216:1 + | +LL | #[allow_internal_unsafe = 1] + | ^^^^^^^^^^^^^^^^^^^^^^^^---^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[allow_internal_unsafe]` + error[E0565]: malformed `type_const` attribute input - --> $DIR/malformed-attrs.rs:140:5 + --> $DIR/malformed-attrs.rs:143:5 | LL | #[type_const = 1] | ^^^^^^^^^^^^^---^ @@ -582,20 +736,20 @@ LL | | #[coroutine = 63] || {} LL | | } | |_- not a `const fn` -error: `#[repr(align(...))]` is not supported on function items - --> $DIR/malformed-attrs.rs:45:1 +error: `#[repr(align(...))]` is not supported on functions + --> $DIR/malformed-attrs.rs:47:1 | LL | #[repr] | ^^^^^^^ | help: use `#[rustc_align(...)]` instead - --> $DIR/malformed-attrs.rs:45:1 + --> $DIR/malformed-attrs.rs:47:1 | LL | #[repr] | ^^^^^^^ warning: `#[diagnostic::do_not_recommend]` does not expect any arguments - --> $DIR/malformed-attrs.rs:146:1 + --> $DIR/malformed-attrs.rs:149:1 | LL | #[diagnostic::do_not_recommend()] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -603,7 +757,7 @@ LL | #[diagnostic::do_not_recommend()] = note: `#[warn(malformed_diagnostic_attributes)]` on by default warning: missing options for `on_unimplemented` attribute - --> $DIR/malformed-attrs.rs:135:1 + --> $DIR/malformed-attrs.rs:138:1 | LL | #[diagnostic::on_unimplemented] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -611,15 +765,15 @@ LL | #[diagnostic::on_unimplemented] = help: at least one of the `message`, `note` and `label` options are expected warning: malformed `on_unimplemented` attribute - --> $DIR/malformed-attrs.rs:137:1 + --> $DIR/malformed-attrs.rs:140:1 | LL | #[diagnostic::on_unimplemented = 1] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here | = help: only `message`, `note` and `label` are allowed as options -error: valid forms for the attribute are `#[inline(always|never)]` and `#[inline]` - --> $DIR/malformed-attrs.rs:50:1 +error: valid forms for the attribute are `#[inline(always)]`, `#[inline(never)]`, and `#[inline]` + --> $DIR/malformed-attrs.rs:52:1 | LL | #[inline = 5] | ^^^^^^^^^^^^^ @@ -628,7 +782,7 @@ LL | #[inline = 5] = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` - --> $DIR/malformed-attrs.rs:91:1 + --> $DIR/malformed-attrs.rs:94:1 | LL | #[ignore()] | ^^^^^^^^^^^ @@ -637,7 +791,7 @@ LL | #[ignore()] = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` - --> $DIR/malformed-attrs.rs:220:1 + --> $DIR/malformed-attrs.rs:223:1 | LL | #[ignore = 1] | ^^^^^^^^^^^^^ @@ -646,7 +800,7 @@ LL | #[ignore = 1] = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> error[E0308]: mismatched types - --> $DIR/malformed-attrs.rs:108:23 + --> $DIR/malformed-attrs.rs:111:23 | LL | fn test() { | - help: a return type might be missing here: `-> _` @@ -654,9 +808,78 @@ LL | #[coroutine = 63] || {} | ^^^^^ expected `()`, found coroutine | = note: expected unit type `()` - found coroutine `{coroutine@$DIR/malformed-attrs.rs:108:23: 108:25}` + found coroutine `{coroutine@$DIR/malformed-attrs.rs:111:23: 111:25}` -error: aborting due to 74 previous errors; 3 warnings emitted +error: aborting due to 77 previous errors; 3 warnings emitted Some errors have detailed explanations: E0308, E0463, E0539, E0565, E0658, E0805. For more information about an error, try `rustc --explain E0308`. +Future incompatibility report: Future breakage diagnostic: +error: valid forms for the attribute are `#[doc(hidden)]`, `#[doc(inline)]`, and `#[doc = "string"]` + --> $DIR/malformed-attrs.rs:41:1 + | +LL | #[doc] + | ^^^^^^ + | + = 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 #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: for more information, visit <https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html> + = note: `#[deny(ill_formed_attribute_input)]` on by default + +Future breakage diagnostic: +error: valid forms for the attribute are `#[doc(hidden)]`, `#[doc(inline)]`, and `#[doc = "string"]` + --> $DIR/malformed-attrs.rs:76:1 + | +LL | #[doc] + | ^^^^^^ + | + = 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 #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: for more information, visit <https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html> + = note: `#[deny(ill_formed_attribute_input)]` on by default + +Future breakage diagnostic: +error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]` + --> $DIR/malformed-attrs.rs:83:1 + | +LL | #[link] + | ^^^^^^^ + | + = 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 #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> + = note: `#[deny(ill_formed_attribute_input)]` on by default + +Future breakage diagnostic: +error: valid forms for the attribute are `#[inline(always)]`, `#[inline(never)]`, and `#[inline]` + --> $DIR/malformed-attrs.rs:52:1 + | +LL | #[inline = 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 #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: `#[deny(ill_formed_attribute_input)]` on by default + +Future breakage diagnostic: +error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` + --> $DIR/malformed-attrs.rs:94:1 + | +LL | #[ignore()] + | ^^^^^^^^^^^ + | + = 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 #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: `#[deny(ill_formed_attribute_input)]` on by default + +Future breakage diagnostic: +error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` + --> $DIR/malformed-attrs.rs:223:1 + | +LL | #[ignore = 1] + | ^^^^^^^^^^^^^ + | + = 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 #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: `#[deny(ill_formed_attribute_input)]` on by default + diff --git a/tests/ui/attributes/malformed-fn-align.rs b/tests/ui/attributes/malformed-fn-align.rs index cf143b28e54..adce84763ab 100644 --- a/tests/ui/attributes/malformed-fn-align.rs +++ b/tests/ui/attributes/malformed-fn-align.rs @@ -23,7 +23,7 @@ fn f2() {} #[rustc_align(0)] //~ ERROR invalid alignment value: not a power of two fn f3() {} -#[repr(align(16))] //~ ERROR `#[repr(align(...))]` is not supported on function items +#[repr(align(16))] //~ ERROR `#[repr(align(...))]` is not supported on functions fn f4() {} #[rustc_align(-1)] //~ ERROR expected unsuffixed literal, found `-` @@ -41,14 +41,14 @@ fn f7() {} #[rustc_align(16)] fn f8() {} -#[rustc_align(16)] //~ ERROR `#[rustc_align(...)]` is not supported on struct items +#[rustc_align(16)] //~ ERROR attribute cannot be used on struct S1; -#[rustc_align(32)] //~ ERROR `#[rustc_align(...)]` should be applied to a function item +#[rustc_align(32)] //~ ERROR attribute cannot be used on const FOO: i32 = 42; -#[rustc_align(32)] //~ ERROR `#[rustc_align(...)]` should be applied to a function item +#[rustc_align(32)] //~ ERROR attribute cannot be used on mod test {} -#[rustc_align(32)] //~ ERROR `#[rustc_align(...)]` should be applied to a function item +#[rustc_align(32)] //~ ERROR attribute cannot be used on use ::std::iter; diff --git a/tests/ui/attributes/malformed-fn-align.stderr b/tests/ui/attributes/malformed-fn-align.stderr index d995a7bf070..346fe2b4b7f 100644 --- a/tests/ui/attributes/malformed-fn-align.stderr +++ b/tests/ui/attributes/malformed-fn-align.stderr @@ -69,53 +69,49 @@ error[E0589]: invalid alignment value: not a power of two LL | #[rustc_align(3)] | ^ -error: `#[repr(align(...))]` is not supported on function items - --> $DIR/malformed-fn-align.rs:26:8 - | -LL | #[repr(align(16))] - | ^^^^^^^^^ - | -help: use `#[rustc_align(...)]` instead - --> $DIR/malformed-fn-align.rs:26:8 - | -LL | #[repr(align(16))] - | ^^^^^^^^^ - -error: `#[rustc_align(...)]` is not supported on struct items +error: `#[rustc_align]` attribute cannot be used on structs --> $DIR/malformed-fn-align.rs:44:1 | LL | #[rustc_align(16)] | ^^^^^^^^^^^^^^^^^^ | -help: use `#[repr(align(...))]` instead - | -LL - #[rustc_align(16)] -LL + #[repr(align(16))] - | + = help: `#[rustc_align]` can only be applied to functions -error: `#[rustc_align(...)]` should be applied to a function item +error: `#[rustc_align]` attribute cannot be used on constants --> $DIR/malformed-fn-align.rs:47:1 | LL | #[rustc_align(32)] | ^^^^^^^^^^^^^^^^^^ -LL | const FOO: i32 = 42; - | -------------------- not a function item + | + = help: `#[rustc_align]` can only be applied to functions -error: `#[rustc_align(...)]` should be applied to a function item +error: `#[rustc_align]` attribute cannot be used on modules --> $DIR/malformed-fn-align.rs:50:1 | LL | #[rustc_align(32)] | ^^^^^^^^^^^^^^^^^^ -LL | mod test {} - | ----------- not a function item + | + = help: `#[rustc_align]` can only be applied to functions -error: `#[rustc_align(...)]` should be applied to a function item +error: `#[rustc_align]` attribute cannot be used on use statements --> $DIR/malformed-fn-align.rs:53:1 | LL | #[rustc_align(32)] | ^^^^^^^^^^^^^^^^^^ -LL | use ::std::iter; - | ---------------- not a function item + | + = help: `#[rustc_align]` can only be applied to functions + +error: `#[repr(align(...))]` is not supported on functions + --> $DIR/malformed-fn-align.rs:26:8 + | +LL | #[repr(align(16))] + | ^^^^^^^^^ + | +help: use `#[rustc_align(...)]` instead + --> $DIR/malformed-fn-align.rs:26:8 + | +LL | #[repr(align(16))] + | ^^^^^^^^^ error: aborting due to 15 previous errors diff --git a/tests/ui/attributes/malformed-reprs.stderr b/tests/ui/attributes/malformed-reprs.stderr index c39c98dde31..43085b9c341 100644 --- a/tests/ui/attributes/malformed-reprs.stderr +++ b/tests/ui/attributes/malformed-reprs.stderr @@ -2,10 +2,24 @@ error[E0539]: malformed `repr` attribute input --> $DIR/malformed-reprs.rs:4:1 | LL | #![repr] - | ^^^^^^^^ - | | - | expected this to be a list - | help: must be of the form: `#[repr(C | Rust | align(...) | packed(...) | <integer type> | transparent)]` + | ^^^^^^^^ expected this to be a list + | + = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations> +help: try changing it to one of the following valid forms of the attribute + | +LL - #![repr] +LL + #[repr(<integer type>)] + | +LL - #![repr] +LL + #[repr(C)] + | +LL - #![repr] +LL + #[repr(Rust)] + | +LL - #![repr] +LL + #[repr(align(...))] + | + = and 2 other candidates error[E0589]: invalid `repr(align)` attribute: not a power of two --> $DIR/malformed-reprs.rs:9:14 diff --git a/tests/ui/attributes/multiple-invalid.rs b/tests/ui/attributes/multiple-invalid.rs index ae044eb843b..49d1aeed604 100644 --- a/tests/ui/attributes/multiple-invalid.rs +++ b/tests/ui/attributes/multiple-invalid.rs @@ -2,9 +2,9 @@ // on an item. #[inline] -//~^ ERROR attribute should be applied to function or closure [E0518] +//~^ ERROR attribute cannot be used on #[target_feature(enable = "sse2")] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on const FOO: u8 = 0; fn main() { } diff --git a/tests/ui/attributes/multiple-invalid.stderr b/tests/ui/attributes/multiple-invalid.stderr index f4f7dd7c4f1..182d39b14bc 100644 --- a/tests/ui/attributes/multiple-invalid.stderr +++ b/tests/ui/attributes/multiple-invalid.stderr @@ -1,21 +1,18 @@ -error: attribute should be applied to a function definition +error: `#[inline]` attribute cannot be used on constants + --> $DIR/multiple-invalid.rs:4:1 + | +LL | #[inline] + | ^^^^^^^^^ + | + = help: `#[inline]` can only be applied to functions + +error: `#[target_feature]` attribute cannot be used on constants --> $DIR/multiple-invalid.rs:6:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | const FOO: u8 = 0; - | ------------------ not a function definition - -error[E0518]: attribute should be applied to function or closure - --> $DIR/multiple-invalid.rs:4:1 | -LL | #[inline] - | ^^^^^^^^^ -... -LL | const FOO: u8 = 0; - | ------------------ not a function or closure + = help: `#[target_feature]` can only be applied to functions error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0518`. diff --git a/tests/ui/attributes/optimize.rs b/tests/ui/attributes/optimize.rs index 7a1cc1be9ee..78e05f111e7 100644 --- a/tests/ui/attributes/optimize.rs +++ b/tests/ui/attributes/optimize.rs @@ -5,11 +5,11 @@ //@ edition: 2018 -#[optimize(speed)] //~ ERROR attribute applied to an invalid target +#[optimize(speed)] //~ ERROR attribute cannot be used on struct F; fn invalid() { - #[optimize(speed)] //~ ERROR attribute applied to an invalid target + #[optimize(speed)] //~ ERROR attribute cannot be used on { 1 }; @@ -18,10 +18,10 @@ fn invalid() { #[optimize(speed)] fn valid() {} -#[optimize(speed)] //~ ERROR attribute applied to an invalid target +#[optimize(speed)] //~ ERROR attribute cannot be used on mod valid_module {} -#[optimize(speed)] //~ ERROR attribute applied to an invalid target +#[optimize(speed)] //~ ERROR attribute cannot be used on impl F {} fn main() { diff --git a/tests/ui/attributes/optimize.stderr b/tests/ui/attributes/optimize.stderr index ad9309d27a5..2ded1a973f3 100644 --- a/tests/ui/attributes/optimize.stderr +++ b/tests/ui/attributes/optimize.stderr @@ -1,36 +1,34 @@ -error: attribute applied to an invalid target +error: `#[optimize]` attribute cannot be used on structs --> $DIR/optimize.rs:8:1 | LL | #[optimize(speed)] | ^^^^^^^^^^^^^^^^^^ -LL | struct F; - | --------- invalid target + | + = help: `#[optimize]` can only be applied to functions -error: attribute applied to an invalid target +error: `#[optimize]` attribute cannot be used on expressions --> $DIR/optimize.rs:12:5 | -LL | #[optimize(speed)] - | ^^^^^^^^^^^^^^^^^^ -LL | / { -LL | | 1 -LL | | }; - | |_____- invalid target +LL | #[optimize(speed)] + | ^^^^^^^^^^^^^^^^^^ + | + = help: `#[optimize]` can only be applied to functions -error: attribute applied to an invalid target +error: `#[optimize]` attribute cannot be used on modules --> $DIR/optimize.rs:21:1 | LL | #[optimize(speed)] | ^^^^^^^^^^^^^^^^^^ -LL | mod valid_module {} - | ------------------- invalid target + | + = help: `#[optimize]` can only be applied to functions -error: attribute applied to an invalid target +error: `#[optimize]` attribute cannot be used on inherent impl blocks --> $DIR/optimize.rs:24:1 | LL | #[optimize(speed)] | ^^^^^^^^^^^^^^^^^^ -LL | impl F {} - | --------- invalid target + | + = help: `#[optimize]` can only be applied to functions error: aborting due to 4 previous errors diff --git a/tests/ui/attributes/positions/used.rs b/tests/ui/attributes/positions/used.rs index 7950fa773a1..7e106d278f2 100644 --- a/tests/ui/attributes/positions/used.rs +++ b/tests/ui/attributes/positions/used.rs @@ -4,20 +4,20 @@ #[used] static FOO: u32 = 0; // OK -#[used] //~ ERROR attribute must be applied to a `static` variable +#[used] //~ ERROR attribute cannot be used on fn foo() {} -#[used] //~ ERROR attribute must be applied to a `static` variable +#[used] //~ ERROR attribute cannot be used on struct Foo {} -#[used] //~ ERROR attribute must be applied to a `static` variable +#[used] //~ ERROR attribute cannot be used on trait Bar {} -#[used] //~ ERROR attribute must be applied to a `static` variable +#[used] //~ ERROR attribute cannot be used on impl Bar for Foo {} // Regression test for <https://github.com/rust-lang/rust/issues/126789>. extern "C" { - #[used] //~ ERROR attribute must be applied to a `static` variable + #[used] //~ ERROR attribute cannot be used on static BAR: i32; } diff --git a/tests/ui/attributes/positions/used.stderr b/tests/ui/attributes/positions/used.stderr index 64460c178cb..79011f3a758 100644 --- a/tests/ui/attributes/positions/used.stderr +++ b/tests/ui/attributes/positions/used.stderr @@ -1,42 +1,42 @@ -error: attribute must be applied to a `static` variable +error: `#[used]` attribute cannot be used on functions --> $DIR/used.rs:7:1 | LL | #[used] | ^^^^^^^ -LL | fn foo() {} - | ----------- but this is a function + | + = help: `#[used]` can only be applied to statics -error: attribute must be applied to a `static` variable +error: `#[used]` attribute cannot be used on structs --> $DIR/used.rs:10:1 | LL | #[used] | ^^^^^^^ -LL | struct Foo {} - | ------------- but this is a struct + | + = help: `#[used]` can only be applied to statics -error: attribute must be applied to a `static` variable +error: `#[used]` attribute cannot be used on traits --> $DIR/used.rs:13:1 | LL | #[used] | ^^^^^^^ -LL | trait Bar {} - | ------------ but this is a trait + | + = help: `#[used]` can only be applied to statics -error: attribute must be applied to a `static` variable +error: `#[used]` attribute cannot be used on trait impl blocks --> $DIR/used.rs:16:1 | LL | #[used] | ^^^^^^^ -LL | impl Bar for Foo {} - | ------------------- but this is a trait implementation block + | + = help: `#[used]` can only be applied to statics -error: attribute must be applied to a `static` variable +error: `#[used]` attribute cannot be used on foreign statics --> $DIR/used.rs:21:5 | LL | #[used] | ^^^^^^^ -LL | static BAR: i32; - | ---------------- but this is a foreign static item + | + = help: `#[used]` can only be applied to statics error: aborting due to 5 previous errors diff --git a/tests/ui/attributes/rustc_confusables.rs b/tests/ui/attributes/rustc_confusables.rs index a8095936cff..91c66a75cc3 100644 --- a/tests/ui/attributes/rustc_confusables.rs +++ b/tests/ui/attributes/rustc_confusables.rs @@ -43,5 +43,6 @@ impl Bar { } #[rustc_confusables("blah")] -//~^ ERROR attribute should be applied to an inherent method +//~^ ERROR attribute cannot be used on +//~| HELP can only be applied to fn not_inherent_impl_method() {} diff --git a/tests/ui/attributes/rustc_confusables.stderr b/tests/ui/attributes/rustc_confusables.stderr index 3ed4efeb4db..c714257ee77 100644 --- a/tests/ui/attributes/rustc_confusables.stderr +++ b/tests/ui/attributes/rustc_confusables.stderr @@ -22,11 +22,13 @@ LL | #[rustc_confusables(invalid_meta_item)] | | expected a string literal here | help: must be of the form: `#[rustc_confusables("name1", "name2", ...)]` -error: attribute should be applied to an inherent method +error: `#[rustc_confusables]` attribute cannot be used on functions --> $DIR/rustc_confusables.rs:45:1 | LL | #[rustc_confusables("blah")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[rustc_confusables]` can only be applied to inherent methods error[E0599]: no method named `inser` found for struct `rustc_confusables_across_crate::BTreeSet` in the current scope --> $DIR/rustc_confusables.rs:12:7 diff --git a/tests/ui/attributes/rustc_confusables_std_cases.stderr b/tests/ui/attributes/rustc_confusables_std_cases.stderr index f2d9ebe2c0e..771c0c6dfe9 100644 --- a/tests/ui/attributes/rustc_confusables_std_cases.stderr +++ b/tests/ui/attributes/rustc_confusables_std_cases.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `push` found for struct `BTreeSet` in the current scope +error[E0599]: no method named `push` found for struct `BTreeSet<T, A>` in the current scope --> $DIR/rustc_confusables_std_cases.rs:6:7 | LL | x.push(1); @@ -22,7 +22,7 @@ LL - x.push_back(1); LL + x.push(1); | -error[E0599]: no method named `push` found for struct `VecDeque` in the current scope +error[E0599]: no method named `push` found for struct `VecDeque<T, A>` in the current scope --> $DIR/rustc_confusables_std_cases.rs:12:7 | LL | x.push(1); @@ -35,7 +35,7 @@ LL | let mut x = Vec::new(); | ^^^^^ `x` of type `Vec<_>` that has method `push` defined earlier here ... LL | let mut x = VecDeque::new(); - | ----- earlier `x` shadowed here with type `VecDeque` + | ----- earlier `x` shadowed here with type `VecDeque<_>` help: you might have meant to use `push_back` | LL | x.push_back(1); diff --git a/tests/ui/attributes/rustc_skip_during_method_dispatch.rs b/tests/ui/attributes/rustc_skip_during_method_dispatch.rs index 25b473d5a58..e1bd0ca3896 100644 --- a/tests/ui/attributes/rustc_skip_during_method_dispatch.rs +++ b/tests/ui/attributes/rustc_skip_during_method_dispatch.rs @@ -32,7 +32,7 @@ trait String {} trait OK {} #[rustc_skip_during_method_dispatch(array)] -//~^ ERROR: attribute should be applied to a trait +//~^ ERROR: attribute cannot be used on impl OK for () {} fn main() {} diff --git a/tests/ui/attributes/rustc_skip_during_method_dispatch.stderr b/tests/ui/attributes/rustc_skip_during_method_dispatch.stderr index 2f5d7968489..094987e944f 100644 --- a/tests/ui/attributes/rustc_skip_during_method_dispatch.stderr +++ b/tests/ui/attributes/rustc_skip_during_method_dispatch.stderr @@ -61,14 +61,13 @@ LL | #[rustc_skip_during_method_dispatch("array")] | | didn't expect a literal here | help: must be of the form: `#[rustc_skip_during_method_dispatch(array, boxed_slice)]` -error: attribute should be applied to a trait +error: `#[rustc_skip_during_method_dispatch]` attribute cannot be used on trait impl blocks --> $DIR/rustc_skip_during_method_dispatch.rs:34:1 | LL | #[rustc_skip_during_method_dispatch(array)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | impl OK for () {} - | ----------------- not a trait + | + = help: `#[rustc_skip_during_method_dispatch]` can only be applied to traits error: aborting due to 8 previous errors diff --git a/tests/ui/attributes/unsafe/proc-unsafe-attributes.stderr b/tests/ui/attributes/unsafe/proc-unsafe-attributes.stderr index 884e7663c85..107e053ae0c 100644 --- a/tests/ui/attributes/unsafe/proc-unsafe-attributes.stderr +++ b/tests/ui/attributes/unsafe/proc-unsafe-attributes.stderr @@ -119,9 +119,18 @@ error[E0565]: malformed `proc_macro_derive` attribute input | LL | #[proc_macro_derive(unsafe(Foo))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^-----^^ - | | | - | | didn't expect any arguments here - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | didn't expect any arguments here + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(unsafe(Foo))] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(unsafe(Foo))] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0452]: malformed lint attribute input --> $DIR/proc-unsafe-attributes.rs:27:16 diff --git a/tests/ui/attributes/used_with_multi_args.stderr b/tests/ui/attributes/used_with_multi_args.stderr index e48209cf204..308f0519b8c 100644 --- a/tests/ui/attributes/used_with_multi_args.stderr +++ b/tests/ui/attributes/used_with_multi_args.stderr @@ -9,7 +9,10 @@ LL | #[used(compiler, linker)] help: try changing it to one of the following valid forms of the attribute | LL - #[used(compiler, linker)] -LL + #[used(compiler|linker)] +LL + #[used(compiler)] + | +LL - #[used(compiler, linker)] +LL + #[used(linker)] | LL - #[used(compiler, linker)] LL + #[used] diff --git a/tests/ui/auto-traits/assoc-ty.current.stderr b/tests/ui/auto-traits/assoc-ty.current.stderr index 77a1c8fb654..d793ae66526 100644 --- a/tests/ui/auto-traits/assoc-ty.current.stderr +++ b/tests/ui/auto-traits/assoc-ty.current.stderr @@ -5,7 +5,7 @@ LL | auto trait Trait { | ----- auto traits cannot have associated items LL | LL | type Output; - | -----^^^^^^- help: remove these associated items + | ^^^^^^ error[E0658]: auto traits are experimental and possibly buggy --> $DIR/assoc-ty.rs:8:1 diff --git a/tests/ui/auto-traits/assoc-ty.next.stderr b/tests/ui/auto-traits/assoc-ty.next.stderr index 4ce00d17475..a41f7d99278 100644 --- a/tests/ui/auto-traits/assoc-ty.next.stderr +++ b/tests/ui/auto-traits/assoc-ty.next.stderr @@ -5,7 +5,7 @@ LL | auto trait Trait { | ----- auto traits cannot have associated items LL | LL | type Output; - | -----^^^^^^- help: remove these associated items + | ^^^^^^ error[E0658]: auto traits are experimental and possibly buggy --> $DIR/assoc-ty.rs:8:1 diff --git a/tests/ui/auto-traits/auto-trait-validation.fixed b/tests/ui/auto-traits/auto-trait-validation.fixed index 8a445448c85..b24dc1cb2c3 100644 --- a/tests/ui/auto-traits/auto-trait-validation.fixed +++ b/tests/ui/auto-traits/auto-trait-validation.fixed @@ -11,4 +11,15 @@ auto trait LifetimeBound {} //~^ ERROR auto traits cannot have super traits or lifetime bounds [E0568] auto trait MyTrait { } //~^ ERROR auto traits cannot have associated items [E0380] +auto trait AssocTy { } +//~^ ERROR auto traits cannot have associated items [E0380] +auto trait All { + //~^ ERROR auto traits cannot have generic parameters [E0567] + +} +// We can't test both generic params and super-traits because the suggestion span overlaps. +auto trait All2 { + //~^ ERROR auto traits cannot have super traits or lifetime bounds [E0568] + +} fn main() {} diff --git a/tests/ui/auto-traits/auto-trait-validation.rs b/tests/ui/auto-traits/auto-trait-validation.rs index b5e7505d86a..9665e5bc393 100644 --- a/tests/ui/auto-traits/auto-trait-validation.rs +++ b/tests/ui/auto-traits/auto-trait-validation.rs @@ -11,4 +11,19 @@ auto trait LifetimeBound : 'static {} //~^ ERROR auto traits cannot have super traits or lifetime bounds [E0568] auto trait MyTrait { fn foo() {} } //~^ ERROR auto traits cannot have associated items [E0380] +auto trait AssocTy { type Bar; } +//~^ ERROR auto traits cannot have associated items [E0380] +auto trait All<'a, T> { + //~^ ERROR auto traits cannot have generic parameters [E0567] + type Bar; + //~^ ERROR auto traits cannot have associated items [E0380] + fn foo() {} +} +// We can't test both generic params and super-traits because the suggestion span overlaps. +auto trait All2: Copy + 'static { + //~^ ERROR auto traits cannot have super traits or lifetime bounds [E0568] + type Bar; + //~^ ERROR auto traits cannot have associated items [E0380] + fn foo() {} +} fn main() {} diff --git a/tests/ui/auto-traits/auto-trait-validation.stderr b/tests/ui/auto-traits/auto-trait-validation.stderr index a6e5ac54869..60757db6d1e 100644 --- a/tests/ui/auto-traits/auto-trait-validation.stderr +++ b/tests/ui/auto-traits/auto-trait-validation.stderr @@ -2,23 +2,23 @@ error[E0567]: auto traits cannot have generic parameters --> $DIR/auto-trait-validation.rs:6:19 | LL | auto trait Generic<T> {} - | -------^^^ help: remove the parameters + | -------^^^ | | | auto trait cannot have generic parameters error[E0568]: auto traits cannot have super traits or lifetime bounds - --> $DIR/auto-trait-validation.rs:8:17 + --> $DIR/auto-trait-validation.rs:8:20 | LL | auto trait Bound : Copy {} - | -----^^^^^^^ help: remove the super traits or lifetime bounds + | ----- ^^^^ | | | auto traits cannot have super traits or lifetime bounds error[E0568]: auto traits cannot have super traits or lifetime bounds - --> $DIR/auto-trait-validation.rs:10:25 + --> $DIR/auto-trait-validation.rs:10:28 | LL | auto trait LifetimeBound : 'static {} - | -------------^^^^^^^^^^ help: remove the super traits or lifetime bounds + | ------------- ^^^^^^^ | | | auto traits cannot have super traits or lifetime bounds @@ -26,12 +26,59 @@ error[E0380]: auto traits cannot have associated items --> $DIR/auto-trait-validation.rs:12:25 | LL | auto trait MyTrait { fn foo() {} } - | ------- ---^^^----- - | | | - | | help: remove these associated items + | ------- ^^^ + | | + | auto traits cannot have associated items + +error[E0380]: auto traits cannot have associated items + --> $DIR/auto-trait-validation.rs:14:27 + | +LL | auto trait AssocTy { type Bar; } + | ------- ^^^ + | | | auto traits cannot have associated items -error: aborting due to 4 previous errors +error[E0567]: auto traits cannot have generic parameters + --> $DIR/auto-trait-validation.rs:16:15 + | +LL | auto trait All<'a, T> { + | ---^^^^^^^ + | | + | auto trait cannot have generic parameters + +error[E0380]: auto traits cannot have associated items + --> $DIR/auto-trait-validation.rs:18:10 + | +LL | auto trait All<'a, T> { + | --- auto traits cannot have associated items +LL | +LL | type Bar; + | ^^^ +LL | +LL | fn foo() {} + | ^^^ + +error[E0568]: auto traits cannot have super traits or lifetime bounds + --> $DIR/auto-trait-validation.rs:23:18 + | +LL | auto trait All2: Copy + 'static { + | ---- ^^^^ ^^^^^^^ + | | + | auto traits cannot have super traits or lifetime bounds + +error[E0380]: auto traits cannot have associated items + --> $DIR/auto-trait-validation.rs:25:10 + | +LL | auto trait All2: Copy + 'static { + | ---- auto traits cannot have associated items +LL | +LL | type Bar; + | ^^^ +LL | +LL | fn foo() {} + | ^^^ + +error: aborting due to 9 previous errors Some errors have detailed explanations: E0380, E0567, E0568. For more information about an error, try `rustc --explain E0380`. diff --git a/tests/ui/auto-traits/bad-generics-on-dyn.stderr b/tests/ui/auto-traits/bad-generics-on-dyn.stderr index 06c7cbcd76d..a6977c2037e 100644 --- a/tests/ui/auto-traits/bad-generics-on-dyn.stderr +++ b/tests/ui/auto-traits/bad-generics-on-dyn.stderr @@ -2,7 +2,7 @@ error[E0567]: auto traits cannot have generic parameters --> $DIR/bad-generics-on-dyn.rs:3:18 | LL | auto trait Trait1<'a> {} - | ------^^^^ help: remove the parameters + | ------^^^^ | | | auto trait cannot have generic parameters diff --git a/tests/ui/auto-traits/has-arguments.stderr b/tests/ui/auto-traits/has-arguments.stderr index b8a680e6a5c..5228b6d2d1a 100644 --- a/tests/ui/auto-traits/has-arguments.stderr +++ b/tests/ui/auto-traits/has-arguments.stderr @@ -2,7 +2,7 @@ error[E0567]: auto traits cannot have generic parameters --> $DIR/has-arguments.rs:3:18 | LL | auto trait Trait1<'outer> {} - | ------^^^^^^^^ help: remove the parameters + | ------^^^^^^^^ | | | auto trait cannot have generic parameters diff --git a/tests/ui/auto-traits/issue-117789.stderr b/tests/ui/auto-traits/issue-117789.stderr index 99efb213417..1e047c7d2e0 100644 --- a/tests/ui/auto-traits/issue-117789.stderr +++ b/tests/ui/auto-traits/issue-117789.stderr @@ -2,7 +2,7 @@ error[E0567]: auto traits cannot have generic parameters --> $DIR/issue-117789.rs:1:17 | LL | auto trait Trait<P> {} - | -----^^^ help: remove the parameters + | -----^^^ | | | auto trait cannot have generic parameters diff --git a/tests/ui/auto-traits/issue-23080-2.current.stderr b/tests/ui/auto-traits/issue-23080-2.current.stderr index 62c7b37041f..3af97f57d48 100644 --- a/tests/ui/auto-traits/issue-23080-2.current.stderr +++ b/tests/ui/auto-traits/issue-23080-2.current.stderr @@ -4,7 +4,7 @@ error[E0380]: auto traits cannot have associated items LL | unsafe auto trait Trait { | ----- auto traits cannot have associated items LL | type Output; - | -----^^^^^^- help: remove these associated items + | ^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/auto-traits/issue-23080-2.next.stderr b/tests/ui/auto-traits/issue-23080-2.next.stderr index 62c7b37041f..3af97f57d48 100644 --- a/tests/ui/auto-traits/issue-23080-2.next.stderr +++ b/tests/ui/auto-traits/issue-23080-2.next.stderr @@ -4,7 +4,7 @@ error[E0380]: auto traits cannot have associated items LL | unsafe auto trait Trait { | ----- auto traits cannot have associated items LL | type Output; - | -----^^^^^^- help: remove these associated items + | ^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/auto-traits/issue-23080.stderr b/tests/ui/auto-traits/issue-23080.stderr index 5cea45060c8..02a75519102 100644 --- a/tests/ui/auto-traits/issue-23080.stderr +++ b/tests/ui/auto-traits/issue-23080.stderr @@ -1,13 +1,10 @@ error[E0380]: auto traits cannot have associated items --> $DIR/issue-23080.rs:5:8 | -LL | unsafe auto trait Trait { - | ----- auto traits cannot have associated items -LL | fn method(&self) { - | _____- ^^^^^^ -LL | | println!("Hello"); -LL | | } - | |_____- help: remove these associated items +LL | unsafe auto trait Trait { + | ----- auto traits cannot have associated items +LL | fn method(&self) { + | ^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/auto-traits/issue-84075.stderr b/tests/ui/auto-traits/issue-84075.stderr index 943d521ce9e..4edf2ecdf06 100644 --- a/tests/ui/auto-traits/issue-84075.stderr +++ b/tests/ui/auto-traits/issue-84075.stderr @@ -2,7 +2,7 @@ error[E0568]: auto traits cannot have super traits or lifetime bounds --> $DIR/issue-84075.rs:5:18 | LL | auto trait Magic where Self: Copy {} - | ----- ^^^^^^^^^^^^^^^^ help: remove the super traits or lifetime bounds + | ----- ^^^^^^^^^^^^^^^^ | | | auto traits cannot have super traits or lifetime bounds diff --git a/tests/ui/auto-traits/typeck-auto-trait-no-supertraits-2.stderr b/tests/ui/auto-traits/typeck-auto-trait-no-supertraits-2.stderr index 27e38ce06a4..bc17fefc944 100644 --- a/tests/ui/auto-traits/typeck-auto-trait-no-supertraits-2.stderr +++ b/tests/ui/auto-traits/typeck-auto-trait-no-supertraits-2.stderr @@ -1,8 +1,8 @@ error[E0568]: auto traits cannot have super traits or lifetime bounds - --> $DIR/typeck-auto-trait-no-supertraits-2.rs:4:17 + --> $DIR/typeck-auto-trait-no-supertraits-2.rs:4:20 | LL | auto trait Magic : Sized where Option<Self> : Magic {} - | -----^^^^^^^^ help: remove the super traits or lifetime bounds + | ----- ^^^^^ | | | auto traits cannot have super traits or lifetime bounds @@ -10,7 +10,7 @@ error[E0568]: auto traits cannot have super traits or lifetime bounds --> $DIR/typeck-auto-trait-no-supertraits-2.rs:4:26 | LL | auto trait Magic : Sized where Option<Self> : Magic {} - | ----- ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the super traits or lifetime bounds + | ----- ^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | auto traits cannot have super traits or lifetime bounds diff --git a/tests/ui/auto-traits/typeck-auto-trait-no-supertraits.stderr b/tests/ui/auto-traits/typeck-auto-trait-no-supertraits.stderr index 23aae13639c..bc9791a5799 100644 --- a/tests/ui/auto-traits/typeck-auto-trait-no-supertraits.stderr +++ b/tests/ui/auto-traits/typeck-auto-trait-no-supertraits.stderr @@ -1,8 +1,8 @@ error[E0568]: auto traits cannot have super traits or lifetime bounds - --> $DIR/typeck-auto-trait-no-supertraits.rs:28:17 + --> $DIR/typeck-auto-trait-no-supertraits.rs:28:19 | LL | auto trait Magic: Copy {} - | -----^^^^^^ help: remove the super traits or lifetime bounds + | ----- ^^^^ | | | auto traits cannot have super traits or lifetime bounds diff --git a/tests/ui/autodiff/macro_hygiene.rs b/tests/ui/autodiff/macro_hygiene.rs new file mode 100644 index 00000000000..dec58254b99 --- /dev/null +++ b/tests/ui/autodiff/macro_hygiene.rs @@ -0,0 +1,22 @@ +//@ compile-flags: -Zautodiff=Enable -C opt-level=3 -Clto=fat +//@ no-prefer-dynamic +//@ needs-enzyme +//@ check-pass + +// In the past, we just checked for correct macro hygiene information. + +#![feature(autodiff)] + +macro_rules! demo { + () => { + #[std::autodiff::autodiff_reverse(fd, Active, Active)] + fn f(x: f64) -> f64 { + x * x + } + }; +} +demo!(); + +fn main() { + dbg!(f(2.0f64)); +} diff --git a/tests/ui/issues/issue-91489.rs b/tests/ui/autoref-autoderef/auto-deref-on-cow-regression-91489.rs index 0566302c481..929e98ad719 100644 --- a/tests/ui/issues/issue-91489.rs +++ b/tests/ui/autoref-autoderef/auto-deref-on-cow-regression-91489.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/91489 //@ check-pass // regression test for #91489 diff --git a/tests/ui/backtrace/synchronized-panic-handler.run.stderr b/tests/ui/backtrace/synchronized-panic-handler.run.stderr index 7a60ef2da60..c604d49c193 100644 --- a/tests/ui/backtrace/synchronized-panic-handler.run.stderr +++ b/tests/ui/backtrace/synchronized-panic-handler.run.stderr @@ -1,7 +1,7 @@ -thread '<unnamed>' panicked at $DIR/synchronized-panic-handler.rs:11:5: +thread '<unnamed>' ($TID) panicked at $DIR/synchronized-panic-handler.rs:11:5: oops oh no woe is me note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread '<unnamed>' panicked at $DIR/synchronized-panic-handler.rs:11:5: +thread '<unnamed>' ($TID) panicked at $DIR/synchronized-panic-handler.rs:11:5: oops oh no woe is me diff --git a/tests/ui/issues/issue-9725.rs b/tests/ui/binding/struct-destructuring-repeated-bindings-9725.rs index 360effbd119..6b0b8e37b8c 100644 --- a/tests/ui/issues/issue-9725.rs +++ b/tests/ui/binding/struct-destructuring-repeated-bindings-9725.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/9725 struct A { foo: isize } fn main() { diff --git a/tests/ui/issues/issue-9725.stderr b/tests/ui/binding/struct-destructuring-repeated-bindings-9725.stderr index 687e0cc0f3e..f4d19bed419 100644 --- a/tests/ui/issues/issue-9725.stderr +++ b/tests/ui/binding/struct-destructuring-repeated-bindings-9725.stderr @@ -1,11 +1,11 @@ error[E0416]: identifier `foo` is bound more than once in the same pattern - --> $DIR/issue-9725.rs:4:18 + --> $DIR/struct-destructuring-repeated-bindings-9725.rs:5:18 | LL | let A { foo, foo } = A { foo: 3 }; | ^^^ used in a pattern more than once error[E0025]: field `foo` bound multiple times in the pattern - --> $DIR/issue-9725.rs:4:18 + --> $DIR/struct-destructuring-repeated-bindings-9725.rs:5:18 | LL | let A { foo, foo } = A { foo: 3 }; | --- ^^^ multiple uses of `foo` in pattern diff --git a/tests/ui/issues/issue-15783.rs b/tests/ui/borrowck/array-slice-coercion-mismatch-15783.rs index ef948a1a88c..3322ed71c60 100644 --- a/tests/ui/issues/issue-15783.rs +++ b/tests/ui/borrowck/array-slice-coercion-mismatch-15783.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15783 + //@ dont-require-annotations: NOTE pub fn foo(params: Option<&[&str]>) -> usize { diff --git a/tests/ui/issues/issue-15783.stderr b/tests/ui/borrowck/array-slice-coercion-mismatch-15783.stderr index c9c9a723a86..050eb4baa41 100644 --- a/tests/ui/issues/issue-15783.stderr +++ b/tests/ui/borrowck/array-slice-coercion-mismatch-15783.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-15783.rs:10:19 + --> $DIR/array-slice-coercion-mismatch-15783.rs:12:19 | LL | let msg = foo(x); | --- ^ expected `Option<&[&str]>`, found `Option<&[&str; 1]>` @@ -9,7 +9,7 @@ LL | let msg = foo(x); = note: expected enum `Option<&[&str]>` found enum `Option<&[&str; 1]>` note: function defined here - --> $DIR/issue-15783.rs:3:8 + --> $DIR/array-slice-coercion-mismatch-15783.rs:5:8 | LL | pub fn foo(params: Option<&[&str]>) -> usize { | ^^^ ----------------------- diff --git a/tests/ui/borrowck/borrowck-in-static.stderr b/tests/ui/borrowck/borrowck-in-static.stderr index 9bcf64dd62e..32419da0ce2 100644 --- a/tests/ui/borrowck/borrowck-in-static.stderr +++ b/tests/ui/borrowck/borrowck-in-static.stderr @@ -10,6 +10,7 @@ LL | Box::new(|| x) | | | captured by this `Fn` closure | + = help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once help: consider cloning the value if the performance cost is acceptable | LL | Box::new(|| x.clone()) diff --git a/tests/ui/borrowck/borrowck-move-by-capture.stderr b/tests/ui/borrowck/borrowck-move-by-capture.stderr index 732af1593d6..0ace6156281 100644 --- a/tests/ui/borrowck/borrowck-move-by-capture.stderr +++ b/tests/ui/borrowck/borrowck-move-by-capture.stderr @@ -12,6 +12,11 @@ LL | let _h = to_fn_once(move || -> isize { *bar }); | | | `bar` is moved here | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/borrowck-move-by-capture.rs:3:37 + | +LL | fn to_fn_mut<A:std::marker::Tuple,F:FnMut<A>>(f: F) -> F { f } + | ^^^^^^^^ help: consider cloning the value before moving it into the closure | LL ~ let value = bar.clone(); diff --git a/tests/ui/borrowck/issue-103624.stderr b/tests/ui/borrowck/issue-103624.stderr index af65deb16dc..bd6c1c44bfb 100644 --- a/tests/ui/borrowck/issue-103624.stderr +++ b/tests/ui/borrowck/issue-103624.stderr @@ -13,6 +13,11 @@ LL | LL | self.b; | ^^^^^^ `self.b` is moved here | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/issue-103624.rs:7:36 + | +LL | async fn spawn_blocking<T>(f: impl (Fn() -> T) + Send + Sync + 'static) -> T { + | ^^^^^^^^^^^ note: if `StructB` implemented `Clone`, you could clone the value --> $DIR/issue-103624.rs:23:1 | diff --git a/tests/ui/borrowck/issue-87456-point-to-closure.stderr b/tests/ui/borrowck/issue-87456-point-to-closure.stderr index a0c7cac2add..c31d096109c 100644 --- a/tests/ui/borrowck/issue-87456-point-to-closure.stderr +++ b/tests/ui/borrowck/issue-87456-point-to-closure.stderr @@ -10,6 +10,11 @@ LL | LL | let _foo: String = val; | ^^^ move occurs because `val` has type `String`, which does not implement the `Copy` trait | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/issue-87456-point-to-closure.rs:3:24 + | +LL | fn take_mut(_val: impl FnMut()) {} + | ^^^^^^^ help: consider borrowing here | LL | let _foo: String = &val; diff --git a/tests/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.stderr b/tests/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.stderr index 177e9c8d248..69c36674916 100644 --- a/tests/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.stderr +++ b/tests/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.stderr @@ -10,6 +10,11 @@ LL | y.into_iter(); | | | move occurs because `y` has type `Vec<String>`, which does not implement the `Copy` trait | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/unboxed-closures-move-upvar-from-non-once-ref-closure.rs:5:28 + | +LL | fn call<F>(f: F) where F : Fn() { + | ^^^^ note: `into_iter` takes ownership of the receiver `self`, which moves `y` --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL help: you can `clone` the value and consume it, but this might not be your desired behavior diff --git a/tests/ui/issues/issue-14845.rs b/tests/ui/cast/array-field-ptr-cast-14845.rs index d9b20e1f688..9d2da0c8932 100644 --- a/tests/ui/issues/issue-14845.rs +++ b/tests/ui/cast/array-field-ptr-cast-14845.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/14845 + struct X { a: [u8; 1] } diff --git a/tests/ui/issues/issue-14845.stderr b/tests/ui/cast/array-field-ptr-cast-14845.stderr index 2fa9fbaa887..4edde443fc3 100644 --- a/tests/ui/issues/issue-14845.stderr +++ b/tests/ui/cast/array-field-ptr-cast-14845.stderr @@ -1,11 +1,11 @@ error[E0606]: casting `&[u8; 1]` as `*mut u8` is invalid - --> $DIR/issue-14845.rs:7:14 + --> $DIR/array-field-ptr-cast-14845.rs:9:14 | LL | let _f = &x.a as *mut u8; | ^^^^^^^^^^^^^^^ error[E0606]: casting `&[u8; 1]` as `*mut u8` is invalid - --> $DIR/issue-14845.rs:10:14 + --> $DIR/array-field-ptr-cast-14845.rs:12:14 | LL | let _v = &local as *mut u8; | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/issues/issue-9942.rs b/tests/ui/cast/constant-expression-cast-9942.rs index 6332d9b3e08..d0a6f27b7e3 100644 --- a/tests/ui/issues/issue-9942.rs +++ b/tests/ui/cast/constant-expression-cast-9942.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/9942 //@ run-pass pub fn main() { diff --git a/tests/ui/issues/issue-14366.rs b/tests/ui/cast/trait-object-size-error-14366.rs index bb338860d8b..2b66df04600 100644 --- a/tests/ui/issues/issue-14366.rs +++ b/tests/ui/cast/trait-object-size-error-14366.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/14366 + fn main() { let _x = "test" as &dyn (::std::any::Any); //~^ ERROR the size for values of type diff --git a/tests/ui/issues/issue-14366.stderr b/tests/ui/cast/trait-object-size-error-14366.stderr index e7bf555c1b7..2451584e951 100644 --- a/tests/ui/issues/issue-14366.stderr +++ b/tests/ui/cast/trait-object-size-error-14366.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/issue-14366.rs:2:14 + --> $DIR/trait-object-size-error-14366.rs:4:14 | LL | let _x = "test" as &dyn (::std::any::Any); | ^^^^^^ doesn't have a size known at compile-time diff --git a/tests/ui/cfg/cfg-target-compact-errors.stderr b/tests/ui/cfg/cfg-target-compact-errors.stderr index 7df6729e881..cf61f94278a 100644 --- a/tests/ui/cfg/cfg-target-compact-errors.stderr +++ b/tests/ui/cfg/cfg-target-compact-errors.stderr @@ -6,6 +6,8 @@ LL | #[cfg(target(o::o))] | | | | | expected this to be of the form `... = "..."` | help: must be of the form: `#[cfg(predicate)]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute> error[E0539]: malformed `cfg` attribute input --> $DIR/cfg-target-compact-errors.rs:9:1 @@ -15,6 +17,8 @@ LL | #[cfg(target(os = 8))] | | | | | expected a string literal here | help: must be of the form: `#[cfg(predicate)]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute> error[E0539]: malformed `cfg` attribute input --> $DIR/cfg-target-compact-errors.rs:13:1 @@ -24,6 +28,8 @@ LL | #[cfg(target(os = "linux", pointer(width = "64")))] | | | | | expected this to be of the form `... = "..."` | help: must be of the form: `#[cfg(predicate)]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute> error[E0539]: malformed `cfg` attribute input --> $DIR/cfg-target-compact-errors.rs:17:1 @@ -33,6 +39,8 @@ LL | #[cfg(target(true))] | | | | | expected this to be of the form `... = "..."` | help: must be of the form: `#[cfg(predicate)]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute> error: `cfg` predicate key must be an identifier --> $DIR/cfg-target-compact-errors.rs:21:14 diff --git a/tests/ui/check-cfg/cfg-crate-features.stderr b/tests/ui/check-cfg/cfg-crate-features.stderr index 60a5404c073..d69a24f3f64 100644 --- a/tests/ui/check-cfg/cfg-crate-features.stderr +++ b/tests/ui/check-cfg/cfg-crate-features.stderr @@ -24,7 +24,7 @@ warning: unexpected `cfg` condition value: `does_not_exist` LL | #![cfg(not(target(os = "does_not_exist")))] | ^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, and `uefi` and 9 more + = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, and `uefi` and 10 more = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default 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 b07d630e5f5..229390ab460 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr @@ -14,7 +14,7 @@ warning: unexpected `cfg` condition value: `value` LL | #[cfg(target_vendor = "value")] | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `openwrt`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, and `wrs` + = note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `openwrt`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `vex`, `win7`, and `wrs` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `feature` diff --git a/tests/ui/check-cfg/exhaustive-names-values.feature.stderr b/tests/ui/check-cfg/exhaustive-names-values.feature.stderr index 80f8f36c23f..9281392b59e 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.feature.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.feature.stderr @@ -15,7 +15,7 @@ warning: unexpected `cfg` condition value: `value` LL | #[cfg(target_vendor = "value")] | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `openwrt`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, and `wrs` + = note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `openwrt`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `vex`, `win7`, and `wrs` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `unk` diff --git a/tests/ui/check-cfg/exhaustive-names-values.full.stderr b/tests/ui/check-cfg/exhaustive-names-values.full.stderr index 80f8f36c23f..9281392b59e 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.full.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.full.stderr @@ -15,7 +15,7 @@ warning: unexpected `cfg` condition value: `value` LL | #[cfg(target_vendor = "value")] | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `openwrt`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, and `wrs` + = note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `openwrt`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `vex`, `win7`, and `wrs` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `unk` diff --git a/tests/ui/check-cfg/target_feature.stderr b/tests/ui/check-cfg/target_feature.stderr index f422919983b..5dd81f486c8 100644 --- a/tests/ui/check-cfg/target_feature.stderr +++ b/tests/ui/check-cfg/target_feature.stderr @@ -183,6 +183,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `nnp-assist` `nontrapping-fptoint` `nvic` +`outline-atomics` `paca` `pacg` `pan` @@ -198,6 +199,35 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `power9-altivec` `power9-vector` `prfchw` +`ptx32` +`ptx40` +`ptx41` +`ptx42` +`ptx43` +`ptx50` +`ptx60` +`ptx61` +`ptx62` +`ptx63` +`ptx64` +`ptx65` +`ptx70` +`ptx71` +`ptx72` +`ptx73` +`ptx74` +`ptx75` +`ptx76` +`ptx77` +`ptx78` +`ptx80` +`ptx81` +`ptx82` +`ptx83` +`ptx84` +`ptx85` +`ptx86` +`ptx87` `quadword-atomics` `rand` `ras` @@ -222,6 +252,33 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `simd128` `sm3` `sm4` +`sm_100` +`sm_100a` +`sm_101` +`sm_101a` +`sm_120` +`sm_120a` +`sm_20` +`sm_21` +`sm_30` +`sm_32` +`sm_35` +`sm_37` +`sm_50` +`sm_52` +`sm_53` +`sm_60` +`sm_61` +`sm_62` +`sm_70` +`sm_72` +`sm_75` +`sm_80` +`sm_86` +`sm_87` +`sm_89` +`sm_90` +`sm_90a` `sme` `sme-b16b16` `sme-f16f16` diff --git a/tests/ui/check-cfg/well-known-values.stderr b/tests/ui/check-cfg/well-known-values.stderr index 2484974cdc2..18e038a442e 100644 --- a/tests/ui/check-cfg/well-known-values.stderr +++ b/tests/ui/check-cfg/well-known-values.stderr @@ -156,7 +156,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` LL | target_env = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_env` are: ``, `gnu`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `nto71_iosock`, `nto80`, `ohos`, `p1`, `p2`, `relibc`, `sgx`, and `uclibc` + = note: expected values for `target_env` are: ``, `gnu`, `macabi`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `nto71_iosock`, `nto80`, `ohos`, `p1`, `p2`, `relibc`, `sgx`, `sim`, `uclibc`, and `v5` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` @@ -201,7 +201,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` LL | target_os = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm` + = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `vexos`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` @@ -230,7 +230,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` LL | target_vendor = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `openwrt`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, and `wrs` + = note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `openwrt`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `vex`, `win7`, and `wrs` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` @@ -274,7 +274,7 @@ 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`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm` + = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `vexos`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration warning: 28 warnings emitted diff --git a/tests/ui/issues/issue-13808.rs b/tests/ui/closures/boxed-closure-lifetime-13808.rs index d2961b35f2e..e8324796b5f 100644 --- a/tests/ui/issues/issue-13808.rs +++ b/tests/ui/closures/boxed-closure-lifetime-13808.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13808 + //@ run-pass #![allow(dead_code)] #![allow(unused_variables)] diff --git a/tests/ui/issues/issue-9129.rs b/tests/ui/closures/closure-type-inference-in-context-9129.rs index 3856cd133e8..53ee8faab85 100644 --- a/tests/ui/issues/issue-9129.rs +++ b/tests/ui/closures/closure-type-inference-in-context-9129.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/9129 //@ run-pass #![allow(dead_code)] #![allow(non_camel_case_types)] diff --git a/tests/ui/issues/issue-16256.rs b/tests/ui/closures/unused-closure-ice-16256.rs index 1024e4511d6..fd569dd8a0a 100644 --- a/tests/ui/issues/issue-16256.rs +++ b/tests/ui/closures/unused-closure-ice-16256.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/16256 + //@ run-pass fn main() { diff --git a/tests/ui/issues/issue-16256.stderr b/tests/ui/closures/unused-closure-ice-16256.stderr index 75c3ec1bd1c..9df433add5d 100644 --- a/tests/ui/issues/issue-16256.stderr +++ b/tests/ui/closures/unused-closure-ice-16256.stderr @@ -1,5 +1,5 @@ warning: unused closure that must be used - --> $DIR/issue-16256.rs:5:5 + --> $DIR/unused-closure-ice-16256.rs:7:5 | LL | |c: u8| buf.push(c); | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/issues/issue-15793.rs b/tests/ui/codegen/nested-enum-match-optimization-15793.rs index af92e9dfa4c..420e3ad82b2 100644 --- a/tests/ui/issues/issue-15793.rs +++ b/tests/ui/codegen/nested-enum-match-optimization-15793.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15793 + //@ run-pass #![allow(dead_code)] diff --git a/tests/ui/codegen/overflow-during-mono.rs b/tests/ui/codegen/overflow-during-mono.rs index a9045840173..3aafe05ba05 100644 --- a/tests/ui/codegen/overflow-during-mono.rs +++ b/tests/ui/codegen/overflow-during-mono.rs @@ -1,5 +1,6 @@ -//~ ERROR overflow evaluating the requirement `for<'a> {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}: FnMut(&'a _)` +//~ ERROR overflow evaluating the requirement `for<'a> {closure@$DIR/overflow-during-mono.rs:14:41: 14:44}: FnMut(&'a _)` //@ build-fail +//@ compile-flags: -Zwrite-long-types-to-disk=yes #![recursion_limit = "32"] diff --git a/tests/ui/codegen/overflow-during-mono.stderr b/tests/ui/codegen/overflow-during-mono.stderr index 74d98fde285..1559de757e7 100644 --- a/tests/ui/codegen/overflow-during-mono.stderr +++ b/tests/ui/codegen/overflow-during-mono.stderr @@ -1,10 +1,12 @@ -error[E0275]: overflow evaluating the requirement `for<'a> {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}: FnMut(&'a _)` +error[E0275]: overflow evaluating the requirement `for<'a> {closure@$DIR/overflow-during-mono.rs:14:41: 14:44}: FnMut(&'a _)` | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "64"]` attribute to your crate (`overflow_during_mono`) - = note: required for `Filter<std::array::IntoIter<i32, 11>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>` to implement `Iterator` + = note: required for `Filter<IntoIter<i32, 11>, {closure@overflow-during-mono.rs:14:41}>` to implement `Iterator` = note: 31 redundant requirements hidden - = note: required for `Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<std::array::IntoIter<i32, 11>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>` to implement `Iterator` - = note: required for `Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<std::array::IntoIter<i32, 11>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>` to implement `IntoIterator` + = note: required for `Filter<Filter<Filter<Filter<Filter<..., ...>, ...>, ...>, ...>, ...>` to implement `Iterator` + = note: required for `Filter<Filter<Filter<Filter<Filter<..., ...>, ...>, ...>, ...>, ...>` to implement `IntoIterator` + = note: the full name for the type has been written to '$TEST_BUILD_DIR/overflow-during-mono.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error diff --git a/tests/ui/codemap_tests/issue-28308.rs b/tests/ui/codemap_tests/issue-28308.rs index 81493f8c453..b0e04d0f1f6 100644 --- a/tests/ui/codemap_tests/issue-28308.rs +++ b/tests/ui/codemap_tests/issue-28308.rs @@ -1,4 +1,16 @@ fn main() { - assert!("foo"); - //~^ ERROR cannot apply unary operator `!` + assert!("foo"); //~ ERROR mismatched types + //~^ NOTE expected `bool`, found `str` + //~| NOTE in this expansion of assert! + let x = Some(&1); + assert!(x); //~ ERROR mismatched types + //~^ NOTE expected `bool`, found `Option<&{integer}>` + //~| NOTE expected enum `bool` + //~| NOTE in this expansion of assert! + //~| NOTE in this expansion of assert! + assert!(x, ""); //~ ERROR mismatched types + //~^ NOTE expected `bool`, found `Option<&{integer}>` + //~| NOTE expected enum `bool` + //~| NOTE in this expansion of assert! + //~| NOTE in this expansion of assert! } diff --git a/tests/ui/codemap_tests/issue-28308.stderr b/tests/ui/codemap_tests/issue-28308.stderr index 7bc9e05dfc0..e84ceb44aac 100644 --- a/tests/ui/codemap_tests/issue-28308.stderr +++ b/tests/ui/codemap_tests/issue-28308.stderr @@ -1,9 +1,27 @@ -error[E0600]: cannot apply unary operator `!` to type `&'static str` - --> $DIR/issue-28308.rs:2:5 +error[E0308]: mismatched types + --> $DIR/issue-28308.rs:2:13 | LL | assert!("foo"); - | ^^^^^^^^^^^^^^ cannot apply unary operator `!` + | ^^^^^ expected `bool`, found `str` -error: aborting due to 1 previous error +error[E0308]: mismatched types + --> $DIR/issue-28308.rs:6:13 + | +LL | assert!(x); + | ^ expected `bool`, found `Option<&{integer}>` + | + = note: expected enum `bool` + found type `Option<&{integer}>` + +error[E0308]: mismatched types + --> $DIR/issue-28308.rs:11:13 + | +LL | assert!(x, ""); + | ^ expected `bool`, found `Option<&{integer}>` + | + = note: expected enum `bool` + found type `Option<&{integer}>` + +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0600`. +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/issues/issue-14399.rs b/tests/ui/coercion/method-return-trait-object-14399.rs index a539e270fb0..49eee152d88 100644 --- a/tests/ui/issues/issue-14399.rs +++ b/tests/ui/coercion/method-return-trait-object-14399.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/14399 + //@ run-pass // #14399 // We'd previously ICE if we had a method call whose return diff --git a/tests/ui/issues/issue-14399.stderr b/tests/ui/coercion/method-return-trait-object-14399.stderr index 5821c3cc389..1aa87f53ff8 100644 --- a/tests/ui/issues/issue-14399.stderr +++ b/tests/ui/coercion/method-return-trait-object-14399.stderr @@ -1,5 +1,5 @@ warning: method `foo` is never used - --> $DIR/issue-14399.rs:11:14 + --> $DIR/method-return-trait-object-14399.rs:13:14 | LL | trait A { fn foo(&self) {} } | - ^^^ diff --git a/tests/ui/issues/issue-9951.rs b/tests/ui/coercion/trait-object-coercion-distribution-9951.rs index 2cd7cd4f430..526d6561510 100644 --- a/tests/ui/issues/issue-9951.rs +++ b/tests/ui/coercion/trait-object-coercion-distribution-9951.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/9951 //@ run-pass #![allow(unused_variables)] diff --git a/tests/ui/issues/issue-9951.stderr b/tests/ui/coercion/trait-object-coercion-distribution-9951.stderr index 62ed9f3e0cc..0c672aa9b33 100644 --- a/tests/ui/issues/issue-9951.stderr +++ b/tests/ui/coercion/trait-object-coercion-distribution-9951.stderr @@ -1,5 +1,5 @@ warning: method `noop` is never used - --> $DIR/issue-9951.rs:6:6 + --> $DIR/trait-object-coercion-distribution-9951.rs:7:6 | LL | trait Bar { | --- method in this trait diff --git a/tests/ui/coherence/coherence-tuple-conflict.stderr b/tests/ui/coherence/coherence-tuple-conflict.stderr index 95f9a1a8841..8ce65f79aca 100644 --- a/tests/ui/coherence/coherence-tuple-conflict.stderr +++ b/tests/ui/coherence/coherence-tuple-conflict.stderr @@ -12,6 +12,8 @@ error[E0609]: no field `dummy` on type `&(A, B)` | LL | fn get(&self) -> usize { self.dummy } | ^^^^^ unknown field + | + = note: available fields are: `0`, `1` error: aborting due to 2 previous errors diff --git a/tests/ui/conditional-compilation/cfg-attr-syntax-validation.rs b/tests/ui/conditional-compilation/cfg-attr-syntax-validation.rs index df87a3d846e..126a534dc6f 100644 --- a/tests/ui/conditional-compilation/cfg-attr-syntax-validation.rs +++ b/tests/ui/conditional-compilation/cfg-attr-syntax-validation.rs @@ -1,21 +1,25 @@ #[cfg] //~^ ERROR malformed `cfg` attribute //~| NOTE expected this to be a list +//~| NOTE for more information, visit struct S1; #[cfg = 10] //~^ ERROR malformed `cfg` attribute //~| NOTE expected this to be a list +//~| NOTE for more information, visit struct S2; #[cfg()] //~^ ERROR malformed `cfg` attribute //~| NOTE expected a single argument here +//~| NOTE for more information, visit struct S3; #[cfg(a, b)] //~^ ERROR malformed `cfg` attribute //~| NOTE expected a single argument here +//~| NOTE for more information, visit struct S4; #[cfg("str")] //~ ERROR `cfg` predicate key must be an identifier @@ -29,6 +33,7 @@ struct S7; #[cfg(a = 10)] //~ ERROR malformed `cfg` attribute input //~^ NOTE expected a string literal here +//~| NOTE for more information, visit struct S8; #[cfg(a = b"hi")] //~ ERROR malformed `cfg` attribute input diff --git a/tests/ui/conditional-compilation/cfg-attr-syntax-validation.stderr b/tests/ui/conditional-compilation/cfg-attr-syntax-validation.stderr index 75e9b9209c0..6acde758ea5 100644 --- a/tests/ui/conditional-compilation/cfg-attr-syntax-validation.stderr +++ b/tests/ui/conditional-compilation/cfg-attr-syntax-validation.stderr @@ -6,63 +6,73 @@ LL | #[cfg] | | | expected this to be a list | help: must be of the form: `#[cfg(predicate)]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute> error[E0539]: malformed `cfg` attribute input - --> $DIR/cfg-attr-syntax-validation.rs:6:1 + --> $DIR/cfg-attr-syntax-validation.rs:7:1 | LL | #[cfg = 10] | ^^^^^^^^^^^ | | | expected this to be a list | help: must be of the form: `#[cfg(predicate)]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute> error[E0805]: malformed `cfg` attribute input - --> $DIR/cfg-attr-syntax-validation.rs:11:1 + --> $DIR/cfg-attr-syntax-validation.rs:13:1 | LL | #[cfg()] | ^^^^^--^ | | | | | expected a single argument here | help: must be of the form: `#[cfg(predicate)]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute> error[E0805]: malformed `cfg` attribute input - --> $DIR/cfg-attr-syntax-validation.rs:16:1 + --> $DIR/cfg-attr-syntax-validation.rs:19:1 | LL | #[cfg(a, b)] | ^^^^^------^ | | | | | expected a single argument here | help: must be of the form: `#[cfg(predicate)]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute> error: `cfg` predicate key must be an identifier - --> $DIR/cfg-attr-syntax-validation.rs:21:7 + --> $DIR/cfg-attr-syntax-validation.rs:25:7 | LL | #[cfg("str")] | ^^^^^ error: `cfg` predicate key must be an identifier - --> $DIR/cfg-attr-syntax-validation.rs:24:7 + --> $DIR/cfg-attr-syntax-validation.rs:28:7 | LL | #[cfg(a::b)] | ^^^^ error[E0537]: invalid predicate `a` - --> $DIR/cfg-attr-syntax-validation.rs:27:7 + --> $DIR/cfg-attr-syntax-validation.rs:31:7 | LL | #[cfg(a())] | ^^^ error[E0539]: malformed `cfg` attribute input - --> $DIR/cfg-attr-syntax-validation.rs:30:1 + --> $DIR/cfg-attr-syntax-validation.rs:34:1 | LL | #[cfg(a = 10)] | ^^^^^^^^^^--^^ | | | | | expected a string literal here | help: must be of the form: `#[cfg(predicate)]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute> error[E0539]: malformed `cfg` attribute input - --> $DIR/cfg-attr-syntax-validation.rs:34:1 + --> $DIR/cfg-attr-syntax-validation.rs:39:1 | LL | #[cfg(a = b"hi")] | ^^^^^^^^^^-^^^^^^ @@ -72,7 +82,7 @@ LL | #[cfg(a = b"hi")] = note: expected a normal string literal, not a byte string literal error: expected unsuffixed literal, found `expr` metavariable - --> $DIR/cfg-attr-syntax-validation.rs:40:25 + --> $DIR/cfg-attr-syntax-validation.rs:45:25 | LL | #[cfg(feature = $expr)] | ^^^^^ diff --git a/tests/ui/confuse-field-and-method/issue-18343.stderr b/tests/ui/confuse-field-and-method/issue-18343.stderr index e50c971d837..9517617fe34 100644 --- a/tests/ui/confuse-field-and-method/issue-18343.stderr +++ b/tests/ui/confuse-field-and-method/issue-18343.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `closure` found for struct `Obj` in the current scope +error[E0599]: no method named `closure` found for struct `Obj<F>` in the current scope --> $DIR/issue-18343.rs:7:7 | LL | struct Obj<F> where F: FnMut() -> u32 { diff --git a/tests/ui/confuse-field-and-method/issue-2392.stderr b/tests/ui/confuse-field-and-method/issue-2392.stderr index 77930de44a7..e1ad24df80f 100644 --- a/tests/ui/confuse-field-and-method/issue-2392.stderr +++ b/tests/ui/confuse-field-and-method/issue-2392.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `closure` found for struct `Obj` in the current scope +error[E0599]: no method named `closure` found for struct `Obj<F>` in the current scope --> $DIR/issue-2392.rs:36:15 | LL | struct Obj<F> where F: FnOnce() -> u32 { @@ -12,7 +12,7 @@ help: to call the closure stored in `closure`, surround the field access with pa LL | (o_closure.closure)(); | + + -error[E0599]: no method named `not_closure` found for struct `Obj` in the current scope +error[E0599]: no method named `not_closure` found for struct `Obj<F>` in the current scope --> $DIR/issue-2392.rs:38:15 | LL | struct Obj<F> where F: FnOnce() -> u32 { @@ -23,7 +23,7 @@ LL | o_closure.not_closure(); | | | field, not a method -error[E0599]: no method named `closure` found for struct `Obj` in the current scope +error[E0599]: no method named `closure` found for struct `Obj<F>` in the current scope --> $DIR/issue-2392.rs:42:12 | LL | struct Obj<F> where F: FnOnce() -> u32 { @@ -65,7 +65,7 @@ help: to call the trait object stored in `boxed_closure`, surround the field acc LL | (boxed_closure.boxed_closure)(); | + + -error[E0599]: no method named `closure` found for struct `Obj` in the current scope +error[E0599]: no method named `closure` found for struct `Obj<F>` in the current scope --> $DIR/issue-2392.rs:53:12 | LL | struct Obj<F> where F: FnOnce() -> u32 { @@ -79,7 +79,7 @@ help: to call the function stored in `closure`, surround the field access with p LL | (w.wrap.closure)(); | + + -error[E0599]: no method named `not_closure` found for struct `Obj` in the current scope +error[E0599]: no method named `not_closure` found for struct `Obj<F>` in the current scope --> $DIR/issue-2392.rs:55:12 | LL | struct Obj<F> where F: FnOnce() -> u32 { @@ -90,7 +90,7 @@ LL | w.wrap.not_closure(); | | | field, not a method -error[E0599]: no method named `closure` found for struct `Obj` in the current scope +error[E0599]: no method named `closure` found for struct `Obj<F>` in the current scope --> $DIR/issue-2392.rs:58:24 | LL | struct Obj<F> where F: FnOnce() -> u32 { diff --git a/tests/ui/const-generics/generic_const_exprs/issue-80742.rs b/tests/ui/const-generics/generic_const_exprs/issue-80742.rs index 73357d208c0..ac4d9fc0f4f 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-80742.rs +++ b/tests/ui/const-generics/generic_const_exprs/issue-80742.rs @@ -2,7 +2,7 @@ //@ known-bug: #97477 //@ failure-status: 101 //@ normalize-stderr: "note: .*\n\n" -> "" -//@ normalize-stderr: "thread 'rustc' panicked.*\n" -> "" +//@ normalize-stderr: "thread 'rustc'.*panicked.*\n" -> "" //@ normalize-stderr: "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " //@ rustc-env:RUST_BACKTRACE=0 diff --git a/tests/ui/const-generics/issues/issue-90318.rs b/tests/ui/const-generics/issues/issue-90318.rs index 239171217eb..35b0dd216a1 100644 --- a/tests/ui/const-generics/issues/issue-90318.rs +++ b/tests/ui/const-generics/issues/issue-90318.rs @@ -1,4 +1,3 @@ -#![feature(const_type_id)] #![feature(generic_const_exprs)] #![feature(const_trait_impl, const_cmp)] #![feature(core_intrinsics)] diff --git a/tests/ui/const-generics/issues/issue-90318.stderr b/tests/ui/const-generics/issues/issue-90318.stderr index 7031230db91..f13fd795d7a 100644 --- a/tests/ui/const-generics/issues/issue-90318.stderr +++ b/tests/ui/const-generics/issues/issue-90318.stderr @@ -1,5 +1,5 @@ error: overly complex generic constant - --> $DIR/issue-90318.rs:15:8 + --> $DIR/issue-90318.rs:14:8 | LL | If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True, | ^^-----------------^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True, = note: this operation may be supported in the future error: overly complex generic constant - --> $DIR/issue-90318.rs:22:8 + --> $DIR/issue-90318.rs:21:8 | LL | If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True, | ^^-----------------^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/issues/issue-98299.rs b/tests/ui/const-generics/try-from-with-const-genericsrs-98299.rs index ba63d963475..49c88856bc9 100644 --- a/tests/ui/issues/issue-98299.rs +++ b/tests/ui/const-generics/try-from-with-const-genericsrs-98299.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/98299 use std::convert::TryFrom; pub fn test_usage(p: ()) { diff --git a/tests/ui/issues/issue-98299.stderr b/tests/ui/const-generics/try-from-with-const-genericsrs-98299.stderr index b645267e3b9..1557b83b00e 100644 --- a/tests/ui/issues/issue-98299.stderr +++ b/tests/ui/const-generics/try-from-with-const-genericsrs-98299.stderr @@ -1,5 +1,5 @@ error[E0284]: type annotations needed for `SmallCString<_>` - --> $DIR/issue-98299.rs:4:36 + --> $DIR/try-from-with-const-genericsrs-98299.rs:5:36 | LL | SmallCString::try_from(p).map(|cstr| cstr); | ------------ ^^^^ @@ -7,7 +7,7 @@ LL | SmallCString::try_from(p).map(|cstr| cstr); | type must be known at this point | note: required by a const generic parameter in `SmallCString` - --> $DIR/issue-98299.rs:10:25 + --> $DIR/try-from-with-const-genericsrs-98299.rs:11:25 | LL | pub struct SmallCString<const N: usize> {} | ^^^^^^^^^^^^^^ required by this const generic parameter in `SmallCString` @@ -17,7 +17,7 @@ LL | SmallCString::try_from(p).map(|cstr: SmallCString<N>| cstr); | +++++++++++++++++ error[E0284]: type annotations needed for `SmallCString<_>` - --> $DIR/issue-98299.rs:4:36 + --> $DIR/try-from-with-const-genericsrs-98299.rs:5:36 | LL | SmallCString::try_from(p).map(|cstr| cstr); | ------------ ^^^^ @@ -25,7 +25,7 @@ LL | SmallCString::try_from(p).map(|cstr| cstr); | type must be known at this point | note: required for `SmallCString<_>` to implement `TryFrom<()>` - --> $DIR/issue-98299.rs:12:22 + --> $DIR/try-from-with-const-genericsrs-98299.rs:13:22 | LL | impl<const N: usize> TryFrom<()> for SmallCString<N> { | -------------- ^^^^^^^^^^^ ^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | SmallCString::try_from(p).map(|cstr: SmallCString<N>| cstr); | +++++++++++++++++ error[E0284]: type annotations needed for `SmallCString<_>` - --> $DIR/issue-98299.rs:4:36 + --> $DIR/try-from-with-const-genericsrs-98299.rs:5:36 | LL | SmallCString::try_from(p).map(|cstr| cstr); | ------------------------- ^^^^ @@ -45,7 +45,7 @@ LL | SmallCString::try_from(p).map(|cstr| cstr); | type must be known at this point | note: required for `SmallCString<_>` to implement `TryFrom<()>` - --> $DIR/issue-98299.rs:12:22 + --> $DIR/try-from-with-const-genericsrs-98299.rs:13:22 | LL | impl<const N: usize> TryFrom<()> for SmallCString<N> { | -------------- ^^^^^^^^^^^ ^^^^^^^^^^^^^^^ diff --git a/tests/ui/consts/const-eval/issue-85155.stderr b/tests/ui/consts/const-eval/issue-85155.stderr index f7777bfac02..486d2adaf8c 100644 --- a/tests/ui/consts/const-eval/issue-85155.stderr +++ b/tests/ui/consts/const-eval/issue-85155.stderr @@ -12,7 +12,7 @@ LL | static_assert_imm1!(IMM1); | = note: this note originates in the macro `static_assert_imm1` (in Nightly builds, run with -Z macro-backtrace for more info) -note: the above error was encountered while instantiating `fn post_monomorphization_error::stdarch_intrinsic::<2>` +note: the above error was encountered while instantiating `fn stdarch_intrinsic::<2>` --> $DIR/issue-85155.rs:19:5 | LL | post_monomorphization_error::stdarch_intrinsic::<2>(); diff --git a/tests/ui/consts/const-eval/union-const-eval-field.rs b/tests/ui/consts/const-eval/union-const-eval-field.rs index 719e59b007c..2c9061a7a50 100644 --- a/tests/ui/consts/const-eval/union-const-eval-field.rs +++ b/tests/ui/consts/const-eval/union-const-eval-field.rs @@ -1,5 +1,6 @@ //@ dont-require-annotations: NOTE //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" +//@ normalize-stderr: "([[:xdigit:]]{2}\s){4}(__\s){4}\s+│\s+([?|\.]){4}\W{4}" -> "HEX_DUMP" type Field1 = i32; type Field2 = f32; diff --git a/tests/ui/consts/const-eval/union-const-eval-field.stderr b/tests/ui/consts/const-eval/union-const-eval-field.stderr index 1843ce273ac..3b7e5508d56 100644 --- a/tests/ui/consts/const-eval/union-const-eval-field.stderr +++ b/tests/ui/consts/const-eval/union-const-eval-field.stderr @@ -1,21 +1,21 @@ error[E0080]: reading memory at ALLOC0[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory - --> $DIR/union-const-eval-field.rs:29:37 + --> $DIR/union-const-eval-field.rs:30:37 | LL | const FIELD3: Field3 = unsafe { UNION.field3 }; | ^^^^^^^^^^^^ evaluation of `read_field3::FIELD3` failed here | = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { - 00 00 80 3f __ __ __ __ │ ...?░░░░ + HEX_DUMP } note: erroneous constant encountered - --> $DIR/union-const-eval-field.rs:31:5 + --> $DIR/union-const-eval-field.rs:32:5 | LL | FIELD3 | ^^^^^^ note: erroneous constant encountered - --> $DIR/union-const-eval-field.rs:31:5 + --> $DIR/union-const-eval-field.rs:32:5 | LL | FIELD3 | ^^^^^^ diff --git a/tests/ui/consts/const-typeid-of-rpass.rs b/tests/ui/consts/const-typeid-of-rpass.rs index 15ffdd1e83a..30f41070893 100644 --- a/tests/ui/consts/const-typeid-of-rpass.rs +++ b/tests/ui/consts/const-typeid-of-rpass.rs @@ -1,6 +1,4 @@ //@ run-pass -#![feature(const_type_id)] -#![feature(core_intrinsics)] use std::any::TypeId; diff --git a/tests/ui/consts/const_cmp_type_id.rs b/tests/ui/consts/const_cmp_type_id.rs index 8c21f7b1a5a..ff44876c5c4 100644 --- a/tests/ui/consts/const_cmp_type_id.rs +++ b/tests/ui/consts/const_cmp_type_id.rs @@ -1,6 +1,6 @@ //@ ignore-backends: gcc //@ compile-flags: -Znext-solver -#![feature(const_type_id, const_trait_impl, const_cmp)] +#![feature(const_trait_impl, const_cmp)] use std::any::TypeId; diff --git a/tests/ui/consts/const_transmute_type_id.rs b/tests/ui/consts/const_transmute_type_id.rs index a2d4cf37830..98783ad5b81 100644 --- a/tests/ui/consts/const_transmute_type_id.rs +++ b/tests/ui/consts/const_transmute_type_id.rs @@ -1,4 +1,4 @@ -#![feature(const_type_id, const_trait_impl, const_cmp)] +#![feature(const_trait_impl, const_cmp)] use std::any::TypeId; diff --git a/tests/ui/consts/const_transmute_type_id2.rs b/tests/ui/consts/const_transmute_type_id2.rs index 3ceb2b942b0..7e09947b768 100644 --- a/tests/ui/consts/const_transmute_type_id2.rs +++ b/tests/ui/consts/const_transmute_type_id2.rs @@ -1,6 +1,6 @@ //@ normalize-stderr: "0x(ff)+" -> "<u128::MAX>" -#![feature(const_type_id, const_trait_impl, const_cmp)] +#![feature( const_trait_impl, const_cmp)] use std::any::TypeId; diff --git a/tests/ui/consts/const_transmute_type_id3.rs b/tests/ui/consts/const_transmute_type_id3.rs index f1bb8cddf77..77c469d42f5 100644 --- a/tests/ui/consts/const_transmute_type_id3.rs +++ b/tests/ui/consts/const_transmute_type_id3.rs @@ -1,7 +1,7 @@ //! Test that all bytes of a TypeId must have the //! TypeId marker provenance. -#![feature(const_type_id, const_trait_impl, const_cmp)] +#![feature( const_trait_impl, const_cmp)] use std::any::TypeId; diff --git a/tests/ui/consts/const_transmute_type_id4.rs b/tests/ui/consts/const_transmute_type_id4.rs index 0ea75f2a2f4..bedd6084a16 100644 --- a/tests/ui/consts/const_transmute_type_id4.rs +++ b/tests/ui/consts/const_transmute_type_id4.rs @@ -1,4 +1,4 @@ -#![feature(const_type_id, const_trait_impl, const_cmp)] +#![feature(const_trait_impl, const_cmp)] use std::any::TypeId; diff --git a/tests/ui/consts/const_transmute_type_id5.rs b/tests/ui/consts/const_transmute_type_id5.rs index ae0429f8dbb..7f9a34104a3 100644 --- a/tests/ui/consts/const_transmute_type_id5.rs +++ b/tests/ui/consts/const_transmute_type_id5.rs @@ -1,7 +1,7 @@ //! Test that we require an equal TypeId to have an integer part that properly //! reflects the type id hash. -#![feature(const_type_id, const_trait_impl, const_cmp)] +#![feature(const_trait_impl, const_cmp)] use std::any::TypeId; diff --git a/tests/ui/consts/control-flow/assert.stderr b/tests/ui/consts/control-flow/assert.stderr index 026097a6ba0..deaad6abbcc 100644 --- a/tests/ui/consts/control-flow/assert.stderr +++ b/tests/ui/consts/control-flow/assert.stderr @@ -1,8 +1,8 @@ error[E0080]: evaluation panicked: assertion failed: false - --> $DIR/assert.rs:5:15 + --> $DIR/assert.rs:5:23 | LL | const _: () = assert!(false); - | ^^^^^^^^^^^^^^ evaluation of `_` failed here + | ^^^^^ evaluation of `_` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/issue-102117.rs b/tests/ui/consts/issue-102117.rs index 6cb9832bcd8..b7955283a8d 100644 --- a/tests/ui/consts/issue-102117.rs +++ b/tests/ui/consts/issue-102117.rs @@ -1,5 +1,3 @@ -#![feature(const_type_id)] - use std::alloc::Layout; use std::any::TypeId; use std::mem::transmute; diff --git a/tests/ui/consts/issue-102117.stderr b/tests/ui/consts/issue-102117.stderr index da92db87f18..cea355d01d7 100644 --- a/tests/ui/consts/issue-102117.stderr +++ b/tests/ui/consts/issue-102117.stderr @@ -1,5 +1,5 @@ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/issue-102117.rs:19:26 + --> $DIR/issue-102117.rs:17:26 | LL | type_id: TypeId::of::<T>(), | ^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | pub fn new<T: 'static>() -> &'static Self { | +++++++++ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/issue-102117.rs:19:26 + --> $DIR/issue-102117.rs:17:26 | LL | type_id: TypeId::of::<T>(), | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/consts/issue-19244-1.stderr b/tests/ui/consts/issue-19244-1.stderr index 9c1336402e6..98a33817b4c 100644 --- a/tests/ui/consts/issue-19244-1.stderr +++ b/tests/ui/consts/issue-19244-1.stderr @@ -3,6 +3,8 @@ error[E0609]: no field `1` on type `(usize,)` | LL | let a: [isize; TUP.1]; | ^ unknown field + | + = note: available field is: `0` error: aborting due to 1 previous error diff --git a/tests/ui/consts/issue-73976-monomorphic.rs b/tests/ui/consts/issue-73976-monomorphic.rs index f43823fa155..6459150a660 100644 --- a/tests/ui/consts/issue-73976-monomorphic.rs +++ b/tests/ui/consts/issue-73976-monomorphic.rs @@ -6,7 +6,6 @@ // will be properly rejected. This test will ensure that monomorphic use of these // would not be wrongly rejected in patterns. -#![feature(const_type_id)] #![feature(const_type_name)] #![feature(const_trait_impl)] #![feature(const_cmp)] diff --git a/tests/ui/consts/issue-73976-polymorphic.rs b/tests/ui/consts/issue-73976-polymorphic.rs index 98b4005792d..db06706a970 100644 --- a/tests/ui/consts/issue-73976-polymorphic.rs +++ b/tests/ui/consts/issue-73976-polymorphic.rs @@ -5,7 +5,6 @@ // This test case should either run-pass or be rejected at compile time. // Currently we just disallow this usage and require pattern is monomorphic. -#![feature(const_type_id)] #![feature(const_type_name)] use std::any::{self, TypeId}; diff --git a/tests/ui/consts/issue-73976-polymorphic.stderr b/tests/ui/consts/issue-73976-polymorphic.stderr index ec9512a2616..41a5e804c67 100644 --- a/tests/ui/consts/issue-73976-polymorphic.stderr +++ b/tests/ui/consts/issue-73976-polymorphic.stderr @@ -1,5 +1,5 @@ error[E0158]: constant pattern cannot depend on generic parameters - --> $DIR/issue-73976-polymorphic.rs:20:37 + --> $DIR/issue-73976-polymorphic.rs:19:37 | LL | impl<T: 'static> GetTypeId<T> { | ----------------------------- @@ -12,7 +12,7 @@ LL | matches!(GetTypeId::<T>::VALUE, GetTypeId::<T>::VALUE) | ^^^^^^^^^^^^^^^^^^^^^ `const` depends on a generic parameter error[E0158]: constant pattern cannot depend on generic parameters - --> $DIR/issue-73976-polymorphic.rs:31:42 + --> $DIR/issue-73976-polymorphic.rs:30:42 | LL | impl<T: 'static> GetTypeNameLen<T> { | ---------------------------------- diff --git a/tests/ui/issues/issue-13763.rs b/tests/ui/consts/module-const-array-size-13763.rs index 67b9bdc5f03..b1c6879ffd2 100644 --- a/tests/ui/issues/issue-13763.rs +++ b/tests/ui/consts/module-const-array-size-13763.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13763 + //@ run-pass #![allow(dead_code)] diff --git a/tests/ui/consts/required-consts/collect-in-dead-drop.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-drop.noopt.stderr index 7c6219ccf93..38e169c9701 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-drop.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-drop.noopt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::<T>::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn <Fail<i32> as std::ops::Drop>::drop` +note: the above error was encountered while instantiating `fn <Fail<i32> as Drop>::drop` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/required-consts/collect-in-dead-drop.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-drop.opt.stderr index 7c6219ccf93..38e169c9701 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-drop.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-drop.opt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::<T>::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn <Fail<i32> as std::ops::Drop>::drop` +note: the above error was encountered while instantiating `fn <Fail<i32> as Drop>::drop` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr index a480a8c5a39..42a4ca2fd9d 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::<T>::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn m::not_called::<i32>` +note: the above error was encountered while instantiating `fn not_called::<i32>` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr index a480a8c5a39..42a4ca2fd9d 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::<T>::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn m::not_called::<i32>` +note: the above error was encountered while instantiating `fn not_called::<i32>` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/required-consts/collect-in-dead-move.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-move.noopt.stderr index 6c8edc00260..9f652e26f24 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-move.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-move.noopt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::<T>::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn <Fail<i32> as std::ops::Drop>::drop` +note: the above error was encountered while instantiating `fn <Fail<i32> as Drop>::drop` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/required-consts/collect-in-dead-move.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-move.opt.stderr index 6c8edc00260..9f652e26f24 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-move.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-move.opt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::<T>::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn <Fail<i32> as std::ops::Drop>::drop` +note: the above error was encountered while instantiating `fn <Fail<i32> as Drop>::drop` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/required-consts/collect-in-dead-vtable.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-vtable.noopt.stderr index 4e35beadbf4..0c12c0de197 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-vtable.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-vtable.noopt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::<T>::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn <std::vec::Vec<i32> as MyTrait>::not_called` +note: the above error was encountered while instantiating `fn <Vec<i32> as MyTrait>::not_called` --> $DIR/collect-in-dead-vtable.rs:31:40 | LL | let gen_vtable: &dyn MyTrait = &v; // vtable is "mentioned" here diff --git a/tests/ui/consts/required-consts/collect-in-dead-vtable.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-vtable.opt.stderr index 4e35beadbf4..0c12c0de197 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-vtable.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-vtable.opt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::<T>::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn <std::vec::Vec<i32> as MyTrait>::not_called` +note: the above error was encountered while instantiating `fn <Vec<i32> as MyTrait>::not_called` --> $DIR/collect-in-dead-vtable.rs:31:40 | LL | let gen_vtable: &dyn MyTrait = &v; // vtable is "mentioned" here diff --git a/tests/ui/coroutine/invalid_attr_usage.rs b/tests/ui/coroutine/invalid_attr_usage.rs index 995a3aa3100..5081c17de4b 100644 --- a/tests/ui/coroutine/invalid_attr_usage.rs +++ b/tests/ui/coroutine/invalid_attr_usage.rs @@ -3,9 +3,9 @@ #![feature(coroutines)] #[coroutine] -//~^ ERROR: attribute should be applied to closures +//~^ ERROR: attribute cannot be used on struct Foo; #[coroutine] -//~^ ERROR: attribute should be applied to closures +//~^ ERROR: attribute cannot be used on fn main() {} diff --git a/tests/ui/coroutine/invalid_attr_usage.stderr b/tests/ui/coroutine/invalid_attr_usage.stderr index 316a0117e5d..46fc80c1bad 100644 --- a/tests/ui/coroutine/invalid_attr_usage.stderr +++ b/tests/ui/coroutine/invalid_attr_usage.stderr @@ -1,14 +1,18 @@ -error: attribute should be applied to closures +error: `#[coroutine]` attribute cannot be used on structs --> $DIR/invalid_attr_usage.rs:5:1 | LL | #[coroutine] | ^^^^^^^^^^^^ + | + = help: `#[coroutine]` can only be applied to closures -error: attribute should be applied to closures +error: `#[coroutine]` attribute cannot be used on functions --> $DIR/invalid_attr_usage.rs:9:1 | LL | #[coroutine] | ^^^^^^^^^^^^ + | + = help: `#[coroutine]` can only be applied to closures error: aborting due to 2 previous errors diff --git a/tests/ui/coverage-attr/allowed-positions.rs b/tests/ui/coverage-attr/allowed-positions.rs index f1169fa6570..cfbc7f5e6c0 100644 --- a/tests/ui/coverage-attr/allowed-positions.rs +++ b/tests/ui/coverage-attr/allowed-positions.rs @@ -11,24 +11,24 @@ #[coverage(off)] mod submod {} -#[coverage(off)] //~ ERROR coverage attribute not allowed here [E0788] +#[coverage(off)] //~ ERROR attribute cannot be used on type MyTypeAlias = (); -#[coverage(off)] //~ ERROR [E0788] +#[coverage(off)] //~ ERROR attribute cannot be used on trait MyTrait { - #[coverage(off)] //~ ERROR [E0788] + #[coverage(off)] //~ ERROR attribute cannot be used on const TRAIT_ASSOC_CONST: u32; - #[coverage(off)] //~ ERROR [E0788] + #[coverage(off)] //~ ERROR attribute cannot be used on type TraitAssocType; - #[coverage(off)] //~ ERROR [E0788] + #[coverage(off)] //~ ERROR attribute cannot be used on fn trait_method(&self); #[coverage(off)] fn trait_method_with_default(&self) {} - #[coverage(off)] //~ ERROR [E0788] + #[coverage(off)] //~ ERROR attribute cannot be used on fn trait_assoc_fn(); } @@ -36,7 +36,7 @@ trait MyTrait { impl MyTrait for () { const TRAIT_ASSOC_CONST: u32 = 0; - #[coverage(off)] //~ ERROR [E0788] + #[coverage(off)] //~ ERROR attribute cannot be used on type TraitAssocType = Self; #[coverage(off)] @@ -53,14 +53,14 @@ trait HasAssocType { } impl HasAssocType for () { - #[coverage(off)] //~ ERROR [E0788] + #[coverage(off)] //~ ERROR attribute cannot be used on type T = impl Copy; fn constrain_assoc_type() -> Self::T {} } -#[coverage(off)] //~ ERROR [E0788] +#[coverage(off)] //~ ERROR attribute cannot be used on struct MyStruct { - #[coverage(off)] //~ ERROR [E0788] + #[coverage(off)] //~ ERROR attribute cannot be used on field: u32, } @@ -73,25 +73,25 @@ impl MyStruct { } extern "C" { - #[coverage(off)] //~ ERROR [E0788] + #[coverage(off)] //~ ERROR attribute cannot be used on static X: u32; - #[coverage(off)] //~ ERROR [E0788] + #[coverage(off)] //~ ERROR attribute cannot be used on type T; - #[coverage(off)] //~ ERROR [E0788] + #[coverage(off)] //~ ERROR attribute cannot be used on fn foreign_fn(); } #[coverage(off)] fn main() { - #[coverage(off)] //~ ERROR [E0788] + #[coverage(off)] //~ ERROR attribute cannot be used on let _ = (); // Currently not allowed on let statements, even if they bind to a closure. // It might be nice to support this as a special case someday, but trying // to define the precise boundaries of that special case might be tricky. - #[coverage(off)] //~ ERROR [E0788] + #[coverage(off)] //~ ERROR attribute cannot be used on let _let_closure = || (); // In situations where attributes can already be applied to expressions, @@ -107,10 +107,10 @@ fn main() { //~^ ERROR attributes on expressions are experimental [E0658] match () { - #[coverage(off)] //~ ERROR [E0788] + #[coverage(off)] //~ ERROR attribute cannot be used on () => (), } - #[coverage(off)] //~ ERROR [E0788] + #[coverage(off)] //~ ERROR attribute cannot be used on return (); } diff --git a/tests/ui/coverage-attr/allowed-positions.stderr b/tests/ui/coverage-attr/allowed-positions.stderr index 34562a4da1b..aaef3ad0203 100644 --- a/tests/ui/coverage-attr/allowed-positions.stderr +++ b/tests/ui/coverage-attr/allowed-positions.stderr @@ -8,185 +8,142 @@ LL | let _closure_expr = #[coverage(off)] || (); = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0788]: coverage attribute not allowed here +error: `#[coverage]` attribute cannot be used on type aliases --> $DIR/allowed-positions.rs:14:1 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ -LL | type MyTypeAlias = (); - | ---------------------- not a function, impl block, or module | - = help: coverage attribute can be applied to a function (with body), impl block, or module + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates -error[E0788]: coverage attribute not allowed here +error: `#[coverage]` attribute cannot be used on traits --> $DIR/allowed-positions.rs:17:1 | -LL | #[coverage(off)] - | ^^^^^^^^^^^^^^^^ -LL | / trait MyTrait { -LL | | #[coverage(off)] -LL | | const TRAIT_ASSOC_CONST: u32; -... | -LL | | fn trait_assoc_fn(); -LL | | } - | |_- not a function, impl block, or module +LL | #[coverage(off)] + | ^^^^^^^^^^^^^^^^ | - = help: coverage attribute can be applied to a function (with body), impl block, or module + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates -error[E0788]: coverage attribute not allowed here - --> $DIR/allowed-positions.rs:61:1 +error: `#[coverage]` attribute cannot be used on associated consts + --> $DIR/allowed-positions.rs:19:5 | -LL | #[coverage(off)] - | ^^^^^^^^^^^^^^^^ -LL | / struct MyStruct { -LL | | #[coverage(off)] -LL | | field: u32, -LL | | } - | |_- not a function, impl block, or module +LL | #[coverage(off)] + | ^^^^^^^^^^^^^^^^ | - = help: coverage attribute can be applied to a function (with body), impl block, or module + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates -error[E0788]: coverage attribute not allowed here - --> $DIR/allowed-positions.rs:63:5 +error: `#[coverage]` attribute cannot be used on associated types + --> $DIR/allowed-positions.rs:22:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ -LL | field: u32, - | ---------- not a function, impl block, or module | - = help: coverage attribute can be applied to a function (with body), impl block, or module + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates -error[E0788]: coverage attribute not allowed here - --> $DIR/allowed-positions.rs:88:5 +error: `#[coverage]` attribute cannot be used on required trait methods + --> $DIR/allowed-positions.rs:25:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ -LL | let _ = (); - | ----------- not a function, impl block, or module | - = help: coverage attribute can be applied to a function (with body), impl block, or module + = help: `#[coverage]` can be applied to impl blocks, functions, closures, provided trait methods, trait methods in impl blocks, inherent methods, modules, crates -error[E0788]: coverage attribute not allowed here - --> $DIR/allowed-positions.rs:94:5 +error: `#[coverage]` attribute cannot be used on required trait methods + --> $DIR/allowed-positions.rs:31:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ -LL | let _let_closure = || (); - | ------------------------- not a function, impl block, or module | - = help: coverage attribute can be applied to a function (with body), impl block, or module + = help: `#[coverage]` can be applied to impl blocks, functions, closures, provided trait methods, trait methods in impl blocks, inherent methods, modules, crates -error[E0788]: coverage attribute not allowed here - --> $DIR/allowed-positions.rs:110:9 +error: `#[coverage]` attribute cannot be used on associated types + --> $DIR/allowed-positions.rs:39:5 | -LL | #[coverage(off)] - | ^^^^^^^^^^^^^^^^ -LL | () => (), - | -------- not a function, impl block, or module +LL | #[coverage(off)] + | ^^^^^^^^^^^^^^^^ | - = help: coverage attribute can be applied to a function (with body), impl block, or module + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates -error[E0788]: coverage attribute not allowed here - --> $DIR/allowed-positions.rs:114:5 +error: `#[coverage]` attribute cannot be used on associated types + --> $DIR/allowed-positions.rs:56:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ -LL | return (); - | --------- not a function, impl block, or module | - = help: coverage attribute can be applied to a function (with body), impl block, or module + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates -error[E0788]: coverage attribute not allowed here - --> $DIR/allowed-positions.rs:19:5 +error: `#[coverage]` attribute cannot be used on structs + --> $DIR/allowed-positions.rs:61:1 | -LL | #[coverage(off)] - | ^^^^^^^^^^^^^^^^ -LL | const TRAIT_ASSOC_CONST: u32; - | ----------------------------- not a function, impl block, or module +LL | #[coverage(off)] + | ^^^^^^^^^^^^^^^^ | - = help: coverage attribute can be applied to a function (with body), impl block, or module + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates -error[E0788]: coverage attribute not allowed here - --> $DIR/allowed-positions.rs:22:5 +error: `#[coverage]` attribute cannot be used on struct fields + --> $DIR/allowed-positions.rs:63:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ -LL | type TraitAssocType; - | -------------------- not a function, impl block, or module | - = help: coverage attribute can be applied to a function (with body), impl block, or module + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates -error[E0788]: coverage attribute not allowed here - --> $DIR/allowed-positions.rs:25:5 +error: `#[coverage]` attribute cannot be used on foreign statics + --> $DIR/allowed-positions.rs:76:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ -LL | fn trait_method(&self); - | ----------------------- function has no body | - = help: coverage attribute can be applied to a function (with body), impl block, or module + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates -error[E0788]: coverage attribute not allowed here - --> $DIR/allowed-positions.rs:31:5 +error: `#[coverage]` attribute cannot be used on foreign types + --> $DIR/allowed-positions.rs:79:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ -LL | fn trait_assoc_fn(); - | -------------------- function has no body | - = help: coverage attribute can be applied to a function (with body), impl block, or module + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates -error[E0788]: coverage attribute not allowed here - --> $DIR/allowed-positions.rs:39:5 +error: `#[coverage]` attribute cannot be used on foreign functions + --> $DIR/allowed-positions.rs:82:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ -LL | type TraitAssocType = Self; - | --------------------------- not a function, impl block, or module | - = help: coverage attribute can be applied to a function (with body), impl block, or module + = help: `#[coverage]` can be applied to methods, impl blocks, functions, closures, modules, crates -error[E0788]: coverage attribute not allowed here - --> $DIR/allowed-positions.rs:56:5 +error: `#[coverage]` attribute cannot be used on statements + --> $DIR/allowed-positions.rs:88:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ -LL | type T = impl Copy; - | ------------------- not a function, impl block, or module | - = help: coverage attribute can be applied to a function (with body), impl block, or module + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates -error[E0788]: coverage attribute not allowed here - --> $DIR/allowed-positions.rs:76:5 +error: `#[coverage]` attribute cannot be used on statements + --> $DIR/allowed-positions.rs:94:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ -LL | static X: u32; - | -------------- not a function, impl block, or module | - = help: coverage attribute can be applied to a function (with body), impl block, or module + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates -error[E0788]: coverage attribute not allowed here - --> $DIR/allowed-positions.rs:79:5 +error: `#[coverage]` attribute cannot be used on match arms + --> $DIR/allowed-positions.rs:110:9 | -LL | #[coverage(off)] - | ^^^^^^^^^^^^^^^^ -LL | type T; - | ------- not a function, impl block, or module +LL | #[coverage(off)] + | ^^^^^^^^^^^^^^^^ | - = help: coverage attribute can be applied to a function (with body), impl block, or module + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates -error[E0788]: coverage attribute not allowed here - --> $DIR/allowed-positions.rs:82:5 +error: `#[coverage]` attribute cannot be used on expressions + --> $DIR/allowed-positions.rs:114:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ -LL | fn foreign_fn(); - | ---------------- function has no body | - = help: coverage attribute can be applied to a function (with body), impl block, or module + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates error: aborting due to 18 previous errors -Some errors have detailed explanations: E0658, E0788. -For more information about an error, try `rustc --explain E0658`. +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/coverage-attr/name-value.rs b/tests/ui/coverage-attr/name-value.rs index 8171dbbf692..6e81ab89616 100644 --- a/tests/ui/coverage-attr/name-value.rs +++ b/tests/ui/coverage-attr/name-value.rs @@ -20,6 +20,7 @@ mod my_mod_inner { #[coverage = "off"] //~^ ERROR malformed `coverage` attribute input +//~| ERROR attribute cannot be used on struct MyStruct; #[coverage = "off"] @@ -27,18 +28,22 @@ struct MyStruct; impl MyStruct { #[coverage = "off"] //~^ ERROR malformed `coverage` attribute input + //~| ERROR attribute cannot be used on const X: u32 = 7; } #[coverage = "off"] //~^ ERROR malformed `coverage` attribute input +//~| ERROR attribute cannot be used on trait MyTrait { #[coverage = "off"] //~^ ERROR malformed `coverage` attribute input + //~| ERROR attribute cannot be used on const X: u32; #[coverage = "off"] //~^ ERROR malformed `coverage` attribute input + //~| ERROR attribute cannot be used on type T; } @@ -47,10 +52,12 @@ trait MyTrait { impl MyTrait for MyStruct { #[coverage = "off"] //~^ ERROR malformed `coverage` attribute input + //~| ERROR attribute cannot be used on const X: u32 = 8; #[coverage = "off"] //~^ ERROR malformed `coverage` attribute input + //~| ERROR attribute cannot be used on type T = (); } diff --git a/tests/ui/coverage-attr/name-value.stderr b/tests/ui/coverage-attr/name-value.stderr index a838ec5df8e..2dac2401e3c 100644 --- a/tests/ui/coverage-attr/name-value.stderr +++ b/tests/ui/coverage-attr/name-value.stderr @@ -43,8 +43,16 @@ LL - #[coverage = "off"] LL + #[coverage(on)] | +error: `#[coverage]` attribute cannot be used on structs + --> $DIR/name-value.rs:21:1 + | +LL | #[coverage = "off"] + | ^^^^^^^^^^^^^^^^^^^ + | + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates + error[E0539]: malformed `coverage` attribute input - --> $DIR/name-value.rs:25:1 + --> $DIR/name-value.rs:26:1 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument @@ -59,7 +67,7 @@ LL + #[coverage(on)] | error[E0539]: malformed `coverage` attribute input - --> $DIR/name-value.rs:28:5 + --> $DIR/name-value.rs:29:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument @@ -73,8 +81,16 @@ LL - #[coverage = "off"] LL + #[coverage(on)] | +error: `#[coverage]` attribute cannot be used on associated consts + --> $DIR/name-value.rs:29:5 + | +LL | #[coverage = "off"] + | ^^^^^^^^^^^^^^^^^^^ + | + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates + error[E0539]: malformed `coverage` attribute input - --> $DIR/name-value.rs:33:1 + --> $DIR/name-value.rs:35:1 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument @@ -88,8 +104,16 @@ LL - #[coverage = "off"] LL + #[coverage(on)] | +error: `#[coverage]` attribute cannot be used on traits + --> $DIR/name-value.rs:35:1 + | +LL | #[coverage = "off"] + | ^^^^^^^^^^^^^^^^^^^ + | + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates + error[E0539]: malformed `coverage` attribute input - --> $DIR/name-value.rs:36:5 + --> $DIR/name-value.rs:39:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument @@ -103,8 +127,16 @@ LL - #[coverage = "off"] LL + #[coverage(on)] | +error: `#[coverage]` attribute cannot be used on associated consts + --> $DIR/name-value.rs:39:5 + | +LL | #[coverage = "off"] + | ^^^^^^^^^^^^^^^^^^^ + | + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates + error[E0539]: malformed `coverage` attribute input - --> $DIR/name-value.rs:40:5 + --> $DIR/name-value.rs:44:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument @@ -118,8 +150,16 @@ LL - #[coverage = "off"] LL + #[coverage(on)] | +error: `#[coverage]` attribute cannot be used on associated types + --> $DIR/name-value.rs:44:5 + | +LL | #[coverage = "off"] + | ^^^^^^^^^^^^^^^^^^^ + | + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates + error[E0539]: malformed `coverage` attribute input - --> $DIR/name-value.rs:45:1 + --> $DIR/name-value.rs:50:1 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument @@ -134,7 +174,7 @@ LL + #[coverage(on)] | error[E0539]: malformed `coverage` attribute input - --> $DIR/name-value.rs:48:5 + --> $DIR/name-value.rs:53:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument @@ -148,8 +188,16 @@ LL - #[coverage = "off"] LL + #[coverage(on)] | +error: `#[coverage]` attribute cannot be used on associated consts + --> $DIR/name-value.rs:53:5 + | +LL | #[coverage = "off"] + | ^^^^^^^^^^^^^^^^^^^ + | + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates + error[E0539]: malformed `coverage` attribute input - --> $DIR/name-value.rs:52:5 + --> $DIR/name-value.rs:58:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument @@ -163,8 +211,16 @@ LL - #[coverage = "off"] LL + #[coverage(on)] | +error: `#[coverage]` attribute cannot be used on associated types + --> $DIR/name-value.rs:58:5 + | +LL | #[coverage = "off"] + | ^^^^^^^^^^^^^^^^^^^ + | + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates + error[E0539]: malformed `coverage` attribute input - --> $DIR/name-value.rs:57:1 + --> $DIR/name-value.rs:64:1 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument @@ -178,6 +234,6 @@ LL - #[coverage = "off"] LL + #[coverage(on)] | -error: aborting due to 12 previous errors +error: aborting due to 19 previous errors For more information about this error, try `rustc --explain E0539`. diff --git a/tests/ui/coverage-attr/word-only.rs b/tests/ui/coverage-attr/word-only.rs index 81bd558b8b0..e47279f74ca 100644 --- a/tests/ui/coverage-attr/word-only.rs +++ b/tests/ui/coverage-attr/word-only.rs @@ -20,6 +20,7 @@ mod my_mod_inner { #[coverage] //~^ ERROR malformed `coverage` attribute input +//~| ERROR attribute cannot be used on struct MyStruct; #[coverage] @@ -27,18 +28,22 @@ struct MyStruct; impl MyStruct { #[coverage] //~^ ERROR malformed `coverage` attribute input + //~| ERROR attribute cannot be used on const X: u32 = 7; } #[coverage] //~^ ERROR malformed `coverage` attribute input +//~| ERROR attribute cannot be used on trait MyTrait { #[coverage] //~^ ERROR malformed `coverage` attribute input + //~| ERROR attribute cannot be used on const X: u32; #[coverage] //~^ ERROR malformed `coverage` attribute input + //~| ERROR attribute cannot be used on type T; } @@ -47,10 +52,12 @@ trait MyTrait { impl MyTrait for MyStruct { #[coverage] //~^ ERROR malformed `coverage` attribute input + //~| ERROR attribute cannot be used on const X: u32 = 8; #[coverage] //~^ ERROR malformed `coverage` attribute input + //~| ERROR attribute cannot be used on type T = (); } diff --git a/tests/ui/coverage-attr/word-only.stderr b/tests/ui/coverage-attr/word-only.stderr index dd161360a5c..e916a817e36 100644 --- a/tests/ui/coverage-attr/word-only.stderr +++ b/tests/ui/coverage-attr/word-only.stderr @@ -39,8 +39,16 @@ LL | #[coverage(off)] LL | #[coverage(on)] | ++++ +error: `#[coverage]` attribute cannot be used on structs + --> $DIR/word-only.rs:21:1 + | +LL | #[coverage] + | ^^^^^^^^^^^ + | + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates + error[E0539]: malformed `coverage` attribute input - --> $DIR/word-only.rs:25:1 + --> $DIR/word-only.rs:26:1 | LL | #[coverage] | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument @@ -53,7 +61,7 @@ LL | #[coverage(on)] | ++++ error[E0539]: malformed `coverage` attribute input - --> $DIR/word-only.rs:28:5 + --> $DIR/word-only.rs:29:5 | LL | #[coverage] | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument @@ -65,8 +73,16 @@ LL | #[coverage(off)] LL | #[coverage(on)] | ++++ +error: `#[coverage]` attribute cannot be used on associated consts + --> $DIR/word-only.rs:29:5 + | +LL | #[coverage] + | ^^^^^^^^^^^ + | + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates + error[E0539]: malformed `coverage` attribute input - --> $DIR/word-only.rs:33:1 + --> $DIR/word-only.rs:35:1 | LL | #[coverage] | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument @@ -78,8 +94,16 @@ LL | #[coverage(off)] LL | #[coverage(on)] | ++++ +error: `#[coverage]` attribute cannot be used on traits + --> $DIR/word-only.rs:35:1 + | +LL | #[coverage] + | ^^^^^^^^^^^ + | + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates + error[E0539]: malformed `coverage` attribute input - --> $DIR/word-only.rs:36:5 + --> $DIR/word-only.rs:39:5 | LL | #[coverage] | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument @@ -91,8 +115,16 @@ LL | #[coverage(off)] LL | #[coverage(on)] | ++++ +error: `#[coverage]` attribute cannot be used on associated consts + --> $DIR/word-only.rs:39:5 + | +LL | #[coverage] + | ^^^^^^^^^^^ + | + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates + error[E0539]: malformed `coverage` attribute input - --> $DIR/word-only.rs:40:5 + --> $DIR/word-only.rs:44:5 | LL | #[coverage] | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument @@ -104,8 +136,16 @@ LL | #[coverage(off)] LL | #[coverage(on)] | ++++ +error: `#[coverage]` attribute cannot be used on associated types + --> $DIR/word-only.rs:44:5 + | +LL | #[coverage] + | ^^^^^^^^^^^ + | + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates + error[E0539]: malformed `coverage` attribute input - --> $DIR/word-only.rs:45:1 + --> $DIR/word-only.rs:50:1 | LL | #[coverage] | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument @@ -118,7 +158,7 @@ LL | #[coverage(on)] | ++++ error[E0539]: malformed `coverage` attribute input - --> $DIR/word-only.rs:48:5 + --> $DIR/word-only.rs:53:5 | LL | #[coverage] | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument @@ -130,8 +170,16 @@ LL | #[coverage(off)] LL | #[coverage(on)] | ++++ +error: `#[coverage]` attribute cannot be used on associated consts + --> $DIR/word-only.rs:53:5 + | +LL | #[coverage] + | ^^^^^^^^^^^ + | + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates + error[E0539]: malformed `coverage` attribute input - --> $DIR/word-only.rs:52:5 + --> $DIR/word-only.rs:58:5 | LL | #[coverage] | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument @@ -143,8 +191,16 @@ LL | #[coverage(off)] LL | #[coverage(on)] | ++++ +error: `#[coverage]` attribute cannot be used on associated types + --> $DIR/word-only.rs:58:5 + | +LL | #[coverage] + | ^^^^^^^^^^^ + | + = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates + error[E0539]: malformed `coverage` attribute input - --> $DIR/word-only.rs:57:1 + --> $DIR/word-only.rs:64:1 | LL | #[coverage] | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument @@ -156,6 +212,6 @@ LL | #[coverage(off)] LL | #[coverage(on)] | ++++ -error: aborting due to 12 previous errors +error: aborting due to 19 previous errors For more information about this error, try `rustc --explain E0539`. diff --git a/tests/ui/issues/auxiliary/issue-9155.rs b/tests/ui/cross-crate/auxiliary/aux-9155.rs index 049a96a655a..049a96a655a 100644 --- a/tests/ui/issues/auxiliary/issue-9155.rs +++ b/tests/ui/cross-crate/auxiliary/aux-9155.rs diff --git a/tests/ui/issues/auxiliary/issue-9906.rs b/tests/ui/cross-crate/auxiliary/aux-9906.rs index 8a3eea790a2..8a3eea790a2 100644 --- a/tests/ui/issues/auxiliary/issue-9906.rs +++ b/tests/ui/cross-crate/auxiliary/aux-9906.rs diff --git a/tests/ui/cross-crate/generic-newtypes-cross-crate-usage-9155.rs b/tests/ui/cross-crate/generic-newtypes-cross-crate-usage-9155.rs new file mode 100644 index 00000000000..35286615980 --- /dev/null +++ b/tests/ui/cross-crate/generic-newtypes-cross-crate-usage-9155.rs @@ -0,0 +1,11 @@ +// https://github.com/rust-lang/rust/issues/9155 +//@ run-pass +//@ aux-build:aux-9155.rs + +extern crate aux_9155; + +struct Baz; + +pub fn main() { + aux_9155::Foo::new(Baz); +} diff --git a/tests/ui/cross-crate/reexported-structs-impls-link-error-9906.rs b/tests/ui/cross-crate/reexported-structs-impls-link-error-9906.rs new file mode 100644 index 00000000000..b49951bd1f9 --- /dev/null +++ b/tests/ui/cross-crate/reexported-structs-impls-link-error-9906.rs @@ -0,0 +1,10 @@ +// https://github.com/rust-lang/rust/issues/9906 +//@ run-pass +//@ aux-build:aux-9906.rs + +extern crate aux_9906 as testmod; + +pub fn main() { + testmod::foo(); + testmod::FooBar::new(1); +} diff --git a/tests/ui/custom_test_frameworks/mismatch.stderr b/tests/ui/custom_test_frameworks/mismatch.stderr index c7798635fbf..7cdfaa9e804 100644 --- a/tests/ui/custom_test_frameworks/mismatch.stderr +++ b/tests/ui/custom_test_frameworks/mismatch.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `TestDescAndFn: Testable` is not satisfied --> $DIR/mismatch.rs:9:1 | LL | #[test] - | ------- in this procedural macro expansion + | ------- in this attribute macro expansion LL | fn wrong_kind(){} | ^^^^^^^^^^^^^^^^^ the trait `Testable` is not implemented for `TestDescAndFn` | diff --git a/tests/ui/delegation/correct_body_owner_parent_found_in_diagnostics.stderr b/tests/ui/delegation/correct_body_owner_parent_found_in_diagnostics.stderr index 61e2a8f64dd..b0bfc720658 100644 --- a/tests/ui/delegation/correct_body_owner_parent_found_in_diagnostics.stderr +++ b/tests/ui/delegation/correct_body_owner_parent_found_in_diagnostics.stderr @@ -43,7 +43,7 @@ help: consider introducing lifetime `'a` here LL | impl<'a> Trait for Z { | ++++ -error[E0599]: no function or associated item named `new` found for struct `InvariantRef` in the current scope +error[E0599]: no function or associated item named `new` found for struct `InvariantRef<'a, T>` in the current scope --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:9:41 | LL | pub struct InvariantRef<'a, T: ?Sized>(&'a T, PhantomData<&'a mut &'a T>); diff --git a/tests/ui/deprecation/deprecation-sanity.rs b/tests/ui/deprecation/deprecation-sanity.rs index 80198ab8196..9698a376025 100644 --- a/tests/ui/deprecation/deprecation-sanity.rs +++ b/tests/ui/deprecation/deprecation-sanity.rs @@ -1,3 +1,5 @@ +#![deny(unused_attributes)] + // Various checks that deprecation attributes are used correctly mod bogus_attribute_types_1 { @@ -32,7 +34,8 @@ fn f1() { } struct X; -#[deprecated = "hello"] //~ ERROR this `#[deprecated]` annotation has no effect +#[deprecated = "hello"] //~ ERROR attribute cannot be used on +//~| WARN previously accepted impl Default for X { fn default() -> Self { X diff --git a/tests/ui/deprecation/deprecation-sanity.stderr b/tests/ui/deprecation/deprecation-sanity.stderr index f1b4697485c..1d44215731d 100644 --- a/tests/ui/deprecation/deprecation-sanity.stderr +++ b/tests/ui/deprecation/deprecation-sanity.stderr @@ -1,11 +1,11 @@ error[E0541]: unknown meta item 'reason' - --> $DIR/deprecation-sanity.rs:4:43 + --> $DIR/deprecation-sanity.rs:6:43 | LL | #[deprecated(since = "a", note = "a", reason)] | ^^^^^^ expected one of `since`, `note` error[E0539]: malformed `deprecated` attribute input - --> $DIR/deprecation-sanity.rs:7:5 + --> $DIR/deprecation-sanity.rs:9:5 | LL | #[deprecated(since = "a", note)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^----^^ @@ -18,14 +18,18 @@ LL - #[deprecated(since = "a", note)] LL + #[deprecated = "reason"] | LL - #[deprecated(since = "a", note)] -LL + #[deprecated(/*opt*/ since = "version", /*opt*/ note = "reason")] +LL + #[deprecated(note = "reason")] | LL - #[deprecated(since = "a", note)] -LL + #[deprecated] +LL + #[deprecated(since = "version")] | +LL - #[deprecated(since = "a", note)] +LL + #[deprecated(since = "version", note = "reason")] + | + = and 1 other candidate error[E0539]: malformed `deprecated` attribute input - --> $DIR/deprecation-sanity.rs:10:5 + --> $DIR/deprecation-sanity.rs:12:5 | LL | #[deprecated(since, note = "a")] | ^^^^^^^^^^^^^-----^^^^^^^^^^^^^^ @@ -38,14 +42,18 @@ LL - #[deprecated(since, note = "a")] LL + #[deprecated = "reason"] | LL - #[deprecated(since, note = "a")] -LL + #[deprecated(/*opt*/ since = "version", /*opt*/ note = "reason")] +LL + #[deprecated(note = "reason")] + | +LL - #[deprecated(since, note = "a")] +LL + #[deprecated(since = "version")] | LL - #[deprecated(since, note = "a")] -LL + #[deprecated] +LL + #[deprecated(since = "version", note = "reason")] | + = and 1 other candidate error[E0539]: malformed `deprecated` attribute input - --> $DIR/deprecation-sanity.rs:13:5 + --> $DIR/deprecation-sanity.rs:15:5 | LL | #[deprecated(since = "a", note(b))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^-------^^ @@ -58,14 +66,18 @@ LL - #[deprecated(since = "a", note(b))] LL + #[deprecated = "reason"] | LL - #[deprecated(since = "a", note(b))] -LL + #[deprecated(/*opt*/ since = "version", /*opt*/ note = "reason")] +LL + #[deprecated(note = "reason")] + | +LL - #[deprecated(since = "a", note(b))] +LL + #[deprecated(since = "version")] | LL - #[deprecated(since = "a", note(b))] -LL + #[deprecated] +LL + #[deprecated(since = "version", note = "reason")] | + = and 1 other candidate error[E0539]: malformed `deprecated` attribute input - --> $DIR/deprecation-sanity.rs:16:5 + --> $DIR/deprecation-sanity.rs:18:5 | LL | #[deprecated(since(b), note = "a")] | ^^^^^^^^^^^^^--------^^^^^^^^^^^^^^ @@ -78,14 +90,18 @@ LL - #[deprecated(since(b), note = "a")] LL + #[deprecated = "reason"] | LL - #[deprecated(since(b), note = "a")] -LL + #[deprecated(/*opt*/ since = "version", /*opt*/ note = "reason")] +LL + #[deprecated(note = "reason")] | LL - #[deprecated(since(b), note = "a")] -LL + #[deprecated] +LL + #[deprecated(since = "version")] | +LL - #[deprecated(since(b), note = "a")] +LL + #[deprecated(since = "version", note = "reason")] + | + = and 1 other candidate error[E0539]: malformed `deprecated` attribute input - --> $DIR/deprecation-sanity.rs:19:5 + --> $DIR/deprecation-sanity.rs:21:5 | LL | #[deprecated(note = b"test")] | ^^^^^^^^^^^^^^^^^^^^-^^^^^^^^ @@ -95,7 +111,7 @@ LL | #[deprecated(note = b"test")] = note: expected a normal string literal, not a byte string literal error[E0565]: malformed `deprecated` attribute input - --> $DIR/deprecation-sanity.rs:22:5 + --> $DIR/deprecation-sanity.rs:24:5 | LL | #[deprecated("test")] | ^^^^^^^^^^^^^------^^ @@ -108,26 +124,30 @@ LL - #[deprecated("test")] LL + #[deprecated = "reason"] | LL - #[deprecated("test")] -LL + #[deprecated(/*opt*/ since = "version", /*opt*/ note = "reason")] +LL + #[deprecated(note = "reason")] + | +LL - #[deprecated("test")] +LL + #[deprecated(since = "version")] | LL - #[deprecated("test")] -LL + #[deprecated] +LL + #[deprecated(since = "version", note = "reason")] | + = and 1 other candidate error: multiple `deprecated` attributes - --> $DIR/deprecation-sanity.rs:27:1 + --> $DIR/deprecation-sanity.rs:29:1 | LL | #[deprecated(since = "a", note = "b")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute | note: attribute also specified here - --> $DIR/deprecation-sanity.rs:26:1 + --> $DIR/deprecation-sanity.rs:28:1 | LL | #[deprecated(since = "a", note = "b")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0538]: malformed `deprecated` attribute input - --> $DIR/deprecation-sanity.rs:30:1 + --> $DIR/deprecation-sanity.rs:32:1 | LL | #[deprecated(since = "a", since = "b", note = "c")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^-----------^^^^^^^^^^^^^^ @@ -140,18 +160,24 @@ LL - #[deprecated(since = "a", since = "b", note = "c")] LL + #[deprecated = "reason"] | LL - #[deprecated(since = "a", since = "b", note = "c")] -LL + #[deprecated(/*opt*/ since = "version", /*opt*/ note = "reason")] +LL + #[deprecated(note = "reason")] + | +LL - #[deprecated(since = "a", since = "b", note = "c")] +LL + #[deprecated(since = "version")] | LL - #[deprecated(since = "a", since = "b", note = "c")] -LL + #[deprecated] +LL + #[deprecated(since = "version", note = "reason")] | + = and 1 other candidate -error: this `#[deprecated]` annotation has no effect - --> $DIR/deprecation-sanity.rs:35:1 +error: `#[deprecated]` attribute cannot be used on trait impl blocks + --> $DIR/deprecation-sanity.rs:37:1 | LL | #[deprecated = "hello"] - | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove the unnecessary deprecation attribute + | ^^^^^^^^^^^^^^^^^^^^^^^ | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[deprecated]` can be applied to functions, data types, modules, unions, constants, statics, macro defs, type aliases, use statements, struct fields, traits, associated types, associated consts, enum variants, inherent impl blocks, crates = note: `#[deny(useless_deprecated)]` on by default error: aborting due to 10 previous errors diff --git a/tests/ui/issues/issue-22992.rs b/tests/ui/deref/dereferenceable-type-behavior-22992.rs index 3bc15cc948a..19fc2e7eb0b 100644 --- a/tests/ui/issues/issue-22992.rs +++ b/tests/ui/deref/dereferenceable-type-behavior-22992.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/22992 //@ run-pass struct X { val: i32 } @@ -6,7 +7,6 @@ impl std::ops::Deref for X { fn deref(&self) -> &i32 { &self.val } } - trait M { fn m(self); } impl M for i32 { fn m(self) { println!("i32::m()"); } } impl M for X { fn m(self) { println!("X::m()"); } } diff --git a/tests/ui/issues/issue-15523-big.rs b/tests/ui/derives/derive-partial-ord-discriminant-64bit.rs index 7214a4fb1d5..5b6bf6fbf1f 100644 --- a/tests/ui/issues/issue-15523-big.rs +++ b/tests/ui/derives/derive-partial-ord-discriminant-64bit.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15523 + //@ run-pass // Issue 15523: derive(PartialOrd) should use the provided // discriminant values for the derived ordering. @@ -28,7 +30,6 @@ fn main() { assert!(Eu64::Pos2 < Eu64::PosMax); assert!(Eu64::Pos1 < Eu64::PosMax); - assert!(Ei64::Pos2 > Ei64::Pos1); assert!(Ei64::Pos2 > Ei64::Neg1); assert!(Ei64::Pos1 > Ei64::Neg1); diff --git a/tests/ui/issues/issue-15523.rs b/tests/ui/derives/derive-partial-ord-discriminant.rs index 9fc2e51c6ab..28f325ec966 100644 --- a/tests/ui/issues/issue-15523.rs +++ b/tests/ui/derives/derive-partial-ord-discriminant.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15523 + //@ run-pass // Issue 15523: derive(PartialOrd) should use the provided // discriminant values for the derived ordering. diff --git a/tests/ui/diagnostic-width/long-E0609.stderr b/tests/ui/diagnostic-width/long-E0609.stderr index 36ef8545746..70092ea34bc 100644 --- a/tests/ui/diagnostic-width/long-E0609.stderr +++ b/tests/ui/diagnostic-width/long-E0609.stderr @@ -4,6 +4,7 @@ error[E0609]: no field `field` on type `(..., ..., ..., ...)` LL | x.field; | ^^^^^ unknown field | + = note: available fields are: `0`, `1`, `2`, `3` = note: the full name for the type has been written to '$TEST_BUILD_DIR/long-E0609.long-type-$LONG_TYPE_HASH.txt' = note: consider using `--verbose` to print the full type name to the console diff --git a/tests/ui/dist/cranelift-x86_64-unknown-linux-gnu-dist.rs b/tests/ui/dist/cranelift-x86_64-unknown-linux-gnu-dist.rs new file mode 100644 index 00000000000..198f8d1bc10 --- /dev/null +++ b/tests/ui/dist/cranelift-x86_64-unknown-linux-gnu-dist.rs @@ -0,0 +1,11 @@ +// Ensure that Cranelift can be used to compile a simple program with `x86_64-unknown-linux-gnu` +// dist artifacts. + +//@ only-dist +//@ only-x86_64-unknown-linux-gnu +//@ compile-flags: -Z codegen-backend=cranelift +//@ run-pass + +fn main() { + println!("Hello world!"); +} diff --git a/tests/ui/drop/dropck-normalize-errors.stderr b/tests/ui/drop/dropck-normalize-errors.nll.stderr index 2bb5909c6b2..b008daa51a3 100644 --- a/tests/ui/drop/dropck-normalize-errors.stderr +++ b/tests/ui/drop/dropck-normalize-errors.nll.stderr @@ -1,44 +1,44 @@ error[E0277]: the trait bound `NonImplementedStruct: NonImplementedTrait` is not satisfied in `ADecoder<'a>` - --> $DIR/dropck-normalize-errors.rs:15:28 + --> $DIR/dropck-normalize-errors.rs:19:28 | LL | fn make_a_decoder<'a>() -> ADecoder<'a> { | ^^^^^^^^^^^^ within `ADecoder<'a>`, the trait `NonImplementedTrait` is not implemented for `NonImplementedStruct` | help: this trait has no implementations, consider adding one - --> $DIR/dropck-normalize-errors.rs:7:1 + --> $DIR/dropck-normalize-errors.rs:11:1 | LL | trait NonImplementedTrait { | ^^^^^^^^^^^^^^^^^^^^^^^^^ note: required because it appears within the type `BDecoder` - --> $DIR/dropck-normalize-errors.rs:26:12 + --> $DIR/dropck-normalize-errors.rs:30:12 | LL | pub struct BDecoder { | ^^^^^^^^ note: required because it appears within the type `ADecoder<'a>` - --> $DIR/dropck-normalize-errors.rs:12:12 + --> $DIR/dropck-normalize-errors.rs:16:12 | LL | pub struct ADecoder<'a> { | ^^^^^^^^ = note: the return type of a function must have a statically known size error[E0277]: the trait bound `NonImplementedStruct: NonImplementedTrait` is not satisfied in `BDecoder` - --> $DIR/dropck-normalize-errors.rs:23:20 + --> $DIR/dropck-normalize-errors.rs:27:20 | LL | type Decoder = BDecoder; | ^^^^^^^^ within `BDecoder`, the trait `NonImplementedTrait` is not implemented for `NonImplementedStruct` | help: this trait has no implementations, consider adding one - --> $DIR/dropck-normalize-errors.rs:7:1 + --> $DIR/dropck-normalize-errors.rs:11:1 | LL | trait NonImplementedTrait { | ^^^^^^^^^^^^^^^^^^^^^^^^^ note: required because it appears within the type `BDecoder` - --> $DIR/dropck-normalize-errors.rs:26:12 + --> $DIR/dropck-normalize-errors.rs:30:12 | LL | pub struct BDecoder { | ^^^^^^^^ note: required by a bound in `Decode::Decoder` - --> $DIR/dropck-normalize-errors.rs:4:5 + --> $DIR/dropck-normalize-errors.rs:8:5 | LL | type Decoder; | ^^^^^^^^^^^^^ required by this bound in `Decode::Decoder` @@ -48,25 +48,25 @@ LL | type Decoder: ?Sized; | ++++++++ error[E0277]: the trait bound `NonImplementedStruct: NonImplementedTrait` is not satisfied - --> $DIR/dropck-normalize-errors.rs:27:22 + --> $DIR/dropck-normalize-errors.rs:31:22 | LL | non_implemented: <NonImplementedStruct as NonImplementedTrait>::Assoc, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NonImplementedTrait` is not implemented for `NonImplementedStruct` | help: this trait has no implementations, consider adding one - --> $DIR/dropck-normalize-errors.rs:7:1 + --> $DIR/dropck-normalize-errors.rs:11:1 | LL | trait NonImplementedTrait { | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `NonImplementedStruct: NonImplementedTrait` is not satisfied - --> $DIR/dropck-normalize-errors.rs:15:28 + --> $DIR/dropck-normalize-errors.rs:19:28 | LL | fn make_a_decoder<'a>() -> ADecoder<'a> { | ^^^^^^^^^^^^ the trait `NonImplementedTrait` is not implemented for `NonImplementedStruct` | help: this trait has no implementations, consider adding one - --> $DIR/dropck-normalize-errors.rs:7:1 + --> $DIR/dropck-normalize-errors.rs:11:1 | LL | trait NonImplementedTrait { | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/drop/dropck-normalize-errors.polonius.stderr b/tests/ui/drop/dropck-normalize-errors.polonius.stderr new file mode 100644 index 00000000000..f8674b8e34a --- /dev/null +++ b/tests/ui/drop/dropck-normalize-errors.polonius.stderr @@ -0,0 +1,64 @@ +error[E0277]: the trait bound `NonImplementedStruct: NonImplementedTrait` is not satisfied in `ADecoder<'a>` + --> $DIR/dropck-normalize-errors.rs:19:28 + | +LL | fn make_a_decoder<'a>() -> ADecoder<'a> { + | ^^^^^^^^^^^^ within `ADecoder<'a>`, the trait `NonImplementedTrait` is not implemented for `NonImplementedStruct` + | +help: this trait has no implementations, consider adding one + --> $DIR/dropck-normalize-errors.rs:11:1 + | +LL | trait NonImplementedTrait { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +note: required because it appears within the type `BDecoder` + --> $DIR/dropck-normalize-errors.rs:30:12 + | +LL | pub struct BDecoder { + | ^^^^^^^^ +note: required because it appears within the type `ADecoder<'a>` + --> $DIR/dropck-normalize-errors.rs:16:12 + | +LL | pub struct ADecoder<'a> { + | ^^^^^^^^ + = note: the return type of a function must have a statically known size + +error[E0277]: the trait bound `NonImplementedStruct: NonImplementedTrait` is not satisfied in `BDecoder` + --> $DIR/dropck-normalize-errors.rs:27:20 + | +LL | type Decoder = BDecoder; + | ^^^^^^^^ within `BDecoder`, the trait `NonImplementedTrait` is not implemented for `NonImplementedStruct` + | +help: this trait has no implementations, consider adding one + --> $DIR/dropck-normalize-errors.rs:11:1 + | +LL | trait NonImplementedTrait { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +note: required because it appears within the type `BDecoder` + --> $DIR/dropck-normalize-errors.rs:30:12 + | +LL | pub struct BDecoder { + | ^^^^^^^^ +note: required by a bound in `Decode::Decoder` + --> $DIR/dropck-normalize-errors.rs:8:5 + | +LL | type Decoder; + | ^^^^^^^^^^^^^ required by this bound in `Decode::Decoder` +help: consider relaxing the implicit `Sized` restriction + | +LL | type Decoder: ?Sized; + | ++++++++ + +error[E0277]: the trait bound `NonImplementedStruct: NonImplementedTrait` is not satisfied + --> $DIR/dropck-normalize-errors.rs:31:22 + | +LL | non_implemented: <NonImplementedStruct as NonImplementedTrait>::Assoc, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NonImplementedTrait` is not implemented for `NonImplementedStruct` + | +help: this trait has no implementations, consider adding one + --> $DIR/dropck-normalize-errors.rs:11:1 + | +LL | trait NonImplementedTrait { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/drop/dropck-normalize-errors.rs b/tests/ui/drop/dropck-normalize-errors.rs index 793122bd33d..2ade63f27c5 100644 --- a/tests/ui/drop/dropck-normalize-errors.rs +++ b/tests/ui/drop/dropck-normalize-errors.rs @@ -1,5 +1,9 @@ // Test that we don't ICE when computing the drop types for +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: nll polonius +//@ [polonius] compile-flags: -Zpolonius=next + trait Decode<'a> { type Decoder; } @@ -14,7 +18,7 @@ pub struct ADecoder<'a> { } fn make_a_decoder<'a>() -> ADecoder<'a> { //~^ ERROR the trait bound - //~| ERROR the trait bound + //[nll]~| ERROR the trait bound panic!() } diff --git a/tests/ui/issues/issue-15063.rs b/tests/ui/drop/enum-drop-impl-15063.rs index 969dbe5fad2..a8198abafa0 100644 --- a/tests/ui/issues/issue-15063.rs +++ b/tests/ui/drop/enum-drop-impl-15063.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15063 + //@ run-pass #![allow(dead_code)] #![allow(unused_variables)] diff --git a/tests/ui/issues/issue-15858.rs b/tests/ui/drop/generic-drop-trait-bound-15858.rs index 27887d49e3e..682604d17d8 100644 --- a/tests/ui/issues/issue-15858.rs +++ b/tests/ui/drop/generic-drop-trait-bound-15858.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15858 + //@ run-pass // FIXME(static_mut_refs): this could use an atomic #![allow(static_mut_refs)] diff --git a/tests/ui/issues/issue-15858.stderr b/tests/ui/drop/generic-drop-trait-bound-15858.stderr index 0c082cc0862..86cd6cb6026 100644 --- a/tests/ui/issues/issue-15858.stderr +++ b/tests/ui/drop/generic-drop-trait-bound-15858.stderr @@ -1,5 +1,5 @@ warning: method `do_something` is never used - --> $DIR/issue-15858.rs:7:8 + --> $DIR/generic-drop-trait-bound-15858.rs:9:8 | LL | trait Bar { | --- method in this trait diff --git a/tests/ui/drop/if-let-guards.rs b/tests/ui/drop/if-let-guards.rs new file mode 100644 index 00000000000..bd353112c09 --- /dev/null +++ b/tests/ui/drop/if-let-guards.rs @@ -0,0 +1,88 @@ +//! Tests drop order for `if let` guard bindings and temporaries. This is for behavior specific to +//! `match` expressions, whereas `tests/ui/drop/drop-order-comparisons.rs` compares `let` chains in +//! guards to `let` chains in `if` expressions. Drop order for `let` chains in guards shouldn't +//! differ between Editions, so we test on both 2021 and 2024, expecting the same results. +//@ revisions: e2021 e2024 +//@ [e2021] edition: 2021 +//@ [e2024] edition: 2024 +//@ run-pass + +#![feature(if_let_guard)] +#![deny(rust_2024_compatibility)] + +use core::{cell::RefCell, ops::Drop}; + +fn main() { + // Test that `let` guard bindings and temps are dropped before the arm's pattern's bindings. + assert_drop_order(1..=6, |o| { + // We move out of the scrutinee, so the drop order of the array's elements are based on + // binding declaration order, and they're dropped in the arm's scope. + match [o.log(6), o.log(5)] { + // Partially move from the guard temporary to test drops both for temps and the binding. + [_x, _y] if let [_, _z, _] = [o.log(4), o.log(2), o.log(3)] + && true => { let _a = o.log(1); } + _ => unreachable!(), + } + }); + + // Sanity check: we don't move out of the match scrutinee when the guard fails. + assert_drop_order(1..=4, |o| { + // The scrutinee uses the drop order for arrays since its elements aren't moved. + match [o.log(3), o.log(4)] { + [_x, _y] if let _z = o.log(1) + && false => unreachable!(), + _ => { let _a = o.log(2); } + } + }); + + // Test `let` guards' temporaries are dropped immediately when a guard fails, even if the guard + // is lowered and run multiple times on the same arm due to or-patterns. + assert_drop_order(1..=8, |o| { + let mut _x = 1; + // The match's scrutinee isn't bound by-move, so it outlives the match. + match o.log(8) { + // Failing a guard breaks out of the arm's scope, dropping the `let` guard's scrutinee. + _ | _ | _ if let _ = o.log(_x) + && { _x += 1; false } => unreachable!(), + // The temporaries from a failed guard are dropped before testing the next guard. + _ if let _ = o.log(5) + && { o.push(4); false } => unreachable!(), + // If the guard succeeds, we stay in the arm's scope to execute its body. + _ if let _ = o.log(7) + && true => { o.log(6); } + _ => unreachable!(), + } + }); +} + +// # Test scaffolding... + +struct DropOrder(RefCell<Vec<u64>>); +struct LogDrop<'o>(&'o DropOrder, u64); + +impl DropOrder { + fn log(&self, n: u64) -> LogDrop<'_> { + LogDrop(self, n) + } + fn push(&self, n: u64) { + self.0.borrow_mut().push(n); + } +} + +impl<'o> Drop for LogDrop<'o> { + fn drop(&mut self) { + self.0.push(self.1); + } +} + +#[track_caller] +fn assert_drop_order( + ex: impl IntoIterator<Item = u64>, + f: impl Fn(&DropOrder), +) { + let order = DropOrder(RefCell::new(Vec::new())); + f(&order); + let order = order.0.into_inner(); + let expected: Vec<u64> = ex.into_iter().collect(); + assert_eq!(order, expected); +} diff --git a/tests/ui/issues/issue-25549-multiple-drop.rs b/tests/ui/drop/multiple-drop-safe-code-25549.rs index 1eec15a4aa2..dcf7a3fc79c 100644 --- a/tests/ui/issues/issue-25549-multiple-drop.rs +++ b/tests/ui/drop/multiple-drop-safe-code-25549.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/25549 //@ run-pass #![allow(unused_variables)] struct Foo<'r>(&'r mut i32); diff --git a/tests/ui/issues/issue-15763.rs b/tests/ui/drop/nested-return-drop-order.rs index 0ebadd80541..67ab52e6250 100644 --- a/tests/ui/issues/issue-15763.rs +++ b/tests/ui/drop/nested-return-drop-order.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15763 + //@ run-pass #![allow(unreachable_code)] diff --git a/tests/ui/drop/or-pattern-drop-order.rs b/tests/ui/drop/or-pattern-drop-order.rs index fdc28225c35..cca81673ac3 100644 --- a/tests/ui/drop/or-pattern-drop-order.rs +++ b/tests/ui/drop/or-pattern-drop-order.rs @@ -1,6 +1,7 @@ //@ run-pass //! Test drop order for different ways of declaring pattern bindings involving or-patterns. -//! Currently, it's inconsistent between language constructs (#142163). +//! In particular, are ordered based on the order in which the first occurrence of each binding +//! appears (i.e. the "primary" bindings). Regression test for #142163. use std::cell::RefCell; use std::ops::Drop; @@ -43,11 +44,10 @@ fn main() { y = LogDrop(o, 1); }); - // When bindings are declared with `let pat = expr;`, bindings within or-patterns are seen last, - // thus they're dropped first. + // `let pat = expr;` should have the same drop order. assert_drop_order(1..=3, |o| { - // Drops are right-to-left, treating `y` as rightmost: `y`, `z`, `x`. - let (x, Ok(y) | Err(y), z) = (LogDrop(o, 3), Ok(LogDrop(o, 1)), LogDrop(o, 2)); + // Drops are right-to-left: `z`, `y`, `x`. + let (x, Ok(y) | Err(y), z) = (LogDrop(o, 3), Ok(LogDrop(o, 2)), LogDrop(o, 1)); }); assert_drop_order(1..=2, |o| { // The first or-pattern alternative determines the bindings' drop order: `y`, `x`. @@ -58,30 +58,29 @@ fn main() { let ((true, x, y) | (false, y, x)) = (false, LogDrop(o, 1), LogDrop(o, 2)); }); - // `match` treats or-patterns as last like `let pat = expr;`, but also determines drop order - // using the order of the bindings in the *last* or-pattern alternative. + // `match` should have the same drop order. assert_drop_order(1..=3, |o| { - // Drops are right-to-left, treating `y` as rightmost: `y`, `z`, `x`. - match (LogDrop(o, 3), Ok(LogDrop(o, 1)), LogDrop(o, 2)) { (x, Ok(y) | Err(y), z) => {} } + // Drops are right-to-left: `z`, `y` `x`. + match (LogDrop(o, 3), Ok(LogDrop(o, 2)), LogDrop(o, 1)) { (x, Ok(y) | Err(y), z) => {} } }); assert_drop_order(1..=2, |o| { - // The last or-pattern alternative determines the bindings' drop order: `x`, `y`. - match (true, LogDrop(o, 1), LogDrop(o, 2)) { (true, x, y) | (false, y, x) => {} } + // The first or-pattern alternative determines the bindings' drop order: `y`, `x`. + match (true, LogDrop(o, 2), LogDrop(o, 1)) { (true, x, y) | (false, y, x) => {} } }); assert_drop_order(1..=2, |o| { - // That drop order is used regardless of which or-pattern alternative matches: `x`, `y`. - match (false, LogDrop(o, 2), LogDrop(o, 1)) { (true, x, y) | (false, y, x) => {} } + // That drop order is used regardless of which or-pattern alternative matches: `y`, `x`. + match (false, LogDrop(o, 1), LogDrop(o, 2)) { (true, x, y) | (false, y, x) => {} } }); // Function params are visited one-by-one, and the order of bindings within a param's pattern is - // the same as `let pat = expr`; + // the same as `let pat = expr;` assert_drop_order(1..=3, |o| { // Among separate params, the drop order is right-to-left: `z`, `y`, `x`. (|x, (Ok(y) | Err(y)), z| {})(LogDrop(o, 3), Ok(LogDrop(o, 2)), LogDrop(o, 1)); }); assert_drop_order(1..=3, |o| { - // Within a param's pattern, or-patterns are treated as rightmost: `y`, `z`, `x`. - (|(x, Ok(y) | Err(y), z)| {})((LogDrop(o, 3), Ok(LogDrop(o, 1)), LogDrop(o, 2))); + // Within a param's pattern, likewise: `z`, `y`, `x`. + (|(x, Ok(y) | Err(y), z)| {})((LogDrop(o, 3), Ok(LogDrop(o, 2)), LogDrop(o, 1))); }); assert_drop_order(1..=2, |o| { // The first or-pattern alternative determines the bindings' drop order: `y`, `x`. @@ -89,12 +88,11 @@ fn main() { }); // `if let` and `let`-`else` see bindings in the same order as `let pat = expr;`. - // Vars in or-patterns are seen last (dropped first), and the first alternative's order is used. assert_drop_order(1..=3, |o| { - if let (x, Ok(y) | Err(y), z) = (LogDrop(o, 3), Ok(LogDrop(o, 1)), LogDrop(o, 2)) {} + if let (x, Ok(y) | Err(y), z) = (LogDrop(o, 3), Ok(LogDrop(o, 2)), LogDrop(o, 1)) {} }); assert_drop_order(1..=3, |o| { - let (x, Ok(y) | Err(y), z) = (LogDrop(o, 3), Ok(LogDrop(o, 1)), LogDrop(o, 2)) else { + let (x, Ok(y) | Err(y), z) = (LogDrop(o, 3), Ok(LogDrop(o, 2)), LogDrop(o, 1)) else { unreachable!(); }; }); @@ -106,4 +104,21 @@ fn main() { unreachable!(); }; }); + + // Test nested and adjacent or-patterns, including or-patterns without bindings under a guard. + assert_drop_order(1..=6, |o| { + // The `LogDrop`s that aren't moved into bindings are dropped last. + match [ + [LogDrop(o, 6), LogDrop(o, 4)], + [LogDrop(o, 3), LogDrop(o, 2)], + [LogDrop(o, 1), LogDrop(o, 5)], + ] { + [ + [_ | _, w | w] | [w | w, _ | _], + [x | x, y | y] | [y | y, x | x], + [z | z, _ | _] | [_ | _, z | z], + ] if true => {} + _ => unreachable!(), + } + }); } diff --git a/tests/ui/issues/issue-14875.rs b/tests/ui/drop/panic-during-drop-14875.rs index e330c64a335..5a6f8f42775 100644 --- a/tests/ui/issues/issue-14875.rs +++ b/tests/ui/drop/panic-during-drop-14875.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/14875 + //@ run-pass //@ needs-unwind //@ ignore-backends: gcc diff --git a/tests/ui/drop/same-alloca-reassigned-match-binding-16151.rs b/tests/ui/drop/same-alloca-reassigned-match-binding-16151.rs new file mode 100644 index 00000000000..ecc862ec7be --- /dev/null +++ b/tests/ui/drop/same-alloca-reassigned-match-binding-16151.rs @@ -0,0 +1,34 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/16151 + +//@ run-pass + +// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +#![allow(static_mut_refs)] + +use std::mem; + +static mut DROP_COUNT: usize = 0; + +struct Fragment; + +impl Drop for Fragment { + fn drop(&mut self) { + unsafe { + DROP_COUNT += 1; + } + } +} + +fn main() { + { + let mut fragments = vec![Fragment, Fragment, Fragment]; + let _new_fragments: Vec<Fragment> = mem::replace(&mut fragments, vec![]) + .into_iter() + .skip_while(|_fragment| { + true + }).collect(); + } + unsafe { + assert_eq!(DROP_COUNT, 3); + } +} diff --git a/tests/ui/issues/issue-9243.rs b/tests/ui/drop/static-variable-with-drop-trait-9243.rs index 34ae944d1d8..0ae32c983e9 100644 --- a/tests/ui/issues/issue-9243.rs +++ b/tests/ui/drop/static-variable-with-drop-trait-9243.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/9243 //@ build-pass #![allow(dead_code)] // Regression test for issue 9243 diff --git a/tests/ui/issues/issue-16492.rs b/tests/ui/drop/struct-field-drop-order.rs index cfdba5fda35..80e3ea616a5 100644 --- a/tests/ui/issues/issue-16492.rs +++ b/tests/ui/drop/struct-field-drop-order.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/16492 + //@ run-pass #![allow(non_snake_case)] diff --git a/tests/ui/dropck/dropck_no_diverge_on_nonregular_1.rs b/tests/ui/dropck/dropck_no_diverge_on_nonregular_1.rs index 17b76b6c832..2bb82a2ebf2 100644 --- a/tests/ui/dropck/dropck_no_diverge_on_nonregular_1.rs +++ b/tests/ui/dropck/dropck_no_diverge_on_nonregular_1.rs @@ -1,5 +1,6 @@ // Issue 22443: Reject code using non-regular types that would // otherwise cause dropck to loop infinitely. +//@ compile-flags: -Zwrite-long-types-to-disk=yes use std::marker::PhantomData; diff --git a/tests/ui/dropck/dropck_no_diverge_on_nonregular_1.stderr b/tests/ui/dropck/dropck_no_diverge_on_nonregular_1.stderr index 9360f4a98e9..330a40d925b 100644 --- a/tests/ui/dropck/dropck_no_diverge_on_nonregular_1.stderr +++ b/tests/ui/dropck/dropck_no_diverge_on_nonregular_1.stderr @@ -1,10 +1,12 @@ error[E0320]: overflow while adding drop-check rules for `FingerTree<i32>` - --> $DIR/dropck_no_diverge_on_nonregular_1.rs:24:9 + --> $DIR/dropck_no_diverge_on_nonregular_1.rs:25:9 | LL | let ft = | ^^ | - = note: overflowed on `FingerTree<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<i32>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: overflowed on `FingerTree<Node<Node<Node<Node<Node<Node<Node<Node<Node<...>>>>>>>>>>` + = note: the full name for the type has been written to '$TEST_BUILD_DIR/dropck_no_diverge_on_nonregular_1.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error diff --git a/tests/ui/dropck/eager-by-ref-binding-for-guards.rs b/tests/ui/dropck/eager-by-ref-binding-for-guards.rs index 3f475839171..90ff9a747ae 100644 --- a/tests/ui/dropck/eager-by-ref-binding-for-guards.rs +++ b/tests/ui/dropck/eager-by-ref-binding-for-guards.rs @@ -17,15 +17,15 @@ fn main() { (mut long2, ref short2) if true => long2.0 = &short2, _ => unreachable!(), } - // This depends on the binding modes of the final or-pattern alternatives (see #142163): + // This depends on the binding modes of the first or-pattern alternatives: let res: &Result<u8, &u8> = &Ok(1); match (Struct(&&0), res) { (mut long3, Ok(short3) | &Err(short3)) if true => long3.0 = &short3, - //~^ ERROR `short3` does not live long enough _ => unreachable!(), } match (Struct(&&0), res) { (mut long4, &Err(short4) | Ok(short4)) if true => long4.0 = &short4, + //~^ ERROR `short4` does not live long enough _ => unreachable!(), } } diff --git a/tests/ui/dropck/eager-by-ref-binding-for-guards.stderr b/tests/ui/dropck/eager-by-ref-binding-for-guards.stderr index cb1a04cd444..2648ce6f99c 100644 --- a/tests/ui/dropck/eager-by-ref-binding-for-guards.stderr +++ b/tests/ui/dropck/eager-by-ref-binding-for-guards.stderr @@ -11,15 +11,15 @@ LL | (mut long1, ref short1) => long1.0 = &short1, | = note: values in a scope are dropped in the opposite order they are defined -error[E0597]: `short3` does not live long enough - --> $DIR/eager-by-ref-binding-for-guards.rs:23:69 +error[E0597]: `short4` does not live long enough + --> $DIR/eager-by-ref-binding-for-guards.rs:27:69 | -LL | (mut long3, Ok(short3) | &Err(short3)) if true => long3.0 = &short3, - | ------ ^^^^^^- - | | | | - | | | `short3` dropped here while still borrowed - | | | borrow might be used here, when `long3` is dropped and runs the `Drop` code for type `Struct` - | binding `short3` declared here borrowed value does not live long enough +LL | (mut long4, &Err(short4) | Ok(short4)) if true => long4.0 = &short4, + | ------ ^^^^^^- + | | | | + | | | `short4` dropped here while still borrowed + | | | borrow might be used here, when `long4` is dropped and runs the `Drop` code for type `Struct` + | binding `short4` declared here borrowed value does not live long enough | = note: values in a scope are dropped in the opposite order they are defined diff --git a/tests/ui/dropck/let-else-more-permissive.rs b/tests/ui/dropck/let-else-more-permissive.rs index 0020814aa81..6247b0eb5e2 100644 --- a/tests/ui/dropck/let-else-more-permissive.rs +++ b/tests/ui/dropck/let-else-more-permissive.rs @@ -1,5 +1,5 @@ -//! The drop check is currently more permissive when `let` statements have an `else` block, due to -//! scheduling drops for bindings' storage before pattern-matching (#142056). +//! Regression test for #142056. The drop check used to be more permissive for `let` statements with +//! `else` blocks, due to scheduling drops for bindings' storage before pattern-matching. struct Struct<T>(T); impl<T> Drop for Struct<T> { @@ -14,10 +14,11 @@ fn main() { //~^ ERROR `short1` does not live long enough } { - // This is OK: `short2`'s storage is live until after `long2`'s drop runs. + // This was OK: `short2`'s storage was live until after `long2`'s drop ran. #[expect(irrefutable_let_patterns)] let (mut long2, short2) = (Struct(&0), 1) else { unreachable!() }; long2.0 = &short2; + //~^ ERROR `short2` does not live long enough } { // Sanity check: `short3`'s drop is significant; it's dropped before `long3`: diff --git a/tests/ui/dropck/let-else-more-permissive.stderr b/tests/ui/dropck/let-else-more-permissive.stderr index 7c37e170afa..4f0c193a78d 100644 --- a/tests/ui/dropck/let-else-more-permissive.stderr +++ b/tests/ui/dropck/let-else-more-permissive.stderr @@ -14,8 +14,24 @@ LL | } | = note: values in a scope are dropped in the opposite order they are defined +error[E0597]: `short2` does not live long enough + --> $DIR/let-else-more-permissive.rs:20:19 + | +LL | let (mut long2, short2) = (Struct(&0), 1) else { unreachable!() }; + | ------ binding `short2` declared here +LL | long2.0 = &short2; + | ^^^^^^^ borrowed value does not live long enough +LL | +LL | } + | - + | | + | `short2` dropped here while still borrowed + | borrow might be used here, when `long2` is dropped and runs the `Drop` code for type `Struct` + | + = note: values in a scope are dropped in the opposite order they are defined + error[E0597]: `short3` does not live long enough - --> $DIR/let-else-more-permissive.rs:27:19 + --> $DIR/let-else-more-permissive.rs:28:19 | LL | let (mut long3, short3) = (Struct(&tmp), Box::new(1)) else { unreachable!() }; | ------ binding `short3` declared here @@ -30,6 +46,6 @@ LL | } | = note: values in a scope are dropped in the opposite order they are defined -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0597`. diff --git a/tests/ui/issues/issue-53333.rs b/tests/ui/editions/edition-specific-identifier-shadowing-53333.rs index 468b7d8075f..dd973bb8439 100644 --- a/tests/ui/issues/issue-53333.rs +++ b/tests/ui/editions/edition-specific-identifier-shadowing-53333.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/53333 //@ run-pass #![allow(unused_imports)] //@ edition:2018 diff --git a/tests/ui/editions/never-type-fallback-breaking.e2024.stderr b/tests/ui/editions/never-type-fallback-breaking.e2024.stderr index 2daf00f7804..f0d4de364fb 100644 --- a/tests/ui/editions/never-type-fallback-breaking.e2024.stderr +++ b/tests/ui/editions/never-type-fallback-breaking.e2024.stderr @@ -5,7 +5,7 @@ LL | true => Default::default(), | ^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `!` | = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/48950> for more information) - = help: did you intend to use the type `()` here instead? + = help: you might have intended to use the type `()` here instead error[E0277]: the trait bound `!: Default` is not satisfied --> $DIR/never-type-fallback-breaking.rs:37:5 @@ -14,7 +14,7 @@ LL | deserialize()?; | ^^^^^^^^^^^^^ the trait `Default` is not implemented for `!` | = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/48950> for more information) - = help: did you intend to use the type `()` here instead? + = help: you might have intended to use the type `()` here instead note: required by a bound in `deserialize` --> $DIR/never-type-fallback-breaking.rs:33:23 | @@ -51,7 +51,7 @@ LL | takes_apit(|| Default::default())?; | ^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `!` | = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/48950> for more information) - = help: did you intend to use the type `()` here instead? + = help: you might have intended to use the type `()` here instead error[E0277]: the trait bound `!: Default` is not satisfied --> $DIR/never-type-fallback-breaking.rs:76:17 @@ -62,7 +62,7 @@ LL | takes_apit2(mk()?); | required by a bound introduced by this call | = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/48950> for more information) - = help: did you intend to use the type `()` here instead? + = help: you might have intended to use the type `()` here instead note: required by a bound in `takes_apit2` --> $DIR/never-type-fallback-breaking.rs:71:25 | diff --git a/tests/ui/issues/issue-9837.rs b/tests/ui/enum-discriminant/enum-discriminant-const-eval-truncation-9837.rs index 33152a5d077..8768d81b93f 100644 --- a/tests/ui/issues/issue-9837.rs +++ b/tests/ui/enum-discriminant/enum-discriminant-const-eval-truncation-9837.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/9837 //@ run-pass const C1: i32 = 0x12345678; const C2: isize = C1 as i16 as isize; diff --git a/tests/ui/issues/issue-9814.rs b/tests/ui/enum/single-variant-enum-deref-error-9814.rs index a87478e221b..f10d665299c 100644 --- a/tests/ui/issues/issue-9814.rs +++ b/tests/ui/enum/single-variant-enum-deref-error-9814.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/9814 // Verify that single-variant enums can't be de-referenced // Regression test for issue #9814 diff --git a/tests/ui/issues/issue-9814.stderr b/tests/ui/enum/single-variant-enum-deref-error-9814.stderr index fa23fb7c176..5e069f4c21d 100644 --- a/tests/ui/issues/issue-9814.stderr +++ b/tests/ui/enum/single-variant-enum-deref-error-9814.stderr @@ -1,5 +1,5 @@ error[E0614]: type `Foo` cannot be dereferenced - --> $DIR/issue-9814.rs:7:13 + --> $DIR/single-variant-enum-deref-error-9814.rs:8:13 | LL | let _ = *Foo::Bar(2); | ^^^^^^^^^^^^ can't be dereferenced diff --git a/tests/ui/issues/issue-3037.rs b/tests/ui/enum/zero-variant-enum-pattern-matching-3037.rs index 933b450ac8e..7a7abb1c67c 100644 --- a/tests/ui/issues/issue-3037.rs +++ b/tests/ui/enum/zero-variant-enum-pattern-matching-3037.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/3037 //@ run-pass #![allow(dead_code)] #![allow(non_camel_case_types)] diff --git a/tests/ui/error-codes/E0197.stderr b/tests/ui/error-codes/E0197.stderr index c06777396e8..04c6174b9f1 100644 --- a/tests/ui/error-codes/E0197.stderr +++ b/tests/ui/error-codes/E0197.stderr @@ -5,6 +5,8 @@ LL | unsafe impl Foo { } | ------ ^^^ inherent impl for this type | | | unsafe because of this + | + = note: only trait implementations may be annotated with `unsafe` error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0275.rs b/tests/ui/error-codes/E0275.rs index 28a9676f03e..98d4a3c01b9 100644 --- a/tests/ui/error-codes/E0275.rs +++ b/tests/ui/error-codes/E0275.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Zwrite-long-types-to-disk=yes trait Foo {} struct Bar<T>(T); diff --git a/tests/ui/error-codes/E0275.stderr b/tests/ui/error-codes/E0275.stderr index 3b31c87320a..755404c1e16 100644 --- a/tests/ui/error-codes/E0275.stderr +++ b/tests/ui/error-codes/E0275.stderr @@ -1,17 +1,19 @@ error[E0275]: overflow evaluating the requirement `Bar<Bar<Bar<Bar<Bar<Bar<Bar<...>>>>>>>: Foo` - --> $DIR/E0275.rs:5:33 + --> $DIR/E0275.rs:6:33 | LL | impl<T> Foo for T where Bar<T>: Foo {} | ^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`E0275`) -note: required for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `Foo` - --> $DIR/E0275.rs:5:9 +note: required for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<...>>>>>>>>>>>>>` to implement `Foo` + --> $DIR/E0275.rs:6:9 | LL | impl<T> Foo for T where Bar<T>: Foo {} | ^^^ ^ --- unsatisfied trait bound introduced here = note: 126 redundant requirements hidden = note: required for `Bar<T>` to implement `Foo` + = note: the full name for the type has been written to '$TEST_BUILD_DIR/E0275.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0518.rs b/tests/ui/error-codes/E0518.rs deleted file mode 100644 index 9c99702ada8..00000000000 --- a/tests/ui/error-codes/E0518.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[inline(always)] //~ ERROR: E0518 -struct Foo; - -#[inline(never)] //~ ERROR: E0518 -impl Foo { -} - -fn main() { -} diff --git a/tests/ui/error-codes/E0518.stderr b/tests/ui/error-codes/E0518.stderr deleted file mode 100644 index 561446f8175..00000000000 --- a/tests/ui/error-codes/E0518.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0518]: attribute should be applied to function or closure - --> $DIR/E0518.rs:1:1 - | -LL | #[inline(always)] - | ^^^^^^^^^^^^^^^^^ -LL | struct Foo; - | ----------- not a function or closure - -error[E0518]: attribute should be applied to function or closure - --> $DIR/E0518.rs:4:1 - | -LL | #[inline(never)] - | ^^^^^^^^^^^^^^^^ -LL | / impl Foo { -LL | | } - | |_- not a function or closure - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0518`. diff --git a/tests/ui/error-codes/E0540.stderr b/tests/ui/error-codes/E0540.stderr index 3e5f408feb5..ae23dce5c50 100644 --- a/tests/ui/error-codes/E0540.stderr +++ b/tests/ui/error-codes/E0540.stderr @@ -6,10 +6,13 @@ LL | #[inline()] | | | expected a single argument here | + = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/codegen.html#the-inline-attribute> help: try changing it to one of the following valid forms of the attribute | -LL | #[inline(always|never)] - | ++++++++++++ +LL | #[inline(always)] + | ++++++ +LL | #[inline(never)] + | +++++ LL - #[inline()] LL + #[inline] | diff --git a/tests/ui/error-codes/E0565-1.stderr b/tests/ui/error-codes/E0565-1.stderr index 6277e6400d7..52daf2a62fc 100644 --- a/tests/ui/error-codes/E0565-1.stderr +++ b/tests/ui/error-codes/E0565-1.stderr @@ -12,11 +12,15 @@ LL - #[deprecated("since")] LL + #[deprecated = "reason"] | LL - #[deprecated("since")] -LL + #[deprecated(/*opt*/ since = "version", /*opt*/ note = "reason")] +LL + #[deprecated(note = "reason")] | LL - #[deprecated("since")] -LL + #[deprecated] +LL + #[deprecated(since = "version")] | +LL - #[deprecated("since")] +LL + #[deprecated(since = "version", note = "reason")] + | + = and 1 other candidate error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0718.stderr b/tests/ui/error-codes/E0718.stderr index ec7462765f8..e7784d193ba 100644 --- a/tests/ui/error-codes/E0718.stderr +++ b/tests/ui/error-codes/E0718.stderr @@ -2,7 +2,7 @@ error[E0718]: `owned_box` lang item must be applied to a struct --> $DIR/E0718.rs:4:1 | LL | #[lang = "owned_box"] - | ^^^^^^^^^^^^^^^^^^^^^ attribute should be applied to a struct, not a static item + | ^^^^^^^^^^^^^^^^^^^^^ attribute should be applied to a struct, not a static error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/ex-E0612.stderr b/tests/ui/error-codes/ex-E0612.stderr index 54451d3d452..e6062f6061d 100644 --- a/tests/ui/error-codes/ex-E0612.stderr +++ b/tests/ui/error-codes/ex-E0612.stderr @@ -4,11 +4,7 @@ error[E0609]: no field `1` on type `Foo` LL | y.1; | ^ unknown field | -help: a field with a similar name exists - | -LL - y.1; -LL + y.0; - | + = note: available field is: `0` error: aborting due to 1 previous error diff --git a/tests/ui/explicit-tail-calls/callee_is_track_caller.rs b/tests/ui/explicit-tail-calls/callee_is_track_caller.rs index bcb93fda8c8..b85b335844b 100644 --- a/tests/ui/explicit-tail-calls/callee_is_track_caller.rs +++ b/tests/ui/explicit-tail-calls/callee_is_track_caller.rs @@ -1,10 +1,11 @@ -//@ check-pass -// FIXME(explicit_tail_calls): make this run-pass, once tail calls are properly implemented +//@ run-pass +//@ ignore-pass #![expect(incomplete_features)] #![feature(explicit_tail_calls)] fn a(x: u32) -> u32 { become b(x); + //~^ warning: tail calling a function marked with `#[track_caller]` has no special effect } #[track_caller] diff --git a/tests/ui/explicit-tail-calls/callee_is_track_caller.stderr b/tests/ui/explicit-tail-calls/callee_is_track_caller.stderr new file mode 100644 index 00000000000..e1a251d156f --- /dev/null +++ b/tests/ui/explicit-tail-calls/callee_is_track_caller.stderr @@ -0,0 +1,10 @@ +warning: tail calling a function marked with `#[track_caller]` has no special effect + --> $DIR/callee_is_track_caller.rs:7:12 + | +LL | become b(x); + | ^^^^ + | + = note: `#[warn(tail_call_track_caller)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/explicit-tail-calls/callee_is_track_caller_polymorphic.rs b/tests/ui/explicit-tail-calls/callee_is_track_caller_polymorphic.rs new file mode 100644 index 00000000000..33384de83eb --- /dev/null +++ b/tests/ui/explicit-tail-calls/callee_is_track_caller_polymorphic.rs @@ -0,0 +1,20 @@ +//@ run-pass +//@ ignore-pass +#![expect(incomplete_features)] +#![feature(explicit_tail_calls)] + +fn c<T: Trait>() { + become T::f(); + //~^ warning: tail calling a function marked with `#[track_caller]` has no special effect +} + +trait Trait { + #[track_caller] + fn f() {} +} + +impl Trait for () {} + +fn main() { + c::<()>(); +} diff --git a/tests/ui/explicit-tail-calls/callee_is_track_caller_polymorphic.stderr b/tests/ui/explicit-tail-calls/callee_is_track_caller_polymorphic.stderr new file mode 100644 index 00000000000..5a1c40509ad --- /dev/null +++ b/tests/ui/explicit-tail-calls/callee_is_track_caller_polymorphic.stderr @@ -0,0 +1,10 @@ +warning: tail calling a function marked with `#[track_caller]` has no special effect + --> $DIR/callee_is_track_caller_polymorphic.rs:7:12 + | +LL | become T::f(); + | ^^^^^^ + | + = note: `#[warn(tail_call_track_caller)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/explicit-tail-calls/caller-lifetime-presence.rs b/tests/ui/explicit-tail-calls/caller-lifetime-presence.rs new file mode 100644 index 00000000000..2382bc9dd1e --- /dev/null +++ b/tests/ui/explicit-tail-calls/caller-lifetime-presence.rs @@ -0,0 +1,51 @@ +//! Regression test for: https://github.com/rust-lang/rust/issues/144957 +//! +//! This test ensures that lifetime information is included in diagnostics. +//! +//! Specifically, it checks that the `become` call produces an error with lifetimes shown +//! in both caller and callee signatures. +//! +//! If the test fails: +//! - Lifetimes may be missing (fix the diagnostic), or +//! - The message format changed (update the test). + +#![feature(explicit_tail_calls)] +#![allow(incomplete_features)] + +fn foo<'a>(_: fn(&'a ())) { + become bar(dummy); + //~^ ERROR mismatched signatures + //~| NOTE `become` requires caller and callee to have matching signatures + //~| NOTE caller signature: `fn(fn(&'a ()))` + //~| NOTE callee signature: `fn(for<'a> fn(&'a ()))` +} + +fn bar(_: fn(&())) {} + +fn dummy(_: &()) {} + +fn foo_(_: fn(&())) { + become bar1(dummy2); + //~^ ERROR mismatched signatures + //~| NOTE `become` requires caller and callee to have matching signatures + //~| NOTE caller signature: `fn(for<'a> fn(&'a ()))` + //~| NOTE callee signature: `fn(fn(&'a ()))` +} + +fn bar1<'a>(_: fn(&'a ())) {} + +fn dummy2(_: &()) {} + +fn foo__(_: fn(&'static ())) { + become bar(dummy3); + //~^ ERROR mismatched signatures + //~| NOTE `become` requires caller and callee to have matching signatures + //~| NOTE caller signature: `fn(fn(&'static ()))` + //~| NOTE callee signature: `fn(for<'a> fn(&'a ()))` +} + +fn bar2(_: fn(&())) {} + +fn dummy3(_: &()) {} + +fn main() {} diff --git a/tests/ui/explicit-tail-calls/caller-lifetime-presence.stderr b/tests/ui/explicit-tail-calls/caller-lifetime-presence.stderr new file mode 100644 index 00000000000..2fb981d9682 --- /dev/null +++ b/tests/ui/explicit-tail-calls/caller-lifetime-presence.stderr @@ -0,0 +1,32 @@ +error: mismatched signatures + --> $DIR/caller-lifetime-presence.rs:16:5 + | +LL | become bar(dummy); + | ^^^^^^^^^^^^^^^^^ + | + = note: `become` requires caller and callee to have matching signatures + = note: caller signature: `fn(fn(&'a ()))` + = note: callee signature: `fn(for<'a> fn(&'a ()))` + +error: mismatched signatures + --> $DIR/caller-lifetime-presence.rs:28:5 + | +LL | become bar1(dummy2); + | ^^^^^^^^^^^^^^^^^^^ + | + = note: `become` requires caller and callee to have matching signatures + = note: caller signature: `fn(for<'a> fn(&'a ()))` + = note: callee signature: `fn(fn(&'a ()))` + +error: mismatched signatures + --> $DIR/caller-lifetime-presence.rs:40:5 + | +LL | become bar(dummy3); + | ^^^^^^^^^^^^^^^^^^ + | + = note: `become` requires caller and callee to have matching signatures + = note: caller signature: `fn(fn(&'static ()))` + = note: callee signature: `fn(for<'a> fn(&'a ()))` + +error: aborting due to 3 previous errors + diff --git a/tests/ui/explicit-tail-calls/drop-order.rs b/tests/ui/explicit-tail-calls/drop-order.rs index 242336be484..58e1afbdf0c 100644 --- a/tests/ui/explicit-tail-calls/drop-order.rs +++ b/tests/ui/explicit-tail-calls/drop-order.rs @@ -1,5 +1,3 @@ -// FIXME(explicit_tail_calls): enable this test once rustc_codegen_ssa supports tail calls -//@ ignore-test: tail calls are not implemented in rustc_codegen_ssa yet, so this causes 🧊 //@ run-pass #![expect(incomplete_features)] #![feature(explicit_tail_calls)] diff --git a/tests/ui/explicit-tail-calls/indexer.rs b/tests/ui/explicit-tail-calls/indexer.rs new file mode 100644 index 00000000000..5644506b2f5 --- /dev/null +++ b/tests/ui/explicit-tail-calls/indexer.rs @@ -0,0 +1,22 @@ +//@ run-pass +// Indexing taken from +// https://github.com/phi-go/rfcs/blob/guaranteed-tco/text%2F0000-explicit-tail-calls.md#tail-call-elimination +// no other test has utilized the "function table" +// described in the RFC aside from this one at this point. +#![expect(incomplete_features)] +#![feature(explicit_tail_calls)] + +fn f0(_: usize) {} +fn f1(_: usize) {} +fn f2(_: usize) {} + +fn indexer(idx: usize) { + let v: [fn(usize); 3] = [f0, f1, f2]; + become v[idx](idx) +} + +fn main() { + for idx in 0..3 { + indexer(idx); + } +} diff --git a/tests/ui/extern-flag/empty-extern-arg.rs b/tests/ui/extern-flag/empty-extern-arg.rs index 2dee721ed03..10cc3be7113 100644 --- a/tests/ui/extern-flag/empty-extern-arg.rs +++ b/tests/ui/extern-flag/empty-extern-arg.rs @@ -1,4 +1,5 @@ //~ ERROR extern location for std does not exist +//~^ ERROR cannot resolve a prelude import //@ compile-flags: --extern std= //@ needs-unwind since it affects the error output //@ ignore-emscripten missing eh_catch_typeinfo lang item diff --git a/tests/ui/extern-flag/empty-extern-arg.stderr b/tests/ui/extern-flag/empty-extern-arg.stderr index 79efcc5d8b0..3e0a0d6cd5f 100644 --- a/tests/ui/extern-flag/empty-extern-arg.stderr +++ b/tests/ui/extern-flag/empty-extern-arg.stderr @@ -1,5 +1,7 @@ error: extern location for std does not exist: +error: cannot resolve a prelude import + error: `#[panic_handler]` function required, but not found error: unwinding panics are not supported without std @@ -7,5 +9,5 @@ error: unwinding panics are not supported without std = help: using nightly cargo, use -Zbuild-std with panic="abort" to avoid unwinding = note: since the core library is usually precompiled with panic="unwind", rebuilding your crate with panic="abort" may not be enough to fix the problem -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors diff --git a/tests/ui/issues/issue-16441.rs b/tests/ui/extern/empty-struct-extern-fn-16441.rs index 58cfb389297..82f2eee611d 100644 --- a/tests/ui/issues/issue-16441.rs +++ b/tests/ui/extern/empty-struct-extern-fn-16441.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/16441 + //@ run-pass #![allow(dead_code)] diff --git a/tests/ui/extern/extern-no-mangle.rs b/tests/ui/extern/extern-no-mangle.rs index dba9689a075..6f2d125b923 100644 --- a/tests/ui/extern/extern-no-mangle.rs +++ b/tests/ui/extern/extern-no-mangle.rs @@ -9,21 +9,21 @@ extern "C" { #[no_mangle] - //~^ WARNING `#[no_mangle]` has no effect on a foreign static - //~^^ WARNING this was previously accepted by the compiler + //~^ WARNING attribute cannot be used on + //~| WARN previously accepted pub static FOO: u8; #[no_mangle] - //~^ WARNING `#[no_mangle]` has no effect on a foreign function - //~^^ WARNING this was previously accepted by the compiler + //~^ WARNING attribute cannot be used on + //~| WARN previously accepted pub fn bar(); } fn no_new_warn() { // Should emit the generic "not a function or static" warning #[no_mangle] - //~^ WARNING attribute should be applied to a free function, impl method or static - //~^^ WARNING this was previously accepted by the compiler + //~^ WARNING attribute cannot be used on + //~| WARN previously accepted let x = 0_u8; } diff --git a/tests/ui/extern/extern-no-mangle.stderr b/tests/ui/extern/extern-no-mangle.stderr index f20ee158ac4..b07cf0d4b4d 100644 --- a/tests/ui/extern/extern-no-mangle.stderr +++ b/tests/ui/extern/extern-no-mangle.stderr @@ -1,42 +1,34 @@ -warning: attribute should be applied to a free function, impl method or static - --> $DIR/extern-no-mangle.rs:24:5 +warning: `#[no_mangle]` attribute cannot be used on foreign statics + --> $DIR/extern-no-mangle.rs:11:5 | LL | #[no_mangle] | ^^^^^^^^^^^^ -... -LL | let x = 0_u8; - | ------------- not a free function, impl method or static | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[no_mangle]` can be applied to functions, statics note: the lint level is defined here --> $DIR/extern-no-mangle.rs:1:9 | LL | #![warn(unused_attributes)] | ^^^^^^^^^^^^^^^^^ -warning: `#[no_mangle]` has no effect on a foreign static - --> $DIR/extern-no-mangle.rs:11:5 +warning: `#[no_mangle]` attribute cannot be used on foreign functions + --> $DIR/extern-no-mangle.rs:16:5 | LL | #[no_mangle] - | ^^^^^^^^^^^^ help: remove this attribute -... -LL | pub static FOO: u8; - | ------------------- foreign static + | ^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: symbol names in extern blocks are not mangled + = help: `#[no_mangle]` can be applied to methods, functions, statics -warning: `#[no_mangle]` has no effect on a foreign function - --> $DIR/extern-no-mangle.rs:16:5 +warning: `#[no_mangle]` attribute cannot be used on statements + --> $DIR/extern-no-mangle.rs:24:5 | LL | #[no_mangle] - | ^^^^^^^^^^^^ help: remove this attribute -... -LL | pub fn bar(); - | ------------- foreign function + | ^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: symbol names in extern blocks are not mangled + = help: `#[no_mangle]` can be applied to functions, statics warning: 3 warnings emitted diff --git a/tests/ui/extern/extern-types-field-offset.run.stderr b/tests/ui/extern/extern-types-field-offset.run.stderr index 07bd4fcb13f..b096e8044a7 100644 --- a/tests/ui/extern/extern-types-field-offset.run.stderr +++ b/tests/ui/extern/extern-types-field-offset.run.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at library/core/src/panicking.rs:$LINE:$COL: +thread 'main' ($TID) 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 index 5ba372d60fa..66206f37501 100644 --- a/tests/ui/extern/extern-types-size_of_val.align.run.stderr +++ b/tests/ui/extern/extern-types-size_of_val.align.run.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at library/core/src/panicking.rs:$LINE:$COL: +thread 'main' ($TID) 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.size.run.stderr b/tests/ui/extern/extern-types-size_of_val.size.run.stderr index 5ba372d60fa..66206f37501 100644 --- a/tests/ui/extern/extern-types-size_of_val.size.run.stderr +++ b/tests/ui/extern/extern-types-size_of_val.size.run.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at library/core/src/panicking.rs:$LINE:$COL: +thread 'main' ($TID) 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/issue-47725.rs b/tests/ui/extern/issue-47725.rs index 60d0cd62347..b0a0af930de 100644 --- a/tests/ui/extern/issue-47725.rs +++ b/tests/ui/extern/issue-47725.rs @@ -1,22 +1,26 @@ #![warn(unused_attributes)] //~ NOTE lint level is defined here #[link_name = "foo"] -//~^ WARN attribute should be applied to a foreign function or static [unused_attributes] -//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -struct Foo; //~ NOTE not a foreign function or static +//~^ WARN attribute cannot be used on +//~| WARN previously accepted +//~| HELP can be applied to +struct Foo; #[link_name = "foobar"] -//~^ WARN attribute should be applied to a foreign function or static [unused_attributes] -//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -//~| HELP try `#[link(name = "foobar")]` instead +//~^ WARN attribute cannot be used on +//~| WARN previously accepted +//~| HELP can be applied to extern "C" { fn foo() -> u32; } -//~^^^ NOTE not a foreign function or static #[link_name] //~^ ERROR malformed `link_name` attribute input //~| HELP must be of the form +//~| WARN attribute cannot be used on +//~| WARN previously accepted +//~| HELP can be applied to +//~| NOTE for more information, visit extern "C" { fn bar() -> u32; } diff --git a/tests/ui/extern/issue-47725.stderr b/tests/ui/extern/issue-47725.stderr index 4fd02a1778b..704b1d81b63 100644 --- a/tests/ui/extern/issue-47725.stderr +++ b/tests/ui/extern/issue-47725.stderr @@ -3,41 +3,41 @@ error[E0539]: malformed `link_name` attribute input | LL | #[link_name] | ^^^^^^^^^^^^ help: must be of the form: `#[link_name = "name"]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link_name-attribute> -warning: attribute should be applied to a foreign function or static +warning: `#[link_name]` attribute cannot be used on structs --> $DIR/issue-47725.rs:3:1 | LL | #[link_name = "foo"] | ^^^^^^^^^^^^^^^^^^^^ -... -LL | struct Foo; - | ----------- not a foreign function or static | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[link_name]` can be applied to foreign functions, foreign statics note: the lint level is defined here --> $DIR/issue-47725.rs:1:9 | LL | #![warn(unused_attributes)] | ^^^^^^^^^^^^^^^^^ -warning: attribute should be applied to a foreign function or static - --> $DIR/issue-47725.rs:8:1 +warning: `#[link_name]` attribute cannot be used on foreign modules + --> $DIR/issue-47725.rs:9:1 | -LL | #[link_name = "foobar"] - | ^^^^^^^^^^^^^^^^^^^^^^^ -... -LL | / extern "C" { -LL | | fn foo() -> u32; -LL | | } - | |_- not a foreign function or static +LL | #[link_name = "foobar"] + | ^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -help: try `#[link(name = "foobar")]` instead - --> $DIR/issue-47725.rs:8:1 + = help: `#[link_name]` can be applied to foreign functions, foreign statics + +warning: `#[link_name]` attribute cannot be used on foreign modules + --> $DIR/issue-47725.rs:17:1 | -LL | #[link_name = "foobar"] - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[link_name] + | ^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[link_name]` can be applied to foreign functions, foreign statics -error: aborting due to 1 previous error; 2 warnings emitted +error: aborting due to 1 previous error; 3 warnings emitted For more information about this error, try `rustc --explain E0539`. diff --git a/tests/ui/extern/issue-80074.rs b/tests/ui/extern/issue-80074.rs index ba7b55a450f..942b78916d6 100644 --- a/tests/ui/extern/issue-80074.rs +++ b/tests/ui/extern/issue-80074.rs @@ -11,7 +11,7 @@ extern crate issue_80074_2; fn main() { foo!(); - //~^ WARN: macro `foo` is private + //~^ ERROR: macro `foo` is private //~| WARN: it will become a hard error in a future release! bar!(); //~^ ERROR: cannot find macro `bar` in this scope diff --git a/tests/ui/extern/issue-80074.stderr b/tests/ui/extern/issue-80074.stderr index b30b761593e..510ca1be0a1 100644 --- a/tests/ui/extern/issue-80074.stderr +++ b/tests/ui/extern/issue-80074.stderr @@ -16,7 +16,7 @@ error: cannot find macro `m` in this scope LL | m!(); | ^ -warning: macro `foo` is private +error: macro `foo` is private --> $DIR/issue-80074.rs:13:5 | LL | foo!(); @@ -24,8 +24,19 @@ LL | foo!(); | = 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 #120192 <https://github.com/rust-lang/rust/issues/120192> - = note: `#[warn(private_macro_use)]` on by default + = note: `#[deny(private_macro_use)]` on by default -error: aborting due to 3 previous errors; 1 warning emitted +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0469`. +Future incompatibility report: Future breakage diagnostic: +error: macro `foo` is private + --> $DIR/issue-80074.rs:13:5 + | +LL | foo!(); + | ^^^ + | + = 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 #120192 <https://github.com/rust-lang/rust/issues/120192> + = note: `#[deny(private_macro_use)]` on by default + diff --git a/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.rs b/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.rs index 81b7fe3db2b..91caba81cb6 100644 --- a/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.rs +++ b/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.rs @@ -4,7 +4,7 @@ // FIXME(jdonszelmann): empty attributes are currently ignored, since when its empty no actual // change is applied. This should be fixed when later moving this check to attribute parsing. #[allow_internal_unstable(something)] //~ ERROR allow_internal_unstable side-steps -//~| ERROR attribute should +//~| ERROR attribute cannot be used on struct S; fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.stderr b/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.stderr index 076f2df28e3..cb8cf29e99d 100644 --- a/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.stderr +++ b/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.stderr @@ -7,14 +7,13 @@ LL | #[allow_internal_unstable(something)] = help: add `#![feature(allow_internal_unstable)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: attribute should be applied to a macro +error: `#[allow_internal_unstable]` attribute cannot be used on structs --> $DIR/feature-gate-allow-internal-unstable-struct.rs:6:1 | LL | #[allow_internal_unstable(something)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | struct S; - | --------- not a macro + | + = help: `#[allow_internal_unstable]` can be applied to macro defs, functions error: aborting due to 2 previous errors diff --git a/tests/ui/feature-gates/feature-gate-macro-attr.rs b/tests/ui/feature-gates/feature-gate-macro-attr.rs new file mode 100644 index 00000000000..8419d851147 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-macro-attr.rs @@ -0,0 +1,4 @@ +#![crate_type = "lib"] + +macro_rules! myattr { attr() {} => {} } +//~^ ERROR `macro_rules!` attributes are unstable diff --git a/tests/ui/feature-gates/feature-gate-macro-attr.stderr b/tests/ui/feature-gates/feature-gate-macro-attr.stderr new file mode 100644 index 00000000000..b58418527c5 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-macro-attr.stderr @@ -0,0 +1,13 @@ +error[E0658]: `macro_rules!` attributes are unstable + --> $DIR/feature-gate-macro-attr.rs:3:1 + | +LL | macro_rules! myattr { attr() {} => {} } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information + = help: add `#![feature(macro_attr)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-optimize_attribute.stderr b/tests/ui/feature-gates/feature-gate-optimize_attribute.stderr index e7e62b4f989..646abf8e4a1 100644 --- a/tests/ui/feature-gates/feature-gate-optimize_attribute.stderr +++ b/tests/ui/feature-gates/feature-gate-optimize_attribute.stderr @@ -43,9 +43,20 @@ error[E0539]: malformed `optimize` attribute input | LL | #[optimize(banana)] | ^^^^^^^^^^^------^^ - | | | - | | valid arguments are `size`, `speed` or `none` - | help: must be of the form: `#[optimize(size|speed|none)]` + | | + | valid arguments are `size`, `speed` or `none` + | +help: try changing it to one of the following valid forms of the attribute + | +LL - #[optimize(banana)] +LL + #[optimize(none)] + | +LL - #[optimize(banana)] +LL + #[optimize(size)] + | +LL - #[optimize(banana)] +LL + #[optimize(speed)] + | error: aborting due to 5 previous errors diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs index 7fb11b7bde7..130dd48b0fe 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs +++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs @@ -1,6 +1,4 @@ //~ NOTE: not an `extern crate` item -//~^ NOTE: not a free function, impl method or static -//~^^ NOTE: not a function or closure // This is testing whether various builtin attributes signals an // error or warning when put in "weird" places. // @@ -19,29 +17,25 @@ #![repr()] //~^ ERROR: `repr` attribute cannot be used at crate level #![path = "3800"] -//~^ ERROR: `path` attribute cannot be used at crate level +//~^ ERROR: attribute cannot be used on #![automatically_derived] -//~^ ERROR: `automatically_derived` attribute cannot be used at crate level +//~^ ERROR: attribute cannot be used on #![no_mangle] #![no_link] //~^ ERROR: attribute should be applied to an `extern crate` item #![export_name = "2200"] -//~^ ERROR: attribute should be applied to a free function, impl method or static +//~^ ERROR: attribute cannot be used on #![inline] -//~^ ERROR: attribute should be applied to function or closure +//~^ ERROR: attribute cannot be used on #[inline] -//~^ ERROR attribute should be applied to function or closure +//~^ ERROR attribute cannot be used on mod inline { - //~^ NOTE not a function or closure - //~| NOTE the inner attribute doesn't annotate this module - //~| NOTE the inner attribute doesn't annotate this module - //~| NOTE the inner attribute doesn't annotate this module + //~^ NOTE the inner attribute doesn't annotate this module //~| NOTE the inner attribute doesn't annotate this module //~| NOTE the inner attribute doesn't annotate this module mod inner { #![inline] } - //~^ ERROR attribute should be applied to function or closure - //~| NOTE not a function or closure + //~^ ERROR attribute cannot be used on #[inline = "2100"] fn f() { } //~^ ERROR valid forms for the attribute are @@ -50,16 +44,13 @@ mod inline { //~| NOTE for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> #[inline] struct S; - //~^ ERROR attribute should be applied to function or closure - //~| NOTE not a function or closure + //~^ ERROR attribute cannot be used on #[inline] type T = S; - //~^ ERROR attribute should be applied to function or closure - //~| NOTE not a function or closure + //~^ ERROR attribute cannot be used on #[inline] impl S { } - //~^ ERROR attribute should be applied to function or closure - //~| NOTE not a function or closure + //~^ ERROR attribute cannot be used on } #[no_link] @@ -89,36 +80,27 @@ mod no_link { } #[export_name = "2200"] -//~^ ERROR attribute should be applied to a free function, impl method or static +//~^ ERROR attribute cannot be used on mod export_name { - //~^ NOTE not a free function, impl method or static - mod inner { #![export_name="2200"] } - //~^ ERROR attribute should be applied to a free function, impl method or static - //~| NOTE not a free function, impl method or static + //~^ ERROR attribute cannot be used on #[export_name = "2200"] fn f() { } #[export_name = "2200"] struct S; - //~^ ERROR attribute should be applied to a free function, impl method or static - //~| NOTE not a free function, impl method or static + //~^ ERROR attribute cannot be used on #[export_name = "2200"] type T = S; - //~^ ERROR attribute should be applied to a free function, impl method or static - //~| NOTE not a free function, impl method or static + //~^ ERROR attribute cannot be used on #[export_name = "2200"] impl S { } - //~^ ERROR attribute should be applied to a free function, impl method or static - //~| NOTE not a free function, impl method or static + //~^ ERROR attribute cannot be used on trait Tr { #[export_name = "2200"] fn foo(); - //~^ ERROR attribute should be applied to a free function, impl method or static - //~| NOTE not a free function, impl method or static + //~^ ERROR attribute cannot be used on #[export_name = "2200"] fn bar() {} - //~^ ERROR attribute should be applied to a free function, impl method or static - //~| NOTE not a free function, impl method or static } } diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr index 4cba54bf67c..13dce72a882 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr +++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr @@ -1,5 +1,5 @@ error[E0658]: use of an internal attribute - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:14:1 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:12:1 | LL | #![rustc_main] | ^^^^^^^^^^^^^^ @@ -8,19 +8,128 @@ LL | #![rustc_main] = note: the `#[rustc_main]` attribute is an internal implementation detail that will never be stable = note: the `#[rustc_main]` attribute is used internally to specify test entry point function -error[E0518]: attribute should be applied to function or closure - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:32:1 +error: `#[path]` attribute cannot be used on crates + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:19:1 | -LL | #[inline] - | ^^^^^^^^^ -LL | -LL | / mod inline { -... | -LL | | } - | |_- not a function or closure +LL | #![path = "3800"] + | ^^^^^^^^^^^^^^^^^ + | + = help: `#[path]` can only be applied to modules + +error: `#[automatically_derived]` attribute cannot be used on crates + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:21:1 + | +LL | #![automatically_derived] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[automatically_derived]` can only be applied to trait impl blocks + +error: `#[export_name]` attribute cannot be used on crates + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:26:1 + | +LL | #![export_name = "2200"] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[export_name]` can be applied to functions, statics + +error: `#[inline]` attribute cannot be used on crates + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:28:1 + | +LL | #![inline] + | ^^^^^^^^^^ + | + = help: `#[inline]` can only be applied to functions + +error: `#[inline]` attribute cannot be used on modules + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:30:1 + | +LL | #[inline] + | ^^^^^^^^^ + | + = help: `#[inline]` can only be applied to functions + +error: `#[inline]` attribute cannot be used on modules + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:37:17 + | +LL | mod inner { #![inline] } + | ^^^^^^^^^^ + | + = help: `#[inline]` can only be applied to functions + +error: `#[inline]` attribute cannot be used on structs + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:46:5 + | +LL | #[inline] struct S; + | ^^^^^^^^^ + | + = help: `#[inline]` can only be applied to functions + +error: `#[inline]` attribute cannot be used on type aliases + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:49:5 + | +LL | #[inline] type T = S; + | ^^^^^^^^^ + | + = help: `#[inline]` can only be applied to functions + +error: `#[inline]` attribute cannot be used on inherent impl blocks + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:52:5 + | +LL | #[inline] impl S { } + | ^^^^^^^^^ + | + = help: `#[inline]` can only be applied to functions + +error: `#[export_name]` attribute cannot be used on modules + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:82:1 + | +LL | #[export_name = "2200"] + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[export_name]` can be applied to functions, statics + +error: `#[export_name]` attribute cannot be used on modules + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:85:17 + | +LL | mod inner { #![export_name="2200"] } + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[export_name]` can be applied to functions, statics + +error: `#[export_name]` attribute cannot be used on structs + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:90:5 + | +LL | #[export_name = "2200"] struct S; + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[export_name]` can be applied to functions, statics + +error: `#[export_name]` attribute cannot be used on type aliases + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:93:5 + | +LL | #[export_name = "2200"] type T = S; + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[export_name]` can be applied to functions, statics + +error: `#[export_name]` attribute cannot be used on inherent impl blocks + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:96:5 + | +LL | #[export_name = "2200"] impl S { } + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[export_name]` can be applied to functions, statics + +error: `#[export_name]` attribute cannot be used on required trait methods + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:100:9 + | +LL | #[export_name = "2200"] fn foo(); + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[export_name]` can be applied to statics, functions, inherent methods, provided trait methods, trait methods in impl blocks error: attribute should be applied to an `extern crate` item - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:65:1 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:56:1 | LL | #[no_link] | ^^^^^^^^^^ @@ -33,22 +142,8 @@ LL | | mod inner { #![no_link] } LL | | } | |_- not an `extern crate` item -error: attribute should be applied to a free function, impl method or static - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:91:1 - | -LL | #[export_name = "2200"] - | ^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | / mod export_name { -LL | | -LL | | -LL | | mod inner { #![export_name="2200"] } -... | -LL | | } - | |_- not a free function, impl method or static - error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:125:8 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:107:8 | LL | #[repr(C)] | ^ @@ -61,7 +156,7 @@ LL | | } | |_- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:149:8 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:131:8 | LL | #[repr(Rust)] | ^^^^ @@ -74,25 +169,13 @@ LL | | } | |_- not a struct, enum, or union error: attribute should be applied to an `extern crate` item - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:26:1 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:24:1 | LL | #![no_link] | ^^^^^^^^^^^ not an `extern crate` item -error: attribute should be applied to a free function, impl method or static - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:28:1 - | -LL | #![export_name = "2200"] - | ^^^^^^^^^^^^^^^^^^^^^^^^ not a free function, impl method or static - -error[E0518]: attribute should be applied to function or closure - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:30:1 - | -LL | #![inline] - | ^^^^^^^^^^ not a function or closure - error: `macro_export` attribute cannot be used at crate level - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:12:1 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:10:1 | LL | #![macro_export] | ^^^^^^^^^^^^^^^^ @@ -107,7 +190,7 @@ LL + #[macro_export] | error: `rustc_main` attribute cannot be used at crate level - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:14:1 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:12:1 | LL | #![rustc_main] | ^^^^^^^^^^^^^^ @@ -122,7 +205,7 @@ LL + #[rustc_main] | error: `repr` attribute cannot be used at crate level - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:19:1 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:17:1 | LL | #![repr()] | ^^^^^^^^^^ @@ -136,176 +219,86 @@ LL - #![repr()] LL + #[repr()] | -error: `path` attribute cannot be used at crate level - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:21:1 - | -LL | #![path = "3800"] - | ^^^^^^^^^^^^^^^^^ -... -LL | mod inline { - | ------ the inner attribute doesn't annotate this module - | -help: perhaps you meant to use an outer attribute - | -LL - #![path = "3800"] -LL + #[path = "3800"] - | - -error: `automatically_derived` attribute cannot be used at crate level - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:23:1 - | -LL | #![automatically_derived] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -... -LL | mod inline { - | ------ the inner attribute doesn't annotate this module - | -help: perhaps you meant to use an outer attribute - | -LL - #![automatically_derived] -LL + #[automatically_derived] - | - -error[E0518]: attribute should be applied to function or closure - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:42:17 - | -LL | mod inner { #![inline] } - | ------------^^^^^^^^^^-- not a function or closure - -error[E0518]: attribute should be applied to function or closure - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:52:5 - | -LL | #[inline] struct S; - | ^^^^^^^^^ --------- not a function or closure - -error[E0518]: attribute should be applied to function or closure - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:56:5 - | -LL | #[inline] type T = S; - | ^^^^^^^^^ ----------- not a function or closure - -error[E0518]: attribute should be applied to function or closure - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:60:5 - | -LL | #[inline] impl S { } - | ^^^^^^^^^ ---------- not a function or closure - error: attribute should be applied to an `extern crate` item - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:70:17 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:61:17 | LL | mod inner { #![no_link] } | ------------^^^^^^^^^^^-- not an `extern crate` item error: attribute should be applied to an `extern crate` item - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:74:5 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:65:5 | LL | #[no_link] fn f() { } | ^^^^^^^^^^ ---------- not an `extern crate` item error: attribute should be applied to an `extern crate` item - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:78:5 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:69:5 | LL | #[no_link] struct S; | ^^^^^^^^^^ --------- not an `extern crate` item error: attribute should be applied to an `extern crate` item - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:82:5 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:73:5 | LL | #[no_link]type T = S; | ^^^^^^^^^^----------- not an `extern crate` item error: attribute should be applied to an `extern crate` item - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:86:5 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:77:5 | LL | #[no_link] impl S { } | ^^^^^^^^^^ ---------- not an `extern crate` item -error: attribute should be applied to a free function, impl method or static - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:96:17 - | -LL | mod inner { #![export_name="2200"] } - | ------------^^^^^^^^^^^^^^^^^^^^^^-- not a free function, impl method or static - -error: attribute should be applied to a free function, impl method or static - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:102:5 - | -LL | #[export_name = "2200"] struct S; - | ^^^^^^^^^^^^^^^^^^^^^^^ --------- not a free function, impl method or static - -error: attribute should be applied to a free function, impl method or static - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:106:5 - | -LL | #[export_name = "2200"] type T = S; - | ^^^^^^^^^^^^^^^^^^^^^^^ ----------- not a free function, impl method or static - -error: attribute should be applied to a free function, impl method or static - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:110:5 - | -LL | #[export_name = "2200"] impl S { } - | ^^^^^^^^^^^^^^^^^^^^^^^ ---------- not a free function, impl method or static - -error: attribute should be applied to a free function, impl method or static - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:115:9 - | -LL | #[export_name = "2200"] fn foo(); - | ^^^^^^^^^^^^^^^^^^^^^^^ --------- not a free function, impl method or static - -error: attribute should be applied to a free function, impl method or static - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:119:9 - | -LL | #[export_name = "2200"] fn bar() {} - | ^^^^^^^^^^^^^^^^^^^^^^^ ----------- not a free function, impl method or static - error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:129:25 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:111:25 | LL | mod inner { #![repr(C)] } | --------------------^---- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:133:12 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:115:12 | LL | #[repr(C)] fn f() { } | ^ ---------- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:139:12 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:121:12 | LL | #[repr(C)] type T = S; | ^ ----------- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:143:12 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:125:12 | LL | #[repr(C)] impl S { } | ^ ---------- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:153:25 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:135:25 | LL | mod inner { #![repr(Rust)] } | --------------------^^^^---- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:157:12 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:139:12 | LL | #[repr(Rust)] fn f() { } | ^^^^ ---------- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:163:12 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:145:12 | LL | #[repr(Rust)] type T = S; | ^^^^ ----------- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:167:12 + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:149:12 | LL | #[repr(Rust)] impl S { } | ^^^^ ---------- not a struct, enum, or union -error: valid forms for the attribute are `#[inline(always|never)]` and `#[inline]` - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:46:5 +error: valid forms for the attribute are `#[inline(always)]`, `#[inline(never)]`, and `#[inline]` + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:40:5 | LL | #[inline = "2100"] fn f() { } | ^^^^^^^^^^^^^^^^^^ @@ -314,7 +307,18 @@ LL | #[inline = "2100"] fn f() { } = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> = note: `#[deny(ill_formed_attribute_input)]` on by default -error: aborting due to 38 previous errors +error: aborting due to 37 previous errors -Some errors have detailed explanations: E0517, E0518, E0658. +Some errors have detailed explanations: E0517, E0658. For more information about an error, try `rustc --explain E0517`. +Future incompatibility report: Future breakage diagnostic: +error: valid forms for the attribute are `#[inline(always)]`, `#[inline(never)]`, and `#[inline]` + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:40:5 + | +LL | #[inline = "2100"] fn f() { } + | ^^^^^^^^^^^^^^^^^^ + | + = 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 #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: `#[deny(ill_formed_attribute_input)]` on by default + diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs index b93cb2ea006..8702d852a89 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs +++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs @@ -1,7 +1,4 @@ -//~ NOTE not a function -//~| NOTE not a foreign function or static -//~| NOTE cannot be applied to crates -//~| NOTE not an `extern` block +//~ NOTE not an `extern` block // This test enumerates as many compiler-builtin ungated attributes as // possible (that is, all the mutually compatible ones), and checks // that we get "expected" (*) warnings for each in the various weird @@ -50,27 +47,37 @@ #![macro_use] // (allowed if no argument; see issue-43160-gating-of-macro_use.rs) // skipping testing of cfg // skipping testing of cfg_attr -#![should_panic] //~ WARN `#[should_panic]` only has an effect -#![ignore] //~ WARN `#[ignore]` only has an effect on functions +#![should_panic] //~ WARN attribute cannot be used on +//~| WARN previously accepted +//~| HELP can only be applied to +#![ignore] //~ WARN attribute cannot be used on +//~| WARN previously accepted +//~| HELP can only be applied to #![no_implicit_prelude] #![reexport_test_harness_main = "2900"] // see gated-link-args.rs // see issue-43106-gating-of-macro_escape.rs for crate-level; but non crate-level is below at "2700" // (cannot easily test gating of crate-level #[no_std]; but non crate-level is below at "2600") -#![proc_macro_derive(Test)] //~ WARN `#[proc_macro_derive]` only has an effect +#![proc_macro_derive(Test)] //~ WARN attribute cannot be used on +//~| WARN previously accepted +//~| HELP can only be applied to #![doc = "2400"] -#![cold] //~ WARN attribute should be applied to a function -//~^ WARN this was previously accepted +#![cold] //~ WARN attribute cannot be used on +//~| WARN previously accepted +//~| HELP can only be applied to #![link()] //~ WARN attribute should be applied to an `extern` block //~^ WARN this was previously accepted #![link_name = "1900"] -//~^ WARN attribute should be applied to a foreign function -//~^^ WARN this was previously accepted by the compiler +//~^ WARN attribute cannot be used on +//~| WARN previously accepted +//~| HELP can be applied to #![link_section = "1800"] -//~^ WARN attribute should be applied to a function or static -//~^^ WARN this was previously accepted by the compiler +//~^ WARN attribute cannot be used on +//~| WARN previously accepted +//~| HELP can be applied to #![must_use] //~^ WARN `#[must_use]` has no effect +//~| HELP remove the attribute // see issue-43106-gating-of-stable.rs // see issue-43106-gating-of-unstable.rs // see issue-43106-gating-of-deprecated.rs @@ -174,16 +181,24 @@ mod macro_use { mod inner { #![macro_use] } #[macro_use] fn f() { } - //~^ WARN `#[macro_use]` only has an effect + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can be applied to #[macro_use] struct S; - //~^ WARN `#[macro_use]` only has an effect + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can be applied to #[macro_use] type T = S; - //~^ WARN `#[macro_use]` only has an effect + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can be applied to #[macro_use] impl S { } - //~^ WARN `#[macro_use]` only has an effect + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can be applied to } #[macro_export] @@ -242,116 +257,158 @@ mod path { mod inner { #![path="3800"] } #[path = "3800"] fn f() { } - //~^ WARN `#[path]` only has an effect + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can only be applied to #[path = "3800"] struct S; - //~^ WARN `#[path]` only has an effect + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can only be applied to #[path = "3800"] type T = S; - //~^ WARN `#[path]` only has an effect + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can only be applied to #[path = "3800"] impl S { } - //~^ WARN `#[path]` only has an effect + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can only be applied to } #[automatically_derived] -//~^ WARN `#[automatically_derived]` only has an effect +//~^ WARN attribute cannot be used on +//~| WARN previously accepted +//~| HELP can only be applied to mod automatically_derived { mod inner { #![automatically_derived] } - //~^ WARN `#[automatically_derived] + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can only be applied to #[automatically_derived] fn f() { } - //~^ WARN `#[automatically_derived] + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can only be applied to #[automatically_derived] struct S; - //~^ WARN `#[automatically_derived] + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can only be applied to #[automatically_derived] type T = S; - //~^ WARN `#[automatically_derived] + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can only be applied to #[automatically_derived] trait W { } - //~^ WARN `#[automatically_derived] + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can only be applied to #[automatically_derived] impl S { } - //~^ WARN `#[automatically_derived] + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can only be applied to #[automatically_derived] impl W for S { } } #[no_mangle] -//~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes] -//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +//~^ WARN attribute cannot be used on +//~| WARN previously accepted +//~| HELP can be applied to mod no_mangle { - //~^ NOTE not a free function, impl method or static mod inner { #![no_mangle] } - //~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes] - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - //~| NOTE not a free function, impl method or static + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can be applied to #[no_mangle] fn f() { } #[no_mangle] struct S; - //~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes] - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - //~| NOTE not a free function, impl method or static + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can be applied to #[no_mangle] type T = S; - //~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes] - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - //~| NOTE not a free function, impl method or static + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can be applied to #[no_mangle] impl S { } - //~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes] - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - //~| NOTE not a free function, impl method or static + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can be applied to trait Tr { #[no_mangle] fn foo(); - //~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes] - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - //~| NOTE not a free function, impl method or static + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can be applied to #[no_mangle] fn bar() {} - //~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes] - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - //~| NOTE not a free function, impl method or static + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can be applied to } } #[should_panic] -//~^ WARN `#[should_panic]` only has an effect on +//~^ WARN attribute cannot be used on +//~| WARN previously accepted +//~| HELP can only be applied to mod should_panic { mod inner { #![should_panic] } - //~^ WARN `#[should_panic]` only has an effect on + //~^ WARN attribute cannot be used on + //~| WARN previously accepted + //~| HELP can only be applied to #[should_panic] fn f() { } #[should_panic] struct S; - //~^ WARN `#[should_panic]` only has an effect on + //~^ WARN attribute cannot be used on + //~| WARN previously accepted + //~| HELP can only be applied to #[should_panic] type T = S; - //~^ WARN `#[should_panic]` only has an effect on + //~^ WARN attribute cannot be used on + //~| WARN previously accepted + //~| HELP can only be applied to #[should_panic] impl S { } - //~^ WARN `#[should_panic]` only has an effect on + //~^ WARN attribute cannot be used on + //~| WARN previously accepted + //~| HELP can only be applied to } #[ignore] -//~^ WARN `#[ignore]` only has an effect on functions +//~^ WARN attribute cannot be used on +//~| WARN previously accepted +//~| HELP can only be applied to mod ignore { mod inner { #![ignore] } - //~^ WARN `#[ignore]` only has an effect on functions + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can only be applied to #[ignore] fn f() { } #[ignore] struct S; - //~^ WARN `#[ignore]` only has an effect on functions + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can only be applied to #[ignore] type T = S; - //~^ WARN `#[ignore]` only has an effect on functions + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can only be applied to #[ignore] impl S { } - //~^ WARN `#[ignore]` only has an effect on functions + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can only be applied to } #[no_implicit_prelude] @@ -359,16 +416,24 @@ mod no_implicit_prelude { mod inner { #![no_implicit_prelude] } #[no_implicit_prelude] fn f() { } - //~^ WARN `#[no_implicit_prelude]` only has an effect + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can be applied to #[no_implicit_prelude] struct S; - //~^ WARN `#[no_implicit_prelude]` only has an effect + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can be applied to #[no_implicit_prelude] type T = S; - //~^ WARN `#[no_implicit_prelude]` only has an effect + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can be applied to #[no_implicit_prelude] impl S { } - //~^ WARN `#[no_implicit_prelude]` only has an effect + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can be applied to } #[reexport_test_harness_main = "2900"] @@ -399,16 +464,24 @@ mod macro_escape { //~| HELP try an outer attribute: `#[macro_use]` #[macro_escape] fn f() { } - //~^ WARN `#[macro_escape]` only has an effect + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can be applied to #[macro_escape] struct S; - //~^ WARN `#[macro_escape]` only has an effect + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can be applied to #[macro_escape] type T = S; - //~^ WARN `#[macro_escape]` only has an effect + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can be applied to #[macro_escape] impl S { } - //~^ WARN `#[macro_escape]` only has an effect + //~^ WARN attribute cannot be used on +//~| WARN previously accepted + //~| HELP can be applied to } #[no_std] @@ -448,100 +521,97 @@ mod doc { } #[cold] -//~^ WARN attribute should be applied to a function -//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +//~^ WARN attribute cannot be used on +//~| WARN previously accepted +//~| HELP can only be applied to mod cold { - //~^ NOTE not a function mod inner { #![cold] } - //~^ WARN attribute should be applied to a function - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - //~| NOTE not a function + //~^ WARN attribute cannot be used on + //~| WARN previously accepted + //~| HELP can only be applied to #[cold] fn f() { } #[cold] struct S; - //~^ WARN attribute should be applied to a function - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - //~| NOTE not a function + //~^ WARN attribute cannot be used on + //~| WARN previously accepted + //~| HELP can only be applied to #[cold] type T = S; - //~^ WARN attribute should be applied to a function - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - //~| NOTE not a function + //~^ WARN attribute cannot be used on + //~| WARN previously accepted + //~| HELP can only be applied to #[cold] impl S { } - //~^ WARN attribute should be applied to a function - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - //~| NOTE not a function + //~^ WARN attribute cannot be used on + //~| WARN previously accepted + //~| HELP can only be applied to } #[link_name = "1900"] -//~^ WARN attribute should be applied to a foreign function or static [unused_attributes] -//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +//~^ WARN attribute cannot be used on +//~| WARN previously accepted +//~| HELP can be applied to mod link_name { - //~^ NOTE not a foreign function or static - #[link_name = "1900"] - //~^ WARN attribute should be applied to a foreign function or static [unused_attributes] - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - //~| HELP try `#[link(name = "1900")]` instead + //~^ WARN attribute cannot be used on + //~| WARN previously accepted + //~| HELP can be applied to extern "C" { } - //~^ NOTE not a foreign function or static mod inner { #![link_name="1900"] } - //~^ WARN attribute should be applied to a foreign function or static [unused_attributes] - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - //~| NOTE not a foreign function or static + //~^ WARN attribute cannot be used on + //~| WARN previously accepted + //~| HELP can be applied to #[link_name = "1900"] fn f() { } - //~^ WARN attribute should be applied to a foreign function or static [unused_attributes] - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - //~| NOTE not a foreign function or static + //~^ WARN attribute cannot be used on + //~| WARN previously accepted + //~| HELP can be applied to #[link_name = "1900"] struct S; - //~^ WARN attribute should be applied to a foreign function or static [unused_attributes] - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - //~| NOTE not a foreign function or static + //~^ WARN attribute cannot be used on + //~| WARN previously accepted + //~| HELP can be applied to #[link_name = "1900"] type T = S; - //~^ WARN attribute should be applied to a foreign function or static [unused_attributes] - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - //~| NOTE not a foreign function or static + //~^ WARN attribute cannot be used on + //~| WARN previously accepted + //~| HELP can be applied to #[link_name = "1900"] impl S { } - //~^ WARN attribute should be applied to a foreign function or static [unused_attributes] - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - //~| NOTE not a foreign function or static + //~^ WARN attribute cannot be used on + //~| WARN previously accepted + //~| HELP can be applied to } #[link_section = "1800"] -//~^ WARN attribute should be applied to a function or static [unused_attributes] -//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +//~^ WARN attribute cannot be used on +//~| WARN previously accepted +//~| HELP can be applied to mod link_section { - //~^ NOTE not a function or static - mod inner { #![link_section="1800"] } - //~^ WARN attribute should be applied to a function or static [unused_attributes] - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - //~| NOTE not a function or static + //~^ WARN attribute cannot be used on + //~| WARN previously accepted + //~| HELP can be applied to #[link_section = "1800"] fn f() { } #[link_section = "1800"] struct S; - //~^ WARN attribute should be applied to a function or static [unused_attributes] - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - //~| NOTE not a function or static + //~^ WARN attribute cannot be used on + //~| WARN previously accepted + //~| HELP can be applied to #[link_section = "1800"] type T = S; - //~^ WARN attribute should be applied to a function or static [unused_attributes] - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - //~| NOTE not a function or static + //~^ WARN attribute cannot be used on + //~| WARN previously accepted + //~| HELP can be applied to #[link_section = "1800"] impl S { } - //~^ WARN attribute should be applied to a function or static [unused_attributes] - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - //~| NOTE not a function or static + //~^ WARN attribute cannot be used on + //~| WARN previously accepted + //~| HELP can be applied to } @@ -599,16 +669,20 @@ mod deprecated { } #[must_use] //~ WARN `#[must_use]` has no effect +//~^ HELP remove the attribute mod must_use { mod inner { #![must_use] } //~ WARN `#[must_use]` has no effect + //~^ HELP remove the attribute #[must_use] fn f() { } #[must_use] struct S; #[must_use] type T = S; //~ WARN `#[must_use]` has no effect + //~^ HELP remove the attribute #[must_use] impl S { } //~ WARN `#[must_use]` has no effect + //~^ HELP remove the attribute } #[windows_subsystem = "windows"] diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr index 8bac1f6155e..8e2bffb91ca 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr +++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr @@ -1,5 +1,5 @@ warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:397:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:462:17 | LL | mod inner { #![macro_escape] } | ^^^^^^^^^^^^^^^^ @@ -7,292 +7,211 @@ LL | mod inner { #![macro_escape] } = help: try an outer attribute: `#[macro_use]` warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:394:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:459:1 | LL | #[macro_escape] | ^^^^^^^^^^^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:46:9 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:43:9 | LL | #![warn(x5400)] | ^^^^^ | note: the lint level is defined here - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:40:28 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:37:28 | LL | #![warn(unused_attributes, unknown_lints)] | ^^^^^^^^^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:47:10 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:44:10 | LL | #![allow(x5300)] | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:48:11 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:45:11 | LL | #![forbid(x5200)] | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:49:9 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:46:9 | LL | #![deny(x5100)] | ^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:96:8 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:103:8 | LL | #[warn(x5400)] | ^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:99:25 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:106:25 | LL | mod inner { #![warn(x5400)] } | ^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:102:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:109:12 | LL | #[warn(x5400)] fn f() { } | ^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:105:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:112:12 | LL | #[warn(x5400)] struct S; | ^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:108:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:115:12 | LL | #[warn(x5400)] type T = S; | ^^^^^ warning: unknown lint: `x5400` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:111:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:118:12 | LL | #[warn(x5400)] impl S { } | ^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:115:9 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:122:9 | LL | #[allow(x5300)] | ^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:118:26 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:125:26 | LL | mod inner { #![allow(x5300)] } | ^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:121:13 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:128:13 | LL | #[allow(x5300)] fn f() { } | ^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:124:13 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:131:13 | LL | #[allow(x5300)] struct S; | ^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:127:13 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:134:13 | LL | #[allow(x5300)] type T = S; | ^^^^^ warning: unknown lint: `x5300` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:130:13 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:137:13 | LL | #[allow(x5300)] impl S { } | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:134:10 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:141:10 | LL | #[forbid(x5200)] | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:137:27 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:144:27 | LL | mod inner { #![forbid(x5200)] } | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:140:14 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:147:14 | LL | #[forbid(x5200)] fn f() { } | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:143:14 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:150:14 | LL | #[forbid(x5200)] struct S; | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:146:14 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:153:14 | LL | #[forbid(x5200)] type T = S; | ^^^^^ warning: unknown lint: `x5200` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:149:14 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:156:14 | LL | #[forbid(x5200)] impl S { } | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:153:8 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:160:8 | LL | #[deny(x5100)] | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:156:25 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:163:25 | LL | mod inner { #![deny(x5100)] } | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:159:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:166:12 | LL | #[deny(x5100)] fn f() { } | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:162:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:169:12 | LL | #[deny(x5100)] struct S; | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:165:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:172:12 | LL | #[deny(x5100)] type T = S; | ^^^^^ warning: unknown lint: `x5100` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:168:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:175:12 | LL | #[deny(x5100)] impl S { } | ^^^^^ warning: `#[macro_export]` only has an effect on macro definitions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:189:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:204:1 | LL | #[macro_export] | ^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:40:9 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:37:9 | LL | #![warn(unused_attributes, unknown_lints)] | ^^^^^^^^^^^^^^^^^ -warning: `#[automatically_derived]` only has an effect on trait implementation blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:257:1 - | -LL | #[automatically_derived] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: attribute should be applied to a free function, impl method or static - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:281:1 - | -LL | #[no_mangle] - | ^^^^^^^^^^^^ -... -LL | / mod no_mangle { -LL | | -LL | | mod inner { #![no_mangle] } -... | -LL | | } - | |_- not a free function, impl method or static - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -warning: `#[should_panic]` only has an effect on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:321:1 - | -LL | #[should_panic] - | ^^^^^^^^^^^^^^^ - -warning: `#[ignore]` only has an effect on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:339:1 - | -LL | #[ignore] - | ^^^^^^^^^ - warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:374:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:439:1 | LL | #[reexport_test_harness_main = "2900"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:414:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:487:1 | LL | #[no_std] | ^^^^^^^^^ -warning: attribute should be applied to a function definition - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:450:1 - | -LL | #[cold] - | ^^^^^^^ -... -LL | / mod cold { -LL | | -LL | | -LL | | mod inner { #![cold] } -... | -LL | | } - | |_- not a function definition - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -warning: attribute should be applied to a foreign function or static - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:479:1 - | -LL | #[link_name = "1900"] - | ^^^^^^^^^^^^^^^^^^^^^ -... -LL | / mod link_name { -LL | | -LL | | -LL | | #[link_name = "1900"] -... | -LL | | } - | |_- not a foreign function or static - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -warning: attribute should be applied to a function or static - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:518:1 - | -LL | #[link_section = "1800"] - | ^^^^^^^^^^^^^^^^^^^^^^^^ -... -LL | / mod link_section { -LL | | -LL | | -LL | | mod inner { #![link_section="1800"] } -... | -LL | | } - | |_- not a function or static - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:550:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:620:1 | LL | #[link()] | ^^^^^^^^^ @@ -307,564 +226,174 @@ LL | | } | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: `#[must_use]` has no effect when applied to a module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:601:1 +warning: `#[must_use]` has no effect when applied to modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:671:1 | LL | #[must_use] | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:614:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:688:1 | LL | #[windows_subsystem = "windows"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:635:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:709:1 | LL | #[crate_name = "0900"] | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:654:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:728:1 | LL | #[crate_type = "0800"] | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:673:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:747:1 | LL | #[feature(x0600)] | ^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:693:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:767:1 | LL | #[no_main] | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:712:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:786:1 | LL | #[no_builtins] | ^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:731:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:805:1 | LL | #[recursion_limit="0200"] | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:750:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:824:1 | LL | #[type_length_limit="0100"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: `#[should_panic]` only has an effect on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:53:1 - | -LL | #![should_panic] - | ^^^^^^^^^^^^^^^^ - warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:64:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:68:1 | LL | #![link()] | ^^^^^^^^^^ not an `extern` block | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: `#[ignore]` only has an effect on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:54:1 - | -LL | #![ignore] - | ^^^^^^^^^^ - -warning: attribute should be applied to a foreign function or static - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:66:1 - | -LL | #![link_name = "1900"] - | ^^^^^^^^^^^^^^^^^^^^^^ not a foreign function or static - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -warning: attribute should be applied to a function or static - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:69:1 - | -LL | #![link_section = "1800"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ not a function or static - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -warning: `#[must_use]` has no effect when applied to a module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:72:1 +warning: `#[must_use]` has no effect when applied to modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:78:1 | LL | #![must_use] | ^^^^^^^^^^^^ -warning: `#[proc_macro_derive]` only has an effect on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:60:1 - | -LL | #![proc_macro_derive(Test)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: attribute should be applied to a function definition - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:62:1 - | -LL | #![cold] - | ^^^^^^^^ cannot be applied to crates - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - warning: the feature `rust1` has been stable since 1.0.0 and no longer requires an attribute to enable - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:85:12 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:92:12 | LL | #![feature(rust1)] | ^^^^^ | = note: `#[warn(stable_features)]` on by default -warning: `#[macro_use]` only has an effect on `extern crate` and modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:176:5 - | -LL | #[macro_use] fn f() { } - | ^^^^^^^^^^^^ - -warning: `#[macro_use]` only has an effect on `extern crate` and modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:179:5 - | -LL | #[macro_use] struct S; - | ^^^^^^^^^^^^ - -warning: `#[macro_use]` only has an effect on `extern crate` and modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:182:5 - | -LL | #[macro_use] type T = S; - | ^^^^^^^^^^^^ - -warning: `#[macro_use]` only has an effect on `extern crate` and modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:185:5 - | -LL | #[macro_use] impl S { } - | ^^^^^^^^^^^^ - warning: `#[macro_export]` only has an effect on macro definitions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:192:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:207:17 | LL | mod inner { #![macro_export] } | ^^^^^^^^^^^^^^^^ warning: `#[macro_export]` only has an effect on macro definitions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:195:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:210:5 | LL | #[macro_export] fn f() { } | ^^^^^^^^^^^^^^^ warning: `#[macro_export]` only has an effect on macro definitions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:198:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:213:5 | LL | #[macro_export] struct S; | ^^^^^^^^^^^^^^^ warning: `#[macro_export]` only has an effect on macro definitions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:201:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:216:5 | LL | #[macro_export] type T = S; | ^^^^^^^^^^^^^^^ warning: `#[macro_export]` only has an effect on macro definitions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:204:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:219:5 | LL | #[macro_export] impl S { } | ^^^^^^^^^^^^^^^ -warning: `#[path]` only has an effect on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:244:5 - | -LL | #[path = "3800"] fn f() { } - | ^^^^^^^^^^^^^^^^ - -warning: `#[path]` only has an effect on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:247:5 - | -LL | #[path = "3800"] struct S; - | ^^^^^^^^^^^^^^^^ - -warning: `#[path]` only has an effect on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:250:5 - | -LL | #[path = "3800"] type T = S; - | ^^^^^^^^^^^^^^^^ - -warning: `#[path]` only has an effect on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:253:5 - | -LL | #[path = "3800"] impl S { } - | ^^^^^^^^^^^^^^^^ - -warning: `#[automatically_derived]` only has an effect on trait implementation blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:260:17 - | -LL | mod inner { #![automatically_derived] } - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: `#[automatically_derived]` only has an effect on trait implementation blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:263:5 - | -LL | #[automatically_derived] fn f() { } - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: `#[automatically_derived]` only has an effect on trait implementation blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:266:5 - | -LL | #[automatically_derived] struct S; - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: `#[automatically_derived]` only has an effect on trait implementation blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:269:5 - | -LL | #[automatically_derived] type T = S; - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: `#[automatically_derived]` only has an effect on trait implementation blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:272:5 - | -LL | #[automatically_derived] trait W { } - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: `#[automatically_derived]` only has an effect on trait implementation blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:275:5 - | -LL | #[automatically_derived] impl S { } - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: attribute should be applied to a free function, impl method or static - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:286:17 - | -LL | mod inner { #![no_mangle] } - | ------------^^^^^^^^^^^^^-- not a free function, impl method or static - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -warning: attribute should be applied to a free function, impl method or static - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:293:5 - | -LL | #[no_mangle] struct S; - | ^^^^^^^^^^^^ --------- not a free function, impl method or static - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -warning: attribute should be applied to a free function, impl method or static - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:298:5 - | -LL | #[no_mangle] type T = S; - | ^^^^^^^^^^^^ ----------- not a free function, impl method or static - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -warning: attribute should be applied to a free function, impl method or static - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:303:5 - | -LL | #[no_mangle] impl S { } - | ^^^^^^^^^^^^ ---------- not a free function, impl method or static - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -warning: attribute should be applied to a free function, impl method or static - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:309:9 - | -LL | #[no_mangle] fn foo(); - | ^^^^^^^^^^^^ --------- not a free function, impl method or static - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -warning: attribute should be applied to a free function, impl method or static - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:314:9 - | -LL | #[no_mangle] fn bar() {} - | ^^^^^^^^^^^^ ----------- not a free function, impl method or static - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -warning: `#[should_panic]` only has an effect on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:324:17 - | -LL | mod inner { #![should_panic] } - | ^^^^^^^^^^^^^^^^ - -warning: `#[should_panic]` only has an effect on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:329:5 - | -LL | #[should_panic] struct S; - | ^^^^^^^^^^^^^^^ - -warning: `#[should_panic]` only has an effect on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:332:5 - | -LL | #[should_panic] type T = S; - | ^^^^^^^^^^^^^^^ - -warning: `#[should_panic]` only has an effect on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:335:5 - | -LL | #[should_panic] impl S { } - | ^^^^^^^^^^^^^^^ - -warning: `#[ignore]` only has an effect on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:342:17 - | -LL | mod inner { #![ignore] } - | ^^^^^^^^^^ - -warning: `#[ignore]` only has an effect on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:347:5 - | -LL | #[ignore] struct S; - | ^^^^^^^^^ - -warning: `#[ignore]` only has an effect on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:350:5 - | -LL | #[ignore] type T = S; - | ^^^^^^^^^ - -warning: `#[ignore]` only has an effect on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:353:5 - | -LL | #[ignore] impl S { } - | ^^^^^^^^^ - -warning: `#[no_implicit_prelude]` only has an effect on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:361:5 - | -LL | #[no_implicit_prelude] fn f() { } - | ^^^^^^^^^^^^^^^^^^^^^^ - -warning: `#[no_implicit_prelude]` only has an effect on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:364:5 - | -LL | #[no_implicit_prelude] struct S; - | ^^^^^^^^^^^^^^^^^^^^^^ - -warning: `#[no_implicit_prelude]` only has an effect on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:367:5 - | -LL | #[no_implicit_prelude] type T = S; - | ^^^^^^^^^^^^^^^^^^^^^^ - -warning: `#[no_implicit_prelude]` only has an effect on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:370:5 - | -LL | #[no_implicit_prelude] impl S { } - | ^^^^^^^^^^^^^^^^^^^^^^ - warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:377:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:442:17 | LL | mod inner { #![reexport_test_harness_main="2900"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:380:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:445:5 | LL | #[reexport_test_harness_main = "2900"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:383:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:448:5 | LL | #[reexport_test_harness_main = "2900"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:386:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:451:5 | LL | #[reexport_test_harness_main = "2900"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:389:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:454:5 | LL | #[reexport_test_harness_main = "2900"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: `#[macro_escape]` only has an effect on `extern crate` and modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:401:5 - | -LL | #[macro_escape] fn f() { } - | ^^^^^^^^^^^^^^^ - -warning: `#[macro_escape]` only has an effect on `extern crate` and modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:404:5 - | -LL | #[macro_escape] struct S; - | ^^^^^^^^^^^^^^^ - -warning: `#[macro_escape]` only has an effect on `extern crate` and modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:407:5 - | -LL | #[macro_escape] type T = S; - | ^^^^^^^^^^^^^^^ - -warning: `#[macro_escape]` only has an effect on `extern crate` and modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:410:5 - | -LL | #[macro_escape] impl S { } - | ^^^^^^^^^^^^^^^ - warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:417:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:490:17 | LL | mod inner { #![no_std] } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:420:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:493:5 | LL | #[no_std] fn f() { } | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:423:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:496:5 | LL | #[no_std] struct S; | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:426:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:499:5 | LL | #[no_std] type T = S; | ^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:429:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:502:5 | LL | #[no_std] impl S { } | ^^^^^^^^^ -warning: attribute should be applied to a function definition - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:456:17 - | -LL | mod inner { #![cold] } - | ------------^^^^^^^^-- not a function definition - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -warning: attribute should be applied to a function definition - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:463:5 - | -LL | #[cold] struct S; - | ^^^^^^^ --------- not a function definition - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -warning: attribute should be applied to a function definition - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:468:5 - | -LL | #[cold] type T = S; - | ^^^^^^^ ----------- not a function definition - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -warning: attribute should be applied to a function definition - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:473:5 - | -LL | #[cold] impl S { } - | ^^^^^^^ ---------- not a function definition - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -warning: attribute should be applied to a foreign function or static - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:485:5 - | -LL | #[link_name = "1900"] - | ^^^^^^^^^^^^^^^^^^^^^ -... -LL | extern "C" { } - | -------------- not a foreign function or static - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -help: try `#[link(name = "1900")]` instead - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:485:5 - | -LL | #[link_name = "1900"] - | ^^^^^^^^^^^^^^^^^^^^^ - -warning: attribute should be applied to a foreign function or static - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:492:17 - | -LL | mod inner { #![link_name="1900"] } - | ------------^^^^^^^^^^^^^^^^^^^^-- not a foreign function or static - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -warning: attribute should be applied to a foreign function or static - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:497:5 - | -LL | #[link_name = "1900"] fn f() { } - | ^^^^^^^^^^^^^^^^^^^^^ ---------- not a foreign function or static - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -warning: attribute should be applied to a foreign function or static - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:502:5 - | -LL | #[link_name = "1900"] struct S; - | ^^^^^^^^^^^^^^^^^^^^^ --------- not a foreign function or static - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -warning: attribute should be applied to a foreign function or static - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:507:5 - | -LL | #[link_name = "1900"] type T = S; - | ^^^^^^^^^^^^^^^^^^^^^ ----------- not a foreign function or static - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -warning: attribute should be applied to a foreign function or static - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:512:5 - | -LL | #[link_name = "1900"] impl S { } - | ^^^^^^^^^^^^^^^^^^^^^ ---------- not a foreign function or static - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -warning: attribute should be applied to a function or static - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:524:17 - | -LL | mod inner { #![link_section="1800"] } - | ------------^^^^^^^^^^^^^^^^^^^^^^^-- not a function or static - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -warning: attribute should be applied to a function or static - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:531:5 - | -LL | #[link_section = "1800"] struct S; - | ^^^^^^^^^^^^^^^^^^^^^^^^ --------- not a function or static - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -warning: attribute should be applied to a function or static - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:536:5 - | -LL | #[link_section = "1800"] type T = S; - | ^^^^^^^^^^^^^^^^^^^^^^^^ ----------- not a function or static - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -warning: attribute should be applied to a function or static - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:541:5 - | -LL | #[link_section = "1800"] impl S { } - | ^^^^^^^^^^^^^^^^^^^^^^^^ ---------- not a function or static - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:556:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:626:17 | LL | mod inner { #![link()] } | ------------^^^^^^^^^^-- not an `extern` block @@ -872,7 +401,7 @@ LL | mod inner { #![link()] } = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:561:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:631:5 | LL | #[link()] fn f() { } | ^^^^^^^^^ ---------- not an `extern` block @@ -880,7 +409,7 @@ LL | #[link()] fn f() { } = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:566:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:636:5 | LL | #[link()] struct S; | ^^^^^^^^^ --------- not an `extern` block @@ -888,7 +417,7 @@ LL | #[link()] struct S; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:571:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:641:5 | LL | #[link()] type T = S; | ^^^^^^^^^ ----------- not an `extern` block @@ -896,7 +425,7 @@ LL | #[link()] type T = S; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:576:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:646:5 | LL | #[link()] impl S { } | ^^^^^^^^^ ---------- not an `extern` block @@ -904,270 +433,837 @@ LL | #[link()] impl S { } = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:581:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:651:5 | LL | #[link()] extern "Rust" {} | ^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: `#[must_use]` has no effect when applied to a module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:603:17 +warning: `#[must_use]` has no effect when applied to modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:674:17 | LL | mod inner { #![must_use] } | ^^^^^^^^^^^^ -warning: `#[must_use]` has no effect when applied to a type alias - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:609:5 +warning: `#[must_use]` has no effect when applied to type aliases + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:681:5 | LL | #[must_use] type T = S; | ^^^^^^^^^^^ -warning: `#[must_use]` has no effect when applied to an inherent implementation block - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:611:5 +warning: `#[must_use]` has no effect when applied to inherent impl blocks + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:684:5 | LL | #[must_use] impl S { } | ^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:617:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:691:17 | LL | mod inner { #![windows_subsystem="windows"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:620:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:694:5 | LL | #[windows_subsystem = "windows"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:623:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:697:5 | LL | #[windows_subsystem = "windows"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:626:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:700:5 | LL | #[windows_subsystem = "windows"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:629:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:703:5 | LL | #[windows_subsystem = "windows"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:638:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:712:17 | LL | mod inner { #![crate_name="0900"] } | ^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:641:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:715:5 | LL | #[crate_name = "0900"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:644:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:718:5 | LL | #[crate_name = "0900"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:647:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:721:5 | LL | #[crate_name = "0900"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:650:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:724:5 | LL | #[crate_name = "0900"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:657:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:731:17 | LL | mod inner { #![crate_type="0800"] } | ^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:660:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:734:5 | LL | #[crate_type = "0800"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:663:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:737:5 | LL | #[crate_type = "0800"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:666:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:740:5 | LL | #[crate_type = "0800"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:669:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:743:5 | LL | #[crate_type = "0800"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:676:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:750:17 | LL | mod inner { #![feature(x0600)] } | ^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:679:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:753:5 | LL | #[feature(x0600)] fn f() { } | ^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:682:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:756:5 | LL | #[feature(x0600)] struct S; | ^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:685:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:759:5 | LL | #[feature(x0600)] type T = S; | ^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:688:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:762:5 | LL | #[feature(x0600)] impl S { } | ^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:696:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:770:17 | LL | mod inner { #![no_main] } | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:699:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:773:5 | LL | #[no_main] fn f() { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:702:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:776:5 | LL | #[no_main] struct S; | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:705:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:779:5 | LL | #[no_main] type T = S; | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:708:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:782:5 | LL | #[no_main] impl S { } | ^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:715:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:789:17 | LL | mod inner { #![no_builtins] } | ^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:718:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:792:5 | LL | #[no_builtins] fn f() { } | ^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:721:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:795:5 | LL | #[no_builtins] struct S; | ^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:724:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:798:5 | LL | #[no_builtins] type T = S; | ^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:727:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:801:5 | LL | #[no_builtins] impl S { } | ^^^^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:734:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:808:17 | LL | mod inner { #![recursion_limit="0200"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:737:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:811:5 | LL | #[recursion_limit="0200"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:740:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:814:5 | LL | #[recursion_limit="0200"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:743:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:817:5 | LL | #[recursion_limit="0200"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:746:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:820:5 | LL | #[recursion_limit="0200"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:753:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:827:17 | LL | mod inner { #![type_length_limit="0100"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:756:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:830:5 | LL | #[type_length_limit="0100"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:759:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:833:5 | LL | #[type_length_limit="0100"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:762:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:836:5 | LL | #[type_length_limit="0100"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:765:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:839:5 | LL | #[type_length_limit="0100"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +warning: `#[macro_use]` attribute cannot be used on functions + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:183:5 + | +LL | #[macro_use] fn f() { } + | ^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[macro_use]` can be applied to modules, extern crates, crates + +warning: `#[macro_use]` attribute cannot be used on structs + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:188:5 + | +LL | #[macro_use] struct S; + | ^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[macro_use]` can be applied to modules, extern crates, crates + +warning: `#[macro_use]` attribute cannot be used on type aliases + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:193:5 + | +LL | #[macro_use] type T = S; + | ^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[macro_use]` can be applied to modules, extern crates, crates + +warning: `#[macro_use]` attribute cannot be used on inherent impl blocks + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:198:5 + | +LL | #[macro_use] impl S { } + | ^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[macro_use]` can be applied to modules, extern crates, crates + +warning: `#[path]` attribute cannot be used on functions + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:259:5 + | +LL | #[path = "3800"] fn f() { } + | ^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[path]` can only be applied to modules + +warning: `#[path]` attribute cannot be used on structs + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:264:5 + | +LL | #[path = "3800"] struct S; + | ^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[path]` can only be applied to modules + +warning: `#[path]` attribute cannot be used on type aliases + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:269:5 + | +LL | #[path = "3800"] type T = S; + | ^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[path]` can only be applied to modules + +warning: `#[path]` attribute cannot be used on inherent impl blocks + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:274:5 + | +LL | #[path = "3800"] impl S { } + | ^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[path]` can only be applied to modules + +warning: `#[automatically_derived]` attribute cannot be used on modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:280:1 + | +LL | #[automatically_derived] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[automatically_derived]` can only be applied to trait impl blocks + +warning: `#[automatically_derived]` attribute cannot be used on modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:285:17 + | +LL | mod inner { #![automatically_derived] } + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[automatically_derived]` can only be applied to trait impl blocks + +warning: `#[automatically_derived]` attribute cannot be used on functions + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:290:5 + | +LL | #[automatically_derived] fn f() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[automatically_derived]` can only be applied to trait impl blocks + +warning: `#[automatically_derived]` attribute cannot be used on structs + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:295:5 + | +LL | #[automatically_derived] struct S; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[automatically_derived]` can only be applied to trait impl blocks + +warning: `#[automatically_derived]` attribute cannot be used on type aliases + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:300:5 + | +LL | #[automatically_derived] type T = S; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[automatically_derived]` can only be applied to trait impl blocks + +warning: `#[automatically_derived]` attribute cannot be used on traits + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:305:5 + | +LL | #[automatically_derived] trait W { } + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[automatically_derived]` can only be applied to trait impl blocks + +warning: `#[automatically_derived]` attribute cannot be used on inherent impl blocks + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:310:5 + | +LL | #[automatically_derived] impl S { } + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[automatically_derived]` can only be applied to trait impl blocks + +warning: `#[no_mangle]` attribute cannot be used on modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:318:1 + | +LL | #[no_mangle] + | ^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[no_mangle]` can be applied to functions, statics + +warning: `#[no_mangle]` attribute cannot be used on modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:323:17 + | +LL | mod inner { #![no_mangle] } + | ^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[no_mangle]` can be applied to functions, statics + +warning: `#[no_mangle]` attribute cannot be used on structs + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:330:5 + | +LL | #[no_mangle] struct S; + | ^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[no_mangle]` can be applied to functions, statics + +warning: `#[no_mangle]` attribute cannot be used on type aliases + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:335:5 + | +LL | #[no_mangle] type T = S; + | ^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[no_mangle]` can be applied to functions, statics + +warning: `#[no_mangle]` attribute cannot be used on inherent impl blocks + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:340:5 + | +LL | #[no_mangle] impl S { } + | ^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[no_mangle]` can be applied to functions, statics + +warning: `#[no_mangle]` attribute cannot be used on required trait methods + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:346:9 + | +LL | #[no_mangle] fn foo(); + | ^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[no_mangle]` can be applied to functions, statics, inherent methods, trait methods in impl blocks + +warning: `#[no_mangle]` attribute cannot be used on provided trait methods + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:351:9 + | +LL | #[no_mangle] fn bar() {} + | ^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[no_mangle]` can be applied to functions, statics, inherent methods, trait methods in impl blocks + +warning: `#[should_panic]` attribute cannot be used on modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:358:1 + | +LL | #[should_panic] + | ^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[should_panic]` can only be applied to functions + +warning: `#[should_panic]` attribute cannot be used on modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:363:17 + | +LL | mod inner { #![should_panic] } + | ^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[should_panic]` can only be applied to functions + +warning: `#[should_panic]` attribute cannot be used on structs + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:370:5 + | +LL | #[should_panic] struct S; + | ^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[should_panic]` can only be applied to functions + +warning: `#[should_panic]` attribute cannot be used on type aliases + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:375:5 + | +LL | #[should_panic] type T = S; + | ^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[should_panic]` can only be applied to functions + +warning: `#[should_panic]` attribute cannot be used on inherent impl blocks + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:380:5 + | +LL | #[should_panic] impl S { } + | ^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[should_panic]` can only be applied to functions + +warning: `#[ignore]` attribute cannot be used on modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:386:1 + | +LL | #[ignore] + | ^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[ignore]` can only be applied to functions + +warning: `#[ignore]` attribute cannot be used on modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:391:17 + | +LL | mod inner { #![ignore] } + | ^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[ignore]` can only be applied to functions + +warning: `#[ignore]` attribute cannot be used on structs + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:398:5 + | +LL | #[ignore] struct S; + | ^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[ignore]` can only be applied to functions + +warning: `#[ignore]` attribute cannot be used on type aliases + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:403:5 + | +LL | #[ignore] type T = S; + | ^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[ignore]` can only be applied to functions + +warning: `#[ignore]` attribute cannot be used on inherent impl blocks + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:408:5 + | +LL | #[ignore] impl S { } + | ^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[ignore]` can only be applied to functions + +warning: `#[no_implicit_prelude]` attribute cannot be used on functions + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:418:5 + | +LL | #[no_implicit_prelude] fn f() { } + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[no_implicit_prelude]` can be applied to modules, crates + +warning: `#[no_implicit_prelude]` attribute cannot be used on structs + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:423:5 + | +LL | #[no_implicit_prelude] struct S; + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[no_implicit_prelude]` can be applied to modules, crates + +warning: `#[no_implicit_prelude]` attribute cannot be used on type aliases + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:428:5 + | +LL | #[no_implicit_prelude] type T = S; + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[no_implicit_prelude]` can be applied to modules, crates + +warning: `#[no_implicit_prelude]` attribute cannot be used on inherent impl blocks + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:433:5 + | +LL | #[no_implicit_prelude] impl S { } + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[no_implicit_prelude]` can be applied to modules, crates + +warning: `#[macro_escape]` attribute cannot be used on functions + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:466:5 + | +LL | #[macro_escape] fn f() { } + | ^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[macro_escape]` can be applied to modules, extern crates, crates + +warning: `#[macro_escape]` attribute cannot be used on structs + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:471:5 + | +LL | #[macro_escape] struct S; + | ^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[macro_escape]` can be applied to modules, extern crates, crates + +warning: `#[macro_escape]` attribute cannot be used on type aliases + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:476:5 + | +LL | #[macro_escape] type T = S; + | ^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[macro_escape]` can be applied to modules, extern crates, crates + +warning: `#[macro_escape]` attribute cannot be used on inherent impl blocks + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:481:5 + | +LL | #[macro_escape] impl S { } + | ^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[macro_escape]` can be applied to modules, extern crates, crates + +warning: `#[cold]` attribute cannot be used on modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:523:1 + | +LL | #[cold] + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[cold]` can only be applied to functions + +warning: `#[cold]` attribute cannot be used on modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:529:17 + | +LL | mod inner { #![cold] } + | ^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[cold]` can only be applied to functions + +warning: `#[cold]` attribute cannot be used on structs + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:536:5 + | +LL | #[cold] struct S; + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[cold]` can only be applied to functions + +warning: `#[cold]` attribute cannot be used on type aliases + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:541:5 + | +LL | #[cold] type T = S; + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[cold]` can only be applied to functions + +warning: `#[cold]` attribute cannot be used on inherent impl blocks + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:546:5 + | +LL | #[cold] impl S { } + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[cold]` can only be applied to functions + +warning: `#[link_name]` attribute cannot be used on modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:552:1 + | +LL | #[link_name = "1900"] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[link_name]` can be applied to foreign functions, foreign statics + +warning: `#[link_name]` attribute cannot be used on foreign modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:557:5 + | +LL | #[link_name = "1900"] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[link_name]` can be applied to foreign functions, foreign statics + +warning: `#[link_name]` attribute cannot be used on modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:563:17 + | +LL | mod inner { #![link_name="1900"] } + | ^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[link_name]` can be applied to foreign functions, foreign statics + +warning: `#[link_name]` attribute cannot be used on functions + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:568:5 + | +LL | #[link_name = "1900"] fn f() { } + | ^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[link_name]` can be applied to foreign functions, foreign statics + +warning: `#[link_name]` attribute cannot be used on structs + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:573:5 + | +LL | #[link_name = "1900"] struct S; + | ^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[link_name]` can be applied to foreign functions, foreign statics + +warning: `#[link_name]` attribute cannot be used on type aliases + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:578:5 + | +LL | #[link_name = "1900"] type T = S; + | ^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[link_name]` can be applied to foreign functions, foreign statics + +warning: `#[link_name]` attribute cannot be used on inherent impl blocks + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:583:5 + | +LL | #[link_name = "1900"] impl S { } + | ^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[link_name]` can be applied to foreign functions, foreign statics + +warning: `#[link_section]` attribute cannot be used on modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:589:1 + | +LL | #[link_section = "1800"] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[link_section]` can be applied to statics, functions + +warning: `#[link_section]` attribute cannot be used on modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:594:17 + | +LL | mod inner { #![link_section="1800"] } + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[link_section]` can be applied to statics, functions + +warning: `#[link_section]` attribute cannot be used on structs + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:601:5 + | +LL | #[link_section = "1800"] struct S; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[link_section]` can be applied to statics, functions + +warning: `#[link_section]` attribute cannot be used on type aliases + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:606:5 + | +LL | #[link_section = "1800"] type T = S; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[link_section]` can be applied to statics, functions + +warning: `#[link_section]` attribute cannot be used on inherent impl blocks + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:611:5 + | +LL | #[link_section = "1800"] impl S { } + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[link_section]` can be applied to statics, functions + +warning: `#[should_panic]` attribute cannot be used on crates + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:50:1 + | +LL | #![should_panic] + | ^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[should_panic]` can only be applied to functions + +warning: `#[ignore]` attribute cannot be used on crates + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:53:1 + | +LL | #![ignore] + | ^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[ignore]` can only be applied to functions + +warning: `#[proc_macro_derive]` attribute cannot be used on crates + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:61:1 + | +LL | #![proc_macro_derive(Test)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[proc_macro_derive]` can only be applied to functions + +warning: `#[cold]` attribute cannot be used on crates + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:65:1 + | +LL | #![cold] + | ^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[cold]` can only be applied to functions + +warning: `#[link_name]` attribute cannot be used on crates + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:70:1 + | +LL | #![link_name = "1900"] + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[link_name]` can be applied to foreign functions, foreign statics + +warning: `#[link_section]` attribute cannot be used on crates + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:74:1 + | +LL | #![link_section = "1800"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[link_section]` can be applied to statics, functions + warning: 173 warnings emitted diff --git a/tests/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.rs b/tests/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.rs index 392880e1b3b..35392b4eff6 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.rs +++ b/tests/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.rs @@ -1,34 +1,29 @@ -// At time of authorship, #[proc_macro_derive = "2500"] will emit an -// error when it occurs on a mod (apart from crate-level), but will -// not descend further into the mod for other occurrences of the same -// error. -// -// This file sits on its own because the "weird" occurrences here +// This file sits on its own because the occurrences here // signal errors, making it incompatible with the "warnings only" // nature of issue-43106-gating-of-builtin-attrs.rs #[proc_macro_derive(Test)] -//~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions +//~^ ERROR attribute cannot be used on mod proc_macro_derive1 { mod inner { #![proc_macro_derive(Test)] } - // (no error issued here if there was one on outer module) + //~^ ERROR attribute cannot be used on } mod proc_macro_derive2 { mod inner { #![proc_macro_derive(Test)] } - //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions + //~^ ERROR attribute cannot be used on #[proc_macro_derive(Test)] fn f() { } //~^ ERROR the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` #[proc_macro_derive(Test)] struct S; - //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions + //~^ ERROR attribute cannot be used on #[proc_macro_derive(Test)] type T = S; - //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions + //~^ ERROR attribute cannot be used on #[proc_macro_derive(Test)] impl S { } - //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions + //~^ ERROR attribute cannot be used on } fn main() {} diff --git a/tests/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.stderr b/tests/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.stderr index 537032d777f..753e3e2f21d 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.stderr +++ b/tests/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.stderr @@ -1,38 +1,56 @@ -error: the `#[proc_macro_derive]` attribute may only be used on bare functions - --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:10:1 +error: the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` crate type + --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:16:5 + | +LL | #[proc_macro_derive(Test)] fn f() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `#[proc_macro_derive]` attribute cannot be used on modules + --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:5:1 | LL | #[proc_macro_derive(Test)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[proc_macro_derive]` can only be applied to functions -error: the `#[proc_macro_derive]` attribute may only be used on bare functions - --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:18:17 +error: `#[proc_macro_derive]` attribute cannot be used on modules + --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:8:17 | LL | mod inner { #![proc_macro_derive(Test)] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[proc_macro_derive]` can only be applied to functions -error: the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` crate type - --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:21:5 +error: `#[proc_macro_derive]` attribute cannot be used on modules + --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:13:17 | -LL | #[proc_macro_derive(Test)] fn f() { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | mod inner { #![proc_macro_derive(Test)] } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[proc_macro_derive]` can only be applied to functions -error: the `#[proc_macro_derive]` attribute may only be used on bare functions - --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:24:5 +error: `#[proc_macro_derive]` attribute cannot be used on structs + --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:19:5 | LL | #[proc_macro_derive(Test)] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[proc_macro_derive]` can only be applied to functions -error: the `#[proc_macro_derive]` attribute may only be used on bare functions - --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:27:5 +error: `#[proc_macro_derive]` attribute cannot be used on type aliases + --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:22:5 | LL | #[proc_macro_derive(Test)] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[proc_macro_derive]` can only be applied to functions -error: the `#[proc_macro_derive]` attribute may only be used on bare functions - --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:30:5 +error: `#[proc_macro_derive]` attribute cannot be used on inherent impl blocks + --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:25:5 | LL | #[proc_macro_derive(Test)] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[proc_macro_derive]` can only be applied to functions -error: aborting due to 6 previous errors +error: aborting due to 7 previous errors diff --git a/tests/ui/ffi-attrs/ffi_const.rs b/tests/ui/ffi-attrs/ffi_const.rs index dddc862b0fa..caeaf8a25a9 100644 --- a/tests/ui/ffi-attrs/ffi_const.rs +++ b/tests/ui/ffi-attrs/ffi_const.rs @@ -1,16 +1,16 @@ #![feature(ffi_const)] #![crate_type = "lib"] -#[unsafe(ffi_const)] //~ ERROR `#[ffi_const]` may only be used on foreign functions +#[unsafe(ffi_const)] //~ ERROR attribute cannot be used on pub fn foo() {} -#[unsafe(ffi_const)] //~ ERROR `#[ffi_const]` may only be used on foreign functions +#[unsafe(ffi_const)] //~ ERROR attribute cannot be used on macro_rules! bar { () => {}; } extern "C" { - #[unsafe(ffi_const)] //~ ERROR `#[ffi_const]` may only be used on foreign functions + #[unsafe(ffi_const)] //~ ERROR attribute cannot be used on static INT: i32; #[ffi_const] //~ ERROR unsafe attribute used without unsafe diff --git a/tests/ui/ffi-attrs/ffi_const.stderr b/tests/ui/ffi-attrs/ffi_const.stderr index 7f31237539d..f3be9254318 100644 --- a/tests/ui/ffi-attrs/ffi_const.stderr +++ b/tests/ui/ffi-attrs/ffi_const.stderr @@ -9,24 +9,29 @@ help: wrap the attribute in `unsafe(...)` LL | #[unsafe(ffi_const)] | +++++++ + -error[E0756]: `#[ffi_const]` may only be used on foreign functions +error: `#[ffi_const]` attribute cannot be used on functions --> $DIR/ffi_const.rs:4:1 | LL | #[unsafe(ffi_const)] | ^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[ffi_const]` can only be applied to foreign functions -error[E0756]: `#[ffi_const]` may only be used on foreign functions +error: `#[ffi_const]` attribute cannot be used on macro defs --> $DIR/ffi_const.rs:7:1 | LL | #[unsafe(ffi_const)] | ^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[ffi_const]` can only be applied to foreign functions -error[E0756]: `#[ffi_const]` may only be used on foreign functions +error: `#[ffi_const]` attribute cannot be used on foreign statics --> $DIR/ffi_const.rs:13:5 | LL | #[unsafe(ffi_const)] | ^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[ffi_const]` can only be applied to foreign functions error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0756`. diff --git a/tests/ui/ffi-attrs/ffi_pure.rs b/tests/ui/ffi-attrs/ffi_pure.rs index 1f4812f55cf..c56be793919 100644 --- a/tests/ui/ffi-attrs/ffi_pure.rs +++ b/tests/ui/ffi-attrs/ffi_pure.rs @@ -1,16 +1,16 @@ #![feature(ffi_pure)] #![crate_type = "lib"] -#[unsafe(ffi_pure)] //~ ERROR `#[ffi_pure]` may only be used on foreign functions +#[unsafe(ffi_pure)] //~ ERROR attribute cannot be used on pub fn foo() {} -#[unsafe(ffi_pure)] //~ ERROR `#[ffi_pure]` may only be used on foreign functions +#[unsafe(ffi_pure)] //~ ERROR attribute cannot be used on macro_rules! bar { () => {}; } extern "C" { - #[unsafe(ffi_pure)] //~ ERROR `#[ffi_pure]` may only be used on foreign functions + #[unsafe(ffi_pure)] //~ ERROR attribute cannot be used on static INT: i32; #[ffi_pure] //~ ERROR unsafe attribute used without unsafe diff --git a/tests/ui/ffi-attrs/ffi_pure.stderr b/tests/ui/ffi-attrs/ffi_pure.stderr index bd1177c01e2..da1eae975ac 100644 --- a/tests/ui/ffi-attrs/ffi_pure.stderr +++ b/tests/ui/ffi-attrs/ffi_pure.stderr @@ -9,24 +9,29 @@ help: wrap the attribute in `unsafe(...)` LL | #[unsafe(ffi_pure)] | +++++++ + -error[E0755]: `#[ffi_pure]` may only be used on foreign functions +error: `#[ffi_pure]` attribute cannot be used on functions --> $DIR/ffi_pure.rs:4:1 | LL | #[unsafe(ffi_pure)] | ^^^^^^^^^^^^^^^^^^^ + | + = help: `#[ffi_pure]` can only be applied to foreign functions -error[E0755]: `#[ffi_pure]` may only be used on foreign functions +error: `#[ffi_pure]` attribute cannot be used on macro defs --> $DIR/ffi_pure.rs:7:1 | LL | #[unsafe(ffi_pure)] | ^^^^^^^^^^^^^^^^^^^ + | + = help: `#[ffi_pure]` can only be applied to foreign functions -error[E0755]: `#[ffi_pure]` may only be used on foreign functions +error: `#[ffi_pure]` attribute cannot be used on foreign statics --> $DIR/ffi_pure.rs:13:5 | LL | #[unsafe(ffi_pure)] | ^^^^^^^^^^^^^^^^^^^ + | + = help: `#[ffi_pure]` can only be applied to foreign functions error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0755`. diff --git a/tests/ui/fn/fn-arg-count-mismatch-diagnostics.rs b/tests/ui/fn/fn-arg-count-mismatch-diagnostics.rs index b2f80ba1bf6..3b12ea1a736 100644 --- a/tests/ui/fn/fn-arg-count-mismatch-diagnostics.rs +++ b/tests/ui/fn/fn-arg-count-mismatch-diagnostics.rs @@ -46,9 +46,21 @@ impl Bar { } } +fn function_with_lots_of_arguments(a: i32, b: char, c: i32, d: i32, e: i32, f: i32) {} + fn main() { foo(1, 2, 3); //~^ ERROR function takes 4 arguments but 3 bar(1, 2, 3); //~^ ERROR function takes 6 arguments but 3 + + let variable_name = 42; + function_with_lots_of_arguments( + variable_name, + variable_name, + variable_name, + variable_name, + variable_name, + ); + //~^^^^^^^ ERROR this function takes 6 arguments but 5 arguments were supplied [E0061] } diff --git a/tests/ui/fn/fn-arg-count-mismatch-diagnostics.stderr b/tests/ui/fn/fn-arg-count-mismatch-diagnostics.stderr index 6af7671af03..dda9b398a83 100644 --- a/tests/ui/fn/fn-arg-count-mismatch-diagnostics.stderr +++ b/tests/ui/fn/fn-arg-count-mismatch-diagnostics.stderr @@ -52,7 +52,7 @@ LL | <$from>::$method(8, /* u8 */) | ++++++++++ error[E0061]: this function takes 4 arguments but 3 arguments were supplied - --> $DIR/fn-arg-count-mismatch-diagnostics.rs:50:5 + --> $DIR/fn-arg-count-mismatch-diagnostics.rs:52:5 | LL | foo(1, 2, 3); | ^^^--------- argument #4 of type `isize` is missing @@ -68,7 +68,7 @@ LL | foo(1, 2, 3, /* isize */); | +++++++++++++ error[E0061]: this function takes 6 arguments but 3 arguments were supplied - --> $DIR/fn-arg-count-mismatch-diagnostics.rs:52:5 + --> $DIR/fn-arg-count-mismatch-diagnostics.rs:54:5 | LL | bar(1, 2, 3); | ^^^--------- three arguments of type `i32`, `i32`, and `i32` are missing @@ -83,6 +83,28 @@ help: provide the arguments LL | bar(1, 2, 3, /* i32 */, /* i32 */, /* i32 */); | +++++++++++++++++++++++++++++++++ -error: aborting due to 5 previous errors +error[E0061]: this function takes 6 arguments but 5 arguments were supplied + --> $DIR/fn-arg-count-mismatch-diagnostics.rs:58:5 + | +LL | function_with_lots_of_arguments( + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | variable_name, +LL | variable_name, + | ------------- argument #2 of type `char` is missing + | +note: function defined here + --> $DIR/fn-arg-count-mismatch-diagnostics.rs:49:4 + | +LL | fn function_with_lots_of_arguments(a: i32, b: char, c: i32, d: i32, e: i32, f: i32) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------- +help: provide the argument + | +LL | function_with_lots_of_arguments( +LL | variable_name, +LL ~ /* char */, +LL ~ variable_name, + | + +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0061`. diff --git a/tests/ui/issues/issue-15094.rs b/tests/ui/fn/fn-traits-call-once-signature-15094.rs index 408ab82eb8c..f550bafe43d 100644 --- a/tests/ui/issues/issue-15094.rs +++ b/tests/ui/fn/fn-traits-call-once-signature-15094.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15094 + #![feature(fn_traits, unboxed_closures)] use std::{fmt, ops}; diff --git a/tests/ui/issues/issue-15094.stderr b/tests/ui/fn/fn-traits-call-once-signature-15094.stderr index 8e0fc8f1770..bb1d336e848 100644 --- a/tests/ui/issues/issue-15094.stderr +++ b/tests/ui/fn/fn-traits-call-once-signature-15094.stderr @@ -1,5 +1,5 @@ error[E0053]: method `call_once` has an incompatible type for trait - --> $DIR/issue-15094.rs:11:5 + --> $DIR/fn-traits-call-once-signature-15094.rs:13:5 | LL | fn call_once(self, _args: ()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected "rust-call" fn, found "Rust" fn diff --git a/tests/ui/issues/issue-14959.rs b/tests/ui/fn_traits/closure-trait-impl-14959.rs index 57af1207ff9..94d43055e64 100644 --- a/tests/ui/issues/issue-14959.rs +++ b/tests/ui/fn_traits/closure-trait-impl-14959.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/14959 + //@ check-pass #![feature(fn_traits, unboxed_closures)] diff --git a/tests/ui/force-inlining/invalid.rs b/tests/ui/force-inlining/invalid.rs index e9f5712413e..6047739992f 100644 --- a/tests/ui/force-inlining/invalid.rs +++ b/tests/ui/force-inlining/invalid.rs @@ -28,110 +28,110 @@ pub fn forced4() { } #[rustc_force_inline] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on extern crate std as other_std; #[rustc_force_inline] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on use std::collections::HashMap; #[rustc_force_inline] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on static _FOO: &'static str = "FOO"; #[rustc_force_inline] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on const _BAR: u32 = 3; #[rustc_force_inline] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on mod foo { } #[rustc_force_inline] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on unsafe extern "C" { #[rustc_force_inline] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on static X: &'static u32; #[rustc_force_inline] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on type Y; #[rustc_force_inline] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on fn foo(); } #[rustc_force_inline] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on type Foo = u32; #[rustc_force_inline] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on enum Bar<#[rustc_force_inline] T> { -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on #[rustc_force_inline] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on Baz(std::marker::PhantomData<T>), } #[rustc_force_inline] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on struct Qux { #[rustc_force_inline] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on field: u32, } #[rustc_force_inline] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on union FooBar { x: u32, y: u32, } #[rustc_force_inline] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on trait FooBaz { #[rustc_force_inline] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on type Foo; #[rustc_force_inline] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on const Bar: i32; #[rustc_force_inline] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on fn foo() {} } #[rustc_force_inline] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on trait FooQux = FooBaz; #[rustc_force_inline] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on impl<T> Bar<T> { #[rustc_force_inline] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on fn foo() {} } #[rustc_force_inline] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on impl<T> FooBaz for Bar<T> { type Foo = u32; const Bar: i32 = 3; } #[rustc_force_inline] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on macro_rules! barqux { ($foo:tt) => { $foo }; } fn barqux(#[rustc_force_inline] _x: u32) {} //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters -//~^^ ERROR attribute should be applied to a function +//~^^ ERROR attribute cannot be used on #[rustc_force_inline] //~^ ERROR attribute cannot be applied to a `async`, `gen` or `async gen` function @@ -147,16 +147,16 @@ async gen fn async_gen_foo() {} fn main() { let _x = #[rustc_force_inline] || { }; -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on let _y = #[rustc_force_inline] 3 + 4; -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on #[rustc_force_inline] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on let _z = 3; match _z { #[rustc_force_inline] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on 1 => (), _ => (), } diff --git a/tests/ui/force-inlining/invalid.stderr b/tests/ui/force-inlining/invalid.stderr index 3b3da00ae88..299a3ed4a46 100644 --- a/tests/ui/force-inlining/invalid.stderr +++ b/tests/ui/force-inlining/invalid.stderr @@ -64,322 +64,272 @@ LL - #[rustc_force_inline = 2] LL + #[rustc_force_inline] | -error: attribute should be applied to a function +error: `#[rustc_force_inline]` attribute cannot be used on extern crates --> $DIR/invalid.rs:30:1 | LL | #[rustc_force_inline] | ^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | extern crate std as other_std; - | ------------------------------ not a function definition + | + = help: `#[rustc_force_inline]` can only be applied to functions -error: attribute should be applied to a function +error: `#[rustc_force_inline]` attribute cannot be used on use statements --> $DIR/invalid.rs:34:1 | LL | #[rustc_force_inline] | ^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | use std::collections::HashMap; - | ------------------------------ not a function definition + | + = help: `#[rustc_force_inline]` can only be applied to functions -error: attribute should be applied to a function +error: `#[rustc_force_inline]` attribute cannot be used on statics --> $DIR/invalid.rs:38:1 | LL | #[rustc_force_inline] | ^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | static _FOO: &'static str = "FOO"; - | ---------------------------------- not a function definition + | + = help: `#[rustc_force_inline]` can only be applied to functions -error: attribute should be applied to a function +error: `#[rustc_force_inline]` attribute cannot be used on constants --> $DIR/invalid.rs:42:1 | LL | #[rustc_force_inline] | ^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | const _BAR: u32 = 3; - | -------------------- not a function definition + | + = help: `#[rustc_force_inline]` can only be applied to functions -error: attribute should be applied to a function +error: `#[rustc_force_inline]` attribute cannot be used on modules --> $DIR/invalid.rs:46:1 | LL | #[rustc_force_inline] | ^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | mod foo { } - | ----------- not a function definition + | + = help: `#[rustc_force_inline]` can only be applied to functions -error: attribute should be applied to a function +error: `#[rustc_force_inline]` attribute cannot be used on foreign modules --> $DIR/invalid.rs:50:1 | -LL | #[rustc_force_inline] - | ^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | / unsafe extern "C" { -LL | | #[rustc_force_inline] -LL | | -LL | | static X: &'static u32; -... | -LL | | fn foo(); -LL | | } - | |_- not a function definition - -error: attribute should be applied to a function +LL | #[rustc_force_inline] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[rustc_force_inline]` can only be applied to functions + +error: `#[rustc_force_inline]` attribute cannot be used on foreign statics + --> $DIR/invalid.rs:53:5 + | +LL | #[rustc_force_inline] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[rustc_force_inline]` can only be applied to functions + +error: `#[rustc_force_inline]` attribute cannot be used on foreign types + --> $DIR/invalid.rs:57:5 + | +LL | #[rustc_force_inline] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[rustc_force_inline]` can only be applied to functions + +error: `#[rustc_force_inline]` attribute cannot be used on foreign functions + --> $DIR/invalid.rs:61:5 + | +LL | #[rustc_force_inline] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[rustc_force_inline]` can only be applied to functions + +error: `#[rustc_force_inline]` attribute cannot be used on type aliases --> $DIR/invalid.rs:66:1 | LL | #[rustc_force_inline] | ^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | type Foo = u32; - | --------------- not a function definition + | + = help: `#[rustc_force_inline]` can only be applied to functions -error: attribute should be applied to a function +error: `#[rustc_force_inline]` attribute cannot be used on enums --> $DIR/invalid.rs:70:1 | -LL | #[rustc_force_inline] - | ^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | / enum Bar<#[rustc_force_inline] T> { -LL | | -LL | | #[rustc_force_inline] -... | -LL | | } - | |_- not a function definition - -error: attribute should be applied to a function +LL | #[rustc_force_inline] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[rustc_force_inline]` can only be applied to functions + +error: `#[rustc_force_inline]` attribute cannot be used on function params --> $DIR/invalid.rs:72:10 | LL | enum Bar<#[rustc_force_inline] T> { - | ^^^^^^^^^^^^^^^^^^^^^ - not a function definition + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[rustc_force_inline]` can only be applied to functions -error: attribute should be applied to a function +error: `#[rustc_force_inline]` attribute cannot be used on enum variants --> $DIR/invalid.rs:74:5 | LL | #[rustc_force_inline] | ^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | Baz(std::marker::PhantomData<T>), - | -------------------------------- not a function definition + | + = help: `#[rustc_force_inline]` can only be applied to functions -error: attribute should be applied to a function +error: `#[rustc_force_inline]` attribute cannot be used on structs --> $DIR/invalid.rs:79:1 | -LL | #[rustc_force_inline] - | ^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | / struct Qux { -LL | | #[rustc_force_inline] -LL | | -LL | | field: u32, -LL | | } - | |_- not a function definition - -error: attribute should be applied to a function +LL | #[rustc_force_inline] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[rustc_force_inline]` can only be applied to functions + +error: `#[rustc_force_inline]` attribute cannot be used on struct fields --> $DIR/invalid.rs:82:5 | LL | #[rustc_force_inline] | ^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | field: u32, - | ---------- not a function definition + | + = help: `#[rustc_force_inline]` can only be applied to functions -error: attribute should be applied to a function +error: `#[rustc_force_inline]` attribute cannot be used on unions --> $DIR/invalid.rs:87:1 | -LL | #[rustc_force_inline] - | ^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | / union FooBar { -LL | | x: u32, -LL | | y: u32, -LL | | } - | |_- not a function definition +LL | #[rustc_force_inline] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[rustc_force_inline]` can only be applied to functions -error: attribute should be applied to a function +error: `#[rustc_force_inline]` attribute cannot be used on traits --> $DIR/invalid.rs:94:1 | -LL | #[rustc_force_inline] - | ^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | / trait FooBaz { -LL | | #[rustc_force_inline] -LL | | -LL | | type Foo; -... | -LL | | fn foo() {} -LL | | } - | |_- not a function definition - -error: attribute should be applied to a function - --> $DIR/invalid.rs:109:1 - | LL | #[rustc_force_inline] | ^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | trait FooQux = FooBaz; - | ---------------------- not a function definition + | + = help: `#[rustc_force_inline]` can only be applied to functions -error: attribute should be applied to a function - --> $DIR/invalid.rs:113:1 +error: `#[rustc_force_inline]` attribute cannot be used on associated types + --> $DIR/invalid.rs:97:5 | -LL | #[rustc_force_inline] - | ^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | / impl<T> Bar<T> { -LL | | #[rustc_force_inline] -LL | | -LL | | fn foo() {} -LL | | } - | |_- not a function definition - -error: attribute should be applied to a function - --> $DIR/invalid.rs:121:1 +LL | #[rustc_force_inline] + | ^^^^^^^^^^^^^^^^^^^^^ | -LL | #[rustc_force_inline] - | ^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | / impl<T> FooBaz for Bar<T> { -LL | | type Foo = u32; -LL | | const Bar: i32 = 3; -LL | | } - | |_- not a function definition + = help: `#[rustc_force_inline]` can only be applied to functions -error: attribute should be applied to a function - --> $DIR/invalid.rs:128:1 +error: `#[rustc_force_inline]` attribute cannot be used on associated consts + --> $DIR/invalid.rs:100:5 + | +LL | #[rustc_force_inline] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[rustc_force_inline]` can only be applied to functions + +error: `#[rustc_force_inline]` attribute cannot be used on provided trait methods + --> $DIR/invalid.rs:104:5 + | +LL | #[rustc_force_inline] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[rustc_force_inline]` can only be applied to functions + +error: `#[rustc_force_inline]` attribute cannot be used on trait aliases + --> $DIR/invalid.rs:109:1 | LL | #[rustc_force_inline] | ^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | macro_rules! barqux { ($foo:tt) => { $foo }; } - | ---------------------------------------------- not a function definition - -error: attribute should be applied to a function - --> $DIR/invalid.rs:132:11 | -LL | fn barqux(#[rustc_force_inline] _x: u32) {} - | ^^^^^^^^^^^^^^^^^^^^^-------- - | | - | not a function definition + = help: `#[rustc_force_inline]` can only be applied to functions -error: attribute cannot be applied to a `async`, `gen` or `async gen` function - --> $DIR/invalid.rs:136:1 +error: `#[rustc_force_inline]` attribute cannot be used on inherent impl blocks + --> $DIR/invalid.rs:113:1 | LL | #[rustc_force_inline] | ^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | async fn async_foo() {} - | -------------------- `async`, `gen` or `async gen` function + | + = help: `#[rustc_force_inline]` can only be applied to functions -error: attribute cannot be applied to a `async`, `gen` or `async gen` function - --> $DIR/invalid.rs:140:1 +error: `#[rustc_force_inline]` attribute cannot be used on inherent methods + --> $DIR/invalid.rs:116:5 + | +LL | #[rustc_force_inline] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[rustc_force_inline]` can only be applied to functions + +error: `#[rustc_force_inline]` attribute cannot be used on trait impl blocks + --> $DIR/invalid.rs:121:1 | LL | #[rustc_force_inline] | ^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | gen fn gen_foo() {} - | ---------------- `async`, `gen` or `async gen` function + | + = help: `#[rustc_force_inline]` can only be applied to functions -error: attribute cannot be applied to a `async`, `gen` or `async gen` function - --> $DIR/invalid.rs:144:1 +error: `#[rustc_force_inline]` attribute cannot be used on macro defs + --> $DIR/invalid.rs:128:1 | LL | #[rustc_force_inline] | ^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | async gen fn async_gen_foo() {} - | ---------------------------- `async`, `gen` or `async gen` function + | + = help: `#[rustc_force_inline]` can only be applied to functions -error: attribute should be applied to a function +error: `#[rustc_force_inline]` attribute cannot be used on function params + --> $DIR/invalid.rs:132:11 + | +LL | fn barqux(#[rustc_force_inline] _x: u32) {} + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[rustc_force_inline]` can only be applied to functions + +error: `#[rustc_force_inline]` attribute cannot be used on closures --> $DIR/invalid.rs:149:14 | LL | let _x = #[rustc_force_inline] || { }; - | ^^^^^^^^^^^^^^^^^^^^^ ------ not a function definition + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[rustc_force_inline]` can only be applied to functions -error: attribute should be applied to a function +error: `#[rustc_force_inline]` attribute cannot be used on expressions --> $DIR/invalid.rs:151:14 | LL | let _y = #[rustc_force_inline] 3 + 4; - | ^^^^^^^^^^^^^^^^^^^^^ - not a function definition + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[rustc_force_inline]` can only be applied to functions -error: attribute should be applied to a function +error: `#[rustc_force_inline]` attribute cannot be used on statements --> $DIR/invalid.rs:153:5 | LL | #[rustc_force_inline] | ^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | let _z = 3; - | ----------- not a function definition + | + = help: `#[rustc_force_inline]` can only be applied to functions -error: attribute should be applied to a function +error: `#[rustc_force_inline]` attribute cannot be used on match arms --> $DIR/invalid.rs:158:9 | LL | #[rustc_force_inline] | ^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | 1 => (), - | ------- not a function definition - -error: attribute should be applied to a function - --> $DIR/invalid.rs:97:5 - | -LL | #[rustc_force_inline] - | ^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | type Foo; - | --------- not a function definition - -error: attribute should be applied to a function - --> $DIR/invalid.rs:100:5 - | -LL | #[rustc_force_inline] - | ^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | const Bar: i32; - | --------------- not a function definition - -error: attribute should be applied to a function - --> $DIR/invalid.rs:104:5 - | -LL | #[rustc_force_inline] - | ^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | fn foo() {} - | ----------- not a function definition - -error: attribute should be applied to a function - --> $DIR/invalid.rs:116:5 | -LL | #[rustc_force_inline] - | ^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | fn foo() {} - | ----------- not a function definition + = help: `#[rustc_force_inline]` can only be applied to functions -error: attribute should be applied to a function - --> $DIR/invalid.rs:53:5 +error: attribute cannot be applied to a `async`, `gen` or `async gen` function + --> $DIR/invalid.rs:136:1 | -LL | #[rustc_force_inline] - | ^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_force_inline] + | ^^^^^^^^^^^^^^^^^^^^^ LL | -LL | static X: &'static u32; - | ----------------------- not a function definition +LL | async fn async_foo() {} + | -------------------- `async`, `gen` or `async gen` function -error: attribute should be applied to a function - --> $DIR/invalid.rs:57:5 +error: attribute cannot be applied to a `async`, `gen` or `async gen` function + --> $DIR/invalid.rs:140:1 | -LL | #[rustc_force_inline] - | ^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_force_inline] + | ^^^^^^^^^^^^^^^^^^^^^ LL | -LL | type Y; - | ------- not a function definition +LL | gen fn gen_foo() {} + | ---------------- `async`, `gen` or `async gen` function -error: attribute should be applied to a function - --> $DIR/invalid.rs:61:5 +error: attribute cannot be applied to a `async`, `gen` or `async gen` function + --> $DIR/invalid.rs:144:1 | -LL | #[rustc_force_inline] - | ^^^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_force_inline] + | ^^^^^^^^^^^^^^^^^^^^^ LL | -LL | fn foo(); - | --------- not a function definition +LL | async gen fn async_gen_foo() {} + | ---------------------------- `async`, `gen` or `async gen` function error: aborting due to 37 previous errors diff --git a/tests/ui/issues/issue-14092.rs b/tests/ui/generics/box-missing-generics-14092.rs index 67c2a42eafb..3570d5f675f 100644 --- a/tests/ui/issues/issue-14092.rs +++ b/tests/ui/generics/box-missing-generics-14092.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/14092 + fn fn1(0: Box) {} //~^ ERROR missing generics for struct `Box` diff --git a/tests/ui/issues/issue-14092.stderr b/tests/ui/generics/box-missing-generics-14092.stderr index 0de7b902fe0..0822d781ac7 100644 --- a/tests/ui/issues/issue-14092.stderr +++ b/tests/ui/generics/box-missing-generics-14092.stderr @@ -1,5 +1,5 @@ error[E0107]: missing generics for struct `Box` - --> $DIR/issue-14092.rs:1:11 + --> $DIR/box-missing-generics-14092.rs:3:11 | LL | fn fn1(0: Box) {} | ^^^ expected at least 1 generic argument diff --git a/tests/ui/generics/post_monomorphization_error_backtrace.stderr b/tests/ui/generics/post_monomorphization_error_backtrace.stderr index 6953414f0c2..92c7df73638 100644 --- a/tests/ui/generics/post_monomorphization_error_backtrace.stderr +++ b/tests/ui/generics/post_monomorphization_error_backtrace.stderr @@ -1,8 +1,8 @@ error[E0080]: evaluation panicked: assertion failed: std::mem::size_of::<T>() == 0 - --> $DIR/post_monomorphization_error_backtrace.rs:6:23 + --> $DIR/post_monomorphization_error_backtrace.rs:6:31 | LL | const V: () = assert!(std::mem::size_of::<T>() == 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `assert_zst::F::<u32>::V` failed here + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `assert_zst::F::<u32>::V` failed here note: erroneous constant encountered --> $DIR/post_monomorphization_error_backtrace.rs:14:5 @@ -17,10 +17,10 @@ LL | assert_zst::<U>() | ^^^^^^^^^^^^^^^^^ error[E0080]: evaluation panicked: assertion failed: std::mem::size_of::<T>() == 0 - --> $DIR/post_monomorphization_error_backtrace.rs:6:23 + --> $DIR/post_monomorphization_error_backtrace.rs:6:31 | LL | const V: () = assert!(std::mem::size_of::<T>() == 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `assert_zst::F::<i32>::V` failed here + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `assert_zst::F::<i32>::V` failed here note: erroneous constant encountered --> $DIR/post_monomorphization_error_backtrace.rs:14:5 diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.rs index d8a1f3fa69e..d2793afdd06 100644 --- a/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.rs +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.rs @@ -6,6 +6,8 @@ // This tests double-checks that we do not allow such behavior to leak // through again. +//@ compile-flags: -Zwrite-long-types-to-disk=yes + pub trait Stream { type Item; fn next(self) -> Option<Self::Item>; diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.stderr b/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.stderr index 23b979e2ef0..91e65b2b073 100644 --- a/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.stderr +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.stderr @@ -1,5 +1,5 @@ -error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:109:30: 109:37}>`, but its trait bounds were not satisfied - --> $DIR/hrtb-doesnt-borrow-self-2.rs:110:24 +error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, fn(&u64) -> &u64 {identity::<u64>}>, {closure@...}>`, but its trait bounds were not satisfied + --> $DIR/hrtb-doesnt-borrow-self-2.rs:112:24 | LL | pub struct Filter<S, F> { | ----------------------- method `countx` not found for this struct because it doesn't satisfy `_: StreamExt` @@ -8,19 +8,21 @@ LL | let count = filter.countx(); | ^^^^^^ method cannot be called due to unsatisfied trait bounds | note: the following trait bounds were not satisfied: - `&'a mut &Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:109:30: 109:37}>: Stream` - `&'a mut &mut Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:109:30: 109:37}>: Stream` - `&'a mut Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:109:30: 109:37}>: Stream` - --> $DIR/hrtb-doesnt-borrow-self-2.rs:96:50 + `&'a mut &Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:111:30: 111:37}>: Stream` + `&'a mut &mut Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:111:30: 111:37}>: Stream` + `&'a mut Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:111:30: 111:37}>: Stream` + --> $DIR/hrtb-doesnt-borrow-self-2.rs:98:50 | LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {} | --------- - ^^^^^^ unsatisfied trait bound introduced here = help: items from traits can only be used if the trait is implemented and in scope note: `StreamExt` defines an item `countx`, perhaps you need to implement it - --> $DIR/hrtb-doesnt-borrow-self-2.rs:64:1 + --> $DIR/hrtb-doesnt-borrow-self-2.rs:66:1 | LL | pub trait StreamExt | ^^^^^^^^^^^^^^^^^^^ + = note: the full name for the type has been written to '$TEST_BUILD_DIR/hrtb-doesnt-borrow-self-2.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error diff --git a/tests/ui/hygiene/arguments.stderr b/tests/ui/hygiene/arguments.stderr index 0d8d652b6f3..fe92daf6437 100644 --- a/tests/ui/hygiene/arguments.stderr +++ b/tests/ui/hygiene/arguments.stderr @@ -1,6 +1,9 @@ error[E0412]: cannot find type `S` in this scope --> $DIR/arguments.rs:14:8 | +LL | struct S; + | - you might have meant to refer to this struct +... LL | m!(S, S); | ^ not found in this scope diff --git a/tests/ui/hygiene/cross-crate-name-hiding-2.stderr b/tests/ui/hygiene/cross-crate-name-hiding-2.stderr index a5d509fab99..fe3a12e93a7 100644 --- a/tests/ui/hygiene/cross-crate-name-hiding-2.stderr +++ b/tests/ui/hygiene/cross-crate-name-hiding-2.stderr @@ -3,6 +3,11 @@ error[E0422]: cannot find struct, variant or union type `MyStruct` in this scope | LL | let x = MyStruct {}; | ^^^^^^^^ not found in this scope + | + ::: $DIR/auxiliary/use_by_macro.rs:15:1 + | +LL | x!(my_struct); + | ------------- you might have meant to refer to this struct error: aborting due to 1 previous error diff --git a/tests/ui/hygiene/globs.stderr b/tests/ui/hygiene/globs.stderr index 31f25b182f1..85946bf34bc 100644 --- a/tests/ui/hygiene/globs.stderr +++ b/tests/ui/hygiene/globs.stderr @@ -48,7 +48,10 @@ error[E0425]: cannot find function `f` in this scope --> $DIR/globs.rs:61:12 | LL | n!(f); - | ----- in this macro invocation + | ----- + | | | + | | you might have meant to refer to this function + | in this macro invocation ... LL | $j(); | -- due to this macro variable @@ -56,15 +59,16 @@ LL | $j(); LL | n!(f); | ^ not found in this scope | - = help: consider importing this function: - foo::f = note: this error originates in the macro `n` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0425]: cannot find function `f` in this scope --> $DIR/globs.rs:65:17 | LL | n!(f); - | ----- in this macro invocation + | ----- + | | | + | | you might have meant to refer to this function + | in this macro invocation ... LL | $j(); | -- due to this macro variable @@ -72,8 +76,6 @@ LL | $j(); LL | f | ^ not found in this scope | - = help: consider importing this function: - foo::f = note: this error originates in the macro `n` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 4 previous errors diff --git a/tests/ui/hygiene/panic-location.run.stderr b/tests/ui/hygiene/panic-location.run.stderr index 5cd07dcda4c..d28ab864183 100644 --- a/tests/ui/hygiene/panic-location.run.stderr +++ b/tests/ui/hygiene/panic-location.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at $DIR/panic-location.rs:LL:CC: +thread 'main' ($TID) panicked at $DIR/panic-location.rs:LL:CC: capacity overflow note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.rs b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.rs index 09450089ada..ead81bf3374 100644 --- a/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.rs +++ b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Zwrite-long-types-to-disk=yes use std::cell::Cell; use std::rc::Rc; diff --git a/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.stderr b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.stderr index 52fa28145d6..ba76d9ba2b8 100644 --- a/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.stderr +++ b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.stderr @@ -1,5 +1,5 @@ error[E0277]: `Rc<Cell<i32>>` cannot be sent between threads safely - --> $DIR/auto-trait-leak2.rs:20:10 + --> $DIR/auto-trait-leak2.rs:21:10 | LL | fn before() -> impl Fn(i32) { | ------------ within this `impl Fn(i32)` @@ -11,23 +11,23 @@ LL | send(before()); | = help: within `impl Fn(i32)`, the trait `Send` is not implemented for `Rc<Cell<i32>>` note: required because it's used within this closure - --> $DIR/auto-trait-leak2.rs:10:5 + --> $DIR/auto-trait-leak2.rs:11:5 | LL | move |x| p.set(x) | ^^^^^^^^ note: required because it appears within the type `impl Fn(i32)` - --> $DIR/auto-trait-leak2.rs:5:16 + --> $DIR/auto-trait-leak2.rs:6:16 | LL | fn before() -> impl Fn(i32) { | ^^^^^^^^^^^^ note: required by a bound in `send` - --> $DIR/auto-trait-leak2.rs:13:12 + --> $DIR/auto-trait-leak2.rs:14:12 | LL | fn send<T: Send>(_: T) {} | ^^^^ required by this bound in `send` error[E0277]: `Rc<Cell<i32>>` cannot be sent between threads safely - --> $DIR/auto-trait-leak2.rs:25:10 + --> $DIR/auto-trait-leak2.rs:26:10 | LL | send(after()); | ---- ^^^^^^^ `Rc<Cell<i32>>` cannot be sent between threads safely @@ -39,17 +39,17 @@ LL | fn after() -> impl Fn(i32) { | = help: within `impl Fn(i32)`, the trait `Send` is not implemented for `Rc<Cell<i32>>` note: required because it's used within this closure - --> $DIR/auto-trait-leak2.rs:38:5 + --> $DIR/auto-trait-leak2.rs:39:5 | LL | move |x| p.set(x) | ^^^^^^^^ note: required because it appears within the type `impl Fn(i32)` - --> $DIR/auto-trait-leak2.rs:33:15 + --> $DIR/auto-trait-leak2.rs:34:15 | LL | fn after() -> impl Fn(i32) { | ^^^^^^^^^^^^ note: required by a bound in `send` - --> $DIR/auto-trait-leak2.rs:13:12 + --> $DIR/auto-trait-leak2.rs:14:12 | LL | fn send<T: Send>(_: T) {} | ^^^^ required by this bound in `send` diff --git a/tests/ui/impl-trait/issues/type-error-post-normalization-test.rs b/tests/ui/impl-trait/issues/type-error-post-normalization-test.rs new file mode 100644 index 00000000000..0108bb23611 --- /dev/null +++ b/tests/ui/impl-trait/issues/type-error-post-normalization-test.rs @@ -0,0 +1,24 @@ +//@ compile-flags: -Zvalidate-mir -Zinline-mir=yes + +// This previously introduced a `{type_error}`` in the MIR body +// during the `PostAnalysisNormalize` pass. While the underlying issue +// #135528 did not get fixed, this reproducer no longer ICEs. + +#![feature(type_alias_impl_trait)] +type Tait = impl Copy; + +fn set(x: &isize) -> isize { + *x +} + +#[define_opaque(Tait)] +fn d(x: Tait) { + set(x); +} + +#[define_opaque(Tait)] +fn other_define() -> Tait { + () //~^ ERROR concrete type differs from previous defining opaque type use +} + +fn main() {} diff --git a/tests/ui/impl-trait/issues/type-error-post-normalization-test.stderr b/tests/ui/impl-trait/issues/type-error-post-normalization-test.stderr new file mode 100644 index 00000000000..7d63c1cfbd6 --- /dev/null +++ b/tests/ui/impl-trait/issues/type-error-post-normalization-test.stderr @@ -0,0 +1,14 @@ +error: concrete type differs from previous defining opaque type use + --> $DIR/type-error-post-normalization-test.rs:20:22 + | +LL | fn other_define() -> Tait { + | ^^^^ expected `&isize`, got `()` + | +note: previous use here + --> $DIR/type-error-post-normalization-test.rs:16:9 + | +LL | set(x); + | ^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/impl-trait/member-constraints/apply_member_constraint-no-req-eq.rs b/tests/ui/impl-trait/member-constraints/apply_member_constraint-no-req-eq.rs new file mode 100644 index 00000000000..3aa52fe2644 --- /dev/null +++ b/tests/ui/impl-trait/member-constraints/apply_member_constraint-no-req-eq.rs @@ -0,0 +1,24 @@ +//@ check-pass +// FIXME(-Znext-solver): enable this test + +trait Id { + type This; +} +impl<T> Id for T { + type This = T; +} + +// We have two member constraints here: +// +// - 'unconstrained member ['a, 'static] +// - 'unconstrained member ['static] +// +// Applying the first constraint results in `'unconstrained: 'a` +// while the second then adds `'unconstrained: 'static`. If applying +// member constraints were to require the member region equal to the +// choice region, applying the first constraint first and then the +// second would result in a `'a: 'static` requirement. +fn test<'a>() -> impl Id<This = impl Sized + use<>> + use<'a> { + &() +} +fn main() {} diff --git a/tests/ui/impl-trait/member-constraints/incomplete-constraint.rs b/tests/ui/impl-trait/member-constraints/incomplete-constraint.rs new file mode 100644 index 00000000000..4c085cc1eed --- /dev/null +++ b/tests/ui/impl-trait/member-constraints/incomplete-constraint.rs @@ -0,0 +1,21 @@ +//@ check-pass +// FIXME(-Znext-solver): enable this test + +// These functions currently do not normalize the opaque type but will do +// so in the future. At this point we've got a new use of the opaque with fully +// universal arguments but for which lifetimes in the hidden type are unconstrained. +// +// Applying the member constraints would then incompletely infer `'unconstrained` to `'static`. +fn new_defining_use<F: FnOnce(T) -> R, T, R>(_: F) {} + +fn rpit1<'a, 'b: 'b>(x: &'b ()) -> impl Sized + use<'a, 'b> { + new_defining_use(rpit1::<'a, 'b>); + x +} + +struct Inv<'a, 'b>(*mut (&'a (), &'b ())); +fn rpit2<'a>(_: ()) -> impl Sized + use<'a> { + new_defining_use(rpit2::<'a>); + Inv::<'a, 'static>(std::ptr::null_mut()) +} +fn main() {} diff --git a/tests/ui/nll/member-constraints/min-choice-reject-ambiguous.rs b/tests/ui/impl-trait/member-constraints/min-choice-reject-ambiguous.rs index 09138095523..09138095523 100644 --- a/tests/ui/nll/member-constraints/min-choice-reject-ambiguous.rs +++ b/tests/ui/impl-trait/member-constraints/min-choice-reject-ambiguous.rs diff --git a/tests/ui/nll/member-constraints/min-choice-reject-ambiguous.stderr b/tests/ui/impl-trait/member-constraints/min-choice-reject-ambiguous.stderr index 911ddd3dc80..911ddd3dc80 100644 --- a/tests/ui/nll/member-constraints/min-choice-reject-ambiguous.stderr +++ b/tests/ui/impl-trait/member-constraints/min-choice-reject-ambiguous.stderr diff --git a/tests/ui/nll/member-constraints/min-choice.rs b/tests/ui/impl-trait/member-constraints/min-choice.rs index 4fbffeb4b2a..4fbffeb4b2a 100644 --- a/tests/ui/nll/member-constraints/min-choice.rs +++ b/tests/ui/impl-trait/member-constraints/min-choice.rs diff --git a/tests/ui/nll/member-constraints/nested-impl-trait-fail.rs b/tests/ui/impl-trait/member-constraints/nested-impl-trait-fail.rs index 0bf32a2624f..0bf32a2624f 100644 --- a/tests/ui/nll/member-constraints/nested-impl-trait-fail.rs +++ b/tests/ui/impl-trait/member-constraints/nested-impl-trait-fail.rs diff --git a/tests/ui/nll/member-constraints/nested-impl-trait-fail.stderr b/tests/ui/impl-trait/member-constraints/nested-impl-trait-fail.stderr index 1a0611e715e..1a0611e715e 100644 --- a/tests/ui/nll/member-constraints/nested-impl-trait-fail.stderr +++ b/tests/ui/impl-trait/member-constraints/nested-impl-trait-fail.stderr diff --git a/tests/ui/nll/member-constraints/nested-impl-trait-pass.rs b/tests/ui/impl-trait/member-constraints/nested-impl-trait-pass.rs index 4633ad68230..6860fc5e6a5 100644 --- a/tests/ui/nll/member-constraints/nested-impl-trait-pass.rs +++ b/tests/ui/impl-trait/member-constraints/nested-impl-trait-pass.rs @@ -1,6 +1,7 @@ // Nested impl-traits can impose different member constraints on the same region variable. //@ check-pass +// FIXME(-Znext-solver): enable this test trait Cap<'a> {} impl<T> Cap<'_> for T {} @@ -8,7 +9,9 @@ impl<T> Cap<'_> for T {} // Assuming the hidden type is `[&'?15 u8; 1]`, we have two distinct member constraints: // - '?15 member ['static, 'a, 'b] // from outer impl-trait // - '?15 member ['static, 'a] // from inner impl-trait -// To satisfy both we can only choose 'a. +// To satisfy both we can only choose 'a. Concretely, first member constraint requires ?15 +// to outlive at least 'b while the second requires ?15 to outlive 'a. As 'a outlives 'b we +// end up with 'a as the final member region. fn pass_early_bound<'s, 'a, 'b>(a: &'s u8) -> impl IntoIterator<Item = impl Cap<'a>> + Cap<'b> where 's: 'a, diff --git a/tests/ui/impl-trait/member-constraints/reject-choice-due-to-prev-constraint.rs b/tests/ui/impl-trait/member-constraints/reject-choice-due-to-prev-constraint.rs new file mode 100644 index 00000000000..33f2d277fe5 --- /dev/null +++ b/tests/ui/impl-trait/member-constraints/reject-choice-due-to-prev-constraint.rs @@ -0,0 +1,34 @@ +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ check-pass + +// We've got `'0 member ['a, 'b, 'static]` and `'1 member ['a, 'b, 'static]`. +// +// As '0 gets outlived by 'a - its "upper bound" - the only applicable choice +// region is 'a. +// +// '1 has to outlive 'b so the only applicable choice regions are 'b and 'static. +// Considering this member constraint by itself would choose 'b as it is the +// smaller of the two regions. +// +// However, this is only the case when ignoring the member constraint on '0. +// After applying this constraint and requiring '0 to outlive 'a. As '1 outlives +// '0, the region 'b is no longer an applicable choice region for '1 as 'b does +// does not outlive 'a. We would therefore choose 'static. +// +// This means applying member constraints is order dependent. We handle this by +// first applying member constraints for regions 'x and then consider the resulting +// constraints when applying member constraints for regions 'y with 'y: 'x. +fn with_constraints<'r0, 'r1, 'a, 'b>() -> *mut (&'r0 (), &'r1 ()) +where + 'r1: 'r0, + 'a: 'r0, + 'r1: 'b, +{ + loop {} +} +fn foo<'a, 'b>() -> impl Sized + use<'a, 'b> { + with_constraints::<'_, '_, 'a, 'b>() +} +fn main() {} diff --git a/tests/ui/impl-trait/no-anonymize-regions.rs b/tests/ui/impl-trait/no-anonymize-regions.rs new file mode 100644 index 00000000000..4f7f7c0641c --- /dev/null +++ b/tests/ui/impl-trait/no-anonymize-regions.rs @@ -0,0 +1,18 @@ +//@ check-pass +// FIXME(-Znext-solver): enable this test + +// A regression test for an error in `redis` while working on #139587. +// +// We check for structural equality when adding defining uses of opaques. +// In this test one defining use had anonymized regions while the other +// one did not, causing an error. +struct W<T>(T); +fn constrain<F: FnOnce(T) -> R, T, R>(f: F) -> R { + loop {} +} +fn foo<'a>(x: for<'b> fn(&'b ())) -> impl Sized + use<'a> { + let mut r = constrain(foo::<'_>); + r = W(x); + r +} +fn main() {} diff --git a/tests/ui/issues/auxiliary/issue-9968.rs b/tests/ui/imports/auxiliary/aux-9968.rs index 8d795b59ea8..8d795b59ea8 100644 --- a/tests/ui/issues/auxiliary/issue-9968.rs +++ b/tests/ui/imports/auxiliary/aux-9968.rs diff --git a/tests/ui/issues/issue-15774.rs b/tests/ui/imports/enum-variant-import-path-15774.rs index dadd59cc077..583fe4da179 100644 --- a/tests/ui/issues/issue-15774.rs +++ b/tests/ui/imports/enum-variant-import-path-15774.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15774 + //@ edition: 2015 //@ run-pass diff --git a/tests/ui/imports/issue-109148.rs b/tests/ui/imports/issue-109148.rs index 9d657a87381..49fc2fe0f5b 100644 --- a/tests/ui/imports/issue-109148.rs +++ b/tests/ui/imports/issue-109148.rs @@ -10,6 +10,7 @@ macro_rules! m { m!(); -use std::mem; +use std::mem; //~ ERROR `std` is ambiguous +use ::std::mem as _; //~ ERROR `std` is ambiguous fn main() {} diff --git a/tests/ui/imports/issue-109148.stderr b/tests/ui/imports/issue-109148.stderr index b7f1f69dc8f..ee047385ae3 100644 --- a/tests/ui/imports/issue-109148.stderr +++ b/tests/ui/imports/issue-109148.stderr @@ -9,5 +9,43 @@ LL | m!(); | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 1 previous error +error[E0659]: `std` is ambiguous + --> $DIR/issue-109148.rs:13:5 + | +LL | use std::mem; + | ^^^ ambiguous name + | + = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution + = note: `std` could refer to a built-in crate +note: `std` could also refer to the crate imported here + --> $DIR/issue-109148.rs:6:9 + | +LL | extern crate core as std; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | m!(); + | ---- in this macro invocation + = help: use `crate::std` to refer to this crate unambiguously + = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0659]: `std` is ambiguous + --> $DIR/issue-109148.rs:14:7 + | +LL | use ::std::mem as _; + | ^^^ ambiguous name + | + = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution + = note: `std` could refer to a built-in crate +note: `std` could also refer to the crate imported here + --> $DIR/issue-109148.rs:6:9 + | +LL | extern crate core as std; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | m!(); + | ---- in this macro invocation + = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/local-modularized-tricky-fail-2.stderr b/tests/ui/imports/local-modularized-tricky-fail-2.stderr index 49f5c72947f..ea4056b3d75 100644 --- a/tests/ui/imports/local-modularized-tricky-fail-2.stderr +++ b/tests/ui/imports/local-modularized-tricky-fail-2.stderr @@ -41,3 +41,47 @@ LL | define_exported!(); error: aborting due to 2 previous errors +Future incompatibility report: Future breakage diagnostic: +error: macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths + --> $DIR/local-modularized-tricky-fail-2.rs:13:9 + | +LL | use crate::exported; + | ^^^^^^^^^^^^^^^ + | + = 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 #52234 <https://github.com/rust-lang/rust/issues/52234> +note: the macro is defined here + --> $DIR/local-modularized-tricky-fail-2.rs:5:5 + | +LL | / macro_rules! exported { +LL | | () => () +LL | | } + | |_____^ +... +LL | define_exported!(); + | ------------------ in this macro invocation + = note: `#[deny(macro_expanded_macro_exports_accessed_by_absolute_paths)]` on by default + = note: this error originates in the macro `define_exported` (in Nightly builds, run with -Z macro-backtrace for more info) + +Future breakage diagnostic: +error: macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths + --> $DIR/local-modularized-tricky-fail-2.rs:19:5 + | +LL | crate::exported!(); + | ^^^^^^^^^^^^^^^ + | + = 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 #52234 <https://github.com/rust-lang/rust/issues/52234> +note: the macro is defined here + --> $DIR/local-modularized-tricky-fail-2.rs:5:5 + | +LL | / macro_rules! exported { +LL | | () => () +LL | | } + | |_____^ +... +LL | define_exported!(); + | ------------------ in this macro invocation + = note: `#[deny(macro_expanded_macro_exports_accessed_by_absolute_paths)]` on by default + = note: this error originates in the macro `define_exported` (in Nightly builds, run with -Z macro-backtrace for more info) + diff --git a/tests/ui/imports/pub-use-link-errors-9968.rs b/tests/ui/imports/pub-use-link-errors-9968.rs new file mode 100644 index 00000000000..517a0049ce0 --- /dev/null +++ b/tests/ui/imports/pub-use-link-errors-9968.rs @@ -0,0 +1,12 @@ +// https://github.com/rust-lang/rust/issues/9968 +//@ run-pass +//@ aux-build:aux-9968.rs + +extern crate aux_9968 as lib; + +use lib::{Trait, Struct}; + +pub fn main() +{ + Struct::init().test(); +} diff --git a/tests/ui/inference/iterator-sum-array-15673.rs b/tests/ui/inference/iterator-sum-array-15673.rs new file mode 100644 index 00000000000..c3d94415aff --- /dev/null +++ b/tests/ui/inference/iterator-sum-array-15673.rs @@ -0,0 +1,11 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15673 + +//@ run-pass +#![allow(stable_features)] + +#![feature(iter_arith)] + +fn main() { + let x: [u64; 3] = [1, 2, 3]; + assert_eq!(6, (0..3).map(|i| x[i]).sum::<u64>()); +} diff --git a/tests/ui/issues/issue-14919.rs b/tests/ui/inference/matcher-lifetime-inference-14919.rs index 3a834b13d07..742d43f3efe 100644 --- a/tests/ui/issues/issue-14919.rs +++ b/tests/ui/inference/matcher-lifetime-inference-14919.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/14919 + //@ run-pass #![allow(unused_must_use)] #![allow(dead_code)] diff --git a/tests/ui/inference/really-long-type-in-let-binding-without-sufficient-type-info.rs b/tests/ui/inference/really-long-type-in-let-binding-without-sufficient-type-info.rs index 4fd15eea9e0..f1353f1805d 100644 --- a/tests/ui/inference/really-long-type-in-let-binding-without-sufficient-type-info.rs +++ b/tests/ui/inference/really-long-type-in-let-binding-without-sufficient-type-info.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Zwrite-long-types-to-disk=yes type A = (i32, i32, i32, i32); type B = (A, A, A, A); type C = (B, B, B, B); diff --git a/tests/ui/inference/really-long-type-in-let-binding-without-sufficient-type-info.stderr b/tests/ui/inference/really-long-type-in-let-binding-without-sufficient-type-info.stderr index 65fe2ffcb7f..5c4a1a75829 100644 --- a/tests/ui/inference/really-long-type-in-let-binding-without-sufficient-type-info.stderr +++ b/tests/ui/inference/really-long-type-in-let-binding-without-sufficient-type-info.stderr @@ -1,9 +1,11 @@ -error[E0282]: type annotations needed for `Result<_, ((((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32))), (((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32))), (((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32))), (((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32))))>` - --> $DIR/really-long-type-in-let-binding-without-sufficient-type-info.rs:7:9 +error[E0282]: type annotations needed for `Result<_, (((..., ..., ..., ...), ..., ..., ...), ..., ..., ...)>` + --> $DIR/really-long-type-in-let-binding-without-sufficient-type-info.rs:8:9 | LL | let y = Err(x); | ^ ------ type must be known at this point | + = note: the full name for the type has been written to '$TEST_BUILD_DIR/really-long-type-in-let-binding-without-sufficient-type-info.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console help: consider giving `y` an explicit type, where the type for type parameter `T` is specified | LL | let y: Result<T, _> = Err(x); diff --git a/tests/ui/issues/issue-15965.rs b/tests/ui/inference/return-block-type-inference-15965.rs index eef4900d432..50753e309e8 100644 --- a/tests/ui/issues/issue-15965.rs +++ b/tests/ui/inference/return-block-type-inference-15965.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15965 + fn main() { return { return () } diff --git a/tests/ui/issues/issue-15965.stderr b/tests/ui/inference/return-block-type-inference-15965.stderr index 14727e74334..fc4f2defe7f 100644 --- a/tests/ui/issues/issue-15965.stderr +++ b/tests/ui/inference/return-block-type-inference-15965.stderr @@ -1,5 +1,5 @@ error[E0282]: type annotations needed - --> $DIR/issue-15965.rs:3:9 + --> $DIR/return-block-type-inference-15965.rs:5:9 | LL | / { return () } LL | | diff --git a/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.rs b/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.rs index f50c4a5207a..f7117368ece 100644 --- a/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.rs +++ b/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.rs @@ -1,5 +1,6 @@ -//~ ERROR reached the recursion limit while instantiating `<VirtualWrapper<VirtualWrapper<VirtualWrapper +//~ ERROR reached the recursion limit while instantiating `<VirtualWrapper< //@ build-fail +//@ compile-flags: --diagnostic-width=100 -Zwrite-long-types-to-disk=yes // Regression test for #114484: This used to ICE during monomorphization, because we treated // `<VirtualWrapper<...> as Pointee>::Metadata` as a rigid projection after reaching the recursion diff --git a/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.stderr b/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.stderr index 59addc5cc4a..faf9cbe2318 100644 --- a/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.stderr +++ b/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.stderr @@ -17,11 +17,14 @@ error: reached the recursion limit finding the struct tail for `[u8; 256]` = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -note: the above error was encountered while instantiating `fn virtualize_my_trait::<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<SomeData<256>, 0>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>>` - --> $DIR/infinite-instantiation-struct-tail-ice-114484.rs:24:18 +note: the above error was encountered while instantiating `fn virtualize_my_trait::<VirtualWrapper<..., 1>>` + --> $DIR/infinite-instantiation-struct-tail-ice-114484.rs:25:18 | LL | unsafe { virtualize_my_trait(L, self) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the full name for the type has been written to '$TEST_BUILD_DIR/infinite-instantiation-struct-tail-ice-114484.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: reached the recursion limit finding the struct tail for `SomeData<256>` | @@ -42,11 +45,14 @@ error: reached the recursion limit finding the struct tail for `SomeData<256>` = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -note: the above error was encountered while instantiating `fn virtualize_my_trait::<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<SomeData<256>, 0>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>>` - --> $DIR/infinite-instantiation-struct-tail-ice-114484.rs:24:18 +note: the above error was encountered while instantiating `fn virtualize_my_trait::<VirtualWrapper<..., 1>>` + --> $DIR/infinite-instantiation-struct-tail-ice-114484.rs:25:18 | LL | unsafe { virtualize_my_trait(L, self) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the full name for the type has been written to '$TEST_BUILD_DIR/infinite-instantiation-struct-tail-ice-114484.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: reached the recursion limit finding the struct tail for `VirtualWrapper<SomeData<256>, 0>` | @@ -67,20 +73,24 @@ error: reached the recursion limit finding the struct tail for `VirtualWrapper<S = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -note: the above error was encountered while instantiating `fn virtualize_my_trait::<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<SomeData<256>, 0>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>>` - --> $DIR/infinite-instantiation-struct-tail-ice-114484.rs:24:18 +note: the above error was encountered while instantiating `fn virtualize_my_trait::<VirtualWrapper<..., 1>>` + --> $DIR/infinite-instantiation-struct-tail-ice-114484.rs:25:18 | LL | unsafe { virtualize_my_trait(L, self) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the full name for the type has been written to '$TEST_BUILD_DIR/infinite-instantiation-struct-tail-ice-114484.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console -error: reached the recursion limit while instantiating `<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<VirtualWrapper<..., 1>, 1>, 1>, 1>, 1> as MyTrait>::virtualize` +error: reached the recursion limit while instantiating `<VirtualWrapper<..., 1> as MyTrait>::virtualize` | note: `<VirtualWrapper<T, L> as MyTrait>::virtualize` defined here - --> $DIR/infinite-instantiation-struct-tail-ice-114484.rs:23:5 + --> $DIR/infinite-instantiation-struct-tail-ice-114484.rs:24:5 | LL | fn virtualize(&self) -> &dyn MyTrait { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the full type name has been written to '$TEST_BUILD_DIR/infinite-instantiation-struct-tail-ice-114484.long-type.txt' + = note: the full name for the type has been written to '$TEST_BUILD_DIR/infinite-instantiation-struct-tail-ice-114484.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 13 previous errors diff --git a/tests/ui/infinite/infinite-instantiation.rs b/tests/ui/infinite/infinite-instantiation.rs index 7898cc1ffc1..4f86f70ad14 100644 --- a/tests/ui/infinite/infinite-instantiation.rs +++ b/tests/ui/infinite/infinite-instantiation.rs @@ -1,4 +1,5 @@ //@ build-fail +//@ compile-flags: --diagnostic-width=100 -Zwrite-long-types-to-disk=yes trait ToOpt: Sized { fn to_option(&self) -> Option<Self>; diff --git a/tests/ui/infinite/infinite-instantiation.stderr b/tests/ui/infinite/infinite-instantiation.stderr index d7a4a49961a..32185844412 100644 --- a/tests/ui/infinite/infinite-instantiation.stderr +++ b/tests/ui/infinite/infinite-instantiation.stderr @@ -1,15 +1,16 @@ -error: reached the recursion limit while instantiating `function::<Option<Option<Option<Option<Option<...>>>>>>` - --> $DIR/infinite-instantiation.rs:21:9 +error: reached the recursion limit while instantiating `function::<Option<Option<Option<Option<...>>>>>` + --> $DIR/infinite-instantiation.rs:22:9 | LL | function(counter - 1, t.to_option()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `function` defined here - --> $DIR/infinite-instantiation.rs:19:1 + --> $DIR/infinite-instantiation.rs:20:1 | LL | fn function<T:ToOpt + Clone>(counter: usize, t: T) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the full type name has been written to '$TEST_BUILD_DIR/infinite-instantiation.long-type.txt' + = note: the full name for the type has been written to '$TEST_BUILD_DIR/infinite-instantiation.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error diff --git a/tests/ui/infinite/issue-41731-infinite-macro-print.rs b/tests/ui/infinite/issue-41731-infinite-macro-print.rs index 7cd3ff3d629..aa5555b117a 100644 --- a/tests/ui/infinite/issue-41731-infinite-macro-print.rs +++ b/tests/ui/infinite/issue-41731-infinite-macro-print.rs @@ -5,7 +5,7 @@ fn main() { macro_rules! stack { ($overflow:expr) => { - print!(stack!($overflow)); + print!(stack!($overflow)) //~^ ERROR recursion limit reached while expanding //~| ERROR format argument must be a string literal }; diff --git a/tests/ui/infinite/issue-41731-infinite-macro-print.stderr b/tests/ui/infinite/issue-41731-infinite-macro-print.stderr index 71510816d0b..84436de9aa3 100644 --- a/tests/ui/infinite/issue-41731-infinite-macro-print.stderr +++ b/tests/ui/infinite/issue-41731-infinite-macro-print.stderr @@ -14,11 +14,11 @@ LL | stack!("overflow"); | ^^^^^^^^^^^^^^^^^^ | = note: expanding `stack! { "overflow" }` - = note: to `print! (stack! ("overflow"));` + = note: to `print! (stack! ("overflow"))` = note: expanding `print! { stack! ("overflow") }` = note: to `{ $crate :: io :: _print($crate :: format_args! (stack! ("overflow"))); }` = note: expanding `stack! { "overflow" }` - = note: to `print! (stack! ("overflow"));` + = note: to `print! (stack! ("overflow"))` = note: expanding `print! { stack! ("overflow") }` = note: to `{ $crate :: io :: _print($crate :: format_args! (stack! ("overflow"))); }` @@ -31,7 +31,7 @@ LL | stack!("overflow"); = note: this error originates in the macro `print` which comes from the expansion of the macro `stack` (in Nightly builds, run with -Z macro-backtrace for more info) help: you might be missing a string literal to format with | -LL | print!("{}", stack!($overflow)); +LL | print!("{}", stack!($overflow)) | +++++ error: aborting due to 2 previous errors diff --git a/tests/ui/infinite/issue-41731-infinite-macro-println.rs b/tests/ui/infinite/issue-41731-infinite-macro-println.rs index 491f18dc4c6..cf59afb0194 100644 --- a/tests/ui/infinite/issue-41731-infinite-macro-println.rs +++ b/tests/ui/infinite/issue-41731-infinite-macro-println.rs @@ -5,7 +5,7 @@ fn main() { macro_rules! stack { ($overflow:expr) => { - println!(stack!($overflow)); + println!(stack!($overflow)) //~^ ERROR recursion limit reached while expanding //~| ERROR format argument must be a string literal }; diff --git a/tests/ui/infinite/issue-41731-infinite-macro-println.stderr b/tests/ui/infinite/issue-41731-infinite-macro-println.stderr index 645176d45cb..6d0432abe4c 100644 --- a/tests/ui/infinite/issue-41731-infinite-macro-println.stderr +++ b/tests/ui/infinite/issue-41731-infinite-macro-println.stderr @@ -14,11 +14,11 @@ LL | stack!("overflow"); | ^^^^^^^^^^^^^^^^^^ | = note: expanding `stack! { "overflow" }` - = note: to `println! (stack! ("overflow"));` + = note: to `println! (stack! ("overflow"))` = note: expanding `println! { stack! ("overflow") }` = note: to `{ $crate :: io :: _print($crate :: format_args_nl! (stack! ("overflow"))); }` = note: expanding `stack! { "overflow" }` - = note: to `println! (stack! ("overflow"));` + = note: to `println! (stack! ("overflow"))` = note: expanding `println! { stack! ("overflow") }` = note: to `{ $crate :: io :: _print($crate :: format_args_nl! (stack! ("overflow"))); }` @@ -31,7 +31,7 @@ LL | stack!("overflow"); = note: this error originates in the macro `println` which comes from the expansion of the macro `stack` (in Nightly builds, run with -Z macro-backtrace for more info) help: you might be missing a string literal to format with | -LL | println!("{}", stack!($overflow)); +LL | println!("{}", stack!($overflow)) | +++++ error: aborting due to 2 previous errors diff --git a/tests/ui/inline-const/const-expr-generic-err.stderr b/tests/ui/inline-const/const-expr-generic-err.stderr index 26039ba6d44..e053e88db17 100644 --- a/tests/ui/inline-const/const-expr-generic-err.stderr +++ b/tests/ui/inline-const/const-expr-generic-err.stderr @@ -1,8 +1,8 @@ error[E0080]: evaluation panicked: assertion failed: std::mem::size_of::<T>() == 0 - --> $DIR/const-expr-generic-err.rs:4:13 + --> $DIR/const-expr-generic-err.rs:4:21 | LL | const { assert!(std::mem::size_of::<T>() == 0); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `foo::<i32>::{constant#0}` failed here + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `foo::<i32>::{constant#0}` failed here note: erroneous constant encountered --> $DIR/const-expr-generic-err.rs:4:5 diff --git a/tests/ui/instrument-coverage/coverage-options.bad.stderr b/tests/ui/instrument-coverage/coverage-options.bad.stderr index 4a272cf97fb..a7ea721659b 100644 --- a/tests/ui/instrument-coverage/coverage-options.bad.stderr +++ b/tests/ui/instrument-coverage/coverage-options.bad.stderr @@ -1,2 +1,2 @@ -error: incorrect value `bad` for unstable option `coverage-options` - `block` | `branch` | `condition` | `mcdc` was expected +error: incorrect value `bad` for unstable option `coverage-options` - `block` | `branch` | `condition` was expected diff --git a/tests/ui/instrument-coverage/coverage-options.rs b/tests/ui/instrument-coverage/coverage-options.rs index c3eae9625da..ead2e3221d8 100644 --- a/tests/ui/instrument-coverage/coverage-options.rs +++ b/tests/ui/instrument-coverage/coverage-options.rs @@ -1,4 +1,4 @@ -//@ revisions: block branch condition mcdc bad +//@ revisions: block branch condition bad //@ compile-flags -Cinstrument-coverage -Zno-profiler-runtime //@ [block] check-pass @@ -10,9 +10,6 @@ //@ [condition] check-pass //@ [condition] compile-flags: -Zcoverage-options=condition -//@ [mcdc] check-pass -//@ [mcdc] compile-flags: -Zcoverage-options=mcdc - //@ [bad] check-fail //@ [bad] compile-flags: -Zcoverage-options=bad diff --git a/tests/ui/instrument-coverage/mcdc-condition-limit.rs b/tests/ui/instrument-coverage/mcdc-condition-limit.rs deleted file mode 100644 index 74707ba2e67..00000000000 --- a/tests/ui/instrument-coverage/mcdc-condition-limit.rs +++ /dev/null @@ -1,22 +0,0 @@ -//@ edition: 2021 -//@ revisions: good -//@ check-pass -//@ compile-flags: -Cinstrument-coverage -Zcoverage-options=mcdc -Zno-profiler-runtime - -// Check that we emit some kind of diagnostic when MC/DC instrumentation sees -// code that exceeds the limit of 6 conditions per decision, and falls back -// to only instrumenting that code for branch coverage. -// -// See also `tests/coverage/mcdc/condition-limit.rs`, which tests the actual -// effect on instrumentation. -// -// (The limit is enforced in `compiler/rustc_mir_build/src/build/coverageinfo/mcdc.rs`.) - -#[cfg(good)] -fn main() { - // 7 conditions is allowed, so no diagnostic. - let [a, b, c, d, e, f, g] = <[bool; 7]>::default(); - if a && b && c && d && e && f && g { - core::hint::black_box("hello"); - } -} diff --git a/tests/ui/interior-mutability/interior-mutability.rs b/tests/ui/interior-mutability/interior-mutability.rs index c704acc22af..7e4fe76852d 100644 --- a/tests/ui/interior-mutability/interior-mutability.rs +++ b/tests/ui/interior-mutability/interior-mutability.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Zwrite-long-types-to-disk=yes use std::cell::Cell; use std::panic::catch_unwind; fn main() { diff --git a/tests/ui/interior-mutability/interior-mutability.stderr b/tests/ui/interior-mutability/interior-mutability.stderr index cfc64445bf3..5a959d14c8a 100644 --- a/tests/ui/interior-mutability/interior-mutability.stderr +++ b/tests/ui/interior-mutability/interior-mutability.stderr @@ -1,5 +1,5 @@ error[E0277]: the type `UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary - --> $DIR/interior-mutability.rs:5:18 + --> $DIR/interior-mutability.rs:6:18 | LL | catch_unwind(|| { x.set(23); }); | ------------ ^^^^^^^^^^^^^^^^^ `UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary @@ -11,7 +11,7 @@ note: required because it appears within the type `Cell<i32>` --> $SRC_DIR/core/src/cell.rs:LL:COL = note: required for `&Cell<i32>` to implement `UnwindSafe` note: required because it's used within this closure - --> $DIR/interior-mutability.rs:5:18 + --> $DIR/interior-mutability.rs:6:18 | LL | catch_unwind(|| { x.set(23); }); | ^^ diff --git a/tests/ui/intrinsics/bad-intrinsic-monomorphization.stderr b/tests/ui/intrinsics/bad-intrinsic-monomorphization.stderr index f49d95e9cfc..51ef71c9e29 100644 --- a/tests/ui/intrinsics/bad-intrinsic-monomorphization.stderr +++ b/tests/ui/intrinsics/bad-intrinsic-monomorphization.stderr @@ -1,8 +1,8 @@ -error[E0511]: invalid monomorphization of `cttz` intrinsic: expected basic integer type, found `Foo` - --> $DIR/bad-intrinsic-monomorphization.rs:16:5 +error[E0511]: invalid monomorphization of `simd_add` intrinsic: expected SIMD input type, found non-SIMD `Foo` + --> $DIR/bad-intrinsic-monomorphization.rs:26:5 | -LL | intrinsics::cttz(v) - | ^^^^^^^^^^^^^^^^^^^ +LL | intrinsics::simd::simd_add(a, b) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `fadd_fast` intrinsic: expected basic float type, found `Foo` --> $DIR/bad-intrinsic-monomorphization.rs:21:5 @@ -10,11 +10,11 @@ error[E0511]: invalid monomorphization of `fadd_fast` intrinsic: expected basic LL | intrinsics::fadd_fast(a, b) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `simd_add` intrinsic: expected SIMD input type, found non-SIMD `Foo` - --> $DIR/bad-intrinsic-monomorphization.rs:26:5 +error[E0511]: invalid monomorphization of `cttz` intrinsic: expected basic integer type, found `Foo` + --> $DIR/bad-intrinsic-monomorphization.rs:16:5 | -LL | intrinsics::simd::simd_add(a, b) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | intrinsics::cttz(v) + | ^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/intrinsics/const-eval-select-backtrace-std.run.stderr b/tests/ui/intrinsics/const-eval-select-backtrace-std.run.stderr index 71d792b7f77..397eeaf600a 100644 --- a/tests/ui/intrinsics/const-eval-select-backtrace-std.run.stderr +++ b/tests/ui/intrinsics/const-eval-select-backtrace-std.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at $DIR/const-eval-select-backtrace-std.rs:6:8: +thread 'main' ($TID) panicked at $DIR/const-eval-select-backtrace-std.rs:6:8: byte index 1 is out of bounds of `` note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/intrinsics/const-eval-select-backtrace.run.stderr b/tests/ui/intrinsics/const-eval-select-backtrace.run.stderr index 4f11f5966ed..649174017e9 100644 --- a/tests/ui/intrinsics/const-eval-select-backtrace.run.stderr +++ b/tests/ui/intrinsics/const-eval-select-backtrace.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at $DIR/const-eval-select-backtrace.rs:15:5: +thread 'main' ($TID) panicked at $DIR/const-eval-select-backtrace.rs:15:5: Aaah! note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/intrinsics/intrinsic-atomics.rs b/tests/ui/intrinsics/intrinsic-atomics.rs index 2275aafff83..c19948137db 100644 --- a/tests/ui/intrinsics/intrinsic-atomics.rs +++ b/tests/ui/intrinsics/intrinsic-atomics.rs @@ -33,14 +33,14 @@ pub fn main() { assert_eq!(rusti::atomic_xchg::<_, { Release }>(&mut *x, 0), 1); assert_eq!(*x, 0); - assert_eq!(rusti::atomic_xadd::<_, { SeqCst }>(&mut *x, 1), 0); - assert_eq!(rusti::atomic_xadd::<_, { Acquire }>(&mut *x, 1), 1); - assert_eq!(rusti::atomic_xadd::<_, { Release }>(&mut *x, 1), 2); + assert_eq!(rusti::atomic_xadd::<_, _, { SeqCst }>(&mut *x, 1), 0); + assert_eq!(rusti::atomic_xadd::<_, _, { Acquire }>(&mut *x, 1), 1); + assert_eq!(rusti::atomic_xadd::<_, _, { Release }>(&mut *x, 1), 2); assert_eq!(*x, 3); - assert_eq!(rusti::atomic_xsub::<_, { SeqCst }>(&mut *x, 1), 3); - assert_eq!(rusti::atomic_xsub::<_, { Acquire }>(&mut *x, 1), 2); - assert_eq!(rusti::atomic_xsub::<_, { Release }>(&mut *x, 1), 1); + assert_eq!(rusti::atomic_xsub::<_, _, { SeqCst }>(&mut *x, 1), 3); + assert_eq!(rusti::atomic_xsub::<_, _, { Acquire }>(&mut *x, 1), 2); + assert_eq!(rusti::atomic_xsub::<_, _, { Release }>(&mut *x, 1), 1); assert_eq!(*x, 0); loop { diff --git a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs index 15f4a9a778e..ed15f5bba96 100644 --- a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs +++ b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs @@ -1,3 +1,4 @@ +//@ normalize-stderr: "[[:xdigit:]]{2} __ ([[:xdigit:]]{2}\s){2}" -> "HEX_DUMP" #![feature(core_intrinsics)] const RAW_EQ_PADDING: bool = unsafe { diff --git a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr index 5f4ef14d586..329da35297e 100644 --- a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr +++ b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr @@ -1,15 +1,15 @@ error[E0080]: reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory - --> $DIR/intrinsic-raw_eq-const-bad.rs:4:5 + --> $DIR/intrinsic-raw_eq-const-bad.rs:5:5 | LL | std::intrinsics::raw_eq(&(1_u8, 2_u16), &(1_u8, 2_u16)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `RAW_EQ_PADDING` failed here | = note: the raw bytes of the constant (size: 4, align: 2) { - 01 __ 02 00 │ .░.. + HEX_DUMP │ .░.. } error[E0080]: unable to turn pointer into integer - --> $DIR/intrinsic-raw_eq-const-bad.rs:9:5 + --> $DIR/intrinsic-raw_eq-const-bad.rs:10:5 | LL | std::intrinsics::raw_eq(&(&0), &(&1)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `RAW_EQ_PTR` failed here @@ -18,7 +18,7 @@ LL | std::intrinsics::raw_eq(&(&0), &(&1)) = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: accessing memory with alignment 1, but alignment 4 is required - --> $DIR/intrinsic-raw_eq-const-bad.rs:16:5 + --> $DIR/intrinsic-raw_eq-const-bad.rs:17:5 | LL | std::intrinsics::raw_eq(aref, aref) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `RAW_EQ_NOT_ALIGNED` failed here diff --git a/tests/ui/intrinsics/non-integer-atomic.rs b/tests/ui/intrinsics/non-integer-atomic.rs index 853c163710f..30f713f1241 100644 --- a/tests/ui/intrinsics/non-integer-atomic.rs +++ b/tests/ui/intrinsics/non-integer-atomic.rs @@ -13,80 +13,80 @@ pub type Quux = [u8; 100]; pub unsafe fn test_bool_load(p: &mut bool, v: bool) { intrinsics::atomic_load::<_, { SeqCst }>(p); - //~^ ERROR `atomic_load` intrinsic: expected basic integer type, found `bool` + //~^ ERROR `atomic_load` intrinsic: expected basic integer or pointer type, found `bool` } pub unsafe fn test_bool_store(p: &mut bool, v: bool) { intrinsics::atomic_store::<_, { SeqCst }>(p, v); - //~^ ERROR `atomic_store` intrinsic: expected basic integer type, found `bool` + //~^ ERROR `atomic_store` intrinsic: expected basic integer or pointer type, found `bool` } pub unsafe fn test_bool_xchg(p: &mut bool, v: bool) { intrinsics::atomic_xchg::<_, { SeqCst }>(p, v); - //~^ ERROR `atomic_xchg` intrinsic: expected basic integer type, found `bool` + //~^ ERROR `atomic_xchg` intrinsic: expected basic integer or pointer type, found `bool` } pub unsafe fn test_bool_cxchg(p: &mut bool, v: bool) { intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v); - //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer type, found `bool` + //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer or pointer type, found `bool` } pub unsafe fn test_Foo_load(p: &mut Foo, v: Foo) { intrinsics::atomic_load::<_, { SeqCst }>(p); - //~^ ERROR `atomic_load` intrinsic: expected basic integer type, found `Foo` + //~^ ERROR `atomic_load` intrinsic: expected basic integer or pointer type, found `Foo` } pub unsafe fn test_Foo_store(p: &mut Foo, v: Foo) { intrinsics::atomic_store::<_, { SeqCst }>(p, v); - //~^ ERROR `atomic_store` intrinsic: expected basic integer type, found `Foo` + //~^ ERROR `atomic_store` intrinsic: expected basic integer or pointer type, found `Foo` } pub unsafe fn test_Foo_xchg(p: &mut Foo, v: Foo) { intrinsics::atomic_xchg::<_, { SeqCst }>(p, v); - //~^ ERROR `atomic_xchg` intrinsic: expected basic integer type, found `Foo` + //~^ ERROR `atomic_xchg` intrinsic: expected basic integer or pointer type, found `Foo` } pub unsafe fn test_Foo_cxchg(p: &mut Foo, v: Foo) { intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v); - //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer type, found `Foo` + //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer or pointer type, found `Foo` } pub unsafe fn test_Bar_load(p: &mut Bar, v: Bar) { intrinsics::atomic_load::<_, { SeqCst }>(p); - //~^ ERROR expected basic integer type, found `&dyn Fn()` + //~^ ERROR expected basic integer or pointer type, found `&dyn Fn()` } pub unsafe fn test_Bar_store(p: &mut Bar, v: Bar) { intrinsics::atomic_store::<_, { SeqCst }>(p, v); - //~^ ERROR expected basic integer type, found `&dyn Fn()` + //~^ ERROR expected basic integer or pointer type, found `&dyn Fn()` } pub unsafe fn test_Bar_xchg(p: &mut Bar, v: Bar) { intrinsics::atomic_xchg::<_, { SeqCst }>(p, v); - //~^ ERROR expected basic integer type, found `&dyn Fn()` + //~^ ERROR expected basic integer or pointer type, found `&dyn Fn()` } pub unsafe fn test_Bar_cxchg(p: &mut Bar, v: Bar) { intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v); - //~^ ERROR expected basic integer type, found `&dyn Fn()` + //~^ ERROR expected basic integer or pointer type, found `&dyn Fn()` } pub unsafe fn test_Quux_load(p: &mut Quux, v: Quux) { intrinsics::atomic_load::<_, { SeqCst }>(p); - //~^ ERROR `atomic_load` intrinsic: expected basic integer type, found `[u8; 100]` + //~^ ERROR `atomic_load` intrinsic: expected basic integer or pointer type, found `[u8; 100]` } pub unsafe fn test_Quux_store(p: &mut Quux, v: Quux) { intrinsics::atomic_store::<_, { SeqCst }>(p, v); - //~^ ERROR `atomic_store` intrinsic: expected basic integer type, found `[u8; 100]` + //~^ ERROR `atomic_store` intrinsic: expected basic integer or pointer type, found `[u8; 100]` } pub unsafe fn test_Quux_xchg(p: &mut Quux, v: Quux) { intrinsics::atomic_xchg::<_, { SeqCst }>(p, v); - //~^ ERROR `atomic_xchg` intrinsic: expected basic integer type, found `[u8; 100]` + //~^ ERROR `atomic_xchg` intrinsic: expected basic integer or pointer type, found `[u8; 100]` } pub unsafe fn test_Quux_cxchg(p: &mut Quux, v: Quux) { intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v); - //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer type, found `[u8; 100]` + //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer or pointer type, found `[u8; 100]` } diff --git a/tests/ui/intrinsics/non-integer-atomic.stderr b/tests/ui/intrinsics/non-integer-atomic.stderr index e539d99b8ae..330d313639d 100644 --- a/tests/ui/intrinsics/non-integer-atomic.stderr +++ b/tests/ui/intrinsics/non-integer-atomic.stderr @@ -1,98 +1,98 @@ -error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer type, found `bool` - --> $DIR/non-integer-atomic.rs:15:5 +error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer or pointer type, found `&dyn Fn()` + --> $DIR/non-integer-atomic.rs:55:5 | LL | intrinsics::atomic_load::<_, { SeqCst }>(p); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer type, found `bool` - --> $DIR/non-integer-atomic.rs:20:5 +error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer or pointer type, found `Foo` + --> $DIR/non-integer-atomic.rs:35:5 + | +LL | intrinsics::atomic_load::<_, { SeqCst }>(p); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer or pointer type, found `&dyn Fn()` + --> $DIR/non-integer-atomic.rs:60:5 | LL | intrinsics::atomic_store::<_, { SeqCst }>(p, v); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer type, found `bool` - --> $DIR/non-integer-atomic.rs:25:5 +error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer or pointer type, found `[u8; 100]` + --> $DIR/non-integer-atomic.rs:85:5 | LL | intrinsics::atomic_xchg::<_, { SeqCst }>(p, v); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer type, found `bool` - --> $DIR/non-integer-atomic.rs:30:5 +error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer or pointer type, found `&dyn Fn()` + --> $DIR/non-integer-atomic.rs:70:5 | LL | intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer type, found `Foo` - --> $DIR/non-integer-atomic.rs:35:5 - | -LL | intrinsics::atomic_load::<_, { SeqCst }>(p); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer type, found `Foo` +error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer or pointer type, found `Foo` --> $DIR/non-integer-atomic.rs:40:5 | LL | intrinsics::atomic_store::<_, { SeqCst }>(p, v); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer type, found `Foo` - --> $DIR/non-integer-atomic.rs:45:5 - | -LL | intrinsics::atomic_xchg::<_, { SeqCst }>(p, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer type, found `Foo` - --> $DIR/non-integer-atomic.rs:50:5 +error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer or pointer type, found `[u8; 100]` + --> $DIR/non-integer-atomic.rs:90:5 | LL | intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer type, found `&dyn Fn()` - --> $DIR/non-integer-atomic.rs:55:5 +error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer or pointer type, found `[u8; 100]` + --> $DIR/non-integer-atomic.rs:80:5 | -LL | intrinsics::atomic_load::<_, { SeqCst }>(p); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | intrinsics::atomic_store::<_, { SeqCst }>(p, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer type, found `&dyn Fn()` - --> $DIR/non-integer-atomic.rs:60:5 +error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer or pointer type, found `bool` + --> $DIR/non-integer-atomic.rs:20:5 | LL | intrinsics::atomic_store::<_, { SeqCst }>(p, v); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer type, found `&dyn Fn()` +error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer or pointer type, found `&dyn Fn()` --> $DIR/non-integer-atomic.rs:65:5 | LL | intrinsics::atomic_xchg::<_, { SeqCst }>(p, v); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer type, found `&dyn Fn()` - --> $DIR/non-integer-atomic.rs:70:5 +error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer or pointer type, found `[u8; 100]` + --> $DIR/non-integer-atomic.rs:75:5 | -LL | intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | intrinsics::atomic_load::<_, { SeqCst }>(p); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer type, found `[u8; 100]` - --> $DIR/non-integer-atomic.rs:75:5 +error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer or pointer type, found `bool` + --> $DIR/non-integer-atomic.rs:15:5 | LL | intrinsics::atomic_load::<_, { SeqCst }>(p); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer type, found `[u8; 100]` - --> $DIR/non-integer-atomic.rs:80:5 +error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer or pointer type, found `bool` + --> $DIR/non-integer-atomic.rs:30:5 | -LL | intrinsics::atomic_store::<_, { SeqCst }>(p, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer type, found `[u8; 100]` - --> $DIR/non-integer-atomic.rs:85:5 +error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer or pointer type, found `Foo` + --> $DIR/non-integer-atomic.rs:50:5 + | +LL | intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer or pointer type, found `Foo` + --> $DIR/non-integer-atomic.rs:45:5 | LL | intrinsics::atomic_xchg::<_, { SeqCst }>(p, v); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer type, found `[u8; 100]` - --> $DIR/non-integer-atomic.rs:90:5 +error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer or pointer type, found `bool` + --> $DIR/non-integer-atomic.rs:25:5 | -LL | intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | intrinsics::atomic_xchg::<_, { SeqCst }>(p, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 16 previous errors diff --git a/tests/ui/intrinsics/not-overridden.rs b/tests/ui/intrinsics/not-overridden.rs index 2359eee8b26..ce855483527 100644 --- a/tests/ui/intrinsics/not-overridden.rs +++ b/tests/ui/intrinsics/not-overridden.rs @@ -4,7 +4,7 @@ //@ build-fail //@ failure-status:101 //@ normalize-stderr: ".*note: .*\n\n" -> "" -//@ normalize-stderr: "thread 'rustc' panicked.*:\n.*\n" -> "" +//@ normalize-stderr: "thread 'rustc'.*panicked.*:\n.*\n" -> "" //@ normalize-stderr: "internal compiler error:.*: intrinsic const_deallocate " -> "" //@ rustc-env:RUST_BACKTRACE=0 diff --git a/tests/ui/invalid-compile-flags/print-crate-name-request-malformed-crate-name.stderr b/tests/ui/invalid-compile-flags/print-crate-name-request-malformed-crate-name.stderr index 6bf09a2b131..b773f7c97aa 100644 --- a/tests/ui/invalid-compile-flags/print-crate-name-request-malformed-crate-name.stderr +++ b/tests/ui/invalid-compile-flags/print-crate-name-request-malformed-crate-name.stderr @@ -3,6 +3,8 @@ error: malformed `crate_name` attribute input | LL | #![crate_name = concat!("wrapped")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![crate_name = "name"]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/crates-and-source-files.html#the-crate_name-attribute> error: aborting due to 1 previous error diff --git a/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-1.stderr b/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-1.stderr index de62aed79fc..64e38ed8533 100644 --- a/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-1.stderr +++ b/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-1.stderr @@ -3,6 +3,8 @@ error: malformed `crate_name` attribute input | LL | #![crate_name] | ^^^^^^^^^^^^^^ help: must be of the form: `#![crate_name = "name"]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/crates-and-source-files.html#the-crate_name-attribute> error: aborting due to 1 previous error diff --git a/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-2.stderr b/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-2.stderr index 42c33de1221..e9a5b58e4f9 100644 --- a/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-2.stderr +++ b/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name-2.stderr @@ -3,6 +3,8 @@ error: malformed `crate_name` attribute input | LL | #![crate_name = concat!("this_one_is_not")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![crate_name = "name"]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/crates-and-source-files.html#the-crate_name-attribute> error: aborting due to 1 previous error diff --git a/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name.stderr b/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name.stderr index cb5ffaab9ca..e63525c6a5d 100644 --- a/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name.stderr +++ b/tests/ui/invalid-compile-flags/print-file-names-request-malformed-crate-name.stderr @@ -3,6 +3,8 @@ error: malformed `crate_name` attribute input | LL | #![crate_name = concat!("wrapped")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![crate_name = "name"]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/crates-and-source-files.html#the-crate_name-attribute> error: aborting due to 1 previous error diff --git a/tests/ui/invalid/invalid-inline.stderr b/tests/ui/invalid/invalid-inline.stderr index 54e6b2b5408..78ffe3270a7 100644 --- a/tests/ui/invalid/invalid-inline.stderr +++ b/tests/ui/invalid/invalid-inline.stderr @@ -6,10 +6,14 @@ LL | #[inline(please,no)] | | | expected a single argument here | + = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/codegen.html#the-inline-attribute> help: try changing it to one of the following valid forms of the attribute | LL - #[inline(please,no)] -LL + #[inline(always|never)] +LL + #[inline(always)] + | +LL - #[inline(please,no)] +LL + #[inline(never)] | LL - #[inline(please,no)] LL + #[inline] @@ -23,10 +27,13 @@ LL | #[inline()] | | | expected a single argument here | + = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/codegen.html#the-inline-attribute> help: try changing it to one of the following valid forms of the attribute | -LL | #[inline(always|never)] - | ++++++++++++ +LL | #[inline(always)] + | ++++++ +LL | #[inline(never)] + | +++++ LL - #[inline()] LL + #[inline] | diff --git a/tests/ui/invalid/invalid_rustc_layout_scalar_valid_range.stderr b/tests/ui/invalid/invalid_rustc_layout_scalar_valid_range.stderr index 8b9ad78db37..6d5a22e4ced 100644 --- a/tests/ui/invalid/invalid_rustc_layout_scalar_valid_range.stderr +++ b/tests/ui/invalid/invalid_rustc_layout_scalar_valid_range.stderr @@ -25,6 +25,14 @@ LL | #[rustc_layout_scalar_valid_range_end(a = "a")] | | expected an integer literal here | help: must be of the form: `#[rustc_layout_scalar_valid_range_end(end)]` +error: `#[rustc_layout_scalar_valid_range_end]` attribute cannot be used on enums + --> $DIR/invalid_rustc_layout_scalar_valid_range.rs:12:1 + | +LL | #[rustc_layout_scalar_valid_range_end(1)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[rustc_layout_scalar_valid_range_end]` can only be applied to structs + error[E0539]: malformed `rustc_layout_scalar_valid_range_start` attribute input --> $DIR/invalid_rustc_layout_scalar_valid_range.rs:18:1 | @@ -34,17 +42,6 @@ LL | #[rustc_layout_scalar_valid_range_start(rustc_layout_scalar_valid_range_sta | | expected an integer literal here | help: must be of the form: `#[rustc_layout_scalar_valid_range_start(start)]` -error: attribute should be applied to a struct - --> $DIR/invalid_rustc_layout_scalar_valid_range.rs:12:1 - | -LL | #[rustc_layout_scalar_valid_range_end(1)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | / enum E { -LL | | X = 1, -LL | | Y = 14, -LL | | } - | |_- not a struct - error: aborting due to 5 previous errors Some errors have detailed explanations: E0539, E0805. diff --git a/tests/ui/issues/issue-14091-2.rs b/tests/ui/issues/issue-14091-2.rs deleted file mode 100644 index e2f6b183372..00000000000 --- a/tests/ui/issues/issue-14091-2.rs +++ /dev/null @@ -1,17 +0,0 @@ -// - -// Very - -// sensitive -pub struct BytePos(pub u32); - -// to particular - -// line numberings / offsets - -fn main() { - let x = BytePos(1); - - assert!(x, x); - //~^ ERROR cannot apply unary operator `!` to type `BytePos` -} diff --git a/tests/ui/issues/issue-14091-2.stderr b/tests/ui/issues/issue-14091-2.stderr deleted file mode 100644 index d573a0917be..00000000000 --- a/tests/ui/issues/issue-14091-2.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0600]: cannot apply unary operator `!` to type `BytePos` - --> $DIR/issue-14091-2.rs:15:5 - | -LL | assert!(x, x); - | ^^^^^^^^^^^^^ cannot apply unary operator `!` - | -note: an implementation of `Not` might be missing for `BytePos` - --> $DIR/issue-14091-2.rs:6:1 - | -LL | pub struct BytePos(pub u32); - | ^^^^^^^^^^^^^^^^^^ must implement `Not` -note: the trait `Not` must be implemented - --> $SRC_DIR/core/src/ops/bit.rs:LL:COL - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0600`. diff --git a/tests/ui/issues/issue-14091.rs b/tests/ui/issues/issue-14091.rs deleted file mode 100644 index 0ee20de9053..00000000000 --- a/tests/ui/issues/issue-14091.rs +++ /dev/null @@ -1,4 +0,0 @@ -fn main(){ - assert!(1,1); - //~^ ERROR mismatched types -} diff --git a/tests/ui/issues/issue-14091.stderr b/tests/ui/issues/issue-14091.stderr deleted file mode 100644 index 83879583b1f..00000000000 --- a/tests/ui/issues/issue-14091.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-14091.rs:2:5 - | -LL | assert!(1,1); - | ^^^^^^^^^^^^ expected `bool`, found integer - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/issues/issue-14330.rs b/tests/ui/issues/issue-14330.rs deleted file mode 100644 index 11199db5901..00000000000 --- a/tests/ui/issues/issue-14330.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ check-pass -#![allow(unused_imports)] - -#[macro_use] extern crate std as std2; - -fn main() {} diff --git a/tests/ui/issues/issue-31769.rs b/tests/ui/issues/issue-31769.rs index f56c6ea5656..354c1be9ed5 100644 --- a/tests/ui/issues/issue-31769.rs +++ b/tests/ui/issues/issue-31769.rs @@ -1,4 +1,4 @@ fn main() { - #[inline] struct Foo; //~ ERROR attribute should be applied to function or closure + #[inline] struct Foo; //~ ERROR attribute cannot be used on #[repr(C)] fn foo() {} //~ ERROR attribute should be applied to a struct, enum, or union } diff --git a/tests/ui/issues/issue-31769.stderr b/tests/ui/issues/issue-31769.stderr index 03e2f931c84..0f75e84f2a7 100644 --- a/tests/ui/issues/issue-31769.stderr +++ b/tests/ui/issues/issue-31769.stderr @@ -1,8 +1,10 @@ -error[E0518]: attribute should be applied to function or closure +error: `#[inline]` attribute cannot be used on structs --> $DIR/issue-31769.rs:2:5 | LL | #[inline] struct Foo; - | ^^^^^^^^^ ----------- not a function or closure + | ^^^^^^^^^ + | + = help: `#[inline]` can only be applied to functions error[E0517]: attribute should be applied to a struct, enum, or union --> $DIR/issue-31769.rs:3:12 @@ -12,5 +14,4 @@ LL | #[repr(C)] fn foo() {} error: aborting due to 2 previous errors -Some errors have detailed explanations: E0517, E0518. -For more information about an error, try `rustc --explain E0517`. +For more information about this error, try `rustc --explain E0517`. diff --git a/tests/ui/issues/issue-37311-type-length-limit/issue-37311.rs b/tests/ui/issues/issue-37311-type-length-limit/issue-37311.rs index 05adde45204..b978e6eb519 100644 --- a/tests/ui/issues/issue-37311-type-length-limit/issue-37311.rs +++ b/tests/ui/issues/issue-37311-type-length-limit/issue-37311.rs @@ -1,4 +1,5 @@ //@ build-fail +//@ compile-flags: --diagnostic-width=100 -Zwrite-long-types-to-disk=yes trait Mirror { type Image; diff --git a/tests/ui/issues/issue-37311-type-length-limit/issue-37311.stderr b/tests/ui/issues/issue-37311-type-length-limit/issue-37311.stderr index 945fa605e14..835f1c6442a 100644 --- a/tests/ui/issues/issue-37311-type-length-limit/issue-37311.stderr +++ b/tests/ui/issues/issue-37311-type-length-limit/issue-37311.stderr @@ -1,15 +1,16 @@ -error: reached the recursion limit while instantiating `<(&(&(..., ...), ...), ...) as Foo>::recurse` - --> $DIR/issue-37311.rs:16:9 +error: reached the recursion limit while instantiating `<(&(&(&..., ...), ...), ...) as Foo>::recurse` + --> $DIR/issue-37311.rs:17:9 | LL | (self, self).recurse(); | ^^^^^^^^^^^^^^^^^^^^^^ | note: `<T as Foo>::recurse` defined here - --> $DIR/issue-37311.rs:15:5 + --> $DIR/issue-37311.rs:16:5 | LL | fn recurse(&self) { | ^^^^^^^^^^^^^^^^^ - = note: the full type name has been written to '$TEST_BUILD_DIR/issue-37311.long-type.txt' + = note: the full name for the type has been written to '$TEST_BUILD_DIR/issue-37311.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error diff --git a/tests/ui/issues/issue-41880.stderr b/tests/ui/issues/issue-41880.stderr index 1936c0aebd4..2f1ebee7ca5 100644 --- a/tests/ui/issues/issue-41880.stderr +++ b/tests/ui/issues/issue-41880.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `iter` found for struct `Iterate` in the current scope +error[E0599]: no method named `iter` found for struct `Iterate<T, F>` in the current scope --> $DIR/issue-41880.rs:27:24 | LL | pub struct Iterate<T, F> { diff --git a/tests/ui/issues/issue-4335.stderr b/tests/ui/issues/issue-4335.stderr index 42ac6322564..d1a64e3dd46 100644 --- a/tests/ui/issues/issue-4335.stderr +++ b/tests/ui/issues/issue-4335.stderr @@ -10,6 +10,7 @@ LL | id(Box::new(|| *v)) | | | captured by this `FnMut` closure | + = help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once help: if `T` implemented `Clone`, you could clone the value --> $DIR/issue-4335.rs:5:10 | diff --git a/tests/ui/issues/issue-43988.rs b/tests/ui/issues/issue-43988.rs index 5fea5576b7f..bd23e0e2457 100644 --- a/tests/ui/issues/issue-43988.rs +++ b/tests/ui/issues/issue-43988.rs @@ -4,12 +4,13 @@ fn main() { #[inline] let _a = 4; - //~^^ ERROR attribute should be applied to function or closure + //~^^ ERROR attribute cannot be used on #[inline(XYZ)] let _b = 4; //~^^ ERROR malformed `inline` attribute + //~| ERROR attribute cannot be used on #[repr(nothing)] let _x = 0; @@ -30,6 +31,7 @@ fn main() { #[inline(ABC)] foo(); //~^^ ERROR malformed `inline` attribute + //~| ERROR attribute cannot be used on let _z = #[repr] 1; //~^ ERROR malformed `repr` attribute diff --git a/tests/ui/issues/issue-43988.stderr b/tests/ui/issues/issue-43988.stderr index fe61e136a51..0219eeb693e 100644 --- a/tests/ui/issues/issue-43988.stderr +++ b/tests/ui/issues/issue-43988.stderr @@ -1,3 +1,11 @@ +error: `#[inline]` attribute cannot be used on statements + --> $DIR/issue-43988.rs:5:5 + | +LL | #[inline] + | ^^^^^^^^^ + | + = help: `#[inline]` can only be applied to functions + error[E0539]: malformed `inline` attribute input --> $DIR/issue-43988.rs:10:5 | @@ -6,75 +14,113 @@ LL | #[inline(XYZ)] | | | valid arguments are `always` or `never` | + = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/codegen.html#the-inline-attribute> help: try changing it to one of the following valid forms of the attribute | LL - #[inline(XYZ)] -LL + #[inline(always|never)] +LL + #[inline(always)] + | +LL - #[inline(XYZ)] +LL + #[inline(never)] | LL - #[inline(XYZ)] LL + #[inline] | +error: `#[inline]` attribute cannot be used on statements + --> $DIR/issue-43988.rs:10:5 + | +LL | #[inline(XYZ)] + | ^^^^^^^^^^^^^^ + | + = help: `#[inline]` can only be applied to functions + error[E0552]: unrecognized representation hint - --> $DIR/issue-43988.rs:14:12 + --> $DIR/issue-43988.rs:15:12 | LL | #[repr(nothing)] | ^^^^^^^ | = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` + = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html?highlight=repr#representations> error[E0552]: unrecognized representation hint - --> $DIR/issue-43988.rs:18:12 + --> $DIR/issue-43988.rs:19:12 | LL | #[repr(something_not_real)] | ^^^^^^^^^^^^^^^^^^ | = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` + = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html?highlight=repr#representations> error[E0539]: malformed `repr` attribute input - --> $DIR/issue-43988.rs:24:5 + --> $DIR/issue-43988.rs:25:5 | LL | #[repr] - | ^^^^^^^ - | | - | expected this to be a list - | help: must be of the form: `#[repr(C | Rust | align(...) | packed(...) | <integer type> | transparent)]` + | ^^^^^^^ expected this to be a list + | + = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations> +help: try changing it to one of the following valid forms of the attribute + | +LL | #[repr(<integer type>)] + | ++++++++++++++++ +LL | #[repr(C)] + | +++ +LL | #[repr(Rust)] + | ++++++ +LL | #[repr(align(...))] + | ++++++++++++ + = and 2 other candidates error[E0539]: malformed `inline` attribute input - --> $DIR/issue-43988.rs:30:5 + --> $DIR/issue-43988.rs:31:5 | LL | #[inline(ABC)] | ^^^^^^^^^---^^ | | | valid arguments are `always` or `never` | + = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/codegen.html#the-inline-attribute> help: try changing it to one of the following valid forms of the attribute | LL - #[inline(ABC)] -LL + #[inline(always|never)] +LL + #[inline(always)] + | +LL - #[inline(ABC)] +LL + #[inline(never)] | LL - #[inline(ABC)] LL + #[inline] | +error: `#[inline]` attribute cannot be used on expressions + --> $DIR/issue-43988.rs:31:5 + | +LL | #[inline(ABC)] + | ^^^^^^^^^^^^^^ + | + = help: `#[inline]` can only be applied to functions + error[E0539]: malformed `repr` attribute input - --> $DIR/issue-43988.rs:34:14 + --> $DIR/issue-43988.rs:36:14 | LL | let _z = #[repr] 1; - | ^^^^^^^ - | | - | expected this to be a list - | help: must be of the form: `#[repr(C | Rust | align(...) | packed(...) | <integer type> | transparent)]` - -error[E0518]: attribute should be applied to function or closure - --> $DIR/issue-43988.rs:5:5 + | ^^^^^^^ expected this to be a list | -LL | #[inline] - | ^^^^^^^^^ -LL | let _a = 4; - | ----------- not a function or closure + = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations> +help: try changing it to one of the following valid forms of the attribute + | +LL | let _z = #[repr(<integer type>)] 1; + | ++++++++++++++++ +LL | let _z = #[repr(C)] 1; + | +++ +LL | let _z = #[repr(Rust)] 1; + | ++++++ +LL | let _z = #[repr(align(...))] 1; + | ++++++++++++ + = and 2 other candidates -error: aborting due to 7 previous errors +error: aborting due to 9 previous errors -Some errors have detailed explanations: E0518, E0539, E0552. -For more information about an error, try `rustc --explain E0518`. +Some errors have detailed explanations: E0539, E0552. +For more information about an error, try `rustc --explain E0539`. diff --git a/tests/ui/issues/issue-78957.rs b/tests/ui/issues/issue-78957.rs index 567c59fd560..2ff92612e18 100644 --- a/tests/ui/issues/issue-78957.rs +++ b/tests/ui/issues/issue-78957.rs @@ -3,26 +3,26 @@ use std::marker::PhantomData; pub struct Foo<#[inline] const N: usize>; -//~^ ERROR attribute should be applied to function or closure +//~^ ERROR attribute cannot be used on pub struct Bar<#[cold] const N: usize>; -//~^ ERROR attribute should be applied to a function -//~| WARN this was previously accepted +//~^ ERROR attribute cannot be used on +//~| WARN previously accepted pub struct Baz<#[repr(C)] const N: usize>; //~^ ERROR attribute should be applied to a struct, enum, or union // pub struct Foo2<#[inline] 'a>(PhantomData<&'a ()>); -//~^ ERROR attribute should be applied to function or closure +//~^ ERROR attribute cannot be used on pub struct Bar2<#[cold] 'a>(PhantomData<&'a ()>); -//~^ ERROR attribute should be applied to a function -//~| WARN this was previously accepted +//~^ ERROR attribute cannot be used on +//~| WARN previously accepted pub struct Baz2<#[repr(C)] 'a>(PhantomData<&'a ()>); //~^ ERROR attribute should be applied to a struct, enum, or union // pub struct Foo3<#[inline] T>(PhantomData<T>); -//~^ ERROR attribute should be applied to function or closure +//~^ ERROR attribute cannot be used on pub struct Bar3<#[cold] T>(PhantomData<T>); -//~^ ERROR attribute should be applied to a function -//~| WARN this was previously accepted +//~^ ERROR attribute cannot be used on +//~| WARN previously accepted pub struct Baz3<#[repr(C)] T>(PhantomData<T>); //~^ ERROR attribute should be applied to a struct, enum, or union diff --git a/tests/ui/issues/issue-78957.stderr b/tests/ui/issues/issue-78957.stderr index 6de22d6bf79..d271b1840fb 100644 --- a/tests/ui/issues/issue-78957.stderr +++ b/tests/ui/issues/issue-78957.stderr @@ -1,21 +1,26 @@ -error[E0518]: attribute should be applied to function or closure +error: `#[inline]` attribute cannot be used on function params --> $DIR/issue-78957.rs:5:16 | LL | pub struct Foo<#[inline] const N: usize>; - | ^^^^^^^^^ -------------- not a function or closure + | ^^^^^^^^^ + | + = help: `#[inline]` can only be applied to functions -error: attribute should be applied to a function definition - --> $DIR/issue-78957.rs:7:16 +error: `#[inline]` attribute cannot be used on function params + --> $DIR/issue-78957.rs:13:17 | -LL | pub struct Bar<#[cold] const N: usize>; - | ^^^^^^^ -------------- not a function definition +LL | pub struct Foo2<#[inline] 'a>(PhantomData<&'a ()>); + | ^^^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -note: the lint level is defined here - --> $DIR/issue-78957.rs:1:9 + = help: `#[inline]` can only be applied to functions + +error: `#[inline]` attribute cannot be used on function params + --> $DIR/issue-78957.rs:21:17 | -LL | #![deny(unused_attributes)] - | ^^^^^^^^^^^^^^^^^ +LL | pub struct Foo3<#[inline] T>(PhantomData<T>); + | ^^^^^^^^^ + | + = help: `#[inline]` can only be applied to functions error[E0517]: attribute should be applied to a struct, enum, or union --> $DIR/issue-78957.rs:10:23 @@ -23,47 +28,50 @@ error[E0517]: attribute should be applied to a struct, enum, or union LL | pub struct Baz<#[repr(C)] const N: usize>; | ^ -------------- not a struct, enum, or union -error[E0518]: attribute should be applied to function or closure - --> $DIR/issue-78957.rs:13:17 +error[E0517]: attribute should be applied to a struct, enum, or union + --> $DIR/issue-78957.rs:18:24 | -LL | pub struct Foo2<#[inline] 'a>(PhantomData<&'a ()>); - | ^^^^^^^^^ -- not a function or closure +LL | pub struct Baz2<#[repr(C)] 'a>(PhantomData<&'a ()>); + | ^ -- not a struct, enum, or union -error: attribute should be applied to a function definition - --> $DIR/issue-78957.rs:15:17 +error[E0517]: attribute should be applied to a struct, enum, or union + --> $DIR/issue-78957.rs:26:24 | -LL | pub struct Bar2<#[cold] 'a>(PhantomData<&'a ()>); - | ^^^^^^^ -- not a function definition +LL | pub struct Baz3<#[repr(C)] T>(PhantomData<T>); + | ^ - not a struct, enum, or union + +error: `#[cold]` attribute cannot be used on function params + --> $DIR/issue-78957.rs:7:16 + | +LL | pub struct Bar<#[cold] const N: usize>; + | ^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-78957.rs:18:24 + = help: `#[cold]` can only be applied to functions +note: the lint level is defined here + --> $DIR/issue-78957.rs:1:9 | -LL | pub struct Baz2<#[repr(C)] 'a>(PhantomData<&'a ()>); - | ^ -- not a struct, enum, or union +LL | #![deny(unused_attributes)] + | ^^^^^^^^^^^^^^^^^ -error[E0518]: attribute should be applied to function or closure - --> $DIR/issue-78957.rs:21:17 +error: `#[cold]` attribute cannot be used on function params + --> $DIR/issue-78957.rs:15:17 | -LL | pub struct Foo3<#[inline] T>(PhantomData<T>); - | ^^^^^^^^^ - not a function or closure +LL | pub struct Bar2<#[cold] 'a>(PhantomData<&'a ()>); + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[cold]` can only be applied to functions -error: attribute should be applied to a function definition +error: `#[cold]` attribute cannot be used on function params --> $DIR/issue-78957.rs:23:17 | LL | pub struct Bar3<#[cold] T>(PhantomData<T>); - | ^^^^^^^ - not a function definition + | ^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-78957.rs:26:24 - | -LL | pub struct Baz3<#[repr(C)] T>(PhantomData<T>); - | ^ - not a struct, enum, or union + = help: `#[cold]` can only be applied to functions error: aborting due to 9 previous errors -Some errors have detailed explanations: E0517, E0518. -For more information about an error, try `rustc --explain E0517`. +For more information about this error, try `rustc --explain E0517`. diff --git a/tests/ui/issues/issue-8727.rs b/tests/ui/issues/issue-8727.rs index 1883287f140..c1b60e8e085 100644 --- a/tests/ui/issues/issue-8727.rs +++ b/tests/ui/issues/issue-8727.rs @@ -2,6 +2,7 @@ // recursions. //@ build-fail +//@ compile-flags: --diagnostic-width=100 -Zwrite-long-types-to-disk=yes fn generic<T>() { //~ WARN function cannot return without recursing generic::<Option<T>>(); diff --git a/tests/ui/issues/issue-8727.stderr b/tests/ui/issues/issue-8727.stderr index 04158962a01..9fb09a7d4f4 100644 --- a/tests/ui/issues/issue-8727.stderr +++ b/tests/ui/issues/issue-8727.stderr @@ -1,5 +1,5 @@ warning: function cannot return without recursing - --> $DIR/issue-8727.rs:6:1 + --> $DIR/issue-8727.rs:7:1 | LL | fn generic<T>() { | ^^^^^^^^^^^^^^^ cannot return without recursing @@ -9,18 +9,19 @@ LL | generic::<Option<T>>(); = help: a `loop` may express intention better if this is on purpose = note: `#[warn(unconditional_recursion)]` on by default -error: reached the recursion limit while instantiating `generic::<Option<Option<Option<Option<Option<...>>>>>>` - --> $DIR/issue-8727.rs:7:5 +error: reached the recursion limit while instantiating `generic::<Option<Option<Option<Option<...>>>>>` + --> $DIR/issue-8727.rs:8:5 | LL | generic::<Option<T>>(); | ^^^^^^^^^^^^^^^^^^^^^^ | note: `generic` defined here - --> $DIR/issue-8727.rs:6:1 + --> $DIR/issue-8727.rs:7:1 | LL | fn generic<T>() { | ^^^^^^^^^^^^^^^ - = note: the full type name has been written to '$TEST_BUILD_DIR/issue-8727.long-type.txt' + = note: the full name for the type has been written to '$TEST_BUILD_DIR/issue-8727.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/issues/issue-87707.run.stderr b/tests/ui/issues/issue-87707.run.stderr index eb1d65a081f..8485c0578b8 100644 --- a/tests/ui/issues/issue-87707.run.stderr +++ b/tests/ui/issues/issue-87707.run.stderr @@ -1,7 +1,7 @@ -thread 'main' panicked at $DIR/issue-87707.rs:14:24: +thread 'main' ($TID) panicked at $DIR/issue-87707.rs:14:24: Here Once instance is poisoned. note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread 'main' panicked at $DIR/issue-87707.rs:16:7: +thread 'main' ($TID) panicked at $DIR/issue-87707.rs:16:7: Once instance has previously been poisoned diff --git a/tests/ui/issues/issue-9155.rs b/tests/ui/issues/issue-9155.rs deleted file mode 100644 index dfd9dea2009..00000000000 --- a/tests/ui/issues/issue-9155.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ run-pass -//@ aux-build:issue-9155.rs - - -extern crate issue_9155; - -struct Baz; - -pub fn main() { - issue_9155::Foo::new(Baz); -} diff --git a/tests/ui/issues/issue-9906.rs b/tests/ui/issues/issue-9906.rs deleted file mode 100644 index 50417d3e456..00000000000 --- a/tests/ui/issues/issue-9906.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass -//@ aux-build:issue-9906.rs - - -extern crate issue_9906 as testmod; - -pub fn main() { - testmod::foo(); - testmod::FooBar::new(1); -} diff --git a/tests/ui/issues/issue-9968.rs b/tests/ui/issues/issue-9968.rs deleted file mode 100644 index 89e60ba5ac7..00000000000 --- a/tests/ui/issues/issue-9968.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ run-pass -//@ aux-build:issue-9968.rs - - -extern crate issue_9968 as lib; - -use lib::{Trait, Struct}; - -pub fn main() -{ - Struct::init().test(); -} diff --git a/tests/ui/issues/issue-15756.rs b/tests/ui/iterators/explicit-deref-non-deref-type-15756.rs index e0861dee61e..6d4a3bffcf7 100644 --- a/tests/ui/issues/issue-15756.rs +++ b/tests/ui/iterators/explicit-deref-non-deref-type-15756.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15756 + use std::slice::Chunks; use std::slice::ChunksMut; diff --git a/tests/ui/issues/issue-15756.stderr b/tests/ui/iterators/explicit-deref-non-deref-type-15756.stderr index a487d360bef..b4f9aab8496 100644 --- a/tests/ui/issues/issue-15756.stderr +++ b/tests/ui/iterators/explicit-deref-non-deref-type-15756.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `[T]` cannot be known at compilation time - --> $DIR/issue-15756.rs:7:10 + --> $DIR/explicit-deref-non-deref-type-15756.rs:9:10 | LL | &mut something | ^^^^^^^^^ doesn't have a size known at compile-time diff --git a/tests/ui/issues/issue-21655.rs b/tests/ui/iterators/for-loop-over-mut-iterator-21655.rs index 1068b28b338..b5c9826bd45 100644 --- a/tests/ui/issues/issue-21655.rs +++ b/tests/ui/iterators/for-loop-over-mut-iterator-21655.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/21655 //@ run-pass fn test(it: &mut dyn Iterator<Item=i32>) { diff --git a/tests/ui/layout/valid_range_oob.rs b/tests/ui/layout/valid_range_oob.rs index df816e74066..8ae9f6e9726 100644 --- a/tests/ui/layout/valid_range_oob.rs +++ b/tests/ui/layout/valid_range_oob.rs @@ -1,6 +1,6 @@ //@ failure-status: 101 //@ normalize-stderr: "note: .*\n\n" -> "" -//@ normalize-stderr: "thread 'rustc' panicked.*\n" -> "" +//@ normalize-stderr: "thread 'rustc'.*panicked.*\n" -> "" //@ rustc-env:RUST_BACKTRACE=0 #![feature(rustc_attrs)] diff --git a/tests/ui/issues/issue-14285.rs b/tests/ui/lifetimes/explicit-lifetime-required-14285.rs index 2ba9ff71773..3f43dcf8366 100644 --- a/tests/ui/issues/issue-14285.rs +++ b/tests/ui/lifetimes/explicit-lifetime-required-14285.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/14285 + trait Foo { fn dummy(&self) { } } diff --git a/tests/ui/issues/issue-14285.stderr b/tests/ui/lifetimes/explicit-lifetime-required-14285.stderr index edd139eecba..576de45f94f 100644 --- a/tests/ui/issues/issue-14285.stderr +++ b/tests/ui/lifetimes/explicit-lifetime-required-14285.stderr @@ -1,5 +1,5 @@ error[E0621]: explicit lifetime required in the type of `a` - --> $DIR/issue-14285.rs:12:5 + --> $DIR/explicit-lifetime-required-14285.rs:14:5 | LL | B(a) | ^^^^ lifetime `'a` required diff --git a/tests/ui/issues/issue-13703.rs b/tests/ui/lifetimes/lifetime-bound-whitespace-13703.rs index b385e6b9d2e..79b85e4c132 100644 --- a/tests/ui/issues/issue-13703.rs +++ b/tests/ui/lifetimes/lifetime-bound-whitespace-13703.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13703 + //@ check-pass pub struct Foo<'a, 'b: 'a> { foo: &'a &'b isize } diff --git a/tests/ui/issues/issue-13497.rs b/tests/ui/lifetimes/missing-lifetime-specifier-13497.rs index 4b2795aa841..6f4ef0b5620 100644 --- a/tests/ui/issues/issue-13497.rs +++ b/tests/ui/lifetimes/missing-lifetime-specifier-13497.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13497 + fn read_lines_borrowed1() -> Vec< &str //~ ERROR missing lifetime specifier > { diff --git a/tests/ui/issues/issue-13497.stderr b/tests/ui/lifetimes/missing-lifetime-specifier-13497.stderr index ee111f1d262..99f4fa04f12 100644 --- a/tests/ui/issues/issue-13497.stderr +++ b/tests/ui/lifetimes/missing-lifetime-specifier-13497.stderr @@ -1,5 +1,5 @@ error[E0106]: missing lifetime specifier - --> $DIR/issue-13497.rs:2:5 + --> $DIR/missing-lifetime-specifier-13497.rs:4:5 | LL | &str | ^ expected named lifetime parameter diff --git a/tests/ui/issues/issue-15034.rs b/tests/ui/lifetimes/nondeterministic-lifetime-errors-15034.rs index 9ea6ed89ca2..e7f9a94231f 100644 --- a/tests/ui/issues/issue-15034.rs +++ b/tests/ui/lifetimes/nondeterministic-lifetime-errors-15034.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15034 + pub struct Lexer<'a> { input: &'a str, } diff --git a/tests/ui/issues/issue-15034.stderr b/tests/ui/lifetimes/nondeterministic-lifetime-errors-15034.stderr index 7db8ade2e48..0762714d259 100644 --- a/tests/ui/issues/issue-15034.stderr +++ b/tests/ui/lifetimes/nondeterministic-lifetime-errors-15034.stderr @@ -1,5 +1,5 @@ error[E0621]: explicit lifetime required in the type of `lexer` - --> $DIR/issue-15034.rs:17:9 + --> $DIR/nondeterministic-lifetime-errors-15034.rs:19:9 | LL | Parser { lexer: lexer } | ^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required diff --git a/tests/ui/issues/issue-14901.rs b/tests/ui/lifetimes/reader-wrapper-trait-14901.rs index ddc12b9ef3c..672872af03a 100644 --- a/tests/ui/issues/issue-14901.rs +++ b/tests/ui/lifetimes/reader-wrapper-trait-14901.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/14901 + //@ check-pass pub trait Reader {} diff --git a/tests/ui/lifetimes/ref-pattern-lifetime-annotation-13665.rs b/tests/ui/lifetimes/ref-pattern-lifetime-annotation-13665.rs new file mode 100644 index 00000000000..bae2f73baa3 --- /dev/null +++ b/tests/ui/lifetimes/ref-pattern-lifetime-annotation-13665.rs @@ -0,0 +1,16 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13665 + +//@ run-pass + +fn foo<'r>() { + let maybe_value_ref: Option<&'r u8> = None; + + let _ = maybe_value_ref.map(|& ref v| v); + let _ = maybe_value_ref.map(|& ref v| -> &'r u8 {v}); + let _ = maybe_value_ref.map(|& ref v: &'r u8| -> &'r u8 {v}); + let _ = maybe_value_ref.map(|& ref v: &'r u8| {v}); +} + +fn main() { + foo(); +} diff --git a/tests/ui/issues/issue-13497-2.rs b/tests/ui/lifetimes/return-reference-local-variable-13497.rs index c82da0f0096..1ca8074164b 100644 --- a/tests/ui/issues/issue-13497-2.rs +++ b/tests/ui/lifetimes/return-reference-local-variable-13497.rs @@ -1,7 +1,11 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13497 + fn read_lines_borrowed<'a>() -> Vec<&'a str> { let rawLines: Vec<String> = vec!["foo ".to_string(), " bar".to_string()]; rawLines //~ ERROR cannot return value referencing local variable `rawLines` - .iter().map(|l| l.trim()).collect() + .iter() + .map(|l| l.trim()) + .collect() } fn main() {} diff --git a/tests/ui/issues/issue-13497-2.stderr b/tests/ui/lifetimes/return-reference-local-variable-13497.stderr index e2ba1150d07..f5419f114ca 100644 --- a/tests/ui/issues/issue-13497-2.stderr +++ b/tests/ui/lifetimes/return-reference-local-variable-13497.stderr @@ -1,13 +1,15 @@ error[E0515]: cannot return value referencing local variable `rawLines` - --> $DIR/issue-13497-2.rs:3:5 + --> $DIR/return-reference-local-variable-13497.rs:5:5 | LL | rawLines | ^------- | | | _____`rawLines` is borrowed here | | -LL | | .iter().map(|l| l.trim()).collect() - | |___________________________________________^ returns a value referencing data owned by the current function +LL | | .iter() +LL | | .map(|l| l.trim()) +LL | | .collect() + | |__________________^ returns a value referencing data owned by the current function error: aborting due to 1 previous error diff --git a/tests/ui/lifetimes/struct-lifetime-inference-15735.rs b/tests/ui/lifetimes/struct-lifetime-inference-15735.rs new file mode 100644 index 00000000000..39e619648eb --- /dev/null +++ b/tests/ui/lifetimes/struct-lifetime-inference-15735.rs @@ -0,0 +1,19 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15735 + +//@ check-pass +#![allow(dead_code)] +struct A<'a> { + a: &'a i32, + b: &'a i32, +} + +impl <'a> A<'a> { + fn foo<'b>(&'b self) { + A { + a: self.a, + b: self.b, + }; + } +} + +fn main() { } diff --git a/tests/ui/issues/issue-9259.rs b/tests/ui/lifetimes/struct-with-lifetime-parameters-9259.rs index c45288f7d65..7e39fdc3f10 100644 --- a/tests/ui/issues/issue-9259.rs +++ b/tests/ui/lifetimes/struct-with-lifetime-parameters-9259.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/9259 //@ run-pass #![allow(dead_code)] diff --git a/tests/ui/issues/issue-14821.rs b/tests/ui/lifetimes/trait-object-constructor-14821.rs index b11a885b3a0..76f0c7514bc 100644 --- a/tests/ui/issues/issue-14821.rs +++ b/tests/ui/lifetimes/trait-object-constructor-14821.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/14821 + //@ run-pass #![allow(dead_code)] #![allow(unused_variables)] diff --git a/tests/ui/limits/type-length-limit-enforcement.rs b/tests/ui/limits/type-length-limit-enforcement.rs index 3b34d6eb5c8..604435dc326 100644 --- a/tests/ui/limits/type-length-limit-enforcement.rs +++ b/tests/ui/limits/type-length-limit-enforcement.rs @@ -3,7 +3,7 @@ //! Checks the enforcement of the type-length limit //! and its configurability via `#![type_length_limit]`. -//@ compile-flags: -Copt-level=0 -Zenforce-type-length-limit +//@ compile-flags: -Copt-level=0 -Zenforce-type-length-limit --diagnostic-width=100 -Zwrite-long-types-to-disk=yes //@ build-fail diff --git a/tests/ui/limits/type-length-limit-enforcement.stderr b/tests/ui/limits/type-length-limit-enforcement.stderr index 516230ae832..bfea0b5a448 100644 --- a/tests/ui/limits/type-length-limit-enforcement.stderr +++ b/tests/ui/limits/type-length-limit-enforcement.stderr @@ -1,11 +1,12 @@ -error: reached the type-length limit while instantiating `std::mem::drop::<Option<((((..., ..., ...), ..., ...), ..., ...), ..., ...)>>` +error: reached the type-length limit while instantiating `drop::<Option<((..., ..., ...), ..., ...)>>` --> $DIR/type-length-limit-enforcement.rs:34:5 | LL | drop::<Option<A>>(None); | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider adding a `#![type_length_limit="4010"]` attribute to your crate - = note: the full type name has been written to '$TEST_BUILD_DIR/type-length-limit-enforcement.long-type.txt' + = note: the full name for the type has been written to '$TEST_BUILD_DIR/type-length-limit-enforcement.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: reached the type-length limit while instantiating `<{closure@rt::lang_start<()>::{closure#0}} as FnMut<()>>::call_mut` | diff --git a/tests/ui/link-native-libs/link-attr-validation-early.rs b/tests/ui/link-native-libs/link-attr-validation-early.rs index b9a835fb5e9..a7dd80f8920 100644 --- a/tests/ui/link-native-libs/link-attr-validation-early.rs +++ b/tests/ui/link-native-libs/link-attr-validation-early.rs @@ -1,7 +1,7 @@ // Top-level ill-formed -#[link] //~ ERROR attribute must be of the form +#[link] //~ ERROR valid forms for the attribute are //~| WARN this was previously accepted -#[link = "foo"] //~ ERROR attribute must be of the form +#[link = "foo"] //~ ERROR valid forms for the attribute are //~| WARN this was previously accepted extern "C" {} diff --git a/tests/ui/link-native-libs/link-attr-validation-early.stderr b/tests/ui/link-native-libs/link-attr-validation-early.stderr index 24ad9d825f8..36cca6f27ef 100644 --- a/tests/ui/link-native-libs/link-attr-validation-early.stderr +++ b/tests/ui/link-native-libs/link-attr-validation-early.stderr @@ -1,4 +1,4 @@ -error: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ wasm_import_module = "...", /*opt*/ import_name_type = "decorated|noprefix|undecorated")]` +error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]` --> $DIR/link-attr-validation-early.rs:2:1 | LL | #[link] @@ -6,9 +6,10 @@ LL | #[link] | = 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 #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> = note: `#[deny(ill_formed_attribute_input)]` on by default -error: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ wasm_import_module = "...", /*opt*/ import_name_type = "decorated|noprefix|undecorated")]` +error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]` --> $DIR/link-attr-validation-early.rs:4:1 | LL | #[link = "foo"] @@ -16,6 +17,31 @@ LL | #[link = "foo"] | = 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 #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> error: aborting due to 2 previous errors +Future incompatibility report: Future breakage diagnostic: +error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]` + --> $DIR/link-attr-validation-early.rs:2:1 + | +LL | #[link] + | ^^^^^^^ + | + = 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 #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> + = note: `#[deny(ill_formed_attribute_input)]` on by default + +Future breakage diagnostic: +error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]` + --> $DIR/link-attr-validation-early.rs:4:1 + | +LL | #[link = "foo"] + | ^^^^^^^^^^^^^^^ + | + = 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 #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> + = note: `#[deny(ill_formed_attribute_input)]` on by default + diff --git a/tests/ui/linkage-attr/linkage-detect-extern-generated-name-collision.rs b/tests/ui/linkage-attr/linkage-detect-extern-generated-name-collision.rs deleted file mode 100644 index 23848056ee1..00000000000 --- a/tests/ui/linkage-attr/linkage-detect-extern-generated-name-collision.rs +++ /dev/null @@ -1,26 +0,0 @@ -// rust-lang/rust#61232: We used to ICE when trying to detect a -// collision on the symbol generated for the external linkage item in -// an extern crate. - -//@ build-fail -//@ aux-build:def_colliding_external.rs -// FIXME(#83838) codegen-units=1 triggers llvm asserts -//@ compile-flags: -Ccodegen-units=16 - -extern crate def_colliding_external as dep1; - -#[no_mangle] -pub static _rust_extern_with_linkage_collision: i32 = 0; - -mod dep2 { - #[no_mangle] - pub static collision: usize = 0; -} - -fn main() { - unsafe { - println!("{:p}", &dep1::collision); - } -} - -//~? ERROR symbol `collision` is already defined diff --git a/tests/ui/linkage-attr/linkage-detect-extern-generated-name-collision.stderr b/tests/ui/linkage-attr/linkage-detect-extern-generated-name-collision.stderr deleted file mode 100644 index 2448c160c5c..00000000000 --- a/tests/ui/linkage-attr/linkage-detect-extern-generated-name-collision.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: symbol `collision` is already defined - --> $DIR/auxiliary/def_colliding_external.rs:6:5 - | -LL | pub static collision: *const i32; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/linkage-attr/linkage-detect-local-generated-name-collision.rs b/tests/ui/linkage-attr/linkage-detect-local-generated-name-collision.rs deleted file mode 100644 index df952504eef..00000000000 --- a/tests/ui/linkage-attr/linkage-detect-local-generated-name-collision.rs +++ /dev/null @@ -1,26 +0,0 @@ -//@ build-fail -// FIXME(#83838) codegen-units=1 triggers llvm asserts -//@ compile-flags: -Ccodegen-units=16 -#![feature(linkage)] - -mod dep1 { - extern "C" { - #[linkage = "external"] - #[no_mangle] - pub static collision: *const i32; //~ ERROR symbol `collision` is already defined - } -} - -#[no_mangle] -pub static _rust_extern_with_linkage_collision: i32 = 0; - -mod dep2 { - #[no_mangle] - pub static collision: usize = 0; -} - -fn main() { - unsafe { - println!("{:p}", &dep1::collision); - } -} diff --git a/tests/ui/linkage-attr/linkage-detect-local-generated-name-collision.stderr b/tests/ui/linkage-attr/linkage-detect-local-generated-name-collision.stderr deleted file mode 100644 index fcaaa39b674..00000000000 --- a/tests/ui/linkage-attr/linkage-detect-local-generated-name-collision.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: symbol `collision` is already defined - --> $DIR/linkage-detect-local-generated-name-collision.rs:10:9 - | -LL | pub static collision: *const i32; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/linkage-attr/linkage3.rs b/tests/ui/linkage-attr/linkage3.rs index f95e5eecc48..74a6fd6600b 100644 --- a/tests/ui/linkage-attr/linkage3.rs +++ b/tests/ui/linkage-attr/linkage3.rs @@ -5,7 +5,7 @@ extern "C" { #[linkage = "foo"] static foo: *const i32; -//~^ ERROR: invalid linkage specified +//~^^ ERROR: malformed `linkage` attribute input [E0539] } fn main() { diff --git a/tests/ui/linkage-attr/linkage3.stderr b/tests/ui/linkage-attr/linkage3.stderr index 5f7b7ef227c..f1215f09aea 100644 --- a/tests/ui/linkage-attr/linkage3.stderr +++ b/tests/ui/linkage-attr/linkage3.stderr @@ -1,8 +1,27 @@ -error: invalid linkage specified - --> $DIR/linkage3.rs:7:5 +error[E0539]: malformed `linkage` attribute input + --> $DIR/linkage3.rs:6:5 | -LL | static foo: *const i32; - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | #[linkage = "foo"] + | ^^^^^^^^^^^^-----^ + | | + | valid arguments are `available_externally`, `common`, `extern_weak`, `external`, `internal`, `linkonce`, `linkonce_odr`, `weak` or `weak_odr` + | +help: try changing it to one of the following valid forms of the attribute + | +LL - #[linkage = "foo"] +LL + #[linkage = "available_externally"] + | +LL - #[linkage = "foo"] +LL + #[linkage = "common"] + | +LL - #[linkage = "foo"] +LL + #[linkage = "extern_weak"] + | +LL - #[linkage = "foo"] +LL + #[linkage = "external"] + | + = and 5 other candidates error: aborting due to 1 previous error +For more information about this error, try `rustc --explain E0539`. diff --git a/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-invalid-format.stderr b/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-invalid-format.stderr index ffae30aabcc..6bf1eab311a 100644 --- a/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-invalid-format.stderr +++ b/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-invalid-format.stderr @@ -6,6 +6,8 @@ LL | #[link_ordinal("JustMonika")] | | | | | expected an integer literal here | help: must be of the form: `#[link_ordinal(ordinal)]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link_ordinal-attribute> error[E0539]: malformed `link_ordinal` attribute input --> $DIR/link-ordinal-invalid-format.rs:6:5 @@ -15,6 +17,8 @@ LL | #[link_ordinal("JustMonika")] | | | | | expected an integer literal here | help: must be of the form: `#[link_ordinal(ordinal)]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link_ordinal-attribute> error: aborting due to 2 previous errors diff --git a/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-missing-argument.rs b/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-missing-argument.rs index 2a8b9ebacf7..58f19085540 100644 --- a/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-missing-argument.rs +++ b/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-missing-argument.rs @@ -3,10 +3,12 @@ extern "C" { #[link_ordinal()] //~^ ERROR malformed `link_ordinal` attribute input //~| NOTE expected a single argument + //~| NOTE for more information, visit fn foo(); #[link_ordinal()] //~^ ERROR malformed `link_ordinal` attribute input //~| NOTE expected a single argument + //~| NOTE for more information, visit static mut imported_variable: i32; } diff --git a/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-missing-argument.stderr b/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-missing-argument.stderr index c6b8a18d03a..d575b0961af 100644 --- a/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-missing-argument.stderr +++ b/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-missing-argument.stderr @@ -6,15 +6,19 @@ LL | #[link_ordinal()] | | | | | expected a single argument here | help: must be of the form: `#[link_ordinal(ordinal)]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link_ordinal-attribute> error[E0805]: malformed `link_ordinal` attribute input - --> $DIR/link-ordinal-missing-argument.rs:7:5 + --> $DIR/link-ordinal-missing-argument.rs:8:5 | LL | #[link_ordinal()] | ^^^^^^^^^^^^^^--^ | | | | | expected a single argument here | help: must be of the form: `#[link_ordinal(ordinal)]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link_ordinal-attribute> error: aborting due to 2 previous errors diff --git a/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-not-foreign-fn.rs b/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-not-foreign-fn.rs index 5982c771033..301e690be38 100644 --- a/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-not-foreign-fn.rs +++ b/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-not-foreign-fn.rs @@ -1,13 +1,13 @@ #[link_ordinal(123)] -//~^ ERROR attribute should be applied to a foreign function or static +//~^ ERROR attribute cannot be used on struct Foo {} #[link_ordinal(123)] -//~^ ERROR attribute should be applied to a foreign function or static +//~^ ERROR attribute cannot be used on fn test() {} #[link_ordinal(42)] -//~^ ERROR attribute should be applied to a foreign function or static +//~^ ERROR attribute cannot be used on static mut imported_val: i32 = 123; #[link(name = "exporter", kind = "raw-dylib")] diff --git a/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-not-foreign-fn.stderr b/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-not-foreign-fn.stderr index 8f279508720..c561373db77 100644 --- a/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-not-foreign-fn.stderr +++ b/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-not-foreign-fn.stderr @@ -1,20 +1,26 @@ -error: attribute should be applied to a foreign function or static +error: `#[link_ordinal]` attribute cannot be used on structs --> $DIR/link-ordinal-not-foreign-fn.rs:1:1 | LL | #[link_ordinal(123)] | ^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[link_ordinal]` can be applied to foreign functions, foreign statics -error: attribute should be applied to a foreign function or static +error: `#[link_ordinal]` attribute cannot be used on functions --> $DIR/link-ordinal-not-foreign-fn.rs:5:1 | LL | #[link_ordinal(123)] | ^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[link_ordinal]` can be applied to foreign functions, foreign statics -error: attribute should be applied to a foreign function or static +error: `#[link_ordinal]` attribute cannot be used on statics --> $DIR/link-ordinal-not-foreign-fn.rs:9:1 | LL | #[link_ordinal(42)] | ^^^^^^^^^^^^^^^^^^^ + | + = help: `#[link_ordinal]` can be applied to foreign functions, foreign statics error: aborting due to 3 previous errors diff --git a/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-too-many-arguments.rs b/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-too-many-arguments.rs index ddf9583352f..55b18ae0d96 100644 --- a/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-too-many-arguments.rs +++ b/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-too-many-arguments.rs @@ -3,10 +3,12 @@ extern "C" { #[link_ordinal(3, 4)] //~^ ERROR malformed `link_ordinal` attribute input //~| NOTE expected a single argument + //~| NOTE for more information, visit fn foo(); #[link_ordinal(3, 4)] //~^ ERROR malformed `link_ordinal` attribute input //~| NOTE expected a single argument + //~| NOTE for more information, visit static mut imported_variable: i32; } diff --git a/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-too-many-arguments.stderr b/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-too-many-arguments.stderr index 7d63304f598..a84fef9f9e4 100644 --- a/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-too-many-arguments.stderr +++ b/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-too-many-arguments.stderr @@ -6,15 +6,19 @@ LL | #[link_ordinal(3, 4)] | | | | | expected a single argument here | help: must be of the form: `#[link_ordinal(ordinal)]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link_ordinal-attribute> error[E0805]: malformed `link_ordinal` attribute input - --> $DIR/link-ordinal-too-many-arguments.rs:7:5 + --> $DIR/link-ordinal-too-many-arguments.rs:8:5 | LL | #[link_ordinal(3, 4)] | ^^^^^^^^^^^^^^------^ | | | | | expected a single argument here | help: must be of the form: `#[link_ordinal(ordinal)]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link_ordinal-attribute> error: aborting due to 2 previous errors diff --git a/tests/ui/lint/dead-code/self-assign.rs b/tests/ui/lint/dead-code/self-assign.rs index 357846baf22..ce91f53cbf1 100644 --- a/tests/ui/lint/dead-code/self-assign.rs +++ b/tests/ui/lint/dead-code/self-assign.rs @@ -7,23 +7,20 @@ //! - `dead_code` lint expansion for self-assignments was implemented in #87129. //! - Unfortunately implementation components of #87129 had to be disabled as part of reverts //! #86212, #83171 (to revert #81473) to address regressions #81626 and #81658. -//! - Consequently, none of the following warnings are emitted. +//! - Re-enabled in current version to properly detect self-assignments. //@ check-pass -// Implementation of self-assignment `dead_code` lint expansions disabled due to reverts. -//@ known-bug: #75356 - #![allow(unused_assignments)] #![warn(dead_code)] fn main() { let mut x = 0; x = x; - // FIXME ~^ WARNING: useless assignment of variable of type `i32` to itself + //~^ WARNING: useless assignment of variable of type `i32` to itself x = (x); - // FIXME ~^ WARNING: useless assignment of variable of type `i32` to itself + //~^ WARNING: useless assignment of variable of type `i32` to itself x = {x}; // block expressions don't count as self-assignments @@ -32,10 +29,10 @@ fn main() { struct S<'a> { f: &'a str } let mut s = S { f: "abc" }; s = s; - // FIXME ~^ WARNING: useless assignment of variable of type `S` to itself + //~^ WARNING: useless assignment of variable of type `S<'_>` to itself s.f = s.f; - // FIXME ~^ WARNING: useless assignment of field of type `&str` to itself + //~^ WARNING: useless assignment of field of type `&str` to itself struct N0 { x: Box<i32> } @@ -44,11 +41,11 @@ fn main() { struct N3 { n: N2 }; let mut n3 = N3 { n: N2(N1 { n: N0 { x: Box::new(42) } }) }; n3.n.0.n.x = n3.n.0.n.x; - // FIXME ~^ WARNING: useless assignment of field of type `Box<i32>` to itself + //~^ WARNING: useless assignment of field of type `Box<i32>` to itself let mut t = (1, ((2, 3, (4, 5)),)); t.1.0.2.1 = t.1.0.2.1; - // FIXME ~^ WARNING: useless assignment of field of type `i32` to itself + //~^ WARNING: useless assignment of field of type `i32` to itself let mut y = 0; diff --git a/tests/ui/lint/dead-code/self-assign.stderr b/tests/ui/lint/dead-code/self-assign.stderr new file mode 100644 index 00000000000..408ebdb658b --- /dev/null +++ b/tests/ui/lint/dead-code/self-assign.stderr @@ -0,0 +1,44 @@ +warning: useless assignment of variable of type `i32` to itself + --> $DIR/self-assign.rs:19:5 + | +LL | x = x; + | ^^^^^ + | +note: the lint level is defined here + --> $DIR/self-assign.rs:15:9 + | +LL | #![warn(dead_code)] + | ^^^^^^^^^ + +warning: useless assignment of variable of type `i32` to itself + --> $DIR/self-assign.rs:22:5 + | +LL | x = (x); + | ^^^^^^^ + +warning: useless assignment of variable of type `S<'_>` to itself + --> $DIR/self-assign.rs:31:5 + | +LL | s = s; + | ^^^^^ + +warning: useless assignment of field of type `&str` to itself + --> $DIR/self-assign.rs:34:5 + | +LL | s.f = s.f; + | ^^^^^^^^^ + +warning: useless assignment of field of type `Box<i32>` to itself + --> $DIR/self-assign.rs:43:5 + | +LL | n3.n.0.n.x = n3.n.0.n.x; + | ^^^^^^^^^^^^^^^^^^^^^^^ + +warning: useless assignment of field of type `i32` to itself + --> $DIR/self-assign.rs:47:5 + | +LL | t.1.0.2.1 = t.1.0.2.1; + | ^^^^^^^^^^^^^^^^^^^^^ + +warning: 6 warnings emitted + diff --git a/tests/ui/lint/inline-trait-and-foreign-items.rs b/tests/ui/lint/inline-trait-and-foreign-items.rs index 39bc01f71b5..d41a09dee96 100644 --- a/tests/ui/lint/inline-trait-and-foreign-items.rs +++ b/tests/ui/lint/inline-trait-and-foreign-items.rs @@ -4,33 +4,33 @@ #![warn(unused_attributes)] trait Trait { - #[inline] //~ WARN `#[inline]` is ignored on constants - //~^ WARN this was previously accepted + #[inline] //~ WARN attribute cannot be used on +//~| WARN previously accepted const X: u32; - #[inline] //~ ERROR attribute should be applied to function or closure + #[inline] //~ ERROR attribute cannot be used on type T; type U; } impl Trait for () { - #[inline] //~ WARN `#[inline]` is ignored on constants - //~^ WARN this was previously accepted + #[inline] //~ WARN attribute cannot be used on +//~| WARN previously accepted const X: u32 = 0; - #[inline] //~ ERROR attribute should be applied to function or closure + #[inline] //~ ERROR attribute cannot be used on type T = Self; - #[inline] //~ ERROR attribute should be applied to function or closure + #[inline] //~ ERROR attribute cannot be used on type U = impl Trait; //~ ERROR unconstrained opaque type } extern "C" { - #[inline] //~ ERROR attribute should be applied to function or closure + #[inline] //~ ERROR attribute cannot be used on static X: u32; - #[inline] //~ ERROR attribute should be applied to function or closure + #[inline] //~ ERROR attribute cannot be used on type T; } diff --git a/tests/ui/lint/inline-trait-and-foreign-items.stderr b/tests/ui/lint/inline-trait-and-foreign-items.stderr index 2f1fb4c46c0..4bde4bc590a 100644 --- a/tests/ui/lint/inline-trait-and-foreign-items.stderr +++ b/tests/ui/lint/inline-trait-and-foreign-items.stderr @@ -1,65 +1,42 @@ -warning: `#[inline]` is ignored on constants - --> $DIR/inline-trait-and-foreign-items.rs:7:5 - | -LL | #[inline] - | ^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: see issue #65833 <https://github.com/rust-lang/rust/issues/65833> for more information -note: the lint level is defined here - --> $DIR/inline-trait-and-foreign-items.rs:4:9 - | -LL | #![warn(unused_attributes)] - | ^^^^^^^^^^^^^^^^^ - -error[E0518]: attribute should be applied to function or closure +error: `#[inline]` attribute cannot be used on associated types --> $DIR/inline-trait-and-foreign-items.rs:11:5 | LL | #[inline] | ^^^^^^^^^ -LL | type T; - | ------- not a function or closure - -warning: `#[inline]` is ignored on constants - --> $DIR/inline-trait-and-foreign-items.rs:18:5 - | -LL | #[inline] - | ^^^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: see issue #65833 <https://github.com/rust-lang/rust/issues/65833> for more information + = help: `#[inline]` can only be applied to functions -error[E0518]: attribute should be applied to function or closure +error: `#[inline]` attribute cannot be used on associated types --> $DIR/inline-trait-and-foreign-items.rs:22:5 | LL | #[inline] | ^^^^^^^^^ -LL | type T = Self; - | -------------- not a function or closure + | + = help: `#[inline]` can only be applied to functions -error[E0518]: attribute should be applied to function or closure +error: `#[inline]` attribute cannot be used on associated types --> $DIR/inline-trait-and-foreign-items.rs:25:5 | LL | #[inline] | ^^^^^^^^^ -LL | type U = impl Trait; - | -------------------- not a function or closure + | + = help: `#[inline]` can only be applied to functions -error[E0518]: attribute should be applied to function or closure +error: `#[inline]` attribute cannot be used on foreign statics --> $DIR/inline-trait-and-foreign-items.rs:30:5 | LL | #[inline] | ^^^^^^^^^ -LL | static X: u32; - | -------------- not a function or closure + | + = help: `#[inline]` can only be applied to functions -error[E0518]: attribute should be applied to function or closure +error: `#[inline]` attribute cannot be used on foreign types --> $DIR/inline-trait-and-foreign-items.rs:33:5 | LL | #[inline] | ^^^^^^^^^ -LL | type T; - | ------- not a function or closure + | + = help: `#[inline]` can only be applied to functions error: unconstrained opaque type --> $DIR/inline-trait-and-foreign-items.rs:26:14 @@ -69,6 +46,28 @@ LL | type U = impl Trait; | = note: `U` must be used in combination with a concrete type within the same impl +warning: `#[inline]` attribute cannot be used on associated consts + --> $DIR/inline-trait-and-foreign-items.rs:7:5 + | +LL | #[inline] + | ^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[inline]` can only be applied to functions +note: the lint level is defined here + --> $DIR/inline-trait-and-foreign-items.rs:4:9 + | +LL | #![warn(unused_attributes)] + | ^^^^^^^^^^^^^^^^^ + +warning: `#[inline]` attribute cannot be used on associated consts + --> $DIR/inline-trait-and-foreign-items.rs:18:5 + | +LL | #[inline] + | ^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[inline]` can only be applied to functions + error: aborting due to 6 previous errors; 2 warnings emitted -For more information about this error, try `rustc --explain E0518`. diff --git a/tests/ui/lint/lint-malformed.stderr b/tests/ui/lint/lint-malformed.stderr index 0bdcc293b65..25a4298bd75 100644 --- a/tests/ui/lint/lint-malformed.stderr +++ b/tests/ui/lint/lint-malformed.stderr @@ -16,7 +16,20 @@ error: malformed `deny` attribute input --> $DIR/lint-malformed.rs:1:1 | LL | #![deny = "foo"] - | ^^^^^^^^^^^^^^^^ help: must be of the form: `#![deny(lint1, lint2, ..., /*opt*/ reason = "...")]` + | ^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/diagnostics.html#lint-check-attributes> +help: the following are the possible correct uses + | +LL - #![deny = "foo"] +LL + #![deny(lint1)] + | +LL - #![deny = "foo"] +LL + #![deny(lint1, lint2, ...)] + | +LL - #![deny = "foo"] +LL + #![deny(lint1, lint2, lint3, reason = "...")] + | error[E0452]: malformed lint attribute input --> $DIR/lint-malformed.rs:2:10 diff --git a/tests/ui/lint/semicolon-in-expressions-from-macros/warn-semicolon-in-expressions-from-macros.rs b/tests/ui/lint/semicolon-in-expressions-from-macros/warn-semicolon-in-expressions-from-macros.rs index 05fbfec2ae5..8ec70a17864 100644 --- a/tests/ui/lint/semicolon-in-expressions-from-macros/warn-semicolon-in-expressions-from-macros.rs +++ b/tests/ui/lint/semicolon-in-expressions-from-macros/warn-semicolon-in-expressions-from-macros.rs @@ -1,9 +1,8 @@ -//@ check-pass -// Ensure that trailing semicolons cause warnings by default +// Ensure that trailing semicolons cause errors by default macro_rules! foo { () => { - true; //~ WARN trailing semicolon in macro + true; //~ ERROR trailing semicolon in macro //~| WARN this was previously } } diff --git a/tests/ui/lint/semicolon-in-expressions-from-macros/warn-semicolon-in-expressions-from-macros.stderr b/tests/ui/lint/semicolon-in-expressions-from-macros/warn-semicolon-in-expressions-from-macros.stderr index 0fec4996f1a..99cdcafab39 100644 --- a/tests/ui/lint/semicolon-in-expressions-from-macros/warn-semicolon-in-expressions-from-macros.stderr +++ b/tests/ui/lint/semicolon-in-expressions-from-macros/warn-semicolon-in-expressions-from-macros.stderr @@ -1,5 +1,5 @@ -warning: trailing semicolon in macro used in expression position - --> $DIR/warn-semicolon-in-expressions-from-macros.rs:6:13 +error: trailing semicolon in macro used in expression position + --> $DIR/warn-semicolon-in-expressions-from-macros.rs:5:13 | LL | true; | ^ @@ -9,14 +9,14 @@ LL | _ => foo!() | = 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 #79813 <https://github.com/rust-lang/rust/issues/79813> - = note: `#[warn(semicolon_in_expressions_from_macros)]` on by default - = note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: `#[deny(semicolon_in_expressions_from_macros)]` on by default + = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) -warning: 1 warning emitted +error: aborting due to 1 previous error Future incompatibility report: Future breakage diagnostic: -warning: trailing semicolon in macro used in expression position - --> $DIR/warn-semicolon-in-expressions-from-macros.rs:6:13 +error: trailing semicolon in macro used in expression position + --> $DIR/warn-semicolon-in-expressions-from-macros.rs:5:13 | LL | true; | ^ @@ -26,6 +26,6 @@ LL | _ => foo!() | = 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 #79813 <https://github.com/rust-lang/rust/issues/79813> - = note: `#[warn(semicolon_in_expressions_from_macros)]` on by default - = note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: `#[deny(semicolon_in_expressions_from_macros)]` on by default + = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/issues/issue-29710.rs b/tests/ui/lint/unused-results-lint-triggered-by-derive-debug-29710.rs index 906ffe9e77b..51702f69c20 100644 --- a/tests/ui/issues/issue-29710.rs +++ b/tests/ui/lint/unused-results-lint-triggered-by-derive-debug-29710.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/29710 //@ check-pass #![deny(unused_results)] #![allow(dead_code)] diff --git a/tests/ui/lint/unused/unused-attr-duplicate.stderr b/tests/ui/lint/unused/unused-attr-duplicate.stderr index e277f5203c6..6c44e884ba5 100644 --- a/tests/ui/lint/unused/unused-attr-duplicate.stderr +++ b/tests/ui/lint/unused/unused-attr-duplicate.stderr @@ -16,19 +16,6 @@ LL | #![deny(unused_attributes)] | ^^^^^^^^^^^^^^^^^ error: unused attribute - --> $DIR/unused-attr-duplicate.rs:55:1 - | -LL | #[should_panic(expected = "values don't match")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute - | -note: attribute also specified here - --> $DIR/unused-attr-duplicate.rs:54:1 - | -LL | #[should_panic] - | ^^^^^^^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -error: unused attribute --> $DIR/unused-attr-duplicate.rs:14:1 | LL | #![crate_name = "unused_attr_duplicate2"] @@ -154,6 +141,19 @@ LL | #[ignore] | ^^^^^^^^^ error: unused attribute + --> $DIR/unused-attr-duplicate.rs:55:1 + | +LL | #[should_panic(expected = "values don't match")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/unused-attr-duplicate.rs:54:1 + | +LL | #[should_panic] + | ^^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +error: unused attribute --> $DIR/unused-attr-duplicate.rs:60:1 | LL | #[must_use = "some message"] diff --git a/tests/ui/lint/unused/unused-attr-macro-rules.rs b/tests/ui/lint/unused/unused-attr-macro-rules.rs index 7a8a1bb1ae5..96f2834a296 100644 --- a/tests/ui/lint/unused/unused-attr-macro-rules.rs +++ b/tests/ui/lint/unused/unused-attr-macro-rules.rs @@ -4,8 +4,10 @@ // A sample of various built-in attributes. #[macro_export] -#[macro_use] //~ ERROR `#[macro_use]` only has an effect -#[path="foo"] //~ ERROR #[path]` only has an effect +#[macro_use] //~ ERROR attribute cannot be used on +//~| WARN previously accepted +#[path="foo"] //~ ERROR attribute cannot be used on +//~| WARN previously accepted #[recursion_limit="1"] //~ ERROR crate-level attribute should be an inner attribute macro_rules! foo { () => {}; diff --git a/tests/ui/lint/unused/unused-attr-macro-rules.stderr b/tests/ui/lint/unused/unused-attr-macro-rules.stderr index 1e1211af5e2..0c55ae678e9 100644 --- a/tests/ui/lint/unused/unused-attr-macro-rules.stderr +++ b/tests/ui/lint/unused/unused-attr-macro-rules.stderr @@ -1,5 +1,5 @@ error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/unused-attr-macro-rules.rs:9:1 + --> $DIR/unused-attr-macro-rules.rs:11:1 | LL | #[recursion_limit="1"] | ^^^^^^^^^^^^^^^^^^^^^^ @@ -10,17 +10,23 @@ note: the lint level is defined here LL | #![deny(unused_attributes)] | ^^^^^^^^^^^^^^^^^ -error: `#[macro_use]` only has an effect on `extern crate` and modules +error: `#[macro_use]` attribute cannot be used on macro defs --> $DIR/unused-attr-macro-rules.rs:7:1 | LL | #[macro_use] | ^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[macro_use]` can be applied to modules, extern crates, crates -error: `#[path]` only has an effect on modules - --> $DIR/unused-attr-macro-rules.rs:8:1 +error: `#[path]` attribute cannot be used on macro defs + --> $DIR/unused-attr-macro-rules.rs:9:1 | LL | #[path="foo"] | ^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[path]` can only be applied to modules error: aborting due to 3 previous errors diff --git a/tests/ui/lint/unused/unused_attributes-must_use.fixed b/tests/ui/lint/unused/unused_attributes-must_use.fixed new file mode 100644 index 00000000000..80d488296ea --- /dev/null +++ b/tests/ui/lint/unused/unused_attributes-must_use.fixed @@ -0,0 +1,139 @@ +//@ run-rustfix + +#![allow(dead_code, path_statements)] +#![deny(unused_attributes, unused_must_use)] +#![feature(asm_experimental_arch, stmt_expr_attributes, trait_alias)] + + //~ ERROR `#[must_use]` has no effect +extern crate std as std2; + + //~ ERROR `#[must_use]` has no effect +mod test_mod {} + + //~ ERROR `#[must_use]` has no effect +use std::arch::global_asm; + + //~ ERROR `#[must_use]` has no effect +const CONST: usize = 4; + //~ ERROR `#[must_use]` has no effect +#[no_mangle] +static STATIC: usize = 4; + +#[must_use] +struct X; + +#[must_use] +enum Y { + Z, +} + +#[must_use] +union U { + unit: (), +} + + //~ ERROR `#[must_use]` has no effect +impl U { + #[must_use] + fn method() -> i32 { + 4 + } +} + +#[must_use] +#[no_mangle] +fn foo() -> i64 { + 4 +} + + //~ ERROR `#[must_use]` has no effect +extern "Rust" { + #[link_name = "STATIC"] + //~ ERROR `#[must_use]` has no effect + static FOREIGN_STATIC: usize; + + #[link_name = "foo"] + #[must_use] + fn foreign_foo() -> i64; +} + + //~ ERROR unused attribute +global_asm!(""); + + //~ ERROR `#[must_use]` has no effect +type UseMe = (); + +fn qux< T>(_: T) {} //~ ERROR `#[must_use]` has no effect + +#[must_use] +trait Use { + //~ ERROR `#[must_use]` has no effect + const ASSOC_CONST: usize = 4; + //~ ERROR `#[must_use]` has no effect + type AssocTy; + + #[must_use] + fn get_four(&self) -> usize { + 4 + } +} + + //~ ERROR `#[must_use]` has no effect +impl Use for () { + type AssocTy = (); + + //~ ERROR `#[must_use]` has no effect + fn get_four(&self) -> usize { + 4 + } +} + + //~ ERROR `#[must_use]` has no effect +trait Alias = Use; + + //~ ERROR `#[must_use]` has no effect +macro_rules! cool_macro { + () => { + 4 + }; +} + +fn main() { + //~ ERROR `#[must_use]` has no effect + let x = || {}; + x(); + + let x = //~ ERROR `#[must_use]` has no effect + || {}; + x(); + + let _ = X; //~ ERROR that must be used + let _ = Y::Z; //~ ERROR that must be used + let _ = U { unit: () }; //~ ERROR that must be used + let _ = U::method(); //~ ERROR that must be used + let _ = foo(); //~ ERROR that must be used + + unsafe { + let _ = foreign_foo(); //~ ERROR that must be used + }; + + CONST; + STATIC; + unsafe { FOREIGN_STATIC }; + cool_macro!(); + qux(4); + let _ = ().get_four(); //~ ERROR that must be used + + match Some(4) { + //~ ERROR `#[must_use]` has no effect + Some(res) => res, + None => 0, + }; + + struct PatternField { + foo: i32, + } + let s = PatternField { foo: 123 }; //~ ERROR `#[must_use]` has no effect + let PatternField { foo } = s; //~ ERROR `#[must_use]` has no effect + let _ = foo; +} diff --git a/tests/ui/lint/unused/unused_attributes-must_use.rs b/tests/ui/lint/unused/unused_attributes-must_use.rs index 860fc5046d1..edefe8ed65e 100644 --- a/tests/ui/lint/unused/unused_attributes-must_use.rs +++ b/tests/ui/lint/unused/unused_attributes-must_use.rs @@ -1,3 +1,5 @@ +//@ run-rustfix + #![allow(dead_code, path_statements)] #![deny(unused_attributes, unused_must_use)] #![feature(asm_experimental_arch, stmt_expr_attributes, trait_alias)] @@ -133,4 +135,5 @@ fn main() { } let s = PatternField { #[must_use] foo: 123 }; //~ ERROR `#[must_use]` has no effect let PatternField { #[must_use] foo } = s; //~ ERROR `#[must_use]` has no effect + let _ = foo; } diff --git a/tests/ui/lint/unused/unused_attributes-must_use.stderr b/tests/ui/lint/unused/unused_attributes-must_use.stderr index 862ffa42d80..9e37f6504cc 100644 --- a/tests/ui/lint/unused/unused_attributes-must_use.stderr +++ b/tests/ui/lint/unused/unused_attributes-must_use.stderr @@ -1,154 +1,154 @@ error: unused attribute `must_use` - --> $DIR/unused_attributes-must_use.rs:58:1 + --> $DIR/unused_attributes-must_use.rs:60:1 | LL | #[must_use] | ^^^^^^^^^^^ | note: the built-in attribute `must_use` will be ignored, since it's applied to the macro invocation `global_asm` - --> $DIR/unused_attributes-must_use.rs:59:1 + --> $DIR/unused_attributes-must_use.rs:61:1 | LL | global_asm!(""); | ^^^^^^^^^^ note: the lint level is defined here - --> $DIR/unused_attributes-must_use.rs:2:9 + --> $DIR/unused_attributes-must_use.rs:4:9 | LL | #![deny(unused_attributes, unused_must_use)] | ^^^^^^^^^^^^^^^^^ -error: `#[must_use]` has no effect when applied to an extern crate - --> $DIR/unused_attributes-must_use.rs:5:1 +error: `#[must_use]` has no effect when applied to extern crates + --> $DIR/unused_attributes-must_use.rs:7:1 | LL | #[must_use] | ^^^^^^^^^^^ -error: `#[must_use]` has no effect when applied to a module - --> $DIR/unused_attributes-must_use.rs:8:1 +error: `#[must_use]` has no effect when applied to modules + --> $DIR/unused_attributes-must_use.rs:10:1 | LL | #[must_use] | ^^^^^^^^^^^ -error: `#[must_use]` has no effect when applied to a use - --> $DIR/unused_attributes-must_use.rs:11:1 +error: `#[must_use]` has no effect when applied to use statements + --> $DIR/unused_attributes-must_use.rs:13:1 | LL | #[must_use] | ^^^^^^^^^^^ -error: `#[must_use]` has no effect when applied to a constant item - --> $DIR/unused_attributes-must_use.rs:14:1 +error: `#[must_use]` has no effect when applied to constants + --> $DIR/unused_attributes-must_use.rs:16:1 | LL | #[must_use] | ^^^^^^^^^^^ -error: `#[must_use]` has no effect when applied to a static item - --> $DIR/unused_attributes-must_use.rs:16:1 +error: `#[must_use]` has no effect when applied to statics + --> $DIR/unused_attributes-must_use.rs:18:1 | LL | #[must_use] | ^^^^^^^^^^^ -error: `#[must_use]` has no effect when applied to an inherent implementation block - --> $DIR/unused_attributes-must_use.rs:33:1 +error: `#[must_use]` has no effect when applied to inherent impl blocks + --> $DIR/unused_attributes-must_use.rs:35:1 | LL | #[must_use] | ^^^^^^^^^^^ -error: `#[must_use]` has no effect when applied to a foreign module - --> $DIR/unused_attributes-must_use.rs:47:1 +error: `#[must_use]` has no effect when applied to foreign modules + --> $DIR/unused_attributes-must_use.rs:49:1 | LL | #[must_use] | ^^^^^^^^^^^ -error: `#[must_use]` has no effect when applied to a type alias - --> $DIR/unused_attributes-must_use.rs:61:1 +error: `#[must_use]` has no effect when applied to type aliases + --> $DIR/unused_attributes-must_use.rs:63:1 | LL | #[must_use] | ^^^^^^^^^^^ -error: `#[must_use]` has no effect when applied to a type parameter - --> $DIR/unused_attributes-must_use.rs:64:8 +error: `#[must_use]` has no effect when applied to type parameters + --> $DIR/unused_attributes-must_use.rs:66:8 | LL | fn qux<#[must_use] T>(_: T) {} | ^^^^^^^^^^^ -error: `#[must_use]` has no effect when applied to an trait implementation block - --> $DIR/unused_attributes-must_use.rs:79:1 +error: `#[must_use]` has no effect when applied to trait impl blocks + --> $DIR/unused_attributes-must_use.rs:81:1 | LL | #[must_use] | ^^^^^^^^^^^ -error: `#[must_use]` has no effect when applied to a trait alias - --> $DIR/unused_attributes-must_use.rs:89:1 +error: `#[must_use]` has no effect when applied to trait aliases + --> $DIR/unused_attributes-must_use.rs:91:1 | LL | #[must_use] | ^^^^^^^^^^^ -error: `#[must_use]` has no effect when applied to a macro def - --> $DIR/unused_attributes-must_use.rs:92:1 +error: `#[must_use]` has no effect when applied to macro defs + --> $DIR/unused_attributes-must_use.rs:94:1 | LL | #[must_use] | ^^^^^^^^^^^ -error: `#[must_use]` has no effect when applied to a statement - --> $DIR/unused_attributes-must_use.rs:100:5 +error: `#[must_use]` has no effect when applied to statements + --> $DIR/unused_attributes-must_use.rs:102:5 | LL | #[must_use] | ^^^^^^^^^^^ -error: `#[must_use]` has no effect when applied to a closure - --> $DIR/unused_attributes-must_use.rs:104:13 +error: `#[must_use]` has no effect when applied to closures + --> $DIR/unused_attributes-must_use.rs:106:13 | LL | let x = #[must_use] | ^^^^^^^^^^^ -error: `#[must_use]` has no effect when applied to an match arm - --> $DIR/unused_attributes-must_use.rs:126:9 +error: `#[must_use]` has no effect when applied to match arms + --> $DIR/unused_attributes-must_use.rs:128:9 | LL | #[must_use] | ^^^^^^^^^^^ -error: `#[must_use]` has no effect when applied to a struct field - --> $DIR/unused_attributes-must_use.rs:134:28 +error: `#[must_use]` has no effect when applied to struct fields + --> $DIR/unused_attributes-must_use.rs:136:28 | LL | let s = PatternField { #[must_use] foo: 123 }; | ^^^^^^^^^^^ -error: `#[must_use]` has no effect when applied to a pattern field - --> $DIR/unused_attributes-must_use.rs:135:24 +error: `#[must_use]` has no effect when applied to pattern fields + --> $DIR/unused_attributes-must_use.rs:137:24 | LL | let PatternField { #[must_use] foo } = s; | ^^^^^^^^^^^ -error: `#[must_use]` has no effect when applied to an associated const - --> $DIR/unused_attributes-must_use.rs:68:5 +error: `#[must_use]` has no effect when applied to associated consts + --> $DIR/unused_attributes-must_use.rs:70:5 | LL | #[must_use] | ^^^^^^^^^^^ -error: `#[must_use]` has no effect when applied to an associated type - --> $DIR/unused_attributes-must_use.rs:70:5 +error: `#[must_use]` has no effect when applied to associated types + --> $DIR/unused_attributes-must_use.rs:72:5 | LL | #[must_use] | ^^^^^^^^^^^ -error: `#[must_use]` has no effect when applied to a provided trait method - --> $DIR/unused_attributes-must_use.rs:83:5 +error: `#[must_use]` has no effect when applied to provided trait methods + --> $DIR/unused_attributes-must_use.rs:85:5 | LL | #[must_use] | ^^^^^^^^^^^ -error: `#[must_use]` has no effect when applied to a foreign static item - --> $DIR/unused_attributes-must_use.rs:50:5 +error: `#[must_use]` has no effect when applied to foreign statics + --> $DIR/unused_attributes-must_use.rs:52:5 | LL | #[must_use] | ^^^^^^^^^^^ error: unused `X` that must be used - --> $DIR/unused_attributes-must_use.rs:108:5 + --> $DIR/unused_attributes-must_use.rs:110:5 | LL | X; | ^ | note: the lint level is defined here - --> $DIR/unused_attributes-must_use.rs:2:28 + --> $DIR/unused_attributes-must_use.rs:4:28 | LL | #![deny(unused_attributes, unused_must_use)] | ^^^^^^^^^^^^^^^ @@ -158,7 +158,7 @@ LL | let _ = X; | +++++++ error: unused `Y` that must be used - --> $DIR/unused_attributes-must_use.rs:109:5 + --> $DIR/unused_attributes-must_use.rs:111:5 | LL | Y::Z; | ^^^^ @@ -169,7 +169,7 @@ LL | let _ = Y::Z; | +++++++ error: unused `U` that must be used - --> $DIR/unused_attributes-must_use.rs:110:5 + --> $DIR/unused_attributes-must_use.rs:112:5 | LL | U { unit: () }; | ^^^^^^^^^^^^^^ @@ -180,7 +180,7 @@ LL | let _ = U { unit: () }; | +++++++ error: unused return value of `U::method` that must be used - --> $DIR/unused_attributes-must_use.rs:111:5 + --> $DIR/unused_attributes-must_use.rs:113:5 | LL | U::method(); | ^^^^^^^^^^^ @@ -191,7 +191,7 @@ LL | let _ = U::method(); | +++++++ error: unused return value of `foo` that must be used - --> $DIR/unused_attributes-must_use.rs:112:5 + --> $DIR/unused_attributes-must_use.rs:114:5 | LL | foo(); | ^^^^^ @@ -202,7 +202,7 @@ LL | let _ = foo(); | +++++++ error: unused return value of `foreign_foo` that must be used - --> $DIR/unused_attributes-must_use.rs:115:9 + --> $DIR/unused_attributes-must_use.rs:117:9 | LL | foreign_foo(); | ^^^^^^^^^^^^^ @@ -213,7 +213,7 @@ LL | let _ = foreign_foo(); | +++++++ error: unused return value of `Use::get_four` that must be used - --> $DIR/unused_attributes-must_use.rs:123:5 + --> $DIR/unused_attributes-must_use.rs:125:5 | LL | ().get_four(); | ^^^^^^^^^^^^^ diff --git a/tests/ui/lint/warn-unused-inline-on-fn-prototypes.rs b/tests/ui/lint/warn-unused-inline-on-fn-prototypes.rs index 4684fe14577..bef607a4ec5 100644 --- a/tests/ui/lint/warn-unused-inline-on-fn-prototypes.rs +++ b/tests/ui/lint/warn-unused-inline-on-fn-prototypes.rs @@ -1,12 +1,14 @@ #![deny(unused_attributes)] trait Trait { - #[inline] //~ ERROR `#[inline]` is ignored on function prototypes + #[inline] //~ ERROR attribute cannot be used on + //~^ WARN previously accepted fn foo(); } extern "C" { - #[inline] //~ ERROR `#[inline]` is ignored on function prototypes + #[inline] //~ ERROR attribute cannot be used on + //~^ WARN previously accepted fn foo(); } diff --git a/tests/ui/lint/warn-unused-inline-on-fn-prototypes.stderr b/tests/ui/lint/warn-unused-inline-on-fn-prototypes.stderr index ab19d80e732..336366042f9 100644 --- a/tests/ui/lint/warn-unused-inline-on-fn-prototypes.stderr +++ b/tests/ui/lint/warn-unused-inline-on-fn-prototypes.stderr @@ -1,20 +1,25 @@ -error: `#[inline]` is ignored on function prototypes +error: `#[inline]` attribute cannot be used on required trait methods --> $DIR/warn-unused-inline-on-fn-prototypes.rs:4:5 | LL | #[inline] | ^^^^^^^^^ | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[inline]` can be applied to functions, inherent methods, provided trait methods, trait methods in impl blocks, closures note: the lint level is defined here --> $DIR/warn-unused-inline-on-fn-prototypes.rs:1:9 | LL | #![deny(unused_attributes)] | ^^^^^^^^^^^^^^^^^ -error: `#[inline]` is ignored on function prototypes - --> $DIR/warn-unused-inline-on-fn-prototypes.rs:9:5 +error: `#[inline]` attribute cannot be used on foreign functions + --> $DIR/warn-unused-inline-on-fn-prototypes.rs:10:5 | LL | #[inline] | ^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[inline]` can be applied to methods, functions, closures error: aborting due to 2 previous errors diff --git a/tests/ui/loop-match/invalid-attribute.rs b/tests/ui/loop-match/invalid-attribute.rs index d8d2f605eb4..a5d7daac583 100644 --- a/tests/ui/loop-match/invalid-attribute.rs +++ b/tests/ui/loop-match/invalid-attribute.rs @@ -3,17 +3,17 @@ #![allow(incomplete_features)] #![feature(loop_match)] -#![loop_match] //~ ERROR should be applied to a loop -#![const_continue] //~ ERROR should be applied to a break expression +#![loop_match] //~ ERROR attribute cannot be used on +#![const_continue] //~ ERROR attribute cannot be used on extern "C" { - #[loop_match] //~ ERROR should be applied to a loop - #[const_continue] //~ ERROR should be applied to a break expression + #[loop_match] //~ ERROR attribute cannot be used on + #[const_continue] //~ ERROR attribute cannot be used on fn f(); } -#[loop_match] //~ ERROR should be applied to a loop -#[const_continue] //~ ERROR should be applied to a break expression +#[loop_match] //~ ERROR attribute cannot be used on +#[const_continue] //~ ERROR attribute cannot be used on #[repr(C)] struct S { a: u32, @@ -21,18 +21,18 @@ struct S { } trait Invoke { - #[loop_match] //~ ERROR should be applied to a loop - #[const_continue] //~ ERROR should be applied to a break expression + #[loop_match] //~ ERROR attribute cannot be used on + #[const_continue] //~ ERROR attribute cannot be used on extern "C" fn invoke(&self); } -#[loop_match] //~ ERROR should be applied to a loop -#[const_continue] //~ ERROR should be applied to a break expression +#[loop_match] //~ ERROR attribute cannot be used on +#[const_continue] //~ ERROR attribute cannot be used on extern "C" fn ok() {} fn main() { - #[loop_match] //~ ERROR should be applied to a loop - #[const_continue] //~ ERROR should be applied to a break expression + #[loop_match] //~ ERROR attribute cannot be used on + #[const_continue] //~ ERROR attribute cannot be used on || {}; { diff --git a/tests/ui/loop-match/invalid-attribute.stderr b/tests/ui/loop-match/invalid-attribute.stderr index 07015311f9c..ddb68aea31b 100644 --- a/tests/ui/loop-match/invalid-attribute.stderr +++ b/tests/ui/loop-match/invalid-attribute.stderr @@ -1,54 +1,98 @@ -error: `#[const_continue]` should be applied to a break expression - --> $DIR/invalid-attribute.rs:16:1 +error: `#[loop_match]` attribute cannot be used on crates + --> $DIR/invalid-attribute.rs:6:1 | -LL | #[const_continue] - | ^^^^^^^^^^^^^^^^^ -LL | #[repr(C)] -LL | struct S { - | -------- not a break expression +LL | #![loop_match] + | ^^^^^^^^^^^^^^ + | + = help: `#[loop_match]` can be applied to -error: `#[loop_match]` should be applied to a loop +error: `#[const_continue]` attribute cannot be used on crates + --> $DIR/invalid-attribute.rs:7:1 + | +LL | #![const_continue] + | ^^^^^^^^^^^^^^^^^^ + | + = help: `#[const_continue]` can be applied to + +error: `#[loop_match]` attribute cannot be used on foreign functions + --> $DIR/invalid-attribute.rs:10:5 + | +LL | #[loop_match] + | ^^^^^^^^^^^^^ + | + = help: `#[loop_match]` can be applied to + +error: `#[const_continue]` attribute cannot be used on foreign functions + --> $DIR/invalid-attribute.rs:11:5 + | +LL | #[const_continue] + | ^^^^^^^^^^^^^^^^^ + | + = help: `#[const_continue]` can be applied to + +error: `#[loop_match]` attribute cannot be used on structs --> $DIR/invalid-attribute.rs:15:1 | LL | #[loop_match] | ^^^^^^^^^^^^^ -... -LL | struct S { - | -------- not a loop + | + = help: `#[loop_match]` can be applied to -error: `#[const_continue]` should be applied to a break expression - --> $DIR/invalid-attribute.rs:30:1 +error: `#[const_continue]` attribute cannot be used on structs + --> $DIR/invalid-attribute.rs:16:1 | LL | #[const_continue] | ^^^^^^^^^^^^^^^^^ -LL | extern "C" fn ok() {} - | ------------------ not a break expression + | + = help: `#[const_continue]` can be applied to -error: `#[loop_match]` should be applied to a loop +error: `#[loop_match]` attribute cannot be used on required trait methods + --> $DIR/invalid-attribute.rs:24:5 + | +LL | #[loop_match] + | ^^^^^^^^^^^^^ + | + = help: `#[loop_match]` can be applied to + +error: `#[const_continue]` attribute cannot be used on required trait methods + --> $DIR/invalid-attribute.rs:25:5 + | +LL | #[const_continue] + | ^^^^^^^^^^^^^^^^^ + | + = help: `#[const_continue]` can be applied to + +error: `#[loop_match]` attribute cannot be used on functions --> $DIR/invalid-attribute.rs:29:1 | LL | #[loop_match] | ^^^^^^^^^^^^^ -LL | #[const_continue] -LL | extern "C" fn ok() {} - | ------------------ not a loop + | + = help: `#[loop_match]` can be applied to -error: `#[const_continue]` should be applied to a break expression - --> $DIR/invalid-attribute.rs:35:5 +error: `#[const_continue]` attribute cannot be used on functions + --> $DIR/invalid-attribute.rs:30:1 | -LL | #[const_continue] - | ^^^^^^^^^^^^^^^^^ -LL | || {}; - | -- not a break expression +LL | #[const_continue] + | ^^^^^^^^^^^^^^^^^ + | + = help: `#[const_continue]` can be applied to -error: `#[loop_match]` should be applied to a loop +error: `#[loop_match]` attribute cannot be used on closures --> $DIR/invalid-attribute.rs:34:5 | LL | #[loop_match] | ^^^^^^^^^^^^^ + | + = help: `#[loop_match]` can be applied to + +error: `#[const_continue]` attribute cannot be used on closures + --> $DIR/invalid-attribute.rs:35:5 + | LL | #[const_continue] -LL | || {}; - | -- not a loop + | ^^^^^^^^^^^^^^^^^ + | + = help: `#[const_continue]` can be applied to error: `#[const_continue]` should be applied to a break expression --> $DIR/invalid-attribute.rs:40:9 @@ -67,65 +111,5 @@ LL | #[const_continue] LL | 5 | - not a loop -error: `#[const_continue]` should be applied to a break expression - --> $DIR/invalid-attribute.rs:25:5 - | -LL | #[const_continue] - | ^^^^^^^^^^^^^^^^^ -LL | extern "C" fn invoke(&self); - | ---------------------------- not a break expression - -error: `#[loop_match]` should be applied to a loop - --> $DIR/invalid-attribute.rs:24:5 - | -LL | #[loop_match] - | ^^^^^^^^^^^^^ -LL | #[const_continue] -LL | extern "C" fn invoke(&self); - | ---------------------------- not a loop - -error: `#[const_continue]` should be applied to a break expression - --> $DIR/invalid-attribute.rs:11:5 - | -LL | #[const_continue] - | ^^^^^^^^^^^^^^^^^ -LL | fn f(); - | ------- not a break expression - -error: `#[loop_match]` should be applied to a loop - --> $DIR/invalid-attribute.rs:10:5 - | -LL | #[loop_match] - | ^^^^^^^^^^^^^ -LL | #[const_continue] -LL | fn f(); - | ------- not a loop - -error: `#[const_continue]` should be applied to a break expression - --> $DIR/invalid-attribute.rs:7:1 - | -LL | / #![allow(incomplete_features)] -LL | | #![feature(loop_match)] -LL | | #![loop_match] -LL | | #![const_continue] - | | ^^^^^^^^^^^^^^^^^^ -... | -LL | | }; -LL | | } - | |_- not a break expression - -error: `#[loop_match]` should be applied to a loop - --> $DIR/invalid-attribute.rs:6:1 - | -LL | / #![allow(incomplete_features)] -LL | | #![feature(loop_match)] -LL | | #![loop_match] - | | ^^^^^^^^^^^^^^ -LL | | #![const_continue] -... | -LL | | }; -LL | | } - | |_- not a loop - error: aborting due to 14 previous errors diff --git a/tests/ui/issues/issue-9047.rs b/tests/ui/loops/loop-with-label-9047.rs index 97733588d51..29e6dba0b9e 100644 --- a/tests/ui/issues/issue-9047.rs +++ b/tests/ui/loops/loop-with-label-9047.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/9047 //@ run-pass #![allow(unused_mut)] #![allow(unused_variables)] diff --git a/tests/ui/macros/assert-long-condition.run.stderr b/tests/ui/macros/assert-long-condition.run.stderr index c2c5fe5d7d5..a9fac037143 100644 --- a/tests/ui/macros/assert-long-condition.run.stderr +++ b/tests/ui/macros/assert-long-condition.run.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at $DIR/assert-long-condition.rs:7:5: +thread 'main' ($TID) panicked at $DIR/assert-long-condition.rs:7:5: assertion failed: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 == 0 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/macros/assert-macro-lifetimes.rs b/tests/ui/macros/assert-macro-lifetimes.rs new file mode 100644 index 00000000000..cc259283204 --- /dev/null +++ b/tests/ui/macros/assert-macro-lifetimes.rs @@ -0,0 +1,8 @@ +//@ check-pass +#[derive(PartialEq, Eq, Hash)] +struct S; +fn main() { + let foo = std::rc::Rc::new(std::cell::RefCell::new(std::collections::HashMap::<S, S>::new())); + // Ensure that the lifetimes of the borrow do not leak past the end of `main`. + assert!(matches!(foo.borrow().get(&S).unwrap(), S)) +} diff --git a/tests/ui/macros/cfg_select.rs b/tests/ui/macros/cfg_select.rs index 461d2e0e8c1..9241141ef9a 100644 --- a/tests/ui/macros/cfg_select.rs +++ b/tests/ui/macros/cfg_select.rs @@ -8,10 +8,42 @@ fn print() { }); } -fn arm_rhs_must_be_in_braces() -> i32 { +fn print_2() { + println!(cfg_select! { + unix => "unix", + _ => "not unix", + }); +} + +fn arm_rhs_expr_1() -> i32 { cfg_select! { true => 1 - //~^ ERROR: expected `{`, found `1` + } +} + +fn arm_rhs_expr_2() -> i32 { + cfg_select! { + true => 1, + false => 2 + } +} + +fn arm_rhs_expr_3() -> i32 { + cfg_select! { + true => 1, + false => 2, + true => { 42 } + false => -1 as i32, + true => 2 + 2, + false => "", + true => if true { 42 } else { 84 } + false => if true { 42 } else { 84 }, + true => return 42, + false => loop {} + true => (1, 2), + false => (1, 2,), + true => todo!(), + false => println!("hello"), } } diff --git a/tests/ui/macros/cfg_select.stderr b/tests/ui/macros/cfg_select.stderr index 6c18a7c189d..7280f35c16f 100644 --- a/tests/ui/macros/cfg_select.stderr +++ b/tests/ui/macros/cfg_select.stderr @@ -1,11 +1,5 @@ -error: expected `{`, found `1` - --> $DIR/cfg_select.rs:13:17 - | -LL | true => 1 - | ^ expected `{` - warning: unreachable predicate - --> $DIR/cfg_select.rs:20:5 + --> $DIR/cfg_select.rs:52:5 | LL | _ => {} | - always matches @@ -13,7 +7,7 @@ LL | true => {} | ^^^^ this predicate is never reached error: none of the predicates in this `cfg_select` evaluated to true - --> $DIR/cfg_select.rs:24:1 + --> $DIR/cfg_select.rs:56:1 | LL | / cfg_select! { LL | | @@ -22,10 +16,10 @@ LL | | } | |_^ error: none of the predicates in this `cfg_select` evaluated to true - --> $DIR/cfg_select.rs:29:1 + --> $DIR/cfg_select.rs:61:1 | LL | cfg_select! {} | ^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors; 1 warning emitted +error: aborting due to 2 previous errors; 1 warning emitted diff --git a/tests/ui/issues/issue-15189.rs b/tests/ui/macros/for-loop-macro-rules-hygiene.rs index 4dbe2179dd9..fcebda1b9da 100644 --- a/tests/ui/issues/issue-15189.rs +++ b/tests/ui/macros/for-loop-macro-rules-hygiene.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15189 + //@ run-pass macro_rules! third { ($e:expr) => ({let x = 2; $e[x]}) diff --git a/tests/ui/macros/issue-111749.stderr b/tests/ui/macros/issue-111749.stderr index 7db2b8e6ad1..884537ef531 100644 --- a/tests/ui/macros/issue-111749.stderr +++ b/tests/ui/macros/issue-111749.stderr @@ -16,3 +16,14 @@ LL | cbor_map! { #[test(test)] 4}; error: aborting due to 2 previous errors +Future incompatibility report: Future breakage diagnostic: +error: attribute must be of the form `#[test]` + --> $DIR/issue-111749.rs:8:17 + | +LL | cbor_map! { #[test(test)] 4}; + | ^^^^^^^^^^^^^ + | + = 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 #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: `#[deny(ill_formed_attribute_input)]` on by default + diff --git a/tests/ui/macros/issue-68060.rs b/tests/ui/macros/issue-68060.rs index 4eddb96848c..2edf9861743 100644 --- a/tests/ui/macros/issue-68060.rs +++ b/tests/ui/macros/issue-68060.rs @@ -2,13 +2,12 @@ fn main() { (0..) .map( #[target_feature(enable = "")] - //~^ ERROR: attribute should be applied to a function + //~^ ERROR: attribute cannot be used on #[track_caller] //~^ ERROR: `#[track_caller]` on closures is currently unstable //~| NOTE: see issue #87417 //~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |_| (), - //~^ NOTE: not a function ) .next(); } diff --git a/tests/ui/macros/issue-68060.stderr b/tests/ui/macros/issue-68060.stderr index ef2246d5bd6..c701e50f054 100644 --- a/tests/ui/macros/issue-68060.stderr +++ b/tests/ui/macros/issue-68060.stderr @@ -1,11 +1,10 @@ -error: attribute should be applied to a function definition +error: `#[target_feature]` attribute cannot be used on closures --> $DIR/issue-68060.rs:4:13 | LL | #[target_feature(enable = "")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -... -LL | |_| (), - | ------ not a function definition + | + = help: `#[target_feature]` can be applied to methods, functions error[E0658]: `#[track_caller]` on closures is currently unstable --> $DIR/issue-68060.rs:6:13 diff --git a/tests/ui/macros/issue-78325-inconsistent-resolution.rs b/tests/ui/macros/issue-78325-inconsistent-resolution.rs index 919eca4f9bf..021ba599d12 100644 --- a/tests/ui/macros/issue-78325-inconsistent-resolution.rs +++ b/tests/ui/macros/issue-78325-inconsistent-resolution.rs @@ -1,3 +1,5 @@ +//@ edition: 2018 + macro_rules! define_other_core { ( ) => { extern crate std as core; @@ -6,7 +8,8 @@ macro_rules! define_other_core { } fn main() { - core::panic!(); + core::panic!(); //~ ERROR `core` is ambiguous + ::core::panic!(); //~ ERROR `core` is ambiguous } define_other_core!(); diff --git a/tests/ui/macros/issue-78325-inconsistent-resolution.stderr b/tests/ui/macros/issue-78325-inconsistent-resolution.stderr index b75e4a9c9e0..7c745040640 100644 --- a/tests/ui/macros/issue-78325-inconsistent-resolution.stderr +++ b/tests/ui/macros/issue-78325-inconsistent-resolution.stderr @@ -1,5 +1,5 @@ error: macro-expanded `extern crate` items cannot shadow names passed with `--extern` - --> $DIR/issue-78325-inconsistent-resolution.rs:3:9 + --> $DIR/issue-78325-inconsistent-resolution.rs:5:9 | LL | extern crate std as core; | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,5 +9,43 @@ LL | define_other_core!(); | = note: this error originates in the macro `define_other_core` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 1 previous error +error[E0659]: `core` is ambiguous + --> $DIR/issue-78325-inconsistent-resolution.rs:11:5 + | +LL | core::panic!(); + | ^^^^ ambiguous name + | + = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution + = note: `core` could refer to a built-in crate +note: `core` could also refer to the crate imported here + --> $DIR/issue-78325-inconsistent-resolution.rs:5:9 + | +LL | extern crate std as core; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | define_other_core!(); + | -------------------- in this macro invocation + = help: use `crate::core` to refer to this crate unambiguously + = note: this error originates in the macro `define_other_core` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0659]: `core` is ambiguous + --> $DIR/issue-78325-inconsistent-resolution.rs:12:7 + | +LL | ::core::panic!(); + | ^^^^ ambiguous name + | + = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution + = note: `core` could refer to a built-in crate +note: `core` could also refer to the crate imported here + --> $DIR/issue-78325-inconsistent-resolution.rs:5:9 + | +LL | extern crate std as core; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | define_other_core!(); + | -------------------- in this macro invocation + = note: this error originates in the macro `define_other_core` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/macros/lint-trailing-macro-call.rs b/tests/ui/macros/lint-trailing-macro-call.rs index 78b861f1df1..25fa91062c4 100644 --- a/tests/ui/macros/lint-trailing-macro-call.rs +++ b/tests/ui/macros/lint-trailing-macro-call.rs @@ -1,12 +1,10 @@ -//@ check-pass -// // Ensures that we properly lint // a removed 'expression' resulting from a macro // in trailing expression position macro_rules! expand_it { () => { - #[cfg(false)] 25; //~ WARN trailing semicolon in macro + #[cfg(false)] 25; //~ ERROR trailing semicolon in macro //~| WARN this was previously } } diff --git a/tests/ui/macros/lint-trailing-macro-call.stderr b/tests/ui/macros/lint-trailing-macro-call.stderr index 223b85e112e..3fd1ea81345 100644 --- a/tests/ui/macros/lint-trailing-macro-call.stderr +++ b/tests/ui/macros/lint-trailing-macro-call.stderr @@ -1,5 +1,5 @@ -warning: trailing semicolon in macro used in expression position - --> $DIR/lint-trailing-macro-call.rs:9:25 +error: trailing semicolon in macro used in expression position + --> $DIR/lint-trailing-macro-call.rs:7:25 | LL | #[cfg(false)] 25; | ^ @@ -11,14 +11,14 @@ LL | expand_it!() = note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813> = note: macro invocations at the end of a block are treated as expressions = note: to ignore the value produced by the macro, add a semicolon after the invocation of `expand_it` - = note: `#[warn(semicolon_in_expressions_from_macros)]` on by default - = note: this warning originates in the macro `expand_it` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: `#[deny(semicolon_in_expressions_from_macros)]` on by default + = note: this error originates in the macro `expand_it` (in Nightly builds, run with -Z macro-backtrace for more info) -warning: 1 warning emitted +error: aborting due to 1 previous error Future incompatibility report: Future breakage diagnostic: -warning: trailing semicolon in macro used in expression position - --> $DIR/lint-trailing-macro-call.rs:9:25 +error: trailing semicolon in macro used in expression position + --> $DIR/lint-trailing-macro-call.rs:7:25 | LL | #[cfg(false)] 25; | ^ @@ -30,6 +30,6 @@ LL | expand_it!() = note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813> = note: macro invocations at the end of a block are treated as expressions = note: to ignore the value produced by the macro, add a semicolon after the invocation of `expand_it` - = note: `#[warn(semicolon_in_expressions_from_macros)]` on by default - = note: this warning originates in the macro `expand_it` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: `#[deny(semicolon_in_expressions_from_macros)]` on by default + = note: this error originates in the macro `expand_it` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/macros/macro-context.rs b/tests/ui/macros/macro-context.rs index a31470263a0..e1c24ba8b57 100644 --- a/tests/ui/macros/macro-context.rs +++ b/tests/ui/macros/macro-context.rs @@ -6,7 +6,7 @@ macro_rules! m { //~| ERROR macro expansion ignores `;` //~| ERROR cannot find type `i` in this scope //~| ERROR cannot find value `i` in this scope - //~| WARN trailing semicolon in macro + //~| ERROR trailing semicolon in macro //~| WARN this was previously } diff --git a/tests/ui/macros/macro-context.stderr b/tests/ui/macros/macro-context.stderr index 4820a43f00c..6b49c05f360 100644 --- a/tests/ui/macros/macro-context.stderr +++ b/tests/ui/macros/macro-context.stderr @@ -64,7 +64,7 @@ LL | let i = m!(); | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) -warning: trailing semicolon in macro used in expression position +error: trailing semicolon in macro used in expression position --> $DIR/macro-context.rs:3:15 | LL | () => ( i ; typeof ); @@ -75,15 +75,15 @@ LL | let i = m!(); | = 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 #79813 <https://github.com/rust-lang/rust/issues/79813> - = note: `#[warn(semicolon_in_expressions_from_macros)]` on by default - = note: this warning originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: `#[deny(semicolon_in_expressions_from_macros)]` on by default + = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 6 previous errors; 1 warning emitted +error: aborting due to 7 previous errors Some errors have detailed explanations: E0412, E0425. For more information about an error, try `rustc --explain E0412`. Future incompatibility report: Future breakage diagnostic: -warning: trailing semicolon in macro used in expression position +error: trailing semicolon in macro used in expression position --> $DIR/macro-context.rs:3:15 | LL | () => ( i ; typeof ); @@ -94,6 +94,6 @@ LL | let i = m!(); | = 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 #79813 <https://github.com/rust-lang/rust/issues/79813> - = note: `#[warn(semicolon_in_expressions_from_macros)]` on by default - = note: this warning originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: `#[deny(semicolon_in_expressions_from_macros)]` on by default + = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/issues/issue-9110.rs b/tests/ui/macros/macro-expansion-module-structure-9110.rs index 47533dc43b5..b6241a7c18e 100644 --- a/tests/ui/issues/issue-9110.rs +++ b/tests/ui/macros/macro-expansion-module-structure-9110.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/9110 //@ check-pass #![allow(dead_code)] #![allow(non_snake_case)] diff --git a/tests/ui/issues/issue-15167.rs b/tests/ui/macros/macro-hygiene-scope-15167.rs index a2653c10ea4..6578f898a5f 100644 --- a/tests/ui/issues/issue-15167.rs +++ b/tests/ui/macros/macro-hygiene-scope-15167.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15167 + // macro f should not be able to inject a reference to 'n'. macro_rules! f { () => (n) } diff --git a/tests/ui/issues/issue-15167.stderr b/tests/ui/macros/macro-hygiene-scope-15167.stderr index 53082ea0ec6..58112c52df1 100644 --- a/tests/ui/issues/issue-15167.stderr +++ b/tests/ui/macros/macro-hygiene-scope-15167.stderr @@ -1,5 +1,5 @@ error[E0425]: cannot find value `n` in this scope - --> $DIR/issue-15167.rs:3:25 + --> $DIR/macro-hygiene-scope-15167.rs:5:25 | LL | macro_rules! f { () => (n) } | ^ not found in this scope @@ -10,7 +10,7 @@ LL | println!("{}", f!()); = note: this error originates in the macro `f` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0425]: cannot find value `n` in this scope - --> $DIR/issue-15167.rs:3:25 + --> $DIR/macro-hygiene-scope-15167.rs:5:25 | LL | macro_rules! f { () => (n) } | ^ not found in this scope @@ -21,7 +21,7 @@ LL | println!("{}", f!()); = note: this error originates in the macro `f` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0425]: cannot find value `n` in this scope - --> $DIR/issue-15167.rs:3:25 + --> $DIR/macro-hygiene-scope-15167.rs:5:25 | LL | macro_rules! f { () => (n) } | ^ not found in this scope @@ -32,7 +32,7 @@ LL | println!("{}", f!()); = note: this error originates in the macro `f` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0425]: cannot find value `n` in this scope - --> $DIR/issue-15167.rs:3:25 + --> $DIR/macro-hygiene-scope-15167.rs:5:25 | LL | macro_rules! f { () => (n) } | ^ not found in this scope diff --git a/tests/ui/macros/macro-in-expression-context.fixed b/tests/ui/macros/macro-in-expression-context.fixed index 7c830707ffd..52e1b429e48 100644 --- a/tests/ui/macros/macro-in-expression-context.fixed +++ b/tests/ui/macros/macro-in-expression-context.fixed @@ -3,12 +3,12 @@ macro_rules! foo { () => { assert_eq!("A", "A"); - //~^ WARN trailing semicolon in macro + //~^ ERROR trailing semicolon in macro //~| WARN this was previously //~| NOTE macro invocations at the end of a block //~| NOTE to ignore the value produced by the macro //~| NOTE for more information - //~| NOTE `#[warn(semicolon_in_expressions_from_macros)]` on by default + //~| NOTE `#[deny(semicolon_in_expressions_from_macros)]` on by default assert_eq!("B", "B"); } //~^^ ERROR macro expansion ignores `assert_eq` and any tokens following diff --git a/tests/ui/macros/macro-in-expression-context.rs b/tests/ui/macros/macro-in-expression-context.rs index da95017aa5f..5c560e78dad 100644 --- a/tests/ui/macros/macro-in-expression-context.rs +++ b/tests/ui/macros/macro-in-expression-context.rs @@ -3,12 +3,12 @@ macro_rules! foo { () => { assert_eq!("A", "A"); - //~^ WARN trailing semicolon in macro + //~^ ERROR trailing semicolon in macro //~| WARN this was previously //~| NOTE macro invocations at the end of a block //~| NOTE to ignore the value produced by the macro //~| NOTE for more information - //~| NOTE `#[warn(semicolon_in_expressions_from_macros)]` on by default + //~| NOTE `#[deny(semicolon_in_expressions_from_macros)]` on by default assert_eq!("B", "B"); } //~^^ ERROR macro expansion ignores `assert_eq` and any tokens following diff --git a/tests/ui/macros/macro-in-expression-context.stderr b/tests/ui/macros/macro-in-expression-context.stderr index 43419f2678c..b04348d7010 100644 --- a/tests/ui/macros/macro-in-expression-context.stderr +++ b/tests/ui/macros/macro-in-expression-context.stderr @@ -13,7 +13,7 @@ help: you might be missing a semicolon here LL | foo!(); | + -warning: trailing semicolon in macro used in expression position +error: trailing semicolon in macro used in expression position --> $DIR/macro-in-expression-context.rs:5:29 | LL | assert_eq!("A", "A"); @@ -26,13 +26,13 @@ LL | foo!() = note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813> = note: macro invocations at the end of a block are treated as expressions = note: to ignore the value produced by the macro, add a semicolon after the invocation of `foo` - = note: `#[warn(semicolon_in_expressions_from_macros)]` on by default - = note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: `#[deny(semicolon_in_expressions_from_macros)]` on by default + = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 2 previous errors Future incompatibility report: Future breakage diagnostic: -warning: trailing semicolon in macro used in expression position +error: trailing semicolon in macro used in expression position --> $DIR/macro-in-expression-context.rs:5:29 | LL | assert_eq!("A", "A"); @@ -45,6 +45,6 @@ LL | foo!() = note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813> = note: macro invocations at the end of a block are treated as expressions = note: to ignore the value produced by the macro, add a semicolon after the invocation of `foo` - = note: `#[warn(semicolon_in_expressions_from_macros)]` on by default - = note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: `#[deny(semicolon_in_expressions_from_macros)]` on by default + = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/issues/issue-9737.rs b/tests/ui/macros/macro-invocation-with-variable-in-scope-9737.rs index a8a17e58dd6..957c2e3f103 100644 --- a/tests/ui/issues/issue-9737.rs +++ b/tests/ui/macros/macro-invocation-with-variable-in-scope-9737.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/9737 //@ run-pass #![allow(unused_variables)] macro_rules! f { diff --git a/tests/ui/macros/macro-rules-as-derive-or-attr-issue-132928.stderr b/tests/ui/macros/macro-rules-as-derive-or-attr-issue-132928.stderr index e5b913b208d..77f8bef83a4 100644 --- a/tests/ui/macros/macro-rules-as-derive-or-attr-issue-132928.stderr +++ b/tests/ui/macros/macro-rules-as-derive-or-attr-issue-132928.stderr @@ -11,7 +11,7 @@ error: cannot find attribute `sample` in this scope --> $DIR/macro-rules-as-derive-or-attr-issue-132928.rs:5:3 | LL | macro_rules! sample { () => {} } - | ------ `sample` exists, but a declarative macro cannot be used as an attribute macro + | ------ `sample` exists, but has no `attr` rules LL | LL | #[sample] | ^^^^^^ diff --git a/tests/ui/macros/macro-rules-attr-error.rs b/tests/ui/macros/macro-rules-attr-error.rs new file mode 100644 index 00000000000..81eadb6692f --- /dev/null +++ b/tests/ui/macros/macro-rules-attr-error.rs @@ -0,0 +1,52 @@ +#![feature(macro_attr)] + +macro_rules! local_attr { + attr() { $($body:tt)* } => { + compile_error!(concat!("local_attr: ", stringify!($($body)*))); + }; + //~^^ ERROR: local_attr +} + +//~v NOTE: `fn_only` exists, but has no `attr` rules +macro_rules! fn_only { + {} => {} +} + +//~v NOTE: `attr_only` exists, but has no rules for function-like invocation +macro_rules! attr_only { + attr() {} => {} +} + +fn main() { + //~v NOTE: in this expansion of #[local_attr] + #[local_attr] + struct S; + + //~vv ERROR: cannot find macro `local_attr` in this scope + //~| NOTE: `local_attr` is in scope, but it is an attribute + local_attr!(arg); + + //~v ERROR: cannot find attribute `fn_only` in this scope + #[fn_only] + struct S; + + attr_only!(); //~ ERROR: cannot find macro `attr_only` in this scope +} + +//~vv ERROR: cannot find attribute `forward_referenced_attr` in this scope +//~| NOTE: consider moving the definition of `forward_referenced_attr` before this call +#[forward_referenced_attr] +struct S; + +//~v NOTE: a macro with the same name exists, but it appears later +macro_rules! forward_referenced_attr { + attr() {} => {} +} + +//~vv ERROR: cannot find attribute `cyclic_attr` in this scope +//~| NOTE: consider moving the definition of `cyclic_attr` before this call +#[cyclic_attr] +//~v NOTE: a macro with the same name exists, but it appears later +macro_rules! cyclic_attr { + attr() {} => {} +} diff --git a/tests/ui/macros/macro-rules-attr-error.stderr b/tests/ui/macros/macro-rules-attr-error.stderr new file mode 100644 index 00000000000..674d35091b6 --- /dev/null +++ b/tests/ui/macros/macro-rules-attr-error.stderr @@ -0,0 +1,63 @@ +error: local_attr: struct S; + --> $DIR/macro-rules-attr-error.rs:5:9 + | +LL | compile_error!(concat!("local_attr: ", stringify!($($body)*))); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | #[local_attr] + | ------------- in this attribute macro expansion + | + = note: this error originates in the attribute macro `local_attr` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: cannot find macro `local_attr` in this scope + --> $DIR/macro-rules-attr-error.rs:27:5 + | +LL | local_attr!(arg); + | ^^^^^^^^^^ + | + = note: `local_attr` is in scope, but it is an attribute: `#[local_attr]` + +error: cannot find attribute `fn_only` in this scope + --> $DIR/macro-rules-attr-error.rs:30:7 + | +LL | macro_rules! fn_only { + | ------- `fn_only` exists, but has no `attr` rules +... +LL | #[fn_only] + | ^^^^^^^ + +error: cannot find macro `attr_only` in this scope + --> $DIR/macro-rules-attr-error.rs:33:5 + | +LL | macro_rules! attr_only { + | --------- `attr_only` exists, but has no rules for function-like invocation +... +LL | attr_only!(); + | ^^^^^^^^^ + +error: cannot find attribute `forward_referenced_attr` in this scope + --> $DIR/macro-rules-attr-error.rs:38:3 + | +LL | #[forward_referenced_attr] + | ^^^^^^^^^^^^^^^^^^^^^^^ consider moving the definition of `forward_referenced_attr` before this call + | +note: a macro with the same name exists, but it appears later + --> $DIR/macro-rules-attr-error.rs:42:14 + | +LL | macro_rules! forward_referenced_attr { + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: cannot find attribute `cyclic_attr` in this scope + --> $DIR/macro-rules-attr-error.rs:48:3 + | +LL | #[cyclic_attr] + | ^^^^^^^^^^^ consider moving the definition of `cyclic_attr` before this call + | +note: a macro with the same name exists, but it appears later + --> $DIR/macro-rules-attr-error.rs:50:14 + | +LL | macro_rules! cyclic_attr { + | ^^^^^^^^^^^ + +error: aborting due to 6 previous errors + diff --git a/tests/ui/macros/macro-rules-attr-infinite-recursion.rs b/tests/ui/macros/macro-rules-attr-infinite-recursion.rs new file mode 100644 index 00000000000..dc54c32cad3 --- /dev/null +++ b/tests/ui/macros/macro-rules-attr-infinite-recursion.rs @@ -0,0 +1,12 @@ +#![crate_type = "lib"] +#![feature(macro_attr)] + +macro_rules! attr { + attr() { $($body:tt)* } => { + #[attr] $($body)* + }; + //~^^ ERROR: recursion limit reached +} + +#[attr] +struct S; diff --git a/tests/ui/macros/macro-rules-attr-infinite-recursion.stderr b/tests/ui/macros/macro-rules-attr-infinite-recursion.stderr new file mode 100644 index 00000000000..7d9a94338f5 --- /dev/null +++ b/tests/ui/macros/macro-rules-attr-infinite-recursion.stderr @@ -0,0 +1,14 @@ +error: recursion limit reached while expanding `#[attr]` + --> $DIR/macro-rules-attr-infinite-recursion.rs:6:9 + | +LL | #[attr] $($body)* + | ^^^^^^^ +... +LL | #[attr] + | ------- in this attribute macro expansion + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`macro_rules_attr_infinite_recursion`) + = note: this error originates in the attribute macro `attr` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 1 previous error + diff --git a/tests/ui/macros/macro-rules-attr-nested.rs b/tests/ui/macros/macro-rules-attr-nested.rs new file mode 100644 index 00000000000..af5c30f00dd --- /dev/null +++ b/tests/ui/macros/macro-rules-attr-nested.rs @@ -0,0 +1,24 @@ +//@ run-pass +//@ check-run-results +#![feature(macro_attr)] + +macro_rules! nest { + attr() { struct $name:ident; } => { + println!("nest"); + #[nest(1)] + struct $name; + }; + attr(1) { struct $name:ident; } => { + println!("nest(1)"); + #[nest(2)] + struct $name; + }; + attr(2) { struct $name:ident; } => { + println!("nest(2)"); + }; +} + +fn main() { + #[nest] + struct S; +} diff --git a/tests/ui/macros/macro-rules-attr-nested.run.stdout b/tests/ui/macros/macro-rules-attr-nested.run.stdout new file mode 100644 index 00000000000..46017f9ae08 --- /dev/null +++ b/tests/ui/macros/macro-rules-attr-nested.run.stdout @@ -0,0 +1,3 @@ +nest +nest(1) +nest(2) diff --git a/tests/ui/macros/macro-rules-attr.rs b/tests/ui/macros/macro-rules-attr.rs new file mode 100644 index 00000000000..1d6f09b53e1 --- /dev/null +++ b/tests/ui/macros/macro-rules-attr.rs @@ -0,0 +1,90 @@ +//@ run-pass +//@ check-run-results +#![feature(macro_attr)] +#![warn(unused)] + +#[macro_export] +macro_rules! exported_attr { + attr($($args:tt)*) { $($body:tt)* } => { + println!( + "exported_attr: args={:?}, body={:?}", + stringify!($($args)*), + stringify!($($body)*), + ); + }; + { $($args:tt)* } => { + println!("exported_attr!({:?})", stringify!($($args)*)); + }; + attr() {} => { + unused_rule(); + }; + attr() {} => { + compile_error!(); + }; + {} => { + unused_rule(); + }; + {} => { + compile_error!(); + }; +} + +macro_rules! local_attr { + attr($($args:tt)*) { $($body:tt)* } => { + println!( + "local_attr: args={:?}, body={:?}", + stringify!($($args)*), + stringify!($($body)*), + ); + }; + { $($args:tt)* } => { + println!("local_attr!({:?})", stringify!($($args)*)); + }; + attr() {} => { //~ WARN: never used + unused_rule(); + }; + attr() {} => { + compile_error!(); + }; + {} => { //~ WARN: never used + unused_rule(); + }; + {} => { + compile_error!(); + }; +} + +fn main() { + #[crate::exported_attr] + struct S; + #[::exported_attr(arguments, key = "value")] + fn func(_arg: u32) {} + #[self::exported_attr(1)] + #[self::exported_attr(2)] + struct Twice; + + crate::exported_attr!(); + crate::exported_attr!(invoked, arguments); + + #[exported_attr] + struct S; + #[exported_attr(arguments, key = "value")] + fn func(_arg: u32) {} + #[exported_attr(1)] + #[exported_attr(2)] + struct Twice; + + exported_attr!(); + exported_attr!(invoked, arguments); + + #[local_attr] + struct S; + #[local_attr(arguments, key = "value")] + fn func(_arg: u32) {} + #[local_attr(1)] + #[local_attr(2)] + struct Twice; + + local_attr!(); + local_attr!(invoked, arguments); +} diff --git a/tests/ui/macros/macro-rules-attr.run.stdout b/tests/ui/macros/macro-rules-attr.run.stdout new file mode 100644 index 00000000000..77aa94d54f8 --- /dev/null +++ b/tests/ui/macros/macro-rules-attr.run.stdout @@ -0,0 +1,15 @@ +exported_attr: args="", body="struct S;" +exported_attr: args="arguments, key = \"value\"", body="fn func(_arg: u32) {}" +exported_attr: args="1", body="#[self::exported_attr(2)] struct Twice;" +exported_attr!("") +exported_attr!("invoked, arguments") +exported_attr: args="", body="struct S;" +exported_attr: args="arguments, key = \"value\"", body="fn func(_arg: u32) {}" +exported_attr: args="1", body="#[exported_attr(2)] struct Twice;" +exported_attr!("") +exported_attr!("invoked, arguments") +local_attr: args="", body="struct S;" +local_attr: args="arguments, key = \"value\"", body="fn func(_arg: u32) {}" +local_attr: args="1", body="#[local_attr(2)] struct Twice;" +local_attr!("") +local_attr!("invoked, arguments") diff --git a/tests/ui/macros/macro-rules-attr.stderr b/tests/ui/macros/macro-rules-attr.stderr new file mode 100644 index 00000000000..567664cd73d --- /dev/null +++ b/tests/ui/macros/macro-rules-attr.stderr @@ -0,0 +1,21 @@ +warning: rule #3 of macro `local_attr` is never used + --> $DIR/macro-rules-attr.rs:43:9 + | +LL | attr() {} => { + | ^^ ^^ + | +note: the lint level is defined here + --> $DIR/macro-rules-attr.rs:4:9 + | +LL | #![warn(unused)] + | ^^^^^^ + = note: `#[warn(unused_macro_rules)]` implied by `#[warn(unused)]` + +warning: rule #5 of macro `local_attr` is never used + --> $DIR/macro-rules-attr.rs:49:5 + | +LL | {} => { + | ^^ + +warning: 2 warnings emitted + diff --git a/tests/ui/macros/macro-use-bad-args-1.stderr b/tests/ui/macros/macro-use-bad-args-1.stderr index 2f43d0997df..542b4ae2b7a 100644 --- a/tests/ui/macros/macro-use-bad-args-1.stderr +++ b/tests/ui/macros/macro-use-bad-args-1.stderr @@ -6,6 +6,7 @@ LL | #[macro_use(foo(bar))] | | | didn't expect any arguments here | + = note: for more information, visit <https://doc.rust-lang.org/reference/macros-by-example.html#the-macro_use-attribute> help: try changing it to one of the following valid forms of the attribute | LL - #[macro_use(foo(bar))] diff --git a/tests/ui/macros/macro-use-bad-args-2.stderr b/tests/ui/macros/macro-use-bad-args-2.stderr index d7b03c93588..2db9ffe50b0 100644 --- a/tests/ui/macros/macro-use-bad-args-2.stderr +++ b/tests/ui/macros/macro-use-bad-args-2.stderr @@ -6,6 +6,7 @@ LL | #[macro_use(foo="bar")] | | | didn't expect any arguments here | + = note: for more information, visit <https://doc.rust-lang.org/reference/macros-by-example.html#the-macro_use-attribute> help: try changing it to one of the following valid forms of the attribute | LL - #[macro_use(foo="bar")] diff --git a/tests/ui/issues/issue-25386.rs b/tests/ui/macros/private-struct-member-macro-access-25386.rs index b26cc77680d..88e5a22a699 100644 --- a/tests/ui/issues/issue-25386.rs +++ b/tests/ui/macros/private-struct-member-macro-access-25386.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/25386 mod stuff { pub struct Item { c_object: Box<CObj>, diff --git a/tests/ui/issues/issue-25386.stderr b/tests/ui/macros/private-struct-member-macro-access-25386.stderr index 720b77866a5..d02a41848f4 100644 --- a/tests/ui/issues/issue-25386.stderr +++ b/tests/ui/macros/private-struct-member-macro-access-25386.stderr @@ -1,5 +1,5 @@ error[E0616]: field `c_object` of struct `Item` is private - --> $DIR/issue-25386.rs:19:16 + --> $DIR/private-struct-member-macro-access-25386.rs:20:16 | LL | (*$var.c_object).$member.is_some() | ^^^^^^^^ private field diff --git a/tests/ui/malformed/malformed-regressions.rs b/tests/ui/malformed/malformed-regressions.rs index f0a7aac59c1..99f0fc904a9 100644 --- a/tests/ui/malformed/malformed-regressions.rs +++ b/tests/ui/malformed/malformed-regressions.rs @@ -4,9 +4,9 @@ //~^ WARN this was previously accepted #[inline = ""] //~ ERROR valid forms for the attribute are //~^ WARN this was previously accepted -#[link] //~ ERROR attribute must be of the form +#[link] //~ ERROR valid forms for the attribute are //~^ WARN this was previously accepted -#[link = ""] //~ ERROR attribute must be of the form +#[link = ""] //~ ERROR valid forms for the attribute are //~^ WARN this was previously accepted fn main() {} diff --git a/tests/ui/malformed/malformed-regressions.stderr b/tests/ui/malformed/malformed-regressions.stderr index 8c22919a1c2..4a00c9b4a7d 100644 --- a/tests/ui/malformed/malformed-regressions.stderr +++ b/tests/ui/malformed/malformed-regressions.stderr @@ -1,4 +1,4 @@ -error: valid forms for the attribute are `#[doc(hidden|inline|...)]` and `#[doc = "string"]` +error: valid forms for the attribute are `#[doc(hidden)]`, `#[doc(inline)]`, and `#[doc = "string"]` --> $DIR/malformed-regressions.rs:1:1 | LL | #[doc] @@ -6,9 +6,10 @@ LL | #[doc] | = 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 #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: for more information, visit <https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html> = note: `#[deny(ill_formed_attribute_input)]` on by default -error: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ wasm_import_module = "...", /*opt*/ import_name_type = "decorated|noprefix|undecorated")]` +error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]` --> $DIR/malformed-regressions.rs:7:1 | LL | #[link] @@ -16,8 +17,9 @@ LL | #[link] | = 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 #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> -error: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ wasm_import_module = "...", /*opt*/ import_name_type = "decorated|noprefix|undecorated")]` +error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]` --> $DIR/malformed-regressions.rs:9:1 | LL | #[link = ""] @@ -25,6 +27,7 @@ LL | #[link = ""] | = 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 #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` --> $DIR/malformed-regressions.rs:3:1 @@ -35,7 +38,7 @@ LL | #[ignore()] = 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 #57571 <https://github.com/rust-lang/rust/issues/57571> -error: valid forms for the attribute are `#[inline(always|never)]` and `#[inline]` +error: valid forms for the attribute are `#[inline(always)]`, `#[inline(never)]`, and `#[inline]` --> $DIR/malformed-regressions.rs:5:1 | LL | #[inline = ""] @@ -46,3 +49,61 @@ LL | #[inline = ""] error: aborting due to 5 previous errors +Future incompatibility report: Future breakage diagnostic: +error: valid forms for the attribute are `#[doc(hidden)]`, `#[doc(inline)]`, and `#[doc = "string"]` + --> $DIR/malformed-regressions.rs:1:1 + | +LL | #[doc] + | ^^^^^^ + | + = 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 #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: for more information, visit <https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html> + = note: `#[deny(ill_formed_attribute_input)]` on by default + +Future breakage diagnostic: +error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]` + --> $DIR/malformed-regressions.rs:7:1 + | +LL | #[link] + | ^^^^^^^ + | + = 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 #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> + = note: `#[deny(ill_formed_attribute_input)]` on by default + +Future breakage diagnostic: +error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]` + --> $DIR/malformed-regressions.rs:9:1 + | +LL | #[link = ""] + | ^^^^^^^^^^^^ + | + = 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 #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> + = note: `#[deny(ill_formed_attribute_input)]` on by default + +Future breakage diagnostic: +error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` + --> $DIR/malformed-regressions.rs:3:1 + | +LL | #[ignore()] + | ^^^^^^^^^^^ + | + = 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 #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: `#[deny(ill_formed_attribute_input)]` on by default + +Future breakage diagnostic: +error: valid forms for the attribute are `#[inline(always)]`, `#[inline(never)]`, and `#[inline]` + --> $DIR/malformed-regressions.rs:5:1 + | +LL | #[inline = ""] + | ^^^^^^^^^^^^^^ + | + = 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 #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: `#[deny(ill_formed_attribute_input)]` on by default + diff --git a/tests/ui/marker_trait_attr/marker-attribute-on-non-trait.rs b/tests/ui/marker_trait_attr/marker-attribute-on-non-trait.rs index 0bf620934ec..1fb206d628f 100644 --- a/tests/ui/marker_trait_attr/marker-attribute-on-non-trait.rs +++ b/tests/ui/marker_trait_attr/marker-attribute-on-non-trait.rs @@ -1,23 +1,23 @@ #![feature(marker_trait_attr)] -#[marker] //~ ERROR attribute should be applied to a trait +#[marker] //~ ERROR attribute cannot be used on struct Struct {} -#[marker] //~ ERROR attribute should be applied to a trait +#[marker] //~ ERROR attribute cannot be used on impl Struct {} -#[marker] //~ ERROR attribute should be applied to a trait +#[marker] //~ ERROR attribute cannot be used on union Union { x: i32, } -#[marker] //~ ERROR attribute should be applied to a trait +#[marker] //~ ERROR attribute cannot be used on const CONST: usize = 10; -#[marker] //~ ERROR attribute should be applied to a trait +#[marker] //~ ERROR attribute cannot be used on fn function() {} -#[marker] //~ ERROR attribute should be applied to a trait +#[marker] //~ ERROR attribute cannot be used on type Type = (); fn main() {} diff --git a/tests/ui/marker_trait_attr/marker-attribute-on-non-trait.stderr b/tests/ui/marker_trait_attr/marker-attribute-on-non-trait.stderr index 19a5290dd7e..71abe7f39df 100644 --- a/tests/ui/marker_trait_attr/marker-attribute-on-non-trait.stderr +++ b/tests/ui/marker_trait_attr/marker-attribute-on-non-trait.stderr @@ -1,52 +1,50 @@ -error: attribute should be applied to a trait +error: `#[marker]` attribute cannot be used on structs --> $DIR/marker-attribute-on-non-trait.rs:3:1 | LL | #[marker] | ^^^^^^^^^ -LL | struct Struct {} - | ---------------- not a trait + | + = help: `#[marker]` can only be applied to traits -error: attribute should be applied to a trait +error: `#[marker]` attribute cannot be used on inherent impl blocks --> $DIR/marker-attribute-on-non-trait.rs:6:1 | LL | #[marker] | ^^^^^^^^^ -LL | impl Struct {} - | -------------- not a trait + | + = help: `#[marker]` can only be applied to traits -error: attribute should be applied to a trait +error: `#[marker]` attribute cannot be used on unions --> $DIR/marker-attribute-on-non-trait.rs:9:1 | -LL | #[marker] - | ^^^^^^^^^ -LL | / union Union { -LL | | x: i32, -LL | | } - | |_- not a trait +LL | #[marker] + | ^^^^^^^^^ + | + = help: `#[marker]` can only be applied to traits -error: attribute should be applied to a trait +error: `#[marker]` attribute cannot be used on constants --> $DIR/marker-attribute-on-non-trait.rs:14:1 | LL | #[marker] | ^^^^^^^^^ -LL | const CONST: usize = 10; - | ------------------------ not a trait + | + = help: `#[marker]` can only be applied to traits -error: attribute should be applied to a trait +error: `#[marker]` attribute cannot be used on functions --> $DIR/marker-attribute-on-non-trait.rs:17:1 | LL | #[marker] | ^^^^^^^^^ -LL | fn function() {} - | ---------------- not a trait + | + = help: `#[marker]` can only be applied to traits -error: attribute should be applied to a trait +error: `#[marker]` attribute cannot be used on type aliases --> $DIR/marker-attribute-on-non-trait.rs:20:1 | LL | #[marker] | ^^^^^^^^^ -LL | type Type = (); - | --------------- not a trait + | + = help: `#[marker]` can only be applied to traits error: aborting due to 6 previous errors diff --git a/tests/ui/issues/issue-14865.rs b/tests/ui/match/guard-pattern-ordering-14865.rs index e0f8bfe9428..a789599c566 100644 --- a/tests/ui/issues/issue-14865.rs +++ b/tests/ui/match/guard-pattern-ordering-14865.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/14865 + //@ run-pass #![allow(dead_code)] diff --git a/tests/ui/issues/issue-13867.rs b/tests/ui/match/multiple-refutable-patterns-13867.rs index ad7d6d66393..a308219a9b2 100644 --- a/tests/ui/issues/issue-13867.rs +++ b/tests/ui/match/multiple-refutable-patterns-13867.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13867 + //@ run-pass // Test that codegen works correctly when there are multiple refutable // patterns in match expression. diff --git a/tests/ui/issues/issue-14393.rs b/tests/ui/match/tuple-usize-pattern-14393.rs index 69c3fc15d31..12d58d4c059 100644 --- a/tests/ui/issues/issue-14393.rs +++ b/tests/ui/match/tuple-usize-pattern-14393.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/14393 + //@ run-pass fn main() { diff --git a/tests/ui/methods/call_method_unknown_referent.rs b/tests/ui/methods/call_method_unknown_referent.rs index b01e2d80f7f..b26ecc74175 100644 --- a/tests/ui/methods/call_method_unknown_referent.rs +++ b/tests/ui/methods/call_method_unknown_referent.rs @@ -44,5 +44,5 @@ fn main() { // our resolution logic needs to be able to call methods such as foo() // on the outer type even if the inner type is ambiguous. let _c = (ptr as SmartPtr<_>).read(); - //~^ ERROR no method named `read` found for struct `SmartPtr` + //~^ ERROR no method named `read` found for struct `SmartPtr<T>` } diff --git a/tests/ui/methods/call_method_unknown_referent.stderr b/tests/ui/methods/call_method_unknown_referent.stderr index 748b02b52b5..5d6974a00c6 100644 --- a/tests/ui/methods/call_method_unknown_referent.stderr +++ b/tests/ui/methods/call_method_unknown_referent.stderr @@ -10,7 +10,7 @@ error[E0282]: type annotations needed LL | let _b = (rc as std::rc::Rc<_>).read(); | ^^^^ cannot infer type -error[E0599]: no method named `read` found for struct `SmartPtr` in the current scope +error[E0599]: no method named `read` found for struct `SmartPtr<T>` in the current scope --> $DIR/call_method_unknown_referent.rs:46:35 | LL | struct SmartPtr<T>(T); diff --git a/tests/ui/methods/inherent-bound-in-probe.rs b/tests/ui/methods/inherent-bound-in-probe.rs index 4add93e808d..39b4ba983e4 100644 --- a/tests/ui/methods/inherent-bound-in-probe.rs +++ b/tests/ui/methods/inherent-bound-in-probe.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Zwrite-long-types-to-disk=yes // Fixes #110131 // // The issue is that we were constructing an `ImplDerived` cause code for the diff --git a/tests/ui/methods/inherent-bound-in-probe.stderr b/tests/ui/methods/inherent-bound-in-probe.stderr index 77aed390c9a..b7751ca4714 100644 --- a/tests/ui/methods/inherent-bound-in-probe.stderr +++ b/tests/ui/methods/inherent-bound-in-probe.stderr @@ -1,5 +1,5 @@ error[E0277]: `Helper<'a, T>` is not an iterator - --> $DIR/inherent-bound-in-probe.rs:38:21 + --> $DIR/inherent-bound-in-probe.rs:39:21 | LL | type IntoIter = Helper<'a, T>; | ^^^^^^^^^^^^^ `Helper<'a, T>` is not an iterator @@ -9,14 +9,14 @@ note: required by a bound in `std::iter::IntoIterator::IntoIter` --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL error[E0275]: overflow evaluating the requirement `&_: IntoIterator` - --> $DIR/inherent-bound-in-probe.rs:42:9 + --> $DIR/inherent-bound-in-probe.rs:43:9 | LL | Helper::new(&self.0) | ^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`inherent_bound_in_probe`) note: required for `&BitReaderWrapper<_>` to implement `IntoIterator` - --> $DIR/inherent-bound-in-probe.rs:32:13 + --> $DIR/inherent-bound-in-probe.rs:33:13 | LL | impl<'a, T> IntoIterator for &'a BitReaderWrapper<T> | ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,15 +24,17 @@ LL | where LL | &'a T: IntoIterator<Item = &'a u8>, | ------------- unsatisfied trait bound introduced here = note: 126 redundant requirements hidden - = note: required for `&BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<_>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `IntoIterator` + = note: required for `&BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<...>>>` to implement `IntoIterator` note: required by a bound in `Helper` - --> $DIR/inherent-bound-in-probe.rs:16:12 + --> $DIR/inherent-bound-in-probe.rs:17:12 | LL | struct Helper<'a, T> | ------ required by a bound in this struct LL | where LL | &'a T: IntoIterator<Item = &'a u8>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Helper` + = note: the full name for the type has been written to '$TEST_BUILD_DIR/inherent-bound-in-probe.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 2 previous errors diff --git a/tests/ui/methods/issues/issue-105732.stderr b/tests/ui/methods/issues/issue-105732.stderr index 6244f983550..93ce695f27b 100644 --- a/tests/ui/methods/issues/issue-105732.stderr +++ b/tests/ui/methods/issues/issue-105732.stderr @@ -4,7 +4,7 @@ error[E0380]: auto traits cannot have associated items LL | auto trait Foo { | --- auto traits cannot have associated items LL | fn g(&self); - | ---^-------- help: remove these associated items + | ^ error[E0599]: no method named `g` found for reference `&Self` in the current scope --> $DIR/issue-105732.rs:10:14 diff --git a/tests/ui/methods/method-not-found-generic-arg-elision.stderr b/tests/ui/methods/method-not-found-generic-arg-elision.stderr index 8429c3aebac..75fabc27b0f 100644 --- a/tests/ui/methods/method-not-found-generic-arg-elision.stderr +++ b/tests/ui/methods/method-not-found-generic-arg-elision.stderr @@ -10,7 +10,7 @@ LL | let d = point_i32.distance(); = note: the method was found for - `Point<f64>` -error[E0599]: no method named `other` found for struct `Point` in the current scope +error[E0599]: no method named `other` found for struct `Point<T>` in the current scope --> $DIR/method-not-found-generic-arg-elision.rs:84:23 | LL | struct Point<T> { @@ -19,7 +19,7 @@ LL | struct Point<T> { LL | let d = point_i32.other(); | ^^^^^ method not found in `Point<i32>` -error[E0599]: no method named `extend` found for struct `Map` in the current scope +error[E0599]: no method named `extend` found for struct `Map<I, F>` in the current scope --> $DIR/method-not-found-generic-arg-elision.rs:87:67 | LL | v.iter().map(Box::new(|x| x * x) as Box<dyn Fn(&i32) -> i32>).extend(std::iter::once(100)); @@ -41,7 +41,7 @@ LL | wrapper.method(); - `Wrapper<i8>` and 2 more types -error[E0599]: no method named `other` found for struct `Wrapper` in the current scope +error[E0599]: no method named `other` found for struct `Wrapper<T>` in the current scope --> $DIR/method-not-found-generic-arg-elision.rs:92:13 | LL | struct Wrapper<T>(T); @@ -64,7 +64,7 @@ LL | wrapper.method(); - `Wrapper2<'a, i32, C>` - `Wrapper2<'a, i8, C>` -error[E0599]: no method named `other` found for struct `Wrapper2` in the current scope +error[E0599]: no method named `other` found for struct `Wrapper2<'a, T, C>` in the current scope --> $DIR/method-not-found-generic-arg-elision.rs:98:13 | LL | struct Wrapper2<'a, T, const C: usize> { diff --git a/tests/ui/methods/probe-error-on-infinite-deref.rs b/tests/ui/methods/probe-error-on-infinite-deref.rs index 85c1c0c09c1..196d026438b 100644 --- a/tests/ui/methods/probe-error-on-infinite-deref.rs +++ b/tests/ui/methods/probe-error-on-infinite-deref.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Zwrite-long-types-to-disk=yes use std::ops::Deref; // Make sure that method probe error reporting doesn't get too tangled up diff --git a/tests/ui/methods/probe-error-on-infinite-deref.stderr b/tests/ui/methods/probe-error-on-infinite-deref.stderr index 57a9ca2eaa8..6148b001163 100644 --- a/tests/ui/methods/probe-error-on-infinite-deref.stderr +++ b/tests/ui/methods/probe-error-on-infinite-deref.stderr @@ -1,13 +1,15 @@ -error[E0055]: reached the recursion limit while auto-dereferencing `Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<{integer}>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - --> $DIR/probe-error-on-infinite-deref.rs:13:13 +error[E0055]: reached the recursion limit while auto-dereferencing `Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<...>>>>>>>>>>>` + --> $DIR/probe-error-on-infinite-deref.rs:14:13 | LL | Wrap(1).lmao(); | ^^^^ deref recursion limit reached | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`probe_error_on_infinite_deref`) + = note: the full name for the type has been written to '$TEST_BUILD_DIR/probe-error-on-infinite-deref.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error[E0599]: no method named `lmao` found for struct `Wrap<{integer}>` in the current scope - --> $DIR/probe-error-on-infinite-deref.rs:13:13 + --> $DIR/probe-error-on-infinite-deref.rs:14:13 | LL | struct Wrap<T>(T); | -------------- method `lmao` not found for this struct diff --git a/tests/ui/methods/untrimmed-path-type.stderr b/tests/ui/methods/untrimmed-path-type.stderr index 1f3101ff4e7..ee07e2daa1e 100644 --- a/tests/ui/methods/untrimmed-path-type.stderr +++ b/tests/ui/methods/untrimmed-path-type.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `unknown` found for enum `Result` in the current scope +error[E0599]: no method named `unknown` found for enum `Result<T, E>` in the current scope --> $DIR/untrimmed-path-type.rs:5:11 | LL | meow().unknown(); diff --git a/tests/ui/mir/alignment/packed.rs b/tests/ui/mir/alignment/packed.rs index cf908365e1a..aa79880a21a 100644 --- a/tests/ui/mir/alignment/packed.rs +++ b/tests/ui/mir/alignment/packed.rs @@ -12,7 +12,7 @@ fn main() { // Test that we can use addr_of! to get the address of a packed member which according to its // type is not aligned, but because it is a projection from a packed type is a valid place. let ptr0 = std::ptr::addr_of!(memory[0].tail); - let ptr1 = std::ptr::addr_of!(memory[0].tail); + let ptr1 = std::ptr::addr_of!(memory[1].tail); // Even if ptr0 happens to be aligned by chance, ptr1 is not. assert!(!ptr0.is_aligned() || !ptr1.is_aligned()); diff --git a/tests/ui/mir/lint/storage-live.rs b/tests/ui/mir/lint/storage-live.rs index 252e3b8456c..32bd32754dd 100644 --- a/tests/ui/mir/lint/storage-live.rs +++ b/tests/ui/mir/lint/storage-live.rs @@ -1,7 +1,7 @@ //@ compile-flags: -Zlint-mir -Ztreat-err-as-bug //@ failure-status: 101 //@ normalize-stderr: "note: .*\n\n" -> "" -//@ normalize-stderr: "thread 'rustc' panicked.*\n" -> "" +//@ normalize-stderr: "thread 'rustc'.*panicked.*\n" -> "" //@ normalize-stderr: "storage_live\[....\]" -> "storage_live[HASH]" //@ normalize-stderr: "(delayed at [^:]+):\d+:\d+ - " -> "$1:LL:CC - " //@ rustc-env:RUST_BACKTRACE=0 diff --git a/tests/ui/issues/issue-92741.fixed b/tests/ui/mismatched_types/newlines-in-diagnostic-fix-suggestions-92741.fixed index cb37d25273f..c165779e402 100644 --- a/tests/ui/issues/issue-92741.fixed +++ b/tests/ui/mismatched_types/newlines-in-diagnostic-fix-suggestions-92741.fixed @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/92741 //@ run-rustfix fn main() {} fn _foo() -> bool { diff --git a/tests/ui/issues/issue-92741.rs b/tests/ui/mismatched_types/newlines-in-diagnostic-fix-suggestions-92741.rs index 1c5d5810a57..b3fa5f77308 100644 --- a/tests/ui/issues/issue-92741.rs +++ b/tests/ui/mismatched_types/newlines-in-diagnostic-fix-suggestions-92741.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/92741 //@ run-rustfix fn main() {} fn _foo() -> bool { diff --git a/tests/ui/issues/issue-92741.stderr b/tests/ui/mismatched_types/newlines-in-diagnostic-fix-suggestions-92741.stderr index 49315e7a8bf..60917d9a63e 100644 --- a/tests/ui/issues/issue-92741.stderr +++ b/tests/ui/mismatched_types/newlines-in-diagnostic-fix-suggestions-92741.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-92741.rs:4:5 + --> $DIR/newlines-in-diagnostic-fix-suggestions-92741.rs:5:5 | LL | fn _foo() -> bool { | ---- expected `bool` because of return type @@ -15,7 +15,7 @@ LL - mut | error[E0308]: mismatched types - --> $DIR/issue-92741.rs:10:5 + --> $DIR/newlines-in-diagnostic-fix-suggestions-92741.rs:11:5 | LL | fn _bar() -> bool { | ---- expected `bool` because of return type @@ -31,7 +31,7 @@ LL + if true { true } else { false } | error[E0308]: mismatched types - --> $DIR/issue-92741.rs:15:5 + --> $DIR/newlines-in-diagnostic-fix-suggestions-92741.rs:16:5 | LL | fn _baz() -> bool { | ---- expected `bool` because of return type diff --git a/tests/ui/modules/path-invalid-form.stderr b/tests/ui/modules/path-invalid-form.stderr index e8ded1343f7..4e9a62fa7a9 100644 --- a/tests/ui/modules/path-invalid-form.stderr +++ b/tests/ui/modules/path-invalid-form.stderr @@ -3,6 +3,8 @@ error: malformed `path` attribute input | LL | #[path = 123] | ^^^^^^^^^^^^^ help: must be of the form: `#[path = "file"]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/modules.html#the-path-attribute> error: aborting due to 1 previous error diff --git a/tests/ui/modules/path-macro.stderr b/tests/ui/modules/path-macro.stderr index eb02c721edd..fd93871f3a6 100644 --- a/tests/ui/modules/path-macro.stderr +++ b/tests/ui/modules/path-macro.stderr @@ -3,6 +3,8 @@ error: malformed `path` attribute input | LL | #[path = foo!()] | ^^^^^^^^^^^^^^^^ help: must be of the form: `#[path = "file"]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/modules.html#the-path-attribute> error: aborting due to 1 previous error diff --git a/tests/ui/issues/issue-15571.rs b/tests/ui/moves/match-move-same-binding-15571.rs index cf17113a282..f6d79c6d76c 100644 --- a/tests/ui/issues/issue-15571.rs +++ b/tests/ui/moves/match-move-same-binding-15571.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15571 + //@ run-pass fn match_on_local() { diff --git a/tests/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr b/tests/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr index 51d0f85c031..e2aa5718cb6 100644 --- a/tests/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr +++ b/tests/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr @@ -10,6 +10,11 @@ LL | let _f = to_fn(|| test(i)); | | | captured by this `Fn` closure | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/moves-based-on-type-move-out-of-closure-env-issue-1965.rs:3:33 + | +LL | fn to_fn<A:std::marker::Tuple,F:Fn<A>>(f: F) -> F { f } + | ^^^^^ help: consider cloning the value if the performance cost is acceptable | LL | let _f = to_fn(|| test(i.clone())); diff --git a/tests/ui/moves/use-correct-generic-args-in-borrow-suggest.rs b/tests/ui/moves/use-correct-generic-args-in-borrow-suggest.rs new file mode 100644 index 00000000000..0fb0cee2013 --- /dev/null +++ b/tests/ui/moves/use-correct-generic-args-in-borrow-suggest.rs @@ -0,0 +1,13 @@ +//! Regression test for #145164: For normal calls, make sure the suggestion to borrow generic inputs +//! uses the generic args from the callee's type rather than those attached to the callee's HIR +//! node. In cases where the callee isn't an identifier expression, its HIR node won't have its +//! generic arguments attached, which could lead to ICE when it had other generic args. In this +//! case, the callee expression is `run.clone()`, to which `clone`'s generic arguments are attached. + +fn main() { + let value = String::new(); + run.clone()(value, ()); + run(value, ()); + //~^ ERROR use of moved value: `value` +} +fn run<F, T: Clone>(value: T, f: F) {} diff --git a/tests/ui/moves/use-correct-generic-args-in-borrow-suggest.stderr b/tests/ui/moves/use-correct-generic-args-in-borrow-suggest.stderr new file mode 100644 index 00000000000..8c29bfbd290 --- /dev/null +++ b/tests/ui/moves/use-correct-generic-args-in-borrow-suggest.stderr @@ -0,0 +1,18 @@ +error[E0382]: use of moved value: `value` + --> $DIR/use-correct-generic-args-in-borrow-suggest.rs:10:9 + | +LL | let value = String::new(); + | ----- move occurs because `value` has type `String`, which does not implement the `Copy` trait +LL | run.clone()(value, ()); + | ----- value moved here +LL | run(value, ()); + | ^^^^^ value used here after move + | +help: consider borrowing `value` + | +LL | run.clone()(&value, ()); + | + + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/tests/ui/issues/issue-15207.rs b/tests/ui/never/never-type-method-call-15207.rs index 356e55ac912..69cdeeabb7c 100644 --- a/tests/ui/issues/issue-15207.rs +++ b/tests/ui/never/never-type-method-call-15207.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15207 + fn main() { loop { break.push(1) //~ ERROR no method named `push` found for type `!` diff --git a/tests/ui/issues/issue-15207.stderr b/tests/ui/never/never-type-method-call-15207.stderr index a1047e27ba2..265e7c8611d 100644 --- a/tests/ui/issues/issue-15207.stderr +++ b/tests/ui/never/never-type-method-call-15207.stderr @@ -1,5 +1,5 @@ error[E0599]: no method named `push` found for type `!` in the current scope - --> $DIR/issue-15207.rs:3:15 + --> $DIR/never-type-method-call-15207.rs:5:15 | LL | break.push(1) | ^^^^ method not found in `!` diff --git a/tests/ui/never_type/defaulted-never-note.fallback.stderr b/tests/ui/never_type/defaulted-never-note.fallback.stderr index fe9a924f64a..7526a399bf1 100644 --- a/tests/ui/never_type/defaulted-never-note.fallback.stderr +++ b/tests/ui/never_type/defaulted-never-note.fallback.stderr @@ -8,7 +8,7 @@ LL | foo(_x); | = help: the trait `ImplementedForUnitButNotNever` is implemented for `()` = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/48950> for more information) - = help: did you intend to use the type `()` here instead? + = help: you might have intended to use the type `()` here instead note: required by a bound in `foo` --> $DIR/defaulted-never-note.rs:25:11 | diff --git a/tests/ui/never_type/defaulted-never-note.rs b/tests/ui/never_type/defaulted-never-note.rs index badb5d4c51d..71f0d9fa5bb 100644 --- a/tests/ui/never_type/defaulted-never-note.rs +++ b/tests/ui/never_type/defaulted-never-note.rs @@ -35,7 +35,7 @@ fn smeg() { //[fallback]~| HELP trait `ImplementedForUnitButNotNever` is implemented for `()` //[fallback]~| NOTE this error might have been caused //[fallback]~| NOTE required by a bound introduced by this call - //[fallback]~| HELP did you intend + //[fallback]~| HELP you might have intended to use the type `()` } fn main() { diff --git a/tests/ui/never_type/diverging-fallback-no-leak.fallback.stderr b/tests/ui/never_type/diverging-fallback-no-leak.fallback.stderr index c5463814475..610c687194b 100644 --- a/tests/ui/never_type/diverging-fallback-no-leak.fallback.stderr +++ b/tests/ui/never_type/diverging-fallback-no-leak.fallback.stderr @@ -10,7 +10,7 @@ LL | unconstrained_arg(return); () i32 = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/48950> for more information) - = help: did you intend to use the type `()` here instead? + = help: you might have intended to use the type `()` here instead note: required by a bound in `unconstrained_arg` --> $DIR/diverging-fallback-no-leak.rs:12:25 | diff --git a/tests/ui/issues/issue-13847.rs b/tests/ui/never_type/field-access-never-type-13847.rs index 06a0304ae49..ff2a1c67b8c 100644 --- a/tests/ui/issues/issue-13847.rs +++ b/tests/ui/never_type/field-access-never-type-13847.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13847 + fn main() { return.is_failure //~ ERROR no field `is_failure` on type `!` } diff --git a/tests/ui/issues/issue-13847.stderr b/tests/ui/never_type/field-access-never-type-13847.stderr index 1c1855ce94d..1db6b310f0a 100644 --- a/tests/ui/issues/issue-13847.stderr +++ b/tests/ui/never_type/field-access-never-type-13847.stderr @@ -1,5 +1,5 @@ error[E0609]: no field `is_failure` on type `!` - --> $DIR/issue-13847.rs:2:12 + --> $DIR/field-access-never-type-13847.rs:4:12 | LL | return.is_failure | ^^^^^^^^^^ unknown field diff --git a/tests/ui/nll/issue-46589.nll.stderr b/tests/ui/nll/issue-46589.nll.stderr index dc80c1d08de..f2d08d1f4c8 100644 --- a/tests/ui/nll/issue-46589.nll.stderr +++ b/tests/ui/nll/issue-46589.nll.stderr @@ -1,5 +1,5 @@ error[E0499]: cannot borrow `**other` as mutable more than once at a time - --> $DIR/issue-46589.rs:24:21 + --> $DIR/issue-46589.rs:25:21 | LL | *other = match (*other).get_self() { | -------- first mutable borrow occurs here diff --git a/tests/ui/nll/issue-46589.polonius.stderr b/tests/ui/nll/issue-46589.polonius.stderr new file mode 100644 index 00000000000..f2d08d1f4c8 --- /dev/null +++ b/tests/ui/nll/issue-46589.polonius.stderr @@ -0,0 +1,15 @@ +error[E0499]: cannot borrow `**other` as mutable more than once at a time + --> $DIR/issue-46589.rs:25:21 + | +LL | *other = match (*other).get_self() { + | -------- first mutable borrow occurs here +LL | Some(s) => s, +LL | None => (*other).new_self() + | ^^^^^^^^ + | | + | second mutable borrow occurs here + | first borrow later used here + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/nll/issue-46589.rs b/tests/ui/nll/issue-46589.rs index 10aff0d7b4e..9a23f61b8cb 100644 --- a/tests/ui/nll/issue-46589.rs +++ b/tests/ui/nll/issue-46589.rs @@ -1,9 +1,10 @@ //@ ignore-compare-mode-polonius (explicit revisions) -//@ revisions: nll polonius_next polonius -//@ [polonius_next] check-pass -//@ [polonius_next] compile-flags: -Zpolonius=next -//@ [polonius] check-pass -//@ [polonius] compile-flags: -Zpolonius +//@ revisions: nll polonius legacy +//@ [nll] known-bug: #46589 +//@ [polonius] known-bug: #46589 +//@ [polonius] compile-flags: -Zpolonius=next +//@ [legacy] check-pass +//@ [legacy] compile-flags: -Zpolonius=legacy struct Foo; @@ -22,7 +23,6 @@ impl Foo { *other = match (*other).get_self() { Some(s) => s, None => (*other).new_self() - //[nll]~^ ERROR cannot borrow `**other` as mutable more than once at a time [E0499] }; let c = other; diff --git a/tests/ui/nll/issue-51345-2.rs b/tests/ui/nll/issue-51345-2.rs index 39871d56a9a..6c424d436f1 100644 --- a/tests/ui/nll/issue-51345-2.rs +++ b/tests/ui/nll/issue-51345-2.rs @@ -1,6 +1,6 @@ //@ run-fail -//@ error-pattern:thread 'main' panicked -//@ error-pattern:explicit panic +//@ regex-error-pattern: thread 'main'.*panicked +//@ error-pattern: explicit panic //@ needs-subprocess fn main() { diff --git a/tests/ui/nll/issue-52663-span-decl-captured-variable.stderr b/tests/ui/nll/issue-52663-span-decl-captured-variable.stderr index 57546037006..4749e3b8e45 100644 --- a/tests/ui/nll/issue-52663-span-decl-captured-variable.stderr +++ b/tests/ui/nll/issue-52663-span-decl-captured-variable.stderr @@ -10,6 +10,11 @@ LL | expect_fn(|| drop(x.0)); | | | captured by this `Fn` closure | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/issue-52663-span-decl-captured-variable.rs:1:33 + | +LL | fn expect_fn<F>(f: F) where F : Fn() { + | ^^^^ help: consider cloning the value if the performance cost is acceptable | LL | expect_fn(|| drop(x.0.clone())); diff --git a/tests/ui/nll/polonius/array-literal-index-oob-2024.rs b/tests/ui/nll/polonius/array-literal-index-oob-2024.rs new file mode 100644 index 00000000000..2054a32e535 --- /dev/null +++ b/tests/ui/nll/polonius/array-literal-index-oob-2024.rs @@ -0,0 +1,12 @@ +// This test used to ICE under `-Zpolonius=next` when computing loan liveness +// and taking kills into account during reachability traversal of the localized +// constraint graph. Originally from another test but on edition 2024, as +// seen in issue #135646. + +//@ compile-flags: -Zpolonius=next +//@ edition: 2024 +//@ check-pass + +fn main() { + &{ [1, 2, 3][4] }; +} diff --git a/tests/ui/nll/polonius/filtering-lending-iterator-issue-92985.nll.stderr b/tests/ui/nll/polonius/filtering-lending-iterator-issue-92985.nll.stderr new file mode 100644 index 00000000000..d5c85a2af23 --- /dev/null +++ b/tests/ui/nll/polonius/filtering-lending-iterator-issue-92985.nll.stderr @@ -0,0 +1,14 @@ +error[E0499]: cannot borrow `self.iter` as mutable more than once at a time + --> $DIR/filtering-lending-iterator-issue-92985.rs:49:32 + | +LL | fn next(&mut self) -> Option<I::Item<'_>> { + | - let's call the lifetime of this reference `'1` +LL | while let Some(item) = self.iter.next() { + | ^^^^^^^^^ `self.iter` was mutably borrowed here in the previous iteration of the loop +LL | if (self.predicate)(&item) { +LL | return Some(item); + | ---------- returning this value requires that `self.iter` is borrowed for `'1` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/nll/polonius/filtering-lending-iterator-issue-92985.rs b/tests/ui/nll/polonius/filtering-lending-iterator-issue-92985.rs new file mode 100644 index 00000000000..27da62ef00b --- /dev/null +++ b/tests/ui/nll/polonius/filtering-lending-iterator-issue-92985.rs @@ -0,0 +1,56 @@ +#![crate_type = "lib"] + +// This test is an example of a filtering lending iterator with GATs from #92985 (that is similar to +// NLL problem case #3) to ensure it "works" with the polonius alpha analysis as with the datalog +// implementation. +// +// The polonius analysis only changes how the `Filter::next` function is borrowcked, not the bounds +// on the predicate from using the GAT. So even if the #92985 limitation is removed, the unrelated +// 'static limitation on the predicate argument is still there, and the pattern is still impractical +// to use in the real world. + +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: nll polonius legacy +//@ [nll] known-bug: #92985 +//@ [polonius] check-pass +//@ [polonius] compile-flags: -Z polonius=next +//@ [legacy] check-pass +//@ [legacy] compile-flags: -Z polonius=legacy + +trait LendingIterator { + type Item<'a> + where + Self: 'a; + fn next(&mut self) -> Option<Self::Item<'_>>; + + fn filter<P>(self, predicate: P) -> Filter<Self, P> + where + Self: Sized, + P: FnMut(&Self::Item<'_>) -> bool, + { + Filter { iter: self, predicate } + } +} + +pub struct Filter<I, P> { + iter: I, + predicate: P, +} +impl<I: LendingIterator, P> LendingIterator for Filter<I, P> +where + P: FnMut(&I::Item<'_>) -> bool, +{ + type Item<'a> + = I::Item<'a> + where + Self: 'a; + + fn next(&mut self) -> Option<I::Item<'_>> { + while let Some(item) = self.iter.next() { + if (self.predicate)(&item) { + return Some(item); + } + } + return None; + } +} diff --git a/tests/ui/nll/polonius/flow-sensitive-invariance.nll.stderr b/tests/ui/nll/polonius/flow-sensitive-invariance.nll.stderr new file mode 100644 index 00000000000..5756148f4eb --- /dev/null +++ b/tests/ui/nll/polonius/flow-sensitive-invariance.nll.stderr @@ -0,0 +1,36 @@ +error: lifetime may not live long enough + --> $DIR/flow-sensitive-invariance.rs:20:17 + | +LL | fn use_it<'a, 'b>(choice: bool) -> Result<Invariant<'a>, Invariant<'b>> { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | let returned_value = create_invariant(); +LL | if choice { Ok(returned_value) } else { Err(returned_value) } + | ^^^^^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` + | + = help: consider adding the following bound: `'b: 'a` + = note: requirement occurs because of the type `Invariant<'_>`, which makes the generic argument `'_` invariant + = note: the struct `Invariant<'l>` is invariant over the parameter `'l` + = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance + +error: lifetime may not live long enough + --> $DIR/flow-sensitive-invariance.rs:20:45 + | +LL | fn use_it<'a, 'b>(choice: bool) -> Result<Invariant<'a>, Invariant<'b>> { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | let returned_value = create_invariant(); +LL | if choice { Ok(returned_value) } else { Err(returned_value) } + | ^^^^^^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` + | + = help: consider adding the following bound: `'a: 'b` + = note: requirement occurs because of the type `Invariant<'_>`, which makes the generic argument `'_` invariant + = note: the struct `Invariant<'l>` is invariant over the parameter `'l` + = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance + +help: `'a` and `'b` must be the same: replace one with the other + +error: aborting due to 2 previous errors + diff --git a/tests/ui/nll/polonius/flow-sensitive-invariance.polonius.stderr b/tests/ui/nll/polonius/flow-sensitive-invariance.polonius.stderr new file mode 100644 index 00000000000..5756148f4eb --- /dev/null +++ b/tests/ui/nll/polonius/flow-sensitive-invariance.polonius.stderr @@ -0,0 +1,36 @@ +error: lifetime may not live long enough + --> $DIR/flow-sensitive-invariance.rs:20:17 + | +LL | fn use_it<'a, 'b>(choice: bool) -> Result<Invariant<'a>, Invariant<'b>> { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | let returned_value = create_invariant(); +LL | if choice { Ok(returned_value) } else { Err(returned_value) } + | ^^^^^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` + | + = help: consider adding the following bound: `'b: 'a` + = note: requirement occurs because of the type `Invariant<'_>`, which makes the generic argument `'_` invariant + = note: the struct `Invariant<'l>` is invariant over the parameter `'l` + = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance + +error: lifetime may not live long enough + --> $DIR/flow-sensitive-invariance.rs:20:45 + | +LL | fn use_it<'a, 'b>(choice: bool) -> Result<Invariant<'a>, Invariant<'b>> { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | let returned_value = create_invariant(); +LL | if choice { Ok(returned_value) } else { Err(returned_value) } + | ^^^^^^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` + | + = help: consider adding the following bound: `'a: 'b` + = note: requirement occurs because of the type `Invariant<'_>`, which makes the generic argument `'_` invariant + = note: the struct `Invariant<'l>` is invariant over the parameter `'l` + = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance + +help: `'a` and `'b` must be the same: replace one with the other + +error: aborting due to 2 previous errors + diff --git a/tests/ui/nll/polonius/flow-sensitive-invariance.rs b/tests/ui/nll/polonius/flow-sensitive-invariance.rs new file mode 100644 index 00000000000..c5571f131da --- /dev/null +++ b/tests/ui/nll/polonius/flow-sensitive-invariance.rs @@ -0,0 +1,34 @@ +// An example (from @steffahn) of reachability as an approximation of liveness where the polonius +// alpha analysis shows the same imprecision as NLLs, unlike the datalog implementation. + +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: nll polonius legacy +//@ [polonius] compile-flags: -Z polonius=next +//@ [legacy] check-pass +//@ [legacy] compile-flags: -Z polonius=legacy + +use std::cell::Cell; + +struct Invariant<'l>(Cell<&'l ()>); + +fn create_invariant<'l>() -> Invariant<'l> { + Invariant(Cell::new(&())) +} + +fn use_it<'a, 'b>(choice: bool) -> Result<Invariant<'a>, Invariant<'b>> { + let returned_value = create_invariant(); + if choice { Ok(returned_value) } else { Err(returned_value) } + //[nll]~^ ERROR lifetime may not live long enough + //[nll]~| ERROR lifetime may not live long enough + //[polonius]~^^^ ERROR lifetime may not live long enough + //[polonius]~| ERROR lifetime may not live long enough +} + +fn use_it_but_its_the_same_region<'a: 'b, 'b: 'a>( + choice: bool, +) -> Result<Invariant<'a>, Invariant<'b>> { + let returned_value = create_invariant(); + if choice { Ok(returned_value) } else { Err(returned_value) } +} + +fn main() {} diff --git a/tests/ui/nll/polonius/iterating-updating-cursor-issue-108704.nll.stderr b/tests/ui/nll/polonius/iterating-updating-cursor-issue-108704.nll.stderr new file mode 100644 index 00000000000..b768f60590c --- /dev/null +++ b/tests/ui/nll/polonius/iterating-updating-cursor-issue-108704.nll.stderr @@ -0,0 +1,12 @@ +error[E0499]: cannot borrow `*elements` as mutable more than once at a time + --> $DIR/iterating-updating-cursor-issue-108704.rs:41:26 + | +LL | for (idx, el) in elements.iter_mut().enumerate() { + | ^^^^^^^^ + | | + | `*elements` was mutably borrowed here in the previous iteration of the loop + | first borrow used here, in later iteration of loop + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/nll/polonius/iterating-updating-cursor-issue-108704.polonius.stderr b/tests/ui/nll/polonius/iterating-updating-cursor-issue-108704.polonius.stderr new file mode 100644 index 00000000000..b768f60590c --- /dev/null +++ b/tests/ui/nll/polonius/iterating-updating-cursor-issue-108704.polonius.stderr @@ -0,0 +1,12 @@ +error[E0499]: cannot borrow `*elements` as mutable more than once at a time + --> $DIR/iterating-updating-cursor-issue-108704.rs:41:26 + | +LL | for (idx, el) in elements.iter_mut().enumerate() { + | ^^^^^^^^ + | | + | `*elements` was mutably borrowed here in the previous iteration of the loop + | first borrow used here, in later iteration of loop + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/nll/polonius/iterating-updating-cursor-issue-108704.rs b/tests/ui/nll/polonius/iterating-updating-cursor-issue-108704.rs new file mode 100644 index 00000000000..673efa8f225 --- /dev/null +++ b/tests/ui/nll/polonius/iterating-updating-cursor-issue-108704.rs @@ -0,0 +1,48 @@ +#![crate_type = "lib"] + +// An example from #108704 of the linked-list cursor-like pattern of #46859/#48001, where the +// polonius alpha analysis shows the same imprecision as NLLs, unlike the datalog implementation. + +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: nll polonius legacy +//@ [nll] known-bug: #108704 +//@ [polonius] known-bug: #108704 +//@ [polonius] compile-flags: -Z polonius=next +//@ [legacy] check-pass +//@ [legacy] compile-flags: -Z polonius=legacy + +struct Root { + children: Vec<Node>, +} + +struct Node { + name: String, + children: Vec<Node>, +} + +fn merge_tree_ok(root: &mut Root, path: Vec<String>) { + let mut elements = &mut root.children; + + for p in path.iter() { + for (idx, el) in elements.iter_mut().enumerate() { + if el.name == *p { + elements = &mut elements[idx].children; + break; + } + } + } +} + +// NLLs and polonius alpha fail here +fn merge_tree_ko(root: &mut Root, path: Vec<String>) { + let mut elements = &mut root.children; + + for p in path.iter() { + for (idx, el) in elements.iter_mut().enumerate() { + if el.name == *p { + elements = &mut el.children; + break; + } + } + } +} diff --git a/tests/ui/nll/polonius/iterating-updating-cursor-issue-57165.nll.stderr b/tests/ui/nll/polonius/iterating-updating-cursor-issue-57165.nll.stderr new file mode 100644 index 00000000000..34b04e707db --- /dev/null +++ b/tests/ui/nll/polonius/iterating-updating-cursor-issue-57165.nll.stderr @@ -0,0 +1,22 @@ +error[E0499]: cannot borrow `p.0` as mutable more than once at a time + --> $DIR/iterating-updating-cursor-issue-57165.rs:30:20 + | +LL | while let Some(now) = p { + | ^^^ - first borrow used here, in later iteration of loop + | | + | `p.0` was mutably borrowed here in the previous iteration of the loop + +error[E0503]: cannot use `*p` because it was mutably borrowed + --> $DIR/iterating-updating-cursor-issue-57165.rs:30:27 + | +LL | while let Some(now) = p { + | --- ^ + | | | + | | use of borrowed `p.0` + | | borrow later used here + | `p.0` is borrowed here + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0499, E0503. +For more information about an error, try `rustc --explain E0499`. diff --git a/tests/ui/nll/polonius/iterating-updating-cursor-issue-57165.polonius.stderr b/tests/ui/nll/polonius/iterating-updating-cursor-issue-57165.polonius.stderr new file mode 100644 index 00000000000..34b04e707db --- /dev/null +++ b/tests/ui/nll/polonius/iterating-updating-cursor-issue-57165.polonius.stderr @@ -0,0 +1,22 @@ +error[E0499]: cannot borrow `p.0` as mutable more than once at a time + --> $DIR/iterating-updating-cursor-issue-57165.rs:30:20 + | +LL | while let Some(now) = p { + | ^^^ - first borrow used here, in later iteration of loop + | | + | `p.0` was mutably borrowed here in the previous iteration of the loop + +error[E0503]: cannot use `*p` because it was mutably borrowed + --> $DIR/iterating-updating-cursor-issue-57165.rs:30:27 + | +LL | while let Some(now) = p { + | --- ^ + | | | + | | use of borrowed `p.0` + | | borrow later used here + | `p.0` is borrowed here + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0499, E0503. +For more information about an error, try `rustc --explain E0499`. diff --git a/tests/ui/nll/polonius/iterating-updating-cursor-issue-57165.rs b/tests/ui/nll/polonius/iterating-updating-cursor-issue-57165.rs new file mode 100644 index 00000000000..9670fc77e6f --- /dev/null +++ b/tests/ui/nll/polonius/iterating-updating-cursor-issue-57165.rs @@ -0,0 +1,45 @@ +#![crate_type = "lib"] + +// An example from #57165 of the linked-list cursor-like pattern of #46859/#48001, where the +// polonius alpha analysis shows the same imprecision as NLLs, unlike the datalog implementation. + +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: nll polonius legacy +//@ [nll] known-bug: #57165 +//@ [polonius] known-bug: #57165 +//@ [polonius] compile-flags: -Z polonius=next +//@ [legacy] check-pass +//@ [legacy] compile-flags: -Z polonius=legacy + +struct X { + next: Option<Box<X>>, +} + +fn no_control_flow() { + let mut b = Some(Box::new(X { next: None })); + let mut p = &mut b; + while let Some(now) = p { + p = &mut now.next; + } +} + +// NLLs and polonius alpha fail here +fn conditional() { + let mut b = Some(Box::new(X { next: None })); + let mut p = &mut b; + while let Some(now) = p { + if true { + p = &mut now.next; + } + } +} + +fn conditional_with_indirection() { + let mut b = Some(Box::new(X { next: None })); + let mut p = &mut b; + while let Some(now) = p { + if true { + p = &mut p.as_mut().unwrap().next; + } + } +} diff --git a/tests/ui/nll/polonius/iterating-updating-cursor-issue-63908.nll.stderr b/tests/ui/nll/polonius/iterating-updating-cursor-issue-63908.nll.stderr new file mode 100644 index 00000000000..b76e4ff6398 --- /dev/null +++ b/tests/ui/nll/polonius/iterating-updating-cursor-issue-63908.nll.stderr @@ -0,0 +1,18 @@ +error[E0506]: cannot assign to `*node_ref` because it is borrowed + --> $DIR/iterating-updating-cursor-issue-63908.rs:43:5 + | +LL | fn remove_last_node_iterative<T>(mut node_ref: &mut List<T>) { + | - let's call the lifetime of this reference `'1` +LL | loop { +LL | let next_ref = &mut node_ref.as_mut().unwrap().next; + | -------- `*node_ref` is borrowed here +... +LL | node_ref = next_ref; + | ------------------- assignment requires that `*node_ref` is borrowed for `'1` +... +LL | *node_ref = None; + | ^^^^^^^^^ `*node_ref` is assigned to here but it was already borrowed + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/tests/ui/nll/polonius/iterating-updating-cursor-issue-63908.polonius.stderr b/tests/ui/nll/polonius/iterating-updating-cursor-issue-63908.polonius.stderr new file mode 100644 index 00000000000..b76e4ff6398 --- /dev/null +++ b/tests/ui/nll/polonius/iterating-updating-cursor-issue-63908.polonius.stderr @@ -0,0 +1,18 @@ +error[E0506]: cannot assign to `*node_ref` because it is borrowed + --> $DIR/iterating-updating-cursor-issue-63908.rs:43:5 + | +LL | fn remove_last_node_iterative<T>(mut node_ref: &mut List<T>) { + | - let's call the lifetime of this reference `'1` +LL | loop { +LL | let next_ref = &mut node_ref.as_mut().unwrap().next; + | -------- `*node_ref` is borrowed here +... +LL | node_ref = next_ref; + | ------------------- assignment requires that `*node_ref` is borrowed for `'1` +... +LL | *node_ref = None; + | ^^^^^^^^^ `*node_ref` is assigned to here but it was already borrowed + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/tests/ui/nll/polonius/iterating-updating-cursor-issue-63908.rs b/tests/ui/nll/polonius/iterating-updating-cursor-issue-63908.rs new file mode 100644 index 00000000000..6682926c523 --- /dev/null +++ b/tests/ui/nll/polonius/iterating-updating-cursor-issue-63908.rs @@ -0,0 +1,44 @@ +#![crate_type = "lib"] + +// An example from #63908 of the linked-list cursor-like pattern of #46859/#48001, where the +// polonius alpha analysis shows the same imprecision as NLLs, unlike the datalog implementation. + +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: nll polonius legacy +//@ [nll] known-bug: #63908 +//@ [polonius] known-bug: #63908 +//@ [polonius] compile-flags: -Z polonius=next +//@ [legacy] check-pass +//@ [legacy] compile-flags: -Z polonius=legacy + +struct Node<T> { + value: T, + next: Option<Box<Self>>, +} + +type List<T> = Option<Box<Node<T>>>; + +fn remove_last_node_recursive<T>(node_ref: &mut List<T>) { + let next_ref = &mut node_ref.as_mut().unwrap().next; + + if next_ref.is_some() { + remove_last_node_recursive(next_ref); + } else { + *node_ref = None; + } +} + +// NLLs and polonius alpha fail here +fn remove_last_node_iterative<T>(mut node_ref: &mut List<T>) { + loop { + let next_ref = &mut node_ref.as_mut().unwrap().next; + + if next_ref.is_some() { + node_ref = next_ref; + } else { + break; + } + } + + *node_ref = None; +} diff --git a/tests/ui/nll/polonius/iterating-updating-mutref.nll.stderr b/tests/ui/nll/polonius/iterating-updating-mutref.nll.stderr new file mode 100644 index 00000000000..941c736d8d2 --- /dev/null +++ b/tests/ui/nll/polonius/iterating-updating-mutref.nll.stderr @@ -0,0 +1,15 @@ +error[E0499]: cannot borrow `self.buf_read` as mutable more than once at a time + --> $DIR/iterating-updating-mutref.rs:61:23 + | +LL | pub fn next<'a>(&'a mut self) -> &'a str { + | -- lifetime `'a` defined here +LL | loop { +LL | let buf = self.buf_read.fill_buf(); + | ^^^^^^^^^^^^^ `self.buf_read` was mutably borrowed here in the previous iteration of the loop +LL | if let Some(s) = decode(buf) { +LL | return s; + | - returning this value requires that `self.buf_read` is borrowed for `'a` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/nll/polonius/iterating-updating-mutref.rs b/tests/ui/nll/polonius/iterating-updating-mutref.rs new file mode 100644 index 00000000000..a315bf66279 --- /dev/null +++ b/tests/ui/nll/polonius/iterating-updating-mutref.rs @@ -0,0 +1,87 @@ +// These are some examples of iterating through and updating a mutable ref, similar in spirit to the +// linked-list-like pattern of #46859/#48001 where the polonius alpha analysis shows imprecision, +// unlike the datalog implementation. +// +// They differ in that after the loans prior to the loop are either not live after the loop, or with +// control flow and outlives relationships that are simple enough for the reachability +// approximation. They're thus accepted by the alpha analysis, like NLLs did for the simplest cases +// of flow-sensitivity. + +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: nll polonius legacy +//@ [nll] known-bug: #46859 +//@ [polonius] check-pass +//@ [polonius] compile-flags: -Z polonius=next +//@ [legacy] check-pass +//@ [legacy] compile-flags: -Z polonius=legacy + +// The #46859 OP +struct List<T> { + value: T, + next: Option<Box<List<T>>>, +} + +fn to_refs<T>(mut list: &mut List<T>) -> Vec<&mut T> { + let mut result = vec![]; + loop { + result.push(&mut list.value); + if let Some(n) = list.next.as_mut() { + list = n; + } else { + return result; + } + } +} + +// A similar construction, where paths in the constraint graph are also clearly terminating, so it's +// fine even for NLLs. +fn to_refs2<T>(mut list: &mut List<T>) -> Vec<&mut T> { + let mut result = vec![]; + loop { + result.push(&mut list.value); + if let Some(n) = list.next.as_mut() { + list = n; + } else { + break; + } + } + + result +} + +// Another MCVE from the same issue, but was rejected by NLLs. +pub struct Decoder { + buf_read: BufRead, +} + +impl Decoder { + // NLLs fail here + pub fn next<'a>(&'a mut self) -> &'a str { + loop { + let buf = self.buf_read.fill_buf(); + if let Some(s) = decode(buf) { + return s; + } + // loop to get more input data + + // At this point `buf` is not used anymore. + // With NLL I would expect the borrow to end here, + // such that `self.buf_read` is not borrowed anymore + // by the time we start the next loop iteration. + } + } +} + +struct BufRead; + +impl BufRead { + fn fill_buf(&mut self) -> &[u8] { + unimplemented!() + } +} + +fn decode(_: &[u8]) -> Option<&str> { + unimplemented!() +} + +fn main() {} diff --git a/tests/ui/nll/polonius/lending-iterator-sanity-checks.legacy.stderr b/tests/ui/nll/polonius/lending-iterator-sanity-checks.legacy.stderr new file mode 100644 index 00000000000..fa201b89048 --- /dev/null +++ b/tests/ui/nll/polonius/lending-iterator-sanity-checks.legacy.stderr @@ -0,0 +1,28 @@ +error[E0499]: cannot borrow `*t` as mutable more than once at a time + --> $DIR/lending-iterator-sanity-checks.rs:19:19 + | +LL | fn use_live<T: LendingIterator>(t: &mut T) -> Option<(T::Item<'_>, T::Item<'_>)> { + | - let's call the lifetime of this reference `'1` +LL | let Some(i) = t.next() else { return None }; + | - first mutable borrow occurs here +LL | let Some(j) = t.next() else { return None }; + | ^ second mutable borrow occurs here +... +LL | Some((i, j)) + | ------------ returning this value requires that `*t` is borrowed for `'1` + +error[E0499]: cannot borrow `*t` as mutable more than once at a time + --> $DIR/lending-iterator-sanity-checks.rs:31:13 + | +LL | let i = t.next(); + | - first mutable borrow occurs here +... +LL | let j = t.next(); + | ^ second mutable borrow occurs here +LL | +LL | } + | - first borrow might be used here, when `i` is dropped and runs the destructor for type `Option<<T as LendingIterator>::Item<'_>>` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/nll/polonius/lending-iterator-sanity-checks.nll.stderr b/tests/ui/nll/polonius/lending-iterator-sanity-checks.nll.stderr new file mode 100644 index 00000000000..fa201b89048 --- /dev/null +++ b/tests/ui/nll/polonius/lending-iterator-sanity-checks.nll.stderr @@ -0,0 +1,28 @@ +error[E0499]: cannot borrow `*t` as mutable more than once at a time + --> $DIR/lending-iterator-sanity-checks.rs:19:19 + | +LL | fn use_live<T: LendingIterator>(t: &mut T) -> Option<(T::Item<'_>, T::Item<'_>)> { + | - let's call the lifetime of this reference `'1` +LL | let Some(i) = t.next() else { return None }; + | - first mutable borrow occurs here +LL | let Some(j) = t.next() else { return None }; + | ^ second mutable borrow occurs here +... +LL | Some((i, j)) + | ------------ returning this value requires that `*t` is borrowed for `'1` + +error[E0499]: cannot borrow `*t` as mutable more than once at a time + --> $DIR/lending-iterator-sanity-checks.rs:31:13 + | +LL | let i = t.next(); + | - first mutable borrow occurs here +... +LL | let j = t.next(); + | ^ second mutable borrow occurs here +LL | +LL | } + | - first borrow might be used here, when `i` is dropped and runs the destructor for type `Option<<T as LendingIterator>::Item<'_>>` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/nll/polonius/lending-iterator-sanity-checks.polonius.stderr b/tests/ui/nll/polonius/lending-iterator-sanity-checks.polonius.stderr new file mode 100644 index 00000000000..bf8546b63bf --- /dev/null +++ b/tests/ui/nll/polonius/lending-iterator-sanity-checks.polonius.stderr @@ -0,0 +1,26 @@ +error[E0499]: cannot borrow `*t` as mutable more than once at a time + --> $DIR/lending-iterator-sanity-checks.rs:19:19 + | +LL | let Some(i) = t.next() else { return None }; + | - first mutable borrow occurs here +LL | let Some(j) = t.next() else { return None }; + | ^ second mutable borrow occurs here +... +LL | } + | - first borrow might be used here, when `i` is dropped and runs the destructor for type `<T as LendingIterator>::Item<'_>` + +error[E0499]: cannot borrow `*t` as mutable more than once at a time + --> $DIR/lending-iterator-sanity-checks.rs:31:13 + | +LL | let i = t.next(); + | - first mutable borrow occurs here +... +LL | let j = t.next(); + | ^ second mutable borrow occurs here +LL | +LL | } + | - first borrow might be used here, when `i` is dropped and runs the destructor for type `Option<<T as LendingIterator>::Item<'_>>` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/nll/polonius/lending-iterator-sanity-checks.rs b/tests/ui/nll/polonius/lending-iterator-sanity-checks.rs new file mode 100644 index 00000000000..ae8cc78957f --- /dev/null +++ b/tests/ui/nll/polonius/lending-iterator-sanity-checks.rs @@ -0,0 +1,71 @@ +// Some sanity checks for lending iterators with GATs. This is just some non-regression tests +// ensuring the polonius alpha analysis, the datalog implementation, and NLLs agree in these common +// cases of overlapping yielded items. + +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: nll polonius legacy +//@ [polonius] compile-flags: -Z polonius=next +//@ [legacy] compile-flags: -Z polonius=legacy + +trait LendingIterator { + type Item<'a> + where + Self: 'a; + fn next(&mut self) -> Option<Self::Item<'_>>; +} + +fn use_live<T: LendingIterator>(t: &mut T) -> Option<(T::Item<'_>, T::Item<'_>)> { + let Some(i) = t.next() else { return None }; + let Some(j) = t.next() else { return None }; + //~^ ERROR cannot borrow `*t` as mutable more than once at a time + + // `i` is obviously still (use-)live here, but we called `next` again to get `j`. + Some((i, j)) +} + +fn drop_live<T: LendingIterator>(t: &mut T) { + let i = t.next(); + + // Now `i` is use-dead here, but we don't know if the iterator items have a `Drop` impl, so it's + // still drop-live. + let j = t.next(); + //~^ ERROR cannot borrow `*t` as mutable more than once at a time +} + +// But we can still manually serialize the lifetimes with scopes (or preventing the destructor from +// being called), so they're not overlapping. +fn manually_non_overlapping<T: LendingIterator>(t: &mut T) { + { + let i = t.next(); + } + + let j = t.next(); // i is dead + + drop(j); + let k = t.next(); // j is dead + + let k = std::mem::ManuallyDrop::new(k); + let l = t.next(); // we told the compiler that k is not drop-live +} + +// The cfg below is because there's a diagnostic ICE trying to explain the source of the error when +// using the datalog implementation. We're not fixing *that*, outside of removing the implementation +// in the future. +#[cfg(not(legacy))] // FIXME: remove this cfg when removing the datalog implementation +fn items_have_no_borrows<T: LendingIterator>(t: &mut T) +where + for<'a> T::Item<'a>: 'static, +{ + let i = t.next(); + let j = t.next(); +} + +fn items_are_copy<T: LendingIterator>(t: &mut T) +where + for<'a> T::Item<'a>: Copy, +{ + let i = t.next(); + let j = t.next(); +} + +fn main() {} diff --git a/tests/ui/nll/polonius/nll-problem-case-3-issue-112087.nll.stderr b/tests/ui/nll/polonius/nll-problem-case-3-issue-112087.nll.stderr new file mode 100644 index 00000000000..16b5d8f7148 --- /dev/null +++ b/tests/ui/nll/polonius/nll-problem-case-3-issue-112087.nll.stderr @@ -0,0 +1,17 @@ +error[E0506]: cannot assign to `*opt` because it is borrowed + --> $DIR/nll-problem-case-3-issue-112087.rs:23:5 + | +LL | fn issue_112087<'a>(opt: &'a mut Option<i32>, b: bool) -> Result<&'a mut Option<i32>, &'a mut i32> { + | -- lifetime `'a` defined here +LL | if let Some(v) = opt { + | - `*opt` is borrowed here +LL | if b { +LL | return Err(v); + | ------ returning this value requires that `opt.0` is borrowed for `'a` +... +LL | *opt = None; + | ^^^^^^^^^^^ `*opt` is assigned to here but it was already borrowed + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/tests/ui/nll/polonius/nll-problem-case-3-issue-112087.rs b/tests/ui/nll/polonius/nll-problem-case-3-issue-112087.rs new file mode 100644 index 00000000000..d7270f6bfa7 --- /dev/null +++ b/tests/ui/nll/polonius/nll-problem-case-3-issue-112087.rs @@ -0,0 +1,25 @@ +#![crate_type = "lib"] + +// This is part of a collection of regression tests related to the NLL problem case 3 that was +// deferred from the implementation of the NLL RFC, and left to be implemented by polonius. They are +// from open issues, e.g. tagged fixed-by-polonius, to ensure that the polonius alpha analysis does +// handle them, as does the datalog implementation. + +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: nll polonius legacy +//@ [nll] known-bug: #112087 +//@ [polonius] check-pass +//@ [polonius] compile-flags: -Z polonius=next +//@ [legacy] check-pass +//@ [legacy] compile-flags: -Z polonius=legacy + +fn issue_112087<'a>(opt: &'a mut Option<i32>, b: bool) -> Result<&'a mut Option<i32>, &'a mut i32> { + if let Some(v) = opt { + if b { + return Err(v); + } + } + + *opt = None; + return Ok(opt); +} diff --git a/tests/ui/nll/polonius/nll-problem-case-3-issue-123839.nll.stderr b/tests/ui/nll/polonius/nll-problem-case-3-issue-123839.nll.stderr new file mode 100644 index 00000000000..541789b7f17 --- /dev/null +++ b/tests/ui/nll/polonius/nll-problem-case-3-issue-123839.nll.stderr @@ -0,0 +1,16 @@ +error[E0506]: cannot assign to `self.status` because it is borrowed + --> $DIR/nll-problem-case-3-issue-123839.rs:37:9 + | +LL | fn foo(self: &mut Self) -> Result<(), &str> { + | - let's call the lifetime of this reference `'1` +LL | self.bar()?; // rust reports this line conflicts with the next line + | ----------- + | | + | `self.status` is borrowed here + | returning this value requires that `*self` is borrowed for `'1` +LL | self.status = 1; // and this line is the victim + | ^^^^^^^^^^^^^^^ `self.status` is assigned to here but it was already borrowed + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/tests/ui/nll/polonius/nll-problem-case-3-issue-123839.rs b/tests/ui/nll/polonius/nll-problem-case-3-issue-123839.rs new file mode 100644 index 00000000000..a738dace73d --- /dev/null +++ b/tests/ui/nll/polonius/nll-problem-case-3-issue-123839.rs @@ -0,0 +1,40 @@ +#![crate_type = "lib"] + +// This is part of a collection of regression tests related to the NLL problem case 3 that was +// deferred from the implementation of the NLL RFC, and left to be implemented by polonius. They are +// from open issues, e.g. tagged fixed-by-polonius, to ensure that the polonius alpha analysis does +// handle them, as does the datalog implementation. + +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: nll polonius legacy +//@ [nll] known-bug: #123839 +//@ [polonius] check-pass +//@ [polonius] compile-flags: -Z polonius=next +//@ [legacy] check-pass +//@ [legacy] compile-flags: -Z polonius=legacy + +struct Foo { + val: i32, + status: i32, + err_str: String, +} + +impl Foo { + fn bar(self: &mut Self) -> Result<(), &str> { + if self.val == 0 { + self.status = -1; + Err("val is zero") + } else if self.val < 0 { + self.status = -2; + self.err_str = format!("unexpected negative val {}", self.val); + Err(&self.err_str) + } else { + Ok(()) + } + } + fn foo(self: &mut Self) -> Result<(), &str> { + self.bar()?; // rust reports this line conflicts with the next line + self.status = 1; // and this line is the victim + Ok(()) + } +} diff --git a/tests/ui/nll/polonius/nll-problem-case-3-issue-124070.nll.stderr b/tests/ui/nll/polonius/nll-problem-case-3-issue-124070.nll.stderr new file mode 100644 index 00000000000..7c2a383e89c --- /dev/null +++ b/tests/ui/nll/polonius/nll-problem-case-3-issue-124070.nll.stderr @@ -0,0 +1,17 @@ +error[E0502]: cannot borrow `self.field` as immutable because it is also borrowed as mutable + --> $DIR/nll-problem-case-3-issue-124070.rs:28:16 + | +LL | fn f(&mut self) -> &str { + | - let's call the lifetime of this reference `'1` +LL | let a = &mut self.field; + | --------------- mutable borrow occurs here +... +LL | return a; + | - returning this value requires that `self.field` is borrowed for `'1` +... +LL | return &self.field; + | ^^^^^^^^^^^ immutable borrow occurs here + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0502`. diff --git a/tests/ui/nll/polonius/nll-problem-case-3-issue-124070.rs b/tests/ui/nll/polonius/nll-problem-case-3-issue-124070.rs new file mode 100644 index 00000000000..ddf331db8bb --- /dev/null +++ b/tests/ui/nll/polonius/nll-problem-case-3-issue-124070.rs @@ -0,0 +1,30 @@ +#![crate_type = "lib"] + +// This is part of a collection of regression tests related to the NLL problem case 3 that was +// deferred from the implementation of the NLL RFC, and left to be implemented by polonius. They are +// from open issues, e.g. tagged fixed-by-polonius, to ensure that the polonius alpha analysis does +// handle them, as does the datalog implementation. + +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: nll polonius legacy +//@ [nll] known-bug: #124070 +//@ [polonius] check-pass +//@ [polonius] compile-flags: -Z polonius=next +//@ [legacy] check-pass +//@ [legacy] compile-flags: -Z polonius=legacy + +struct S { + field: String, +} + +impl S { + fn f(&mut self) -> &str { + let a = &mut self.field; + + if false { + return a; + } + + return &self.field; + } +} diff --git a/tests/ui/nll/polonius/nll-problem-case-3-issue-124254.nll.stderr b/tests/ui/nll/polonius/nll-problem-case-3-issue-124254.nll.stderr new file mode 100644 index 00000000000..bd5f1203f31 --- /dev/null +++ b/tests/ui/nll/polonius/nll-problem-case-3-issue-124254.nll.stderr @@ -0,0 +1,34 @@ +error[E0499]: cannot borrow `list[_]` as mutable more than once at a time + --> $DIR/nll-problem-case-3-issue-124254.rs:30:5 + | +LL | fn find_lowest_or_first_empty_pos(list: &mut [Option<u8>]) -> &mut Option<u8> { + | - let's call the lifetime of this reference `'1` +LL | let mut low_pos_val: Option<(usize, u8)> = None; +LL | for (idx, i) in list.iter_mut().enumerate() { + | ---- first mutable borrow occurs here +LL | let Some(s) = i else { +LL | return i; + | - returning this value requires that `*list` is borrowed for `'1` +... +LL | &mut list[lowest_idx] + | ^^^^^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + +error[E0503]: cannot use `*list` because it was mutably borrowed + --> $DIR/nll-problem-case-3-issue-124254.rs:30:10 + | +LL | fn find_lowest_or_first_empty_pos(list: &mut [Option<u8>]) -> &mut Option<u8> { + | - let's call the lifetime of this reference `'1` +LL | let mut low_pos_val: Option<(usize, u8)> = None; +LL | for (idx, i) in list.iter_mut().enumerate() { + | ---- `*list` is borrowed here +LL | let Some(s) = i else { +LL | return i; + | - returning this value requires that `*list` is borrowed for `'1` +... +LL | &mut list[lowest_idx] + | ^^^^^^^^^^^^^^^^ use of borrowed `*list` + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0499, E0503. +For more information about an error, try `rustc --explain E0499`. diff --git a/tests/ui/nll/polonius/nll-problem-case-3-issue-124254.rs b/tests/ui/nll/polonius/nll-problem-case-3-issue-124254.rs new file mode 100644 index 00000000000..e3bc2c2febc --- /dev/null +++ b/tests/ui/nll/polonius/nll-problem-case-3-issue-124254.rs @@ -0,0 +1,45 @@ +// This is part of a collection of regression tests related to the NLL problem case 3 that was +// deferred from the implementation of the NLL RFC, and left to be implemented by polonius. They are +// from open issues, e.g. tagged fixed-by-polonius, to ensure that the polonius alpha analysis does +// handle them, as does the datalog implementation. + +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: nll polonius legacy +//@ [nll] known-bug: #124254 +//@ [polonius] check-pass +//@ [polonius] compile-flags: -Z polonius=next +//@ [legacy] check-pass +//@ [legacy] compile-flags: -Z polonius=legacy + +fn find_lowest_or_first_empty_pos(list: &mut [Option<u8>]) -> &mut Option<u8> { + let mut low_pos_val: Option<(usize, u8)> = None; + for (idx, i) in list.iter_mut().enumerate() { + let Some(s) = i else { + return i; + }; + + low_pos_val = match low_pos_val { + Some((_oidx, oval)) if oval > *s => Some((idx, *s)), + Some(old) => Some(old), + None => Some((idx, *s)), + }; + } + let Some((lowest_idx, _)) = low_pos_val else { + unreachable!("Can't have zero length list!"); + }; + &mut list[lowest_idx] +} + +fn main() { + let mut list = [Some(1), Some(2), None, Some(3)]; + let v = find_lowest_or_first_empty_pos(&mut list); + assert!(v.is_none()); + assert_eq!(v as *mut _ as usize, list.as_ptr().wrapping_add(2) as usize); + + let mut list = [Some(1), Some(2), Some(3), Some(0)]; + let v = find_lowest_or_first_empty_pos(&mut list); + assert_eq!(v, &mut Some(0)); + assert_eq!(v as *mut _ as usize, list.as_ptr().wrapping_add(3) as usize); + + println!("pass"); +} diff --git a/tests/ui/nll/polonius/nll-problem-case-3-issue-21906.nll.stderr b/tests/ui/nll/polonius/nll-problem-case-3-issue-21906.nll.stderr new file mode 100644 index 00000000000..dc38b8c127e --- /dev/null +++ b/tests/ui/nll/polonius/nll-problem-case-3-issue-21906.nll.stderr @@ -0,0 +1,96 @@ +error[E0499]: cannot borrow `*map` as mutable more than once at a time + --> $DIR/nll-problem-case-3-issue-21906.rs:26:13 + | +LL | fn from_the_rfc<'r, K: Hash + Eq + Copy, V: Default>( + | -- lifetime `'r` defined here +... +LL | match map.get_mut(&key) { + | - --- first mutable borrow occurs here + | _____| + | | +LL | | Some(value) => value, +LL | | None => { +LL | | map.insert(key, V::default()); + | | ^^^ second mutable borrow occurs here +... | +LL | | } + | |_____- returning this value requires that `*map` is borrowed for `'r` + +error[E0499]: cannot borrow `*map` as mutable more than once at a time + --> $DIR/nll-problem-case-3-issue-21906.rs:27:13 + | +LL | fn from_the_rfc<'r, K: Hash + Eq + Copy, V: Default>( + | -- lifetime `'r` defined here +... +LL | match map.get_mut(&key) { + | - --- first mutable borrow occurs here + | _____| + | | +LL | | Some(value) => value, +LL | | None => { +LL | | map.insert(key, V::default()); +LL | | map.get_mut(&key).unwrap() + | | ^^^ second mutable borrow occurs here +LL | | } +LL | | } + | |_____- returning this value requires that `*map` is borrowed for `'r` + +error[E0499]: cannot borrow `*self` as mutable more than once at a time + --> $DIR/nll-problem-case-3-issue-21906.rs:44:21 + | +LL | fn two(&mut self) -> &i32 { + | - let's call the lifetime of this reference `'1` +LL | loop { +LL | let k = self.one(); + | ^^^^ `*self` was mutably borrowed here in the previous iteration of the loop +LL | if *k > 10i32 { +LL | return k; + | - returning this value requires that `*self` is borrowed for `'1` + +error[E0502]: cannot borrow `x.data` as immutable because it is also borrowed as mutable + --> $DIR/nll-problem-case-3-issue-21906.rs:62:22 + | +LL | fn foo(x: &mut Foo) -> Option<&mut i32> { + | - let's call the lifetime of this reference `'1` +LL | if let Some(y) = x.data.as_mut() { + | ------ mutable borrow occurs here +LL | return Some(y); + | ------- returning this value requires that `x.data` is borrowed for `'1` +... +LL | println!("{:?}", x.data); + | ^^^^^^ immutable borrow occurs here + | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0499]: cannot borrow `*vec` as mutable more than once at a time + --> $DIR/nll-problem-case-3-issue-21906.rs:77:9 + | +LL | fn f(vec: &mut Vec<u8>) -> &u8 { + | - let's call the lifetime of this reference `'1` +LL | if let Some(n) = vec.iter_mut().find(|n| **n == 1) { + | --- first mutable borrow occurs here +LL | *n = 10; +LL | n + | - returning this value requires that `*vec` is borrowed for `'1` +LL | } else { +LL | vec.push(10); + | ^^^ second mutable borrow occurs here + +error[E0502]: cannot borrow `*vec` as immutable because it is also borrowed as mutable + --> $DIR/nll-problem-case-3-issue-21906.rs:78:9 + | +LL | fn f(vec: &mut Vec<u8>) -> &u8 { + | - let's call the lifetime of this reference `'1` +LL | if let Some(n) = vec.iter_mut().find(|n| **n == 1) { + | --- mutable borrow occurs here +LL | *n = 10; +LL | n + | - returning this value requires that `*vec` is borrowed for `'1` +... +LL | vec.last().unwrap() + | ^^^ immutable borrow occurs here + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0499, E0502. +For more information about an error, try `rustc --explain E0499`. diff --git a/tests/ui/nll/polonius/nll-problem-case-3-issue-21906.rs b/tests/ui/nll/polonius/nll-problem-case-3-issue-21906.rs new file mode 100644 index 00000000000..b025ea78f8b --- /dev/null +++ b/tests/ui/nll/polonius/nll-problem-case-3-issue-21906.rs @@ -0,0 +1,85 @@ +#![crate_type = "lib"] + +// This is part of a collection of regression tests related to the NLL problem case 3 that was +// deferred from the implementation of the NLL RFC, and left to be implemented by polonius. They are +// from open issues, e.g. tagged fixed-by-polonius, to ensure that the polonius alpha analysis does +// handle them, as does the datalog implementation. + +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: nll polonius legacy +//@ [nll] known-bug: #21906 +//@ [polonius] check-pass +//@ [polonius] compile-flags: -Z polonius=next +//@ [legacy] check-pass +//@ [legacy] compile-flags: -Z polonius=legacy + +use std::collections::HashMap; +use std::hash::Hash; + +fn from_the_rfc<'r, K: Hash + Eq + Copy, V: Default>( + map: &'r mut HashMap<K, V>, + key: K, +) -> &'r mut V { + match map.get_mut(&key) { + Some(value) => value, + None => { + map.insert(key, V::default()); + map.get_mut(&key).unwrap() + } + } +} + +// MCVE 1 from issue #21906 +struct A { + a: i32, +} + +impl A { + fn one(&mut self) -> &i32 { + self.a = 10; + &self.a + } + fn two(&mut self) -> &i32 { + loop { + let k = self.one(); + if *k > 10i32 { + return k; + } + } + } +} + +// MCVE 2 +struct Foo { + data: Option<i32>, +} + +fn foo(x: &mut Foo) -> Option<&mut i32> { + if let Some(y) = x.data.as_mut() { + return Some(y); + } + + println!("{:?}", x.data); + None +} + +fn mcve2() { + let mut x = Foo { data: Some(1) }; + foo(&mut x); +} + +// MCVE 3 +fn f(vec: &mut Vec<u8>) -> &u8 { + if let Some(n) = vec.iter_mut().find(|n| **n == 1) { + *n = 10; + n + } else { + vec.push(10); + vec.last().unwrap() + } +} + +fn mcve3() { + let mut vec = vec![1, 2, 3]; + f(&mut vec); +} diff --git a/tests/ui/nll/polonius/nll-problem-case-3-issue-51526.nll.stderr b/tests/ui/nll/polonius/nll-problem-case-3-issue-51526.nll.stderr new file mode 100644 index 00000000000..9a740a0edc7 --- /dev/null +++ b/tests/ui/nll/polonius/nll-problem-case-3-issue-51526.nll.stderr @@ -0,0 +1,18 @@ +error[E0502]: cannot borrow `*queue` as mutable because it is also borrowed as immutable + --> $DIR/nll-problem-case-3-issue-51526.rs:26:9 + | +LL | fn next(queue: &mut VecDeque<u32>, above: u32) -> Option<&u32> { + | - let's call the lifetime of this reference `'1` +... +LL | let next = queue.front()?; + | ----- immutable borrow occurs here +... +LL | queue.pop_front(); + | ^^^^^^^^^^^^^^^^^ mutable borrow occurs here +... +LL | Some(result) + | ------------ returning this value requires that `*queue` is borrowed for `'1` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0502`. diff --git a/tests/ui/nll/polonius/nll-problem-case-3-issue-51526.rs b/tests/ui/nll/polonius/nll-problem-case-3-issue-51526.rs new file mode 100644 index 00000000000..3cf211586b2 --- /dev/null +++ b/tests/ui/nll/polonius/nll-problem-case-3-issue-51526.rs @@ -0,0 +1,30 @@ +#![crate_type = "lib"] + +// This is part of a collection of regression tests related to the NLL problem case 3 that was +// deferred from the implementation of the NLL RFC, and left to be implemented by polonius. They are +// from open issues, e.g. tagged fixed-by-polonius, to ensure that the polonius alpha analysis does +// handle them, as does the datalog implementation. + +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: nll polonius legacy +//@ [nll] known-bug: #51526 +//@ [polonius] check-pass +//@ [polonius] compile-flags: -Z polonius=next +//@ [legacy] check-pass +//@ [legacy] compile-flags: -Z polonius=legacy + +use std::collections::VecDeque; + +fn next(queue: &mut VecDeque<u32>, above: u32) -> Option<&u32> { + let result = loop { + { + let next = queue.front()?; + if *next > above { + break next; + } + } + queue.pop_front(); + }; + + Some(result) +} diff --git a/tests/ui/nll/polonius/nll-problem-case-3-issue-51545.nll.stderr b/tests/ui/nll/polonius/nll-problem-case-3-issue-51545.nll.stderr new file mode 100644 index 00000000000..c6a0e1b282f --- /dev/null +++ b/tests/ui/nll/polonius/nll-problem-case-3-issue-51545.nll.stderr @@ -0,0 +1,15 @@ +error[E0499]: cannot borrow `*o` as mutable more than once at a time + --> $DIR/nll-problem-case-3-issue-51545.rs:17:17 + | +LL | fn borrow(o: &mut Option<i32>) -> Option<&mut i32> { + | - let's call the lifetime of this reference `'1` +LL | match o.as_mut() { + | - first mutable borrow occurs here +LL | Some(i) => Some(i), + | ------- returning this value requires that `*o` is borrowed for `'1` +LL | None => o.as_mut(), + | ^ second mutable borrow occurs here + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/nll/polonius/nll-problem-case-3-issue-51545.rs b/tests/ui/nll/polonius/nll-problem-case-3-issue-51545.rs new file mode 100644 index 00000000000..786a8b564b9 --- /dev/null +++ b/tests/ui/nll/polonius/nll-problem-case-3-issue-51545.rs @@ -0,0 +1,28 @@ +// This is part of a collection of regression tests related to the NLL problem case 3 that was +// deferred from the implementation of the NLL RFC, and left to be implemented by polonius. They are +// from open issues, e.g. tagged fixed-by-polonius, to ensure that the polonius alpha analysis does +// handle them, as does the datalog implementation. + +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: nll polonius legacy +//@ [nll] known-bug: #51545 +//@ [polonius] check-pass +//@ [polonius] compile-flags: -Z polonius=next +//@ [legacy] check-pass +//@ [legacy] compile-flags: -Z polonius=legacy + +fn borrow(o: &mut Option<i32>) -> Option<&mut i32> { + match o.as_mut() { + Some(i) => Some(i), + None => o.as_mut(), + } +} + +fn main() { + let mut o: Option<i32> = Some(1i32); + + let x = match o.as_mut() { + Some(i) => Some(i), + None => o.as_mut(), + }; +} diff --git a/tests/ui/nll/polonius/nll-problem-case-3-issue-54663.nll.stderr b/tests/ui/nll/polonius/nll-problem-case-3-issue-54663.nll.stderr new file mode 100644 index 00000000000..fd6fa7632d5 --- /dev/null +++ b/tests/ui/nll/polonius/nll-problem-case-3-issue-54663.nll.stderr @@ -0,0 +1,16 @@ +error[E0499]: cannot borrow `*x` as mutable more than once at a time + --> $DIR/nll-problem-case-3-issue-54663.rs:20:9 + | +LL | fn foo(x: &mut u8) -> Option<&u8> { + | - let's call the lifetime of this reference `'1` +LL | if let Some(y) = bar(x) { + | - first mutable borrow occurs here +LL | return Some(y); + | ------- returning this value requires that `*x` is borrowed for `'1` +LL | } +LL | bar(x) + | ^ second mutable borrow occurs here + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/nll/polonius/nll-problem-case-3-issue-54663.rs b/tests/ui/nll/polonius/nll-problem-case-3-issue-54663.rs new file mode 100644 index 00000000000..b4d571fb9c7 --- /dev/null +++ b/tests/ui/nll/polonius/nll-problem-case-3-issue-54663.rs @@ -0,0 +1,25 @@ +#![crate_type = "lib"] + +// This is part of a collection of regression tests related to the NLL problem case 3 that was +// deferred from the implementation of the NLL RFC, and left to be implemented by polonius. They are +// from open issues, e.g. tagged fixed-by-polonius, to ensure that the polonius alpha analysis does +// handle them, as does the datalog implementation. + +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: nll polonius legacy +//@ [nll] known-bug: #54663 +//@ [polonius] check-pass +//@ [polonius] compile-flags: -Z polonius=next +//@ [legacy] check-pass +//@ [legacy] compile-flags: -Z polonius=legacy + +fn foo(x: &mut u8) -> Option<&u8> { + if let Some(y) = bar(x) { + return Some(y); + } + bar(x) +} + +fn bar(x: &mut u8) -> Option<&u8> { + Some(x) +} diff --git a/tests/ui/nll/polonius/nll-problem-case-3-issue-58787.nll.stderr b/tests/ui/nll/polonius/nll-problem-case-3-issue-58787.nll.stderr new file mode 100644 index 00000000000..53002892df1 --- /dev/null +++ b/tests/ui/nll/polonius/nll-problem-case-3-issue-58787.nll.stderr @@ -0,0 +1,112 @@ +error[E0503]: cannot use `list.0` because it was mutably borrowed + --> $DIR/nll-problem-case-3-issue-58787.rs:34:11 + | +LL | Some(ref mut d) => { + | --------- `list.0.0` is borrowed here +... +LL | match list.0 { + | ^^^^^^ + | | + | use of borrowed `list.0.0` + | borrow later used here + +error[E0499]: cannot borrow `list.0.0` as mutable more than once at a time + --> $DIR/nll-problem-case-3-issue-58787.rs:35:14 + | +LL | Some(ref mut d) => { + | --------- first mutable borrow occurs here +... +LL | Some(ref mut d) => { + | ^^^^^^^^^ + | | + | second mutable borrow occurs here + | first borrow later used here + +error[E0503]: cannot use `list.0` because it was mutably borrowed + --> $DIR/nll-problem-case-3-issue-58787.rs:41:11 + | +LL | Some(ref mut d) => { + | --------- `list.0.0` is borrowed here +... +LL | match list { + | ^^^^ + | | + | use of borrowed `list.0.0` + | borrow later used here + +error[E0499]: cannot borrow `list.0.0` as mutable more than once at a time + --> $DIR/nll-problem-case-3-issue-58787.rs:42:19 + | +LL | Some(ref mut d) => { + | --------- first mutable borrow occurs here +... +LL | List(Some(d)) => { + | ^ + | | + | second mutable borrow occurs here + | first borrow later used here + +error[E0503]: cannot use `list.0` because it was mutably borrowed + --> $DIR/nll-problem-case-3-issue-58787.rs:50:11 + | +LL | List(Some(d)) => { + | - `list.0.0` is borrowed here +... +LL | match list { + | ^^^^ + | | + | use of borrowed `list.0.0` + | borrow later used here + +error[E0499]: cannot borrow `list.0.0` as mutable more than once at a time + --> $DIR/nll-problem-case-3-issue-58787.rs:51:19 + | +LL | List(Some(d)) => { + | - first mutable borrow occurs here +... +LL | List(Some(d)) => { + | ^ + | | + | second mutable borrow occurs here + | first borrow later used here + +error[E0499]: cannot borrow `list.0` as mutable more than once at a time + --> $DIR/nll-problem-case-3-issue-58787.rs:57:11 + | +LL | List(Some(d)) => { + | - first mutable borrow occurs here +... +LL | match &mut list.0 { + | ^^^^^^^^^^^ + | | + | second mutable borrow occurs here + | first borrow later used here + +error[E0499]: cannot borrow `list.0` as mutable more than once at a time + --> $DIR/nll-problem-case-3-issue-58787.rs:66:11 + | +LL | match &mut list.0 { + | ----------- first mutable borrow occurs here +... +LL | match &mut list.0 { + | ^^^^^^^^^^^ + | | + | second mutable borrow occurs here + | first borrow later used here + +error[E0506]: cannot assign to `list.0` because it is borrowed + --> $DIR/nll-problem-case-3-issue-58787.rs:73:5 + | +LL | match &mut list.0 { + | ----------- `list.0` is borrowed here +... +LL | list.0 = None; + | ^^^^^^ + | | + | `list.0` is assigned to here but it was already borrowed + | borrow later used here + +error: aborting due to 9 previous errors + +Some errors have detailed explanations: E0499, E0503, E0506. +For more information about an error, try `rustc --explain E0499`. diff --git a/tests/ui/nll/polonius/nll-problem-case-3-issue-58787.rs b/tests/ui/nll/polonius/nll-problem-case-3-issue-58787.rs new file mode 100644 index 00000000000..75552e24219 --- /dev/null +++ b/tests/ui/nll/polonius/nll-problem-case-3-issue-58787.rs @@ -0,0 +1,74 @@ +#![crate_type = "lib"] + +// This is part of a collection of regression tests related to the NLL problem case 3 that was +// deferred from the implementation of the NLL RFC, and left to be implemented by polonius. They are +// from open issues, e.g. tagged fixed-by-polonius, to ensure that the polonius alpha analysis does +// handle them, as does the datalog implementation. + +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: nll polonius legacy +//@ [nll] known-bug: #58787 +//@ [polonius] check-pass +//@ [polonius] compile-flags: -Z polonius=next +//@ [legacy] check-pass +//@ [legacy] compile-flags: -Z polonius=legacy + +struct Node { + rest: List, +} + +struct List(Option<Box<Node>>); + +fn issue_58787(arg: &mut List) { + let mut list = arg; + + match list.0 { + Some(ref mut d) => { + if true { + list = &mut d.rest; + } + } + None => (), + } + + match list.0 { + Some(ref mut d) => { + list = &mut d.rest; + } + None => (), + } + + match list { + List(Some(d)) => { + if true { + list = &mut d.rest; + } + } + List(None) => (), + } + + match list { + List(Some(d)) => { + list = &mut d.rest; + } + List(None) => (), + } + + match &mut list.0 { + Some(d) => { + if true { + list = &mut d.rest; + } + } + None => (), + } + + match &mut list.0 { + Some(d) => { + list = &mut d.rest; + } + None => (), + } + + list.0 = None; +} diff --git a/tests/ui/nll/polonius/nll-problem-case-3-issue-68934.nll.stderr b/tests/ui/nll/polonius/nll-problem-case-3-issue-68934.nll.stderr new file mode 100644 index 00000000000..212355790bf --- /dev/null +++ b/tests/ui/nll/polonius/nll-problem-case-3-issue-68934.nll.stderr @@ -0,0 +1,17 @@ +error[E0505]: cannot move out of value because it is borrowed + --> $DIR/nll-problem-case-3-issue-68934.rs:35:14 + | +LL | fn deep_fetch(&mut self, value: Either<A, B>) -> Result<&mut Self, (&mut Self, Either<A, B>)> { + | - let's call the lifetime of this reference `'1` +LL | match (self, value) { +LL | (Tree::ABranch(ref mut a, ref v), Either::Left(vv)) if v > &vv => { + | --------- borrow of value occurs here +LL | a.deep_fetch(Either::Left(vv)) + | ------------------------------ returning this value requires that borrow lasts for `'1` +... +LL | (this, _v) => Err((this, _v)), + | ^^^^ move out of value occurs here + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0505`. diff --git a/tests/ui/nll/polonius/nll-problem-case-3-issue-68934.rs b/tests/ui/nll/polonius/nll-problem-case-3-issue-68934.rs new file mode 100644 index 00000000000..ba941510116 --- /dev/null +++ b/tests/ui/nll/polonius/nll-problem-case-3-issue-68934.rs @@ -0,0 +1,38 @@ +#![crate_type = "lib"] + +// This is part of a collection of regression tests related to the NLL problem case 3 that was +// deferred from the implementation of the NLL RFC, and left to be implemented by polonius. They are +// from open issues, e.g. tagged fixed-by-polonius, to ensure that the polonius alpha analysis does +// handle them, as does the datalog implementation. + +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: nll polonius legacy +//@ [nll] known-bug: #68934 +//@ [polonius] check-pass +//@ [polonius] compile-flags: -Z polonius=next +//@ [legacy] check-pass +//@ [legacy] compile-flags: -Z polonius=legacy + +enum Either<A, B> { + Left(A), + Right(B), +} + +enum Tree<'a, A, B> { + ALeaf(A), + BLeaf(B), + ABranch(&'a mut Tree<'a, A, B>, A), + BBranch(&'a mut Tree<'a, A, B>, B), +} + +impl<'a, A: PartialOrd, B> Tree<'a, A, B> { + fn deep_fetch(&mut self, value: Either<A, B>) -> Result<&mut Self, (&mut Self, Either<A, B>)> { + match (self, value) { + (Tree::ABranch(ref mut a, ref v), Either::Left(vv)) if v > &vv => { + a.deep_fetch(Either::Left(vv)) + } + + (this, _v) => Err((this, _v)), + } + } +} diff --git a/tests/ui/numbers-arithmetic/overflowing-add.rs b/tests/ui/numbers-arithmetic/overflowing-add.rs index c1f498c802b..a63fc3bccf1 100644 --- a/tests/ui/numbers-arithmetic/overflowing-add.rs +++ b/tests/ui/numbers-arithmetic/overflowing-add.rs @@ -1,6 +1,6 @@ //@ run-fail -//@ error-pattern:thread 'main' panicked -//@ error-pattern:attempt to add with overflow +//@ regex-error-pattern: thread 'main'.*panicked +//@ error-pattern: attempt to add with overflow //@ compile-flags: -C debug-assertions //@ needs-subprocess diff --git a/tests/ui/numbers-arithmetic/overflowing-mul.rs b/tests/ui/numbers-arithmetic/overflowing-mul.rs index 0eece536929..2645a32d5ad 100644 --- a/tests/ui/numbers-arithmetic/overflowing-mul.rs +++ b/tests/ui/numbers-arithmetic/overflowing-mul.rs @@ -1,6 +1,6 @@ //@ run-fail -//@ error-pattern:thread 'main' panicked -//@ error-pattern:attempt to multiply with overflow +//@ regex-error-pattern: thread 'main'.*panicked +//@ error-pattern: attempt to multiply with overflow //@ needs-subprocess //@ compile-flags: -C debug-assertions diff --git a/tests/ui/numbers-arithmetic/overflowing-pow-signed.rs b/tests/ui/numbers-arithmetic/overflowing-pow-signed.rs index 28deb7cf6ba..6db6682e16f 100644 --- a/tests/ui/numbers-arithmetic/overflowing-pow-signed.rs +++ b/tests/ui/numbers-arithmetic/overflowing-pow-signed.rs @@ -1,6 +1,6 @@ //@ run-fail -//@ error-pattern:thread 'main' panicked -//@ error-pattern:attempt to multiply with overflow +//@ regex-error-pattern: thread 'main'.*panicked +//@ error-pattern: attempt to multiply with overflow //@ needs-subprocess //@ compile-flags: -C debug-assertions diff --git a/tests/ui/numbers-arithmetic/overflowing-pow-unsigned.rs b/tests/ui/numbers-arithmetic/overflowing-pow-unsigned.rs index dea9a4d5428..bde0de6f6f5 100644 --- a/tests/ui/numbers-arithmetic/overflowing-pow-unsigned.rs +++ b/tests/ui/numbers-arithmetic/overflowing-pow-unsigned.rs @@ -1,6 +1,6 @@ //@ run-fail -//@ error-pattern:thread 'main' panicked -//@ error-pattern:attempt to multiply with overflow +//@ regex-error-pattern: thread 'main'.*panicked +//@ error-pattern: attempt to multiply with overflow //@ needs-subprocess //@ compile-flags: -C debug-assertions diff --git a/tests/ui/numbers-arithmetic/overflowing-sub.rs b/tests/ui/numbers-arithmetic/overflowing-sub.rs index 88b1b693f63..1718fccad7a 100644 --- a/tests/ui/numbers-arithmetic/overflowing-sub.rs +++ b/tests/ui/numbers-arithmetic/overflowing-sub.rs @@ -1,6 +1,6 @@ //@ run-fail -//@ error-pattern:thread 'main' panicked -//@ error-pattern:attempt to subtract with overflow +//@ regex-error-pattern: thread 'main'.*panicked +//@ error-pattern: attempt to subtract with overflow //@ needs-subprocess //@ compile-flags: -C debug-assertions diff --git a/tests/ui/offset-of/offset-of-tuple-field.stderr b/tests/ui/offset-of/offset-of-tuple-field.stderr index 4da0d851650..01622c5fa2d 100644 --- a/tests/ui/offset-of/offset-of-tuple-field.stderr +++ b/tests/ui/offset-of/offset-of-tuple-field.stderr @@ -15,60 +15,96 @@ error[E0609]: no field `_0` on type `(u8, u8)` | LL | offset_of!((u8, u8), _0); | ^^ + | +help: a field with a similar name exists + | +LL - offset_of!((u8, u8), _0); +LL + offset_of!((u8, u8), 0); + | error[E0609]: no field `01` on type `(u8, u8)` --> $DIR/offset-of-tuple-field.rs:7:26 | LL | offset_of!((u8, u8), 01); | ^^ + | + = note: available fields are: `0`, `1` error[E0609]: no field `1e2` on type `(u8, u8)` --> $DIR/offset-of-tuple-field.rs:8:26 | LL | offset_of!((u8, u8), 1e2); | ^^^ + | + = note: available fields are: `0`, `1` error[E0609]: no field `1_` on type `(u8, u8)` --> $DIR/offset-of-tuple-field.rs:9:26 | LL | offset_of!((u8, u8), 1_u8); | ^^^^ + | +help: a field with a similar name exists + | +LL - offset_of!((u8, u8), 1_u8); +LL + offset_of!((u8, u8), 1); + | error[E0609]: no field `1e2` on type `(u8, u8)` --> $DIR/offset-of-tuple-field.rs:12:35 | LL | builtin # offset_of((u8, u8), 1e2); | ^^^ + | + = note: available fields are: `0`, `1` error[E0609]: no field `_0` on type `(u8, u8)` --> $DIR/offset-of-tuple-field.rs:13:35 | LL | builtin # offset_of((u8, u8), _0); | ^^ + | +help: a field with a similar name exists + | +LL - builtin # offset_of((u8, u8), _0); +LL + builtin # offset_of((u8, u8), 0); + | error[E0609]: no field `01` on type `(u8, u8)` --> $DIR/offset-of-tuple-field.rs:14:35 | LL | builtin # offset_of((u8, u8), 01); | ^^ + | + = note: available fields are: `0`, `1` error[E0609]: no field `1_` on type `(u8, u8)` --> $DIR/offset-of-tuple-field.rs:15:35 | LL | builtin # offset_of((u8, u8), 1_u8); | ^^^^ + | +help: a field with a similar name exists + | +LL - builtin # offset_of((u8, u8), 1_u8); +LL + builtin # offset_of((u8, u8), 1); + | error[E0609]: no field `2` on type `(u8, u16)` --> $DIR/offset-of-tuple-field.rs:18:47 | LL | offset_of!(((u8, u16), (u32, u16, u8)), 0.2); | ^ + | + = note: available fields are: `0`, `1` error[E0609]: no field `1e2` on type `(u8, u16)` --> $DIR/offset-of-tuple-field.rs:19:47 | LL | offset_of!(((u8, u16), (u32, u16, u8)), 0.1e2); | ^^^ + | + = note: available fields are: `0`, `1` error[E0609]: no field `0` on type `u8` --> $DIR/offset-of-tuple-field.rs:21:49 diff --git a/tests/ui/issues/issue-14915.rs b/tests/ui/operator-recovery/box-arithmetic-14915.rs index 127b909dd63..0e6f0762998 100644 --- a/tests/ui/issues/issue-14915.rs +++ b/tests/ui/operator-recovery/box-arithmetic-14915.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/14915 + fn main() { let x: Box<isize> = Box::new(0); diff --git a/tests/ui/issues/issue-14915.stderr b/tests/ui/operator-recovery/box-arithmetic-14915.stderr index 3558bd651c6..1dd80472bb8 100644 --- a/tests/ui/issues/issue-14915.stderr +++ b/tests/ui/operator-recovery/box-arithmetic-14915.stderr @@ -1,5 +1,5 @@ error[E0369]: cannot add `{integer}` to `Box<isize>` - --> $DIR/issue-14915.rs:4:22 + --> $DIR/box-arithmetic-14915.rs:6:22 | LL | println!("{}", x + 1); | - ^ - {integer} diff --git a/tests/ui/or-patterns/issue-64879-trailing-before-guard.fixed b/tests/ui/or-patterns/issue-64879-trailing-before-guard.fixed new file mode 100644 index 00000000000..0c65f709d66 --- /dev/null +++ b/tests/ui/or-patterns/issue-64879-trailing-before-guard.fixed @@ -0,0 +1,18 @@ +// In this regression test we check that a trailing `|` in an or-pattern just +// before the `if` token of a `match` guard will receive parser recovery with +// an appropriate error message. +//@ run-rustfix +#![allow(dead_code)] + +enum E { A, B } + +fn main() { + match E::A { + E::A | + E::B //~ ERROR a trailing `|` is not allowed in an or-pattern + if true => { + let _recovery_witness: i32 = 0i32; //~ ERROR mismatched types + } + _ => {} + } +} diff --git a/tests/ui/or-patterns/issue-64879-trailing-before-guard.rs b/tests/ui/or-patterns/issue-64879-trailing-before-guard.rs index 181c770096a..d7da564c2e1 100644 --- a/tests/ui/or-patterns/issue-64879-trailing-before-guard.rs +++ b/tests/ui/or-patterns/issue-64879-trailing-before-guard.rs @@ -1,6 +1,8 @@ // In this regression test we check that a trailing `|` in an or-pattern just // before the `if` token of a `match` guard will receive parser recovery with // an appropriate error message. +//@ run-rustfix +#![allow(dead_code)] enum E { A, B } @@ -9,7 +11,8 @@ fn main() { E::A | E::B | //~ ERROR a trailing `|` is not allowed in an or-pattern if true => { - let recovery_witness: bool = 0; //~ ERROR mismatched types + let _recovery_witness: i32 = 0u32; //~ ERROR mismatched types } + _ => {} } } diff --git a/tests/ui/or-patterns/issue-64879-trailing-before-guard.stderr b/tests/ui/or-patterns/issue-64879-trailing-before-guard.stderr index 91db3d049f6..238c76080dc 100644 --- a/tests/ui/or-patterns/issue-64879-trailing-before-guard.stderr +++ b/tests/ui/or-patterns/issue-64879-trailing-before-guard.stderr @@ -1,24 +1,24 @@ error: a trailing `|` is not allowed in an or-pattern - --> $DIR/issue-64879-trailing-before-guard.rs:10:14 + --> $DIR/issue-64879-trailing-before-guard.rs:12:14 | LL | E::A | | ---- while parsing this or-pattern starting here LL | E::B | | ^ + +error[E0308]: mismatched types + --> $DIR/issue-64879-trailing-before-guard.rs:14:42 | -help: remove the `|` +LL | let _recovery_witness: i32 = 0u32; + | --- ^^^^ expected `i32`, found `u32` + | | + | expected due to this | -LL - E::B | -LL + E::B +help: change the type of the numeric literal from `u32` to `i32` | - -error[E0308]: mismatched types - --> $DIR/issue-64879-trailing-before-guard.rs:12:42 +LL - let _recovery_witness: i32 = 0u32; +LL + let _recovery_witness: i32 = 0i32; | -LL | let recovery_witness: bool = 0; - | ---- ^ expected `bool`, found integer - | | - | expected due to this error: aborting due to 2 previous errors diff --git a/tests/ui/or-patterns/remove-leading-vert.fixed b/tests/ui/or-patterns/remove-leading-vert.fixed index 2851b8f18c5..aa7975dc508 100644 --- a/tests/ui/or-patterns/remove-leading-vert.fixed +++ b/tests/ui/or-patterns/remove-leading-vert.fixed @@ -23,26 +23,26 @@ fn leading() { #[cfg(false)] fn trailing() { - let ( A ): E; //~ ERROR a trailing `|` is not allowed in an or-pattern - let (a ,): (E,); //~ ERROR a trailing `|` is not allowed in an or-pattern - let ( A | B ): E; //~ ERROR a trailing `|` is not allowed in an or-pattern - let [ A | B ]: [E; 1]; //~ ERROR a trailing `|` is not allowed in an or-pattern - let S { f: B }; //~ ERROR a trailing `|` is not allowed in an or-pattern - let ( A | B ): E; //~ ERROR unexpected token `||` in pattern + let ( A ): E; //~ ERROR a trailing `|` is not allowed in an or-pattern + let (a,): (E,); //~ ERROR a trailing `|` is not allowed in an or-pattern + let ( A | B ): E; //~ ERROR a trailing `|` is not allowed in an or-pattern + let [ A | B ]: [E; 1]; //~ ERROR a trailing `|` is not allowed in an or-pattern + let S { f: B }; //~ ERROR a trailing `|` is not allowed in an or-pattern + let ( A | B ): E; //~ ERROR unexpected token `||` in pattern //~^ ERROR a trailing `|` is not allowed in an or-pattern match A { - A => {} //~ ERROR a trailing `|` is not allowed in an or-pattern - A => {} //~ ERROR a trailing `|` is not allowed in an or-pattern - A | B => {} //~ ERROR unexpected token `||` in pattern + A => {} //~ ERROR a trailing `|` is not allowed in an or-pattern + A => {} //~ ERROR a trailing `||` is not allowed in an or-pattern + A | B => {} //~ ERROR unexpected token `||` in pattern //~^ ERROR a trailing `|` is not allowed in an or-pattern - | A | B => {} + | A | B => {} //~^ ERROR a trailing `|` is not allowed in an or-pattern } // These test trailing-vert in `let` bindings, but they also test that we don't emit a // duplicate suggestion that would confuse rustfix. - let a : u8 = 0; //~ ERROR a trailing `|` is not allowed in an or-pattern - let a = 0; //~ ERROR a trailing `|` is not allowed in an or-pattern - let a ; //~ ERROR a trailing `|` is not allowed in an or-pattern + let a : u8 = 0; //~ ERROR a trailing `|` is not allowed in an or-pattern + let a = 0; //~ ERROR a trailing `|` is not allowed in an or-pattern + let a ; //~ ERROR a trailing `|` is not allowed in an or-pattern } diff --git a/tests/ui/or-patterns/remove-leading-vert.rs b/tests/ui/or-patterns/remove-leading-vert.rs index 1e1dbfbc6e6..1b4eb669fbb 100644 --- a/tests/ui/or-patterns/remove-leading-vert.rs +++ b/tests/ui/or-patterns/remove-leading-vert.rs @@ -32,7 +32,7 @@ fn trailing() { //~^ ERROR a trailing `|` is not allowed in an or-pattern match A { A | => {} //~ ERROR a trailing `|` is not allowed in an or-pattern - A || => {} //~ ERROR a trailing `|` is not allowed in an or-pattern + A || => {} //~ ERROR a trailing `||` is not allowed in an or-pattern A || B | => {} //~ ERROR unexpected token `||` in pattern //~^ ERROR a trailing `|` is not allowed in an or-pattern | A | B | => {} diff --git a/tests/ui/or-patterns/remove-leading-vert.stderr b/tests/ui/or-patterns/remove-leading-vert.stderr index 0323c64f042..29450153ba4 100644 --- a/tests/ui/or-patterns/remove-leading-vert.stderr +++ b/tests/ui/or-patterns/remove-leading-vert.stderr @@ -3,12 +3,6 @@ error: function parameters require top-level or-patterns in parentheses | LL | fn fun1( | A: E) {} | ^^^ - | -help: remove the `|` - | -LL - fn fun1( | A: E) {} -LL + fn fun1( A: E) {} - | error: unexpected `||` before function parameter --> $DIR/remove-leading-vert.rs:12:14 @@ -78,12 +72,6 @@ LL | let ( A | ): E; | - ^ | | | while parsing this or-pattern starting here - | -help: remove the `|` - | -LL - let ( A | ): E; -LL + let ( A ): E; - | error: a trailing `|` is not allowed in an or-pattern --> $DIR/remove-leading-vert.rs:27:12 @@ -92,12 +80,6 @@ LL | let (a |,): (E,); | - ^ | | | while parsing this or-pattern starting here - | -help: remove the `|` - | -LL - let (a |,): (E,); -LL + let (a ,): (E,); - | error: a trailing `|` is not allowed in an or-pattern --> $DIR/remove-leading-vert.rs:28:17 @@ -106,12 +88,6 @@ LL | let ( A | B | ): E; | - ^ | | | while parsing this or-pattern starting here - | -help: remove the `|` - | -LL - let ( A | B | ): E; -LL + let ( A | B ): E; - | error: a trailing `|` is not allowed in an or-pattern --> $DIR/remove-leading-vert.rs:29:17 @@ -120,12 +96,6 @@ LL | let [ A | B | ]: [E; 1]; | - ^ | | | while parsing this or-pattern starting here - | -help: remove the `|` - | -LL - let [ A | B | ]: [E; 1]; -LL + let [ A | B ]: [E; 1]; - | error: a trailing `|` is not allowed in an or-pattern --> $DIR/remove-leading-vert.rs:30:18 @@ -134,12 +104,6 @@ LL | let S { f: B | }; | - ^ | | | while parsing this or-pattern starting here - | -help: remove the `|` - | -LL - let S { f: B | }; -LL + let S { f: B }; - | error: unexpected token `||` in pattern --> $DIR/remove-leading-vert.rs:31:13 @@ -162,12 +126,6 @@ LL | let ( A || B | ): E; | - ^ | | | while parsing this or-pattern starting here - | -help: remove the `|` - | -LL - let ( A || B | ): E; -LL + let ( A || B ): E; - | error: a trailing `|` is not allowed in an or-pattern --> $DIR/remove-leading-vert.rs:34:11 @@ -176,14 +134,8 @@ LL | A | => {} | - ^ | | | while parsing this or-pattern starting here - | -help: remove the `|` - | -LL - A | => {} -LL + A => {} - | -error: a trailing `|` is not allowed in an or-pattern +error: a trailing `||` is not allowed in an or-pattern --> $DIR/remove-leading-vert.rs:35:11 | LL | A || => {} @@ -192,11 +144,6 @@ LL | A || => {} | while parsing this or-pattern starting here | = note: alternatives in or-patterns are separated with `|`, not `||` -help: remove the `||` - | -LL - A || => {} -LL + A => {} - | error: unexpected token `||` in pattern --> $DIR/remove-leading-vert.rs:36:11 @@ -219,12 +166,6 @@ LL | A || B | => {} | - ^ | | | while parsing this or-pattern starting here - | -help: remove the `|` - | -LL - A || B | => {} -LL + A || B => {} - | error: a trailing `|` is not allowed in an or-pattern --> $DIR/remove-leading-vert.rs:38:17 @@ -233,12 +174,6 @@ LL | | A | B | => {} | - ^ | | | while parsing this or-pattern starting here - | -help: remove the `|` - | -LL - | A | B | => {} -LL + | A | B => {} - | error: a trailing `|` is not allowed in an or-pattern --> $DIR/remove-leading-vert.rs:45:11 @@ -247,12 +182,6 @@ LL | let a | : u8 = 0; | - ^ | | | while parsing this or-pattern starting here - | -help: remove the `|` - | -LL - let a | : u8 = 0; -LL + let a : u8 = 0; - | error: a trailing `|` is not allowed in an or-pattern --> $DIR/remove-leading-vert.rs:46:11 @@ -261,12 +190,6 @@ LL | let a | = 0; | - ^ | | | while parsing this or-pattern starting here - | -help: remove the `|` - | -LL - let a | = 0; -LL + let a = 0; - | error: a trailing `|` is not allowed in an or-pattern --> $DIR/remove-leading-vert.rs:47:11 @@ -275,12 +198,6 @@ LL | let a | ; | - ^ | | | while parsing this or-pattern starting here - | -help: remove the `|` - | -LL - let a | ; -LL + let a ; - | error: aborting due to 21 previous errors diff --git a/tests/ui/issues/issue-99838.rs b/tests/ui/packed/misaligned-reference-drop-field-99838.rs index 687b47fbe71..58e168162cb 100644 --- a/tests/ui/issues/issue-99838.rs +++ b/tests/ui/packed/misaligned-reference-drop-field-99838.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/99838 //@ run-pass use std::hint; diff --git a/tests/ui/panic-handler/panic-handler-wrong-location.stderr b/tests/ui/panic-handler/panic-handler-wrong-location.stderr index 66ee91aa4c1..9b361bf8d60 100644 --- a/tests/ui/panic-handler/panic-handler-wrong-location.stderr +++ b/tests/ui/panic-handler/panic-handler-wrong-location.stderr @@ -2,7 +2,7 @@ error[E0718]: `panic_impl` lang item must be applied to a function --> $DIR/panic-handler-wrong-location.rs:6:1 | LL | #[panic_handler] - | ^^^^^^^^^^^^^^^^ attribute should be applied to a function, not a static item + | ^^^^^^^^^^^^^^^^ attribute should be applied to a function, not a static error: `#[panic_handler]` function required, but not found diff --git a/tests/ui/panics/fmt-only-once.run.stderr b/tests/ui/panics/fmt-only-once.run.stderr index faa3cc91151..f0124e4cb77 100644 --- a/tests/ui/panics/fmt-only-once.run.stderr +++ b/tests/ui/panics/fmt-only-once.run.stderr @@ -1,5 +1,5 @@ fmt -thread 'main' panicked at $DIR/fmt-only-once.rs:20:5: +thread 'main' ($TID) panicked at $DIR/fmt-only-once.rs:20:5: PrintOnFmt note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/panics/issue-47429-short-backtraces.run.stderr b/tests/ui/panics/issue-47429-short-backtraces.run.stderr index 32dc6592271..13b59a7c7af 100644 --- a/tests/ui/panics/issue-47429-short-backtraces.run.stderr +++ b/tests/ui/panics/issue-47429-short-backtraces.run.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at $DIR/issue-47429-short-backtraces.rs:24:5: +thread 'main' ($TID) panicked at $DIR/issue-47429-short-backtraces.rs:24:5: explicit panic stack backtrace: 0: std::panicking::begin_panic diff --git a/tests/ui/panics/location-detail-panic-no-column.run.stderr b/tests/ui/panics/location-detail-panic-no-column.run.stderr index f63c09652b8..8f43936a0af 100644 --- a/tests/ui/panics/location-detail-panic-no-column.run.stderr +++ b/tests/ui/panics/location-detail-panic-no-column.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at $DIR/location-detail-panic-no-column.rs:7:0: +thread 'main' ($TID) panicked at $DIR/location-detail-panic-no-column.rs:7:0: column-redacted note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/panics/location-detail-panic-no-file.run.stderr b/tests/ui/panics/location-detail-panic-no-file.run.stderr index 3d1c6defa31..8d0ee148006 100644 --- a/tests/ui/panics/location-detail-panic-no-file.run.stderr +++ b/tests/ui/panics/location-detail-panic-no-file.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at <redacted>:7:5: +thread 'main' ($TID) panicked at <redacted>:7:5: file-redacted note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/panics/location-detail-panic-no-line.run.stderr b/tests/ui/panics/location-detail-panic-no-line.run.stderr index 9809ab5e2b4..79f5c012b8a 100644 --- a/tests/ui/panics/location-detail-panic-no-line.run.stderr +++ b/tests/ui/panics/location-detail-panic-no-line.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at $DIR/location-detail-panic-no-line.rs:0:5: +thread 'main' ($TID) panicked at $DIR/location-detail-panic-no-line.rs:0:5: line-redacted note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/panics/location-detail-panic-no-location-info.run.stderr b/tests/ui/panics/location-detail-panic-no-location-info.run.stderr index f68a0d663c0..12b3e1b53e3 100644 --- a/tests/ui/panics/location-detail-panic-no-location-info.run.stderr +++ b/tests/ui/panics/location-detail-panic-no-location-info.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at <redacted>:0:0: +thread 'main' ($TID) panicked at <redacted>:0:0: no location info note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/panics/location-detail-unwrap-no-file.run.stderr b/tests/ui/panics/location-detail-unwrap-no-file.run.stderr index af4a4997fae..a4a87423cdc 100644 --- a/tests/ui/panics/location-detail-unwrap-no-file.run.stderr +++ b/tests/ui/panics/location-detail-unwrap-no-file.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at <redacted>:8:9: +thread 'main' ($TID) panicked at <redacted>:8:9: called `Option::unwrap()` on a `None` value note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/panics/main-panic.rs b/tests/ui/panics/main-panic.rs index 0b3d5c3aaec..9f2a92da90f 100644 --- a/tests/ui/panics/main-panic.rs +++ b/tests/ui/panics/main-panic.rs @@ -1,5 +1,5 @@ //@ run-fail -//@ error-pattern:thread 'main' panicked at +//@ regex-error-pattern: thread 'main' \(\d+\) panicked at //@ needs-subprocess fn main() { diff --git a/tests/ui/panics/panic-in-cleanup.run.stderr b/tests/ui/panics/panic-in-cleanup.run.stderr index 34383562c36..bfe3dc8c9d7 100644 --- a/tests/ui/panics/panic-in-cleanup.run.stderr +++ b/tests/ui/panics/panic-in-cleanup.run.stderr @@ -1,12 +1,12 @@ -thread 'main' panicked at $DIR/panic-in-cleanup.rs:22:5: +thread 'main' ($TID) panicked at $DIR/panic-in-cleanup.rs:22:5: explicit panic note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread 'main' panicked at $DIR/panic-in-cleanup.rs:16:9: +thread 'main' ($TID) panicked at $DIR/panic-in-cleanup.rs:16:9: BOOM stack backtrace: -thread 'main' panicked at library/core/src/panicking.rs:$LINE:$COL: +thread 'main' ($TID) panicked at library/core/src/panicking.rs:$LINE:$COL: panic in a destructor during cleanup thread caused non-unwinding panic. aborting. diff --git a/tests/ui/panics/panic-in-ffi.run.stderr b/tests/ui/panics/panic-in-ffi.run.stderr index a6f3ebe5657..ce907d64358 100644 --- a/tests/ui/panics/panic-in-ffi.run.stderr +++ b/tests/ui/panics/panic-in-ffi.run.stderr @@ -1,10 +1,10 @@ -thread 'main' panicked at $DIR/panic-in-ffi.rs:21:5: +thread 'main' ($TID) panicked at $DIR/panic-in-ffi.rs:21:5: Test note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace Noisy Drop -thread 'main' panicked at library/core/src/panicking.rs:$LINE:$COL: +thread 'main' ($TID) panicked at library/core/src/panicking.rs:$LINE:$COL: panic in a function that cannot unwind stack backtrace: thread caused non-unwinding panic. aborting. diff --git a/tests/ui/panics/panic-set-unset-handler.rs b/tests/ui/panics/panic-set-unset-handler.rs index 66d5003d0f1..4f646020037 100644 --- a/tests/ui/panics/panic-set-unset-handler.rs +++ b/tests/ui/panics/panic-set-unset-handler.rs @@ -1,6 +1,6 @@ //@ run-fail -//@ error-pattern:thread 'main' panicked -//@ error-pattern:foobar +//@ regex-error-pattern: thread 'main' \(\d+\) panicked +//@ error-pattern: foobar //@ needs-subprocess use std::panic; diff --git a/tests/ui/panics/panic-short-backtrace-windows-x86_64.run.stderr b/tests/ui/panics/panic-short-backtrace-windows-x86_64.run.stderr index 799a8b30e99..c3c1ce16a4b 100644 --- a/tests/ui/panics/panic-short-backtrace-windows-x86_64.run.stderr +++ b/tests/ui/panics/panic-short-backtrace-windows-x86_64.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at 'd was called', $DIR/panic-short-backtrace-windows-x86_64.rs:48:5 +thread 'main' ($TID) panicked at 'd was called', $DIR/panic-short-backtrace-windows-x86_64.rs:48:5 stack backtrace: 0: std::panicking::begin_panic 1: d diff --git a/tests/ui/panics/panic-take-handler-nop.rs b/tests/ui/panics/panic-take-handler-nop.rs index f10582872df..ebea3ef0685 100644 --- a/tests/ui/panics/panic-take-handler-nop.rs +++ b/tests/ui/panics/panic-take-handler-nop.rs @@ -1,6 +1,6 @@ //@ run-fail -//@ error-pattern:thread 'main' panicked -//@ error-pattern:foobar +//@ regex-error-pattern: thread 'main' \(\d+\) panicked +//@ error-pattern: foobar //@ needs-subprocess use std::panic; diff --git a/tests/ui/panics/panic-task-name-none.rs b/tests/ui/panics/panic-task-name-none.rs index 8695771ff5e..4471cd6795c 100644 --- a/tests/ui/panics/panic-task-name-none.rs +++ b/tests/ui/panics/panic-task-name-none.rs @@ -1,14 +1,14 @@ //@ run-fail -//@ error-pattern:thread '<unnamed>' panicked -//@ error-pattern:test +//@ regex-error-pattern: thread '<unnamed>' \(\d+\) panicked +//@ error-pattern: test //@ needs-threads use std::thread; fn main() { let r: Result<(), _> = thread::spawn(move || { - panic!("test"); - }) - .join(); + panic!("test"); + }) + .join(); assert!(r.is_ok()); } diff --git a/tests/ui/panics/panic-task-name-owned.rs b/tests/ui/panics/panic-task-name-owned.rs index 42ae33b5d35..084ac90512a 100644 --- a/tests/ui/panics/panic-task-name-owned.rs +++ b/tests/ui/panics/panic-task-name-owned.rs @@ -1,19 +1,19 @@ //@ run-fail -//@ error-pattern:thread 'owned name' panicked -//@ error-pattern:test +//@ regex-error-pattern: thread 'owned name' \(\d+\) panicked +//@ error-pattern: test //@ needs-threads use std::thread::Builder; fn main() { let r: () = Builder::new() - .name("owned name".to_string()) - .spawn(move || { - panic!("test"); - () - }) - .unwrap() - .join() - .unwrap(); + .name("owned name".to_string()) + .spawn(move || { + panic!("test"); + () + }) + .unwrap() + .join() + .unwrap(); panic!(); } diff --git a/tests/ui/panics/runtime-switch.run.stderr b/tests/ui/panics/runtime-switch.run.stderr index 70ed127af86..f3f60445952 100644 --- a/tests/ui/panics/runtime-switch.run.stderr +++ b/tests/ui/panics/runtime-switch.run.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at $DIR/runtime-switch.rs:28:5: +thread 'main' ($TID) panicked at $DIR/runtime-switch.rs:28:5: explicit panic stack backtrace: 0: std::panicking::begin_panic diff --git a/tests/ui/panics/short-ice-remove-middle-frames-2.run.stderr b/tests/ui/panics/short-ice-remove-middle-frames-2.run.stderr index 664d51e185d..584b477f3a7 100644 --- a/tests/ui/panics/short-ice-remove-middle-frames-2.run.stderr +++ b/tests/ui/panics/short-ice-remove-middle-frames-2.run.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at $DIR/short-ice-remove-middle-frames-2.rs:62:5: +thread 'main' ($TID) panicked at $DIR/short-ice-remove-middle-frames-2.rs:62:5: debug!!! stack backtrace: 0: std::panicking::begin_panic diff --git a/tests/ui/panics/short-ice-remove-middle-frames.run.stderr b/tests/ui/panics/short-ice-remove-middle-frames.run.stderr index e966462331f..1efcb7d5304 100644 --- a/tests/ui/panics/short-ice-remove-middle-frames.run.stderr +++ b/tests/ui/panics/short-ice-remove-middle-frames.run.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at $DIR/short-ice-remove-middle-frames.rs:58:5: +thread 'main' ($TID) panicked at $DIR/short-ice-remove-middle-frames.rs:58:5: debug!!! stack backtrace: 0: std::panicking::begin_panic diff --git a/tests/ui/parser/bad-lit-suffixes.stderr b/tests/ui/parser/bad-lit-suffixes.stderr index 7876d75c5a4..9a51cf70960 100644 --- a/tests/ui/parser/bad-lit-suffixes.stderr +++ b/tests/ui/parser/bad-lit-suffixes.stderr @@ -158,6 +158,7 @@ LL | #[must_use = "string"suffix] | | | expected a string literal here | + = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-must_use-attribute> help: try changing it to one of the following valid forms of the attribute | LL - #[must_use = "string"suffix] diff --git a/tests/ui/parser/default-on-wrong-item-kind.rs b/tests/ui/parser/default-on-wrong-item-kind.rs index da990a4b421..9de85640565 100644 --- a/tests/ui/parser/default-on-wrong-item-kind.rs +++ b/tests/ui/parser/default-on-wrong-item-kind.rs @@ -19,7 +19,7 @@ mod free_items { default union foo {} //~ ERROR a union cannot be `default` default trait foo {} //~ ERROR a trait cannot be `default` default trait foo = Ord; //~ ERROR a trait alias cannot be `default` - default impl foo {} + default impl foo {} //~ ERROR inherent impls cannot be default default!(); default::foo::bar!(); default default!(); //~ ERROR an item macro invocation cannot be `default` @@ -53,7 +53,7 @@ extern "C" { //~^ ERROR trait is not supported in `extern` blocks default trait foo = Ord; //~ ERROR a trait alias cannot be `default` //~^ ERROR trait alias is not supported in `extern` blocks - default impl foo {} + default impl foo {} //~ ERROR inherent impls cannot be default //~^ ERROR implementation is not supported in `extern` blocks default!(); default::foo::bar!(); @@ -90,7 +90,7 @@ impl S { //~^ ERROR trait is not supported in `trait`s or `impl`s default trait foo = Ord; //~ ERROR a trait alias cannot be `default` //~^ ERROR trait alias is not supported in `trait`s or `impl`s - default impl foo {} + default impl foo {} //~ ERROR inherent impls cannot be default //~^ ERROR implementation is not supported in `trait`s or `impl`s default!(); default::foo::bar!(); @@ -127,7 +127,7 @@ trait T { //~^ ERROR trait is not supported in `trait`s or `impl`s default trait foo = Ord; //~ ERROR a trait alias cannot be `default` //~^ ERROR trait alias is not supported in `trait`s or `impl`s - default impl foo {} + default impl foo {} //~ ERROR inherent impls cannot be default //~^ ERROR implementation is not supported in `trait`s or `impl`s default!(); default::foo::bar!(); diff --git a/tests/ui/parser/default-on-wrong-item-kind.stderr b/tests/ui/parser/default-on-wrong-item-kind.stderr index 56641565b16..0380fcdf775 100644 --- a/tests/ui/parser/default-on-wrong-item-kind.stderr +++ b/tests/ui/parser/default-on-wrong-item-kind.stderr @@ -78,6 +78,16 @@ LL | default trait foo = Ord; | = note: only associated `fn`, `const`, and `type` items can be `default` +error: inherent impls cannot be default + --> $DIR/default-on-wrong-item-kind.rs:22:18 + | +LL | default impl foo {} + | ------- ^^^ inherent impl for this type + | | + | default because of this + | + = note: only trait implementations may be annotated with `default` + error: an item macro invocation cannot be `default` --> $DIR/default-on-wrong-item-kind.rs:25:5 | @@ -275,6 +285,16 @@ LL | default trait foo = Ord; | = help: consider moving the trait alias out to a nearby module scope +error: inherent impls cannot be default + --> $DIR/default-on-wrong-item-kind.rs:56:18 + | +LL | default impl foo {} + | ------- ^^^ inherent impl for this type + | | + | default because of this + | + = note: only trait implementations may be annotated with `default` + error: implementation is not supported in `extern` blocks --> $DIR/default-on-wrong-item-kind.rs:56:5 | @@ -489,6 +509,16 @@ LL | default trait foo = Ord; | = help: consider moving the trait alias out to a nearby module scope +error: inherent impls cannot be default + --> $DIR/default-on-wrong-item-kind.rs:93:18 + | +LL | default impl foo {} + | ------- ^^^ inherent impl for this type + | | + | default because of this + | + = note: only trait implementations may be annotated with `default` + error: implementation is not supported in `trait`s or `impl`s --> $DIR/default-on-wrong-item-kind.rs:93:5 | @@ -703,6 +733,16 @@ LL | default trait foo = Ord; | = help: consider moving the trait alias out to a nearby module scope +error: inherent impls cannot be default + --> $DIR/default-on-wrong-item-kind.rs:130:18 + | +LL | default impl foo {} + | ------- ^^^ inherent impl for this type + | | + | default because of this + | + = note: only trait implementations may be annotated with `default` + error: implementation is not supported in `trait`s or `impl`s --> $DIR/default-on-wrong-item-kind.rs:130:5 | @@ -759,5 +799,5 @@ LL | default macro_rules! foo {} | = help: consider moving the macro definition out to a nearby module scope -error: aborting due to 95 previous errors +error: aborting due to 99 previous errors diff --git a/tests/ui/parser/float-field.stderr b/tests/ui/parser/float-field.stderr index 0cc1b0767dc..078d16a4117 100644 --- a/tests/ui/parser/float-field.stderr +++ b/tests/ui/parser/float-field.stderr @@ -305,6 +305,8 @@ error[E0609]: no field `1e1` on type `(u8, u8)` | LL | { s.1.1e1; } | ^^^ unknown field + | + = note: available fields are: `0`, `1` error[E0609]: no field `0x1e1` on type `S` --> $DIR/float-field.rs:34:9 @@ -343,12 +345,16 @@ error[E0609]: no field `f32` on type `(u8, u8)` | LL | { s.1.f32; } | ^^^ unknown field + | + = note: available fields are: `0`, `1` error[E0609]: no field `1e1` on type `(u8, u8)` --> $DIR/float-field.rs:71:9 | LL | { s.1.1e1f32; } | ^^^^^^^^ unknown field + | + = note: available fields are: `0`, `1` error: aborting due to 57 previous errors diff --git a/tests/ui/issues/issue-15043.rs b/tests/ui/parser/generics-rangle-eq-15043.rs index a9bb46b649b..1afc334dfd8 100644 --- a/tests/ui/issues/issue-15043.rs +++ b/tests/ui/parser/generics-rangle-eq-15043.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15043 + //@ run-pass #![allow(warnings)] diff --git a/tests/ui/parser/macro/macro-attr-bad.rs b/tests/ui/parser/macro/macro-attr-bad.rs new file mode 100644 index 00000000000..4313a4d04ab --- /dev/null +++ b/tests/ui/parser/macro/macro-attr-bad.rs @@ -0,0 +1,32 @@ +#![crate_type = "lib"] +#![feature(macro_attr)] + +macro_rules! attr_incomplete_1 { attr } +//~^ ERROR macro definition ended unexpectedly + +macro_rules! attr_incomplete_2 { attr() } +//~^ ERROR macro definition ended unexpectedly + +macro_rules! attr_incomplete_3 { attr() {} } +//~^ ERROR expected `=>` + +macro_rules! attr_incomplete_4 { attr() {} => } +//~^ ERROR macro definition ended unexpectedly + +macro_rules! attr_noparens_1 { attr{} {} => {} } +//~^ ERROR macro attribute argument matchers require parentheses + +macro_rules! attr_noparens_2 { attr[] {} => {} } +//~^ ERROR macro attribute argument matchers require parentheses + +macro_rules! attr_noparens_3 { attr _ {} => {} } +//~^ ERROR invalid macro matcher + +macro_rules! attr_dup_matcher_1 { attr() {$x:ident $x:ident} => {} } +//~^ ERROR duplicate matcher binding + +macro_rules! attr_dup_matcher_2 { attr($x:ident $x:ident) {} => {} } +//~^ ERROR duplicate matcher binding + +macro_rules! attr_dup_matcher_3 { attr($x:ident) {$x:ident} => {} } +//~^ ERROR duplicate matcher binding diff --git a/tests/ui/parser/macro/macro-attr-bad.stderr b/tests/ui/parser/macro/macro-attr-bad.stderr new file mode 100644 index 00000000000..4d286b66649 --- /dev/null +++ b/tests/ui/parser/macro/macro-attr-bad.stderr @@ -0,0 +1,80 @@ +error: macro definition ended unexpectedly + --> $DIR/macro-attr-bad.rs:4:38 + | +LL | macro_rules! attr_incomplete_1 { attr } + | ^ expected macro attr args + +error: macro definition ended unexpectedly + --> $DIR/macro-attr-bad.rs:7:40 + | +LL | macro_rules! attr_incomplete_2 { attr() } + | ^ expected macro attr body + +error: expected `=>`, found end of macro arguments + --> $DIR/macro-attr-bad.rs:10:43 + | +LL | macro_rules! attr_incomplete_3 { attr() {} } + | ^ expected `=>` + +error: macro definition ended unexpectedly + --> $DIR/macro-attr-bad.rs:13:46 + | +LL | macro_rules! attr_incomplete_4 { attr() {} => } + | ^ expected right-hand side of macro rule + +error: macro attribute argument matchers require parentheses + --> $DIR/macro-attr-bad.rs:16:36 + | +LL | macro_rules! attr_noparens_1 { attr{} {} => {} } + | ^^ + | +help: the delimiters should be `(` and `)` + | +LL - macro_rules! attr_noparens_1 { attr{} {} => {} } +LL + macro_rules! attr_noparens_1 { attr() {} => {} } + | + +error: macro attribute argument matchers require parentheses + --> $DIR/macro-attr-bad.rs:19:36 + | +LL | macro_rules! attr_noparens_2 { attr[] {} => {} } + | ^^ + | +help: the delimiters should be `(` and `)` + | +LL - macro_rules! attr_noparens_2 { attr[] {} => {} } +LL + macro_rules! attr_noparens_2 { attr() {} => {} } + | + +error: invalid macro matcher; matchers must be contained in balanced delimiters + --> $DIR/macro-attr-bad.rs:22:37 + | +LL | macro_rules! attr_noparens_3 { attr _ {} => {} } + | ^ + +error: duplicate matcher binding + --> $DIR/macro-attr-bad.rs:25:52 + | +LL | macro_rules! attr_dup_matcher_1 { attr() {$x:ident $x:ident} => {} } + | -------- ^^^^^^^^ duplicate binding + | | + | previous binding + +error: duplicate matcher binding + --> $DIR/macro-attr-bad.rs:28:49 + | +LL | macro_rules! attr_dup_matcher_2 { attr($x:ident $x:ident) {} => {} } + | -------- ^^^^^^^^ duplicate binding + | | + | previous binding + +error: duplicate matcher binding + --> $DIR/macro-attr-bad.rs:31:51 + | +LL | macro_rules! attr_dup_matcher_3 { attr($x:ident) {$x:ident} => {} } + | -------- ^^^^^^^^ duplicate binding + | | + | previous binding + +error: aborting due to 10 previous errors + diff --git a/tests/ui/parser/macro/macro-attr-recovery.rs b/tests/ui/parser/macro/macro-attr-recovery.rs new file mode 100644 index 00000000000..dbb795f57aa --- /dev/null +++ b/tests/ui/parser/macro/macro-attr-recovery.rs @@ -0,0 +1,19 @@ +#![crate_type = "lib"] +#![feature(macro_attr)] + +macro_rules! attr { + attr[$($args:tt)*] { $($body:tt)* } => { + //~^ ERROR: macro attribute argument matchers require parentheses + //~v ERROR: attr: + compile_error!(concat!( + "attr: args=\"", + stringify!($($args)*), + "\" body=\"", + stringify!($($body)*), + "\"", + )); + }; +} + +#[attr] +struct S; diff --git a/tests/ui/parser/macro/macro-attr-recovery.stderr b/tests/ui/parser/macro/macro-attr-recovery.stderr new file mode 100644 index 00000000000..ab3a0b7c607 --- /dev/null +++ b/tests/ui/parser/macro/macro-attr-recovery.stderr @@ -0,0 +1,31 @@ +error: macro attribute argument matchers require parentheses + --> $DIR/macro-attr-recovery.rs:5:9 + | +LL | attr[$($args:tt)*] { $($body:tt)* } => { + | ^^^^^^^^^^^^^^ + | +help: the delimiters should be `(` and `)` + | +LL - attr[$($args:tt)*] { $($body:tt)* } => { +LL + attr($($args:tt)*) { $($body:tt)* } => { + | + +error: attr: args="" body="struct S;" + --> $DIR/macro-attr-recovery.rs:8:9 + | +LL | / compile_error!(concat!( +LL | | "attr: args=\"", +LL | | stringify!($($args)*), +LL | | "\" body=\"", +LL | | stringify!($($body)*), +LL | | "\"", +LL | | )); + | |__________^ +... +LL | #[attr] + | ------- in this attribute macro expansion + | + = note: this error originates in the attribute macro `attr` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors + diff --git a/tests/ui/issues/issue-13482.rs b/tests/ui/pattern/array-length-mismatch-13482.rs index 244b3237e02..78d024e5227 100644 --- a/tests/ui/issues/issue-13482.rs +++ b/tests/ui/pattern/array-length-mismatch-13482.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13482 + fn main() { let x = [1,2]; let y = match x { diff --git a/tests/ui/issues/issue-13482.stderr b/tests/ui/pattern/array-length-mismatch-13482.stderr index 6226c580811..d366e010927 100644 --- a/tests/ui/issues/issue-13482.stderr +++ b/tests/ui/pattern/array-length-mismatch-13482.stderr @@ -1,5 +1,5 @@ error[E0527]: pattern requires 0 elements but array has 2 - --> $DIR/issue-13482.rs:4:5 + --> $DIR/array-length-mismatch-13482.rs:6:5 | LL | [] => None, | ^^ expected 2 elements diff --git a/tests/ui/issues/issue-13482-2.rs b/tests/ui/pattern/array-length-mismatch-verbose-13482.rs index 619e9d748ef..619e9d748ef 100644 --- a/tests/ui/issues/issue-13482-2.rs +++ b/tests/ui/pattern/array-length-mismatch-verbose-13482.rs diff --git a/tests/ui/issues/issue-13482-2.stderr b/tests/ui/pattern/array-length-mismatch-verbose-13482.stderr index 87a6782a5e6..5b533b30afa 100644 --- a/tests/ui/issues/issue-13482-2.stderr +++ b/tests/ui/pattern/array-length-mismatch-verbose-13482.stderr @@ -1,5 +1,5 @@ error[E0527]: pattern requires 0 elements but array has 2 - --> $DIR/issue-13482-2.rs:6:9 + --> $DIR/array-length-mismatch-verbose-13482.rs:6:9 | LL | [] => None, | ^^ expected 2 elements diff --git a/tests/ui/pattern/bindings-after-at/bind-by-copy-or-pat.rs b/tests/ui/pattern/bindings-after-at/bind-by-copy-or-pat.rs index 1555da2fd1f..dd23acfa235 100644 --- a/tests/ui/pattern/bindings-after-at/bind-by-copy-or-pat.rs +++ b/tests/ui/pattern/bindings-after-at/bind-by-copy-or-pat.rs @@ -1,16 +1,15 @@ -//@ known-bug: unknown +//@ run-pass #![allow(unused)] struct A(u32); pub fn main() { - // The or-pattern bindings are lowered after `x`, which triggers the error. + // Bindings are lowered in the order they appear syntactically, so this works. let x @ (A(a) | A(a)) = A(10); - // ERROR: use of moved value assert!(x.0 == 10); assert!(a == 10); - // This works. + // This also works. let (x @ A(a) | x @ A(a)) = A(10); assert!(x.0 == 10); assert!(a == 10); diff --git a/tests/ui/pattern/bindings-after-at/bind-by-copy-or-pat.stderr b/tests/ui/pattern/bindings-after-at/bind-by-copy-or-pat.stderr deleted file mode 100644 index 79808186358..00000000000 --- a/tests/ui/pattern/bindings-after-at/bind-by-copy-or-pat.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0382]: use of moved value - --> $DIR/bind-by-copy-or-pat.rs:8:16 - | -LL | let x @ (A(a) | A(a)) = A(10); - | - ^ ----- move occurs because value has type `A`, which does not implement the `Copy` trait - | | | - | | value used here after move - | value moved here - | -help: borrow this binding in the pattern to avoid moving the value - | -LL | let ref x @ (A(a) | A(a)) = A(10); - | +++ - -error[E0382]: use of moved value - --> $DIR/bind-by-copy-or-pat.rs:8:23 - | -LL | let x @ (A(a) | A(a)) = A(10); - | - ^ ----- move occurs because value has type `A`, which does not implement the `Copy` trait - | | | - | | value used here after move - | value moved here - | -help: borrow this binding in the pattern to avoid moving the value - | -LL | let ref x @ (A(a) | A(a)) = A(10); - | +++ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0382`. diff --git a/tests/ui/pattern/deref-patterns/usefulness/non-exhaustive.rs b/tests/ui/pattern/deref-patterns/usefulness/non-exhaustive.rs index 704cae8bdbc..bab6308223e 100644 --- a/tests/ui/pattern/deref-patterns/usefulness/non-exhaustive.rs +++ b/tests/ui/pattern/deref-patterns/usefulness/non-exhaustive.rs @@ -15,7 +15,7 @@ fn main() { } match Box::new((true, Box::new(false))) { - //~^ ERROR non-exhaustive patterns: `deref!((false, deref!(false)))` and `deref!((true, deref!(true)))` not covered + //~^ ERROR non-exhaustive patterns: `deref!((true, deref!(true)))` and `deref!((false, deref!(false)))` not covered (true, false) => {} (false, true) => {} } diff --git a/tests/ui/pattern/deref-patterns/usefulness/non-exhaustive.stderr b/tests/ui/pattern/deref-patterns/usefulness/non-exhaustive.stderr index 55fa84bafde..a1abd5f0e3f 100644 --- a/tests/ui/pattern/deref-patterns/usefulness/non-exhaustive.stderr +++ b/tests/ui/pattern/deref-patterns/usefulness/non-exhaustive.stderr @@ -28,11 +28,11 @@ LL ~ true => {}, LL + deref!(deref!(false)) => todo!() | -error[E0004]: non-exhaustive patterns: `deref!((false, deref!(false)))` and `deref!((true, deref!(true)))` not covered +error[E0004]: non-exhaustive patterns: `deref!((true, deref!(true)))` and `deref!((false, deref!(false)))` not covered --> $DIR/non-exhaustive.rs:17:11 | LL | match Box::new((true, Box::new(false))) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ patterns `deref!((false, deref!(false)))` and `deref!((true, deref!(true)))` not covered + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ patterns `deref!((true, deref!(true)))` and `deref!((false, deref!(false)))` not covered | note: `Box<(bool, Box<bool>)>` defined here --> $SRC_DIR/alloc/src/boxed.rs:LL:COL @@ -40,7 +40,7 @@ note: `Box<(bool, Box<bool>)>` defined here help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | LL ~ (false, true) => {}, -LL + deref!((false, deref!(false))) | deref!((true, deref!(true))) => todo!() +LL + deref!((true, deref!(true))) | deref!((false, deref!(false))) => todo!() | error[E0004]: non-exhaustive patterns: `deref!((deref!(T::C), _))` not covered diff --git a/tests/ui/issues/issue-15896.rs b/tests/ui/pattern/enum-struct-pattern-mismatch-15896.rs index d3153b516e6..9f7c5084c0e 100644 --- a/tests/ui/issues/issue-15896.rs +++ b/tests/ui/pattern/enum-struct-pattern-mismatch-15896.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15896 + // Regression test for #15896. It used to ICE rustc. fn main() { diff --git a/tests/ui/issues/issue-15896.stderr b/tests/ui/pattern/enum-struct-pattern-mismatch-15896.stderr index 381f6dc2276..8dee4c37e2f 100644 --- a/tests/ui/issues/issue-15896.stderr +++ b/tests/ui/pattern/enum-struct-pattern-mismatch-15896.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-15896.rs:11:11 + --> $DIR/enum-struct-pattern-mismatch-15896.rs:13:11 | LL | let u = match e { | - this expression has type `E` diff --git a/tests/ui/issues/issue-15381.rs b/tests/ui/pattern/refutable-pattern-for-loop-15381.rs index bd5f62ddc67..3c19612c9cc 100644 --- a/tests/ui/issues/issue-15381.rs +++ b/tests/ui/pattern/refutable-pattern-for-loop-15381.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15381 + fn main() { let values: Vec<u8> = vec![1,2,3,4,5,6,7,8]; diff --git a/tests/ui/issues/issue-15381.stderr b/tests/ui/pattern/refutable-pattern-for-loop-15381.stderr index 03a0100f1bd..3c1d5fb454c 100644 --- a/tests/ui/issues/issue-15381.stderr +++ b/tests/ui/pattern/refutable-pattern-for-loop-15381.stderr @@ -1,5 +1,5 @@ error[E0005]: refutable pattern in `for` loop binding - --> $DIR/issue-15381.rs:4:9 + --> $DIR/refutable-pattern-for-loop-15381.rs:6:9 | LL | for &[x,y,z] in values.chunks(3).filter(|&xs| xs.len() == 3) { | ^^^^^^^^ patterns `&[]`, `&[_]`, `&[_, _]` and 1 more not covered diff --git a/tests/ui/issues/issue-15104.rs b/tests/ui/pattern/slice-pattern-recursion-15104.rs index e68c94c370e..24e3fe78de0 100644 --- a/tests/ui/issues/issue-15104.rs +++ b/tests/ui/pattern/slice-pattern-recursion-15104.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15104 + //@ run-pass fn main() { diff --git a/tests/ui/issues/issue-16149.rs b/tests/ui/pattern/static-binding-shadow-16149.rs index 51b60725c5a..a46f78214c7 100644 --- a/tests/ui/issues/issue-16149.rs +++ b/tests/ui/pattern/static-binding-shadow-16149.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/16149 + extern "C" { static externalValue: isize; } diff --git a/tests/ui/issues/issue-16149.stderr b/tests/ui/pattern/static-binding-shadow-16149.stderr index 9ffd0e7e645..6d8c7634acd 100644 --- a/tests/ui/issues/issue-16149.stderr +++ b/tests/ui/pattern/static-binding-shadow-16149.stderr @@ -1,5 +1,5 @@ error[E0530]: match bindings cannot shadow statics - --> $DIR/issue-16149.rs:7:9 + --> $DIR/static-binding-shadow-16149.rs:9:9 | LL | static externalValue: isize; | ---------------------------- the static `externalValue` is defined here diff --git a/tests/ui/issues/issue-15260.rs b/tests/ui/pattern/struct-field-duplicate-binding-15260.rs index 64fc3df3d23..a3617798cdf 100644 --- a/tests/ui/issues/issue-15260.rs +++ b/tests/ui/pattern/struct-field-duplicate-binding-15260.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15260 + struct Foo { a: usize, } diff --git a/tests/ui/issues/issue-15260.stderr b/tests/ui/pattern/struct-field-duplicate-binding-15260.stderr index 4a3041122b2..536904fbcb3 100644 --- a/tests/ui/issues/issue-15260.stderr +++ b/tests/ui/pattern/struct-field-duplicate-binding-15260.stderr @@ -1,5 +1,5 @@ error[E0025]: field `a` bound multiple times in the pattern - --> $DIR/issue-15260.rs:8:9 + --> $DIR/struct-field-duplicate-binding-15260.rs:10:9 | LL | a: _, | ---- first use of `a` @@ -7,7 +7,7 @@ LL | a: _ | ^^^^ multiple uses of `a` in pattern error[E0025]: field `a` bound multiple times in the pattern - --> $DIR/issue-15260.rs:14:9 + --> $DIR/struct-field-duplicate-binding-15260.rs:16:9 | LL | a, | - first use of `a` @@ -15,7 +15,7 @@ LL | a: _ | ^^^^ multiple uses of `a` in pattern error[E0025]: field `a` bound multiple times in the pattern - --> $DIR/issue-15260.rs:20:9 + --> $DIR/struct-field-duplicate-binding-15260.rs:22:9 | LL | a, | - first use of `a` @@ -23,7 +23,7 @@ LL | a: _, | ^^^^ multiple uses of `a` in pattern error[E0025]: field `a` bound multiple times in the pattern - --> $DIR/issue-15260.rs:22:9 + --> $DIR/struct-field-duplicate-binding-15260.rs:24:9 | LL | a, | - first use of `a` diff --git a/tests/ui/issues/issue-14541.rs b/tests/ui/pattern/struct-mismatch-destructure-14541.rs index 358d29419f9..04e85237cab 100644 --- a/tests/ui/issues/issue-14541.rs +++ b/tests/ui/pattern/struct-mismatch-destructure-14541.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/14541 + struct Vec2 { y: f32 } struct Vec3 { y: f32, z: f32 } diff --git a/tests/ui/issues/issue-14541.stderr b/tests/ui/pattern/struct-mismatch-destructure-14541.stderr index 370e6477901..024d77df2cb 100644 --- a/tests/ui/issues/issue-14541.stderr +++ b/tests/ui/pattern/struct-mismatch-destructure-14541.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-14541.rs:5:9 + --> $DIR/struct-mismatch-destructure-14541.rs:7:9 | LL | let Vec3 { y: _, z: _ } = v; | ^^^^^^^^^^^^^^^^^^^ - this expression has type `Vec2` diff --git a/tests/ui/issues/issue-14308.rs b/tests/ui/pattern/struct-wildcard-pattern-14308.rs index 724be160d06..c1fdf424b8c 100644 --- a/tests/ui/issues/issue-14308.rs +++ b/tests/ui/pattern/struct-wildcard-pattern-14308.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/14308 + //@ run-pass struct A(isize); diff --git a/tests/ui/issues/issue-15129-rpass.rs b/tests/ui/pattern/tuple-enum-match-15129.rs index e2ddb989072..1d6192c4cb3 100644 --- a/tests/ui/issues/issue-15129-rpass.rs +++ b/tests/ui/pattern/tuple-enum-match-15129.rs @@ -1,24 +1,25 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15129 + //@ run-pass pub enum T { T1(()), - T2(()) + T2(()), } pub enum V { V1(isize), - V2(bool) + V2(bool), } fn foo(x: (T, V)) -> String { match x { - (T::T1(()), V::V1(i)) => format!("T1(()), V1({})", i), - (T::T2(()), V::V2(b)) => format!("T2(()), V2({})", b), - _ => String::new() + (T::T1(()), V::V1(i)) => format!("T1(()), V1({})", i), + (T::T2(()), V::V2(b)) => format!("T2(()), V2({})", b), + _ => String::new(), } } - fn main() { assert_eq!(foo((T::T1(()), V::V1(99))), "T1(()), V1(99)".to_string()); assert_eq!(foo((T::T2(()), V::V2(true))), "T2(()), V2(true)".to_string()); diff --git a/tests/ui/issues/issue-16401.rs b/tests/ui/pattern/unit-type-struct-pattern-mismatch-16401.rs index 0985a6806d2..2eba33e177e 100644 --- a/tests/ui/issues/issue-16401.rs +++ b/tests/ui/pattern/unit-type-struct-pattern-mismatch-16401.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/16401 + struct Slice<T> { data: *const T, len: usize, diff --git a/tests/ui/issues/issue-16401.stderr b/tests/ui/pattern/unit-type-struct-pattern-mismatch-16401.stderr index 6af920ca439..22c04e439c4 100644 --- a/tests/ui/issues/issue-16401.stderr +++ b/tests/ui/pattern/unit-type-struct-pattern-mismatch-16401.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-16401.rs:8:9 + --> $DIR/unit-type-struct-pattern-mismatch-16401.rs:10:9 | LL | match () { | -- this expression has type `()` diff --git a/tests/ui/issues/issue-pr29383.rs b/tests/ui/pattern/unit-variant-pattern-matching-29383.rs index 2bcc0aa2782..e339dc01f46 100644 --- a/tests/ui/issues/issue-pr29383.rs +++ b/tests/ui/pattern/unit-variant-pattern-matching-29383.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/29383 enum E { A, B, diff --git a/tests/ui/issues/issue-pr29383.stderr b/tests/ui/pattern/unit-variant-pattern-matching-29383.stderr index 57783d75ba1..e30837568a5 100644 --- a/tests/ui/issues/issue-pr29383.stderr +++ b/tests/ui/pattern/unit-variant-pattern-matching-29383.stderr @@ -1,5 +1,5 @@ error[E0532]: expected tuple struct or tuple variant, found unit variant `E::A` - --> $DIR/issue-pr29383.rs:9:14 + --> $DIR/unit-variant-pattern-matching-29383.rs:10:14 | LL | A, | - `E::A` defined here @@ -8,7 +8,7 @@ LL | Some(E::A(..)) => {} | ^^^^^^^^ help: use this syntax instead: `E::A` error[E0532]: expected tuple struct or tuple variant, found unit variant `E::B` - --> $DIR/issue-pr29383.rs:11:14 + --> $DIR/unit-variant-pattern-matching-29383.rs:12:14 | LL | B, | - `E::B` defined here diff --git a/tests/ui/pattern/usefulness/unions.rs b/tests/ui/pattern/usefulness/unions.rs index 80a7f36a09a..3de79c6f849 100644 --- a/tests/ui/pattern/usefulness/unions.rs +++ b/tests/ui/pattern/usefulness/unions.rs @@ -26,7 +26,7 @@ fn main() { } // Our approach can report duplicate witnesses sometimes. match (x, true) { - //~^ ERROR non-exhaustive patterns: `(U8AsBool { n: 0_u8 }, false)`, `(U8AsBool { b: false }, false)`, `(U8AsBool { n: 0_u8 }, false)` and 1 more not covered + //~^ ERROR non-exhaustive patterns: `(U8AsBool { n: 0_u8 }, false)`, `(U8AsBool { b: true }, false)`, `(U8AsBool { n: 0_u8 }, false)` and 1 more not covered (U8AsBool { b: true }, true) => {} (U8AsBool { b: false }, true) => {} (U8AsBool { n: 1.. }, true) => {} diff --git a/tests/ui/pattern/usefulness/unions.stderr b/tests/ui/pattern/usefulness/unions.stderr index 4b397dc25db..98fb6a33ae4 100644 --- a/tests/ui/pattern/usefulness/unions.stderr +++ b/tests/ui/pattern/usefulness/unions.stderr @@ -16,11 +16,11 @@ LL ~ U8AsBool { n: 1.. } => {}, LL + U8AsBool { n: 0_u8 } | U8AsBool { b: false } => todo!() | -error[E0004]: non-exhaustive patterns: `(U8AsBool { n: 0_u8 }, false)`, `(U8AsBool { b: false }, false)`, `(U8AsBool { n: 0_u8 }, false)` and 1 more not covered +error[E0004]: non-exhaustive patterns: `(U8AsBool { n: 0_u8 }, false)`, `(U8AsBool { b: true }, false)`, `(U8AsBool { n: 0_u8 }, false)` and 1 more not covered --> $DIR/unions.rs:28:15 | LL | match (x, true) { - | ^^^^^^^^^ patterns `(U8AsBool { n: 0_u8 }, false)`, `(U8AsBool { b: false }, false)`, `(U8AsBool { n: 0_u8 }, false)` and 1 more not covered + | ^^^^^^^^^ patterns `(U8AsBool { n: 0_u8 }, false)`, `(U8AsBool { b: true }, false)`, `(U8AsBool { n: 0_u8 }, false)` and 1 more not covered | = note: the matched value is of type `(U8AsBool, bool)` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms diff --git a/tests/ui/proc-macro/attribute.rs b/tests/ui/proc-macro/attribute.rs index 988cdcd0403..dfb26738377 100644 --- a/tests/ui/proc-macro/attribute.rs +++ b/tests/ui/proc-macro/attribute.rs @@ -9,46 +9,55 @@ use proc_macro::*; #[proc_macro_derive] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE expected this to be a list +//~| NOTE for more information, visit pub fn foo1(input: TokenStream) -> TokenStream { input } #[proc_macro_derive = ""] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE expected this to be a list +//~| NOTE for more information, visit pub fn foo2(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d3, a, b)] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE the only valid argument here is `attributes` +//~| NOTE for more information, visit pub fn foo3(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d4, attributes(a), b)] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE didn't expect any arguments here +//~| NOTE for more information, visit pub fn foo4(input: TokenStream) -> TokenStream { input } #[proc_macro_derive("a")] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE didn't expect a literal here +//~| NOTE for more information, visit pub fn foo5(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d6 = "")] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE didn't expect any arguments here +//~| NOTE for more information, visit pub fn foo6(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(m::d7)] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE expected a valid identifier here +//~| NOTE for more information, visit pub fn foo7(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d8(a))] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE didn't expect any arguments here +//~| NOTE for more information, visit pub fn foo8(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(self)] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE expected a valid identifier here +//~| NOTE for more information, visit pub fn foo9(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(PartialEq)] // OK @@ -57,34 +66,41 @@ pub fn foo10(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d11, a)] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE the only valid argument here is `attributes` +//~| NOTE for more information, visit pub fn foo11(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d12, attributes)] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE expected this to be a list +//~| NOTE for more information, visit pub fn foo12(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d13, attributes("a"))] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE expected a valid identifier here +//~| NOTE for more information, visit pub fn foo13(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d14, attributes(a = ""))] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE didn't expect any arguments here +//~| NOTE for more information, visit pub fn foo14(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d15, attributes(m::a))] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE expected a valid identifier here +//~| NOTE for more information, visit pub fn foo15(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d16, attributes(a(b)))] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE didn't expect any arguments here +//~| NOTE for more information, visit pub fn foo16(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d17, attributes(self))] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE expected a valid identifier here +//~| NOTE for more information, visit pub fn foo17(input: TokenStream) -> TokenStream { input } diff --git a/tests/ui/proc-macro/attribute.stderr b/tests/ui/proc-macro/attribute.stderr index db59a1fdfb3..e7127c8ef1d 100644 --- a/tests/ui/proc-macro/attribute.stderr +++ b/tests/ui/proc-macro/attribute.stderr @@ -2,145 +2,283 @@ error[E0539]: malformed `proc_macro_derive` attribute input --> $DIR/attribute.rs:9:1 | LL | #[proc_macro_derive] - | ^^^^^^^^^^^^^^^^^^^^ - | | - | expected this to be a list - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | ^^^^^^^^^^^^^^^^^^^^ expected this to be a list + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL | #[proc_macro_derive(TraitName)] + | +++++++++++ +LL | #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | ++++++++++++++++++++++++++++++++++++++++++ error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:14:1 + --> $DIR/attribute.rs:15:1 | LL | #[proc_macro_derive = ""] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | expected this to be a list - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected this to be a list + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive = ""] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive = ""] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:19:1 + --> $DIR/attribute.rs:21:1 | LL | #[proc_macro_derive(d3, a, b)] | ^^^^^^^^^^^^^^^^^^^^^^^^-^^^^^ - | | | - | | the only valid argument here is `attributes` - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | the only valid argument here is `attributes` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(d3, a, b)] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(d3, a, b)] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0565]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:24:1 + --> $DIR/attribute.rs:27:1 | LL | #[proc_macro_derive(d4, attributes(a), b)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-^^ - | | | - | | didn't expect any arguments here - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | didn't expect any arguments here + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(d4, attributes(a), b)] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(d4, attributes(a), b)] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0565]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:29:1 + --> $DIR/attribute.rs:33:1 | LL | #[proc_macro_derive("a")] | ^^^^^^^^^^^^^^^^^^^^---^^ - | | | - | | didn't expect a literal here - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | didn't expect a literal here + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive("a")] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive("a")] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0565]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:34:1 + --> $DIR/attribute.rs:39:1 | LL | #[proc_macro_derive(d6 = "")] | ^^^^^^^^^^^^^^^^^^^^^^^----^^ - | | | - | | didn't expect any arguments here - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | didn't expect any arguments here + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(d6 = "")] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(d6 = "")] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:39:1 + --> $DIR/attribute.rs:45:1 | LL | #[proc_macro_derive(m::d7)] | ^^^^^^^^^^^^^^^^^^^^-----^^ - | | | - | | expected a valid identifier here - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | expected a valid identifier here + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(m::d7)] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(m::d7)] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0565]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:44:1 + --> $DIR/attribute.rs:51:1 | LL | #[proc_macro_derive(d8(a))] | ^^^^^^^^^^^^^^^^^^^^^^---^^ - | | | - | | didn't expect any arguments here - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | didn't expect any arguments here + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(d8(a))] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(d8(a))] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:49:1 + --> $DIR/attribute.rs:57:1 | LL | #[proc_macro_derive(self)] | ^^^^^^^^^^^^^^^^^^^^----^^ - | | | - | | expected a valid identifier here - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | expected a valid identifier here + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(self)] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(self)] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:57:1 + --> $DIR/attribute.rs:66:1 | LL | #[proc_macro_derive(d11, a)] | ^^^^^^^^^^^^^^^^^^^^^^^^^-^^ - | | | - | | the only valid argument here is `attributes` - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | the only valid argument here is `attributes` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(d11, a)] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(d11, a)] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:62:1 + --> $DIR/attribute.rs:72:1 | LL | #[proc_macro_derive(d12, attributes)] | ^^^^^^^^^^^^^^^^^^^^^^^^^----------^^ - | | | - | | expected this to be a list - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | expected this to be a list + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(d12, attributes)] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(d12, attributes)] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:67:1 + --> $DIR/attribute.rs:78:1 | LL | #[proc_macro_derive(d13, attributes("a"))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---^^^ - | | | - | | expected a valid identifier here - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | expected a valid identifier here + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(d13, attributes("a"))] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(d13, attributes("a"))] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0565]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:72:1 + --> $DIR/attribute.rs:84:1 | LL | #[proc_macro_derive(d14, attributes(a = ""))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----^^^ - | | | - | | didn't expect any arguments here - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | didn't expect any arguments here + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(d14, attributes(a = ""))] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(d14, attributes(a = ""))] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:77:1 + --> $DIR/attribute.rs:90:1 | LL | #[proc_macro_derive(d15, attributes(m::a))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----^^^ - | | | - | | expected a valid identifier here - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | expected a valid identifier here + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(d15, attributes(m::a))] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(d15, attributes(m::a))] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0565]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:82:1 + --> $DIR/attribute.rs:96:1 | LL | #[proc_macro_derive(d16, attributes(a(b)))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---^^^ - | | | - | | didn't expect any arguments here - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | didn't expect any arguments here + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(d16, attributes(a(b)))] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(d16, attributes(a(b)))] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:87:1 + --> $DIR/attribute.rs:102:1 | LL | #[proc_macro_derive(d17, attributes(self))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----^^^ - | | | - | | expected a valid identifier here - | help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + | | + | expected a valid identifier here + | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[proc_macro_derive(d17, attributes(self))] +LL + #[proc_macro_derive(TraitName)] + | +LL - #[proc_macro_derive(d17, attributes(self))] +LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] + | error: aborting due to 16 previous errors diff --git a/tests/ui/proc-macro/auxiliary/match-expander.rs b/tests/ui/proc-macro/auxiliary/match-expander.rs new file mode 100644 index 00000000000..bf78df2addf --- /dev/null +++ b/tests/ui/proc-macro/auxiliary/match-expander.rs @@ -0,0 +1,15 @@ +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro] +pub fn matcher(input: TokenStream) -> TokenStream { +" +struct S(()); +let s = S(()); +match s { + true => {} + _ => {} +} +".parse().unwrap() +} diff --git a/tests/ui/proc-macro/derive-helper-legacy-spurious.rs b/tests/ui/proc-macro/derive-helper-legacy-spurious.rs index 8e902f30419..0b55e775f38 100644 --- a/tests/ui/proc-macro/derive-helper-legacy-spurious.rs +++ b/tests/ui/proc-macro/derive-helper-legacy-spurious.rs @@ -6,7 +6,7 @@ extern crate test_macros; #[derive(Empty)] -#[empty_helper] //~ ERROR cannot find attribute `empty_helper` in this scope +#[empty_helper] struct Foo {} fn main() {} diff --git a/tests/ui/proc-macro/derive-helper-legacy-spurious.stderr b/tests/ui/proc-macro/derive-helper-legacy-spurious.stderr index b34713b8ca6..4cd89904ef3 100644 --- a/tests/ui/proc-macro/derive-helper-legacy-spurious.stderr +++ b/tests/ui/proc-macro/derive-helper-legacy-spurious.stderr @@ -4,11 +4,5 @@ error: cannot find attribute `dummy` in this scope LL | #![dummy] | ^^^^^ -error: cannot find attribute `empty_helper` in this scope - --> $DIR/derive-helper-legacy-spurious.rs:9:3 - | -LL | #[empty_helper] - | ^^^^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error diff --git a/tests/ui/proc-macro/derive-helper-shadowing.rs b/tests/ui/proc-macro/derive-helper-shadowing.rs index e774e464053..ee883be3352 100644 --- a/tests/ui/proc-macro/derive-helper-shadowing.rs +++ b/tests/ui/proc-macro/derive-helper-shadowing.rs @@ -17,7 +17,7 @@ macro_rules! gen_helper_use { } #[empty_helper] //~ ERROR `empty_helper` is ambiguous - //~| WARN derive helper attribute is used before it is introduced + //~| ERROR derive helper attribute is used before it is introduced //~| WARN this was previously accepted #[derive(Empty)] struct S { diff --git a/tests/ui/proc-macro/derive-helper-shadowing.stderr b/tests/ui/proc-macro/derive-helper-shadowing.stderr index 1206778bb23..65989375ab5 100644 --- a/tests/ui/proc-macro/derive-helper-shadowing.stderr +++ b/tests/ui/proc-macro/derive-helper-shadowing.stderr @@ -58,7 +58,7 @@ LL | use test_macros::empty_attr as empty_helper; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use `crate::empty_helper` to refer to this attribute macro unambiguously -warning: derive helper attribute is used before it is introduced +error: derive helper attribute is used before it is introduced --> $DIR/derive-helper-shadowing.rs:19:3 | LL | #[empty_helper] @@ -69,8 +69,22 @@ LL | #[derive(Empty)] | = 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 #79202 <https://github.com/rust-lang/rust/issues/79202> - = note: `#[warn(legacy_derive_helpers)]` on by default + = note: `#[deny(legacy_derive_helpers)]` on by default -error: aborting due to 4 previous errors; 1 warning emitted +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0659`. +Future incompatibility report: Future breakage diagnostic: +error: derive helper attribute is used before it is introduced + --> $DIR/derive-helper-shadowing.rs:19:3 + | +LL | #[empty_helper] + | ^^^^^^^^^^^^ +... +LL | #[derive(Empty)] + | ----- the attribute is introduced here + | + = 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 #79202 <https://github.com/rust-lang/rust/issues/79202> + = note: `#[deny(legacy_derive_helpers)]` on by default + diff --git a/tests/ui/proc-macro/helper-attr-blocked-by-import-ambig.rs b/tests/ui/proc-macro/helper-attr-blocked-by-import-ambig.rs index 1197dd7f3bf..97c81e9945d 100644 --- a/tests/ui/proc-macro/helper-attr-blocked-by-import-ambig.rs +++ b/tests/ui/proc-macro/helper-attr-blocked-by-import-ambig.rs @@ -5,7 +5,7 @@ extern crate test_macros; use test_macros::empty_attr as empty_helper; #[empty_helper] //~ ERROR `empty_helper` is ambiguous - //~| WARN derive helper attribute is used before it is introduced + //~| ERROR derive helper attribute is used before it is introduced //~| WARN this was previously accepted #[derive(Empty)] struct S; diff --git a/tests/ui/proc-macro/helper-attr-blocked-by-import-ambig.stderr b/tests/ui/proc-macro/helper-attr-blocked-by-import-ambig.stderr index 1c12a2804c6..df7951464fb 100644 --- a/tests/ui/proc-macro/helper-attr-blocked-by-import-ambig.stderr +++ b/tests/ui/proc-macro/helper-attr-blocked-by-import-ambig.stderr @@ -17,7 +17,7 @@ LL | use test_macros::empty_attr as empty_helper; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use `crate::empty_helper` to refer to this attribute macro unambiguously -warning: derive helper attribute is used before it is introduced +error: derive helper attribute is used before it is introduced --> $DIR/helper-attr-blocked-by-import-ambig.rs:7:3 | LL | #[empty_helper] @@ -28,8 +28,22 @@ LL | #[derive(Empty)] | = 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 #79202 <https://github.com/rust-lang/rust/issues/79202> - = note: `#[warn(legacy_derive_helpers)]` on by default + = note: `#[deny(legacy_derive_helpers)]` on by default -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0659`. +Future incompatibility report: Future breakage diagnostic: +error: derive helper attribute is used before it is introduced + --> $DIR/helper-attr-blocked-by-import-ambig.rs:7:3 + | +LL | #[empty_helper] + | ^^^^^^^^^^^^ +... +LL | #[derive(Empty)] + | ----- the attribute is introduced here + | + = 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 #79202 <https://github.com/rust-lang/rust/issues/79202> + = note: `#[deny(legacy_derive_helpers)]` on by default + diff --git a/tests/ui/proc-macro/illegal-proc-macro-derive-use.rs b/tests/ui/proc-macro/illegal-proc-macro-derive-use.rs index 4efd9e952fc..19473fb2caf 100644 --- a/tests/ui/proc-macro/illegal-proc-macro-derive-use.rs +++ b/tests/ui/proc-macro/illegal-proc-macro-derive-use.rs @@ -8,7 +8,7 @@ pub fn foo(a: proc_macro::TokenStream) -> proc_macro::TokenStream { // Issue #37590 #[proc_macro_derive(Foo)] -//~^ ERROR: the `#[proc_macro_derive]` attribute may only be used on bare functions +//~^ ERROR: attribute cannot be used on pub struct Foo { } diff --git a/tests/ui/proc-macro/illegal-proc-macro-derive-use.stderr b/tests/ui/proc-macro/illegal-proc-macro-derive-use.stderr index c0930ab7102..f01619b9195 100644 --- a/tests/ui/proc-macro/illegal-proc-macro-derive-use.stderr +++ b/tests/ui/proc-macro/illegal-proc-macro-derive-use.stderr @@ -4,11 +4,13 @@ error: the `#[proc_macro_derive]` attribute is only usable with crates of the `p LL | #[proc_macro_derive(Foo)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: the `#[proc_macro_derive]` attribute may only be used on bare functions +error: `#[proc_macro_derive]` attribute cannot be used on structs --> $DIR/illegal-proc-macro-derive-use.rs:10:1 | LL | #[proc_macro_derive(Foo)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[proc_macro_derive]` can only be applied to functions error: aborting due to 2 previous errors diff --git a/tests/ui/proc-macro/issue-75930-derive-cfg.rs b/tests/ui/proc-macro/issue-75930-derive-cfg.rs index f0851b31e9c..e8df1a66dd9 100644 --- a/tests/ui/proc-macro/issue-75930-derive-cfg.rs +++ b/tests/ui/proc-macro/issue-75930-derive-cfg.rs @@ -6,7 +6,7 @@ // Tests that we cfg-strip all targets before invoking // a derive macro // FIXME: We currently lose spans here (see issue #43081) - +#![warn(legacy_derive_helpers)] #![no_std] // Don't load unnecessary hygiene information from std extern crate std; diff --git a/tests/ui/proc-macro/issue-75930-derive-cfg.stderr b/tests/ui/proc-macro/issue-75930-derive-cfg.stderr index df1e36d7390..906e9c6bf69 100644 --- a/tests/ui/proc-macro/issue-75930-derive-cfg.stderr +++ b/tests/ui/proc-macro/issue-75930-derive-cfg.stderr @@ -9,7 +9,11 @@ LL | #[derive(Print)] | = 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 #79202 <https://github.com/rust-lang/rust/issues/79202> - = note: `#[warn(legacy_derive_helpers)]` on by default +note: the lint level is defined here + --> $DIR/issue-75930-derive-cfg.rs:9:9 + | +LL | #![warn(legacy_derive_helpers)] + | ^^^^^^^^^^^^^^^^^^^^^ warning: derive helper attribute is used before it is introduced --> $DIR/issue-75930-derive-cfg.rs:46:3 @@ -26,3 +30,39 @@ LL | #[derive(Print)] warning: 2 warnings emitted +Future incompatibility report: Future breakage diagnostic: +warning: derive helper attribute is used before it is introduced + --> $DIR/issue-75930-derive-cfg.rs:46:3 + | +LL | #[print_helper(a)] + | ^^^^^^^^^^^^ +... +LL | #[derive(Print)] + | ----- the attribute is introduced here + | + = 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 #79202 <https://github.com/rust-lang/rust/issues/79202> +note: the lint level is defined here + --> $DIR/issue-75930-derive-cfg.rs:9:9 + | +LL | #![warn(legacy_derive_helpers)] + | ^^^^^^^^^^^^^^^^^^^^^ + +Future breakage diagnostic: +warning: derive helper attribute is used before it is introduced + --> $DIR/issue-75930-derive-cfg.rs:46:3 + | +LL | #[print_helper(a)] + | ^^^^^^^^^^^^ +... +LL | #[derive(Print)] + | ----- the attribute is introduced here + | + = 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 #79202 <https://github.com/rust-lang/rust/issues/79202> +note: the lint level is defined here + --> $DIR/issue-75930-derive-cfg.rs:9:9 + | +LL | #![warn(legacy_derive_helpers)] + | ^^^^^^^^^^^^^^^^^^^^^ + diff --git a/tests/ui/proc-macro/load-panic-backtrace.rs b/tests/ui/proc-macro/load-panic-backtrace.rs index 848bdaf9f37..82645eb4e9f 100644 --- a/tests/ui/proc-macro/load-panic-backtrace.rs +++ b/tests/ui/proc-macro/load-panic-backtrace.rs @@ -1,7 +1,7 @@ //@ proc-macro: test-macros.rs //@ compile-flags: -Z proc-macro-backtrace //@ rustc-env:RUST_BACKTRACE=0 -//@ normalize-stderr: "thread '.*' panicked " -> "" +//@ normalize-stderr: "thread '.*' \(0x[[:xdigit:]]+\) panicked " -> "" //@ normalize-stderr: "note:.*RUST_BACKTRACE=1.*\n" -> "" //@ needs-unwind proc macro panics to report errors diff --git a/tests/ui/proc-macro/load-panic-backtrace.stderr b/tests/ui/proc-macro/load-panic-backtrace.stderr index a1049f5a324..b8872eb12b7 100644 --- a/tests/ui/proc-macro/load-panic-backtrace.stderr +++ b/tests/ui/proc-macro/load-panic-backtrace.stderr @@ -1,5 +1,5 @@ -at $DIR/auxiliary/test-macros.rs:38:5: +thread '<unnamed>' ($TID) panicked at $DIR/auxiliary/test-macros.rs:38:5: panic-derive error: proc-macro derive panicked --> $DIR/load-panic-backtrace.rs:11:10 diff --git a/tests/ui/proc-macro/macro-namespace-reserved-2.stderr b/tests/ui/proc-macro/macro-namespace-reserved-2.stderr index 0471124061e..c8a7cc3ba91 100644 --- a/tests/ui/proc-macro/macro-namespace-reserved-2.stderr +++ b/tests/ui/proc-macro/macro-namespace-reserved-2.stderr @@ -95,14 +95,6 @@ error: expected derive macro, found macro `crate::my_macro` | LL | #[derive(crate::my_macro)] | ^^^^^^^^^^^^^^^ not a derive macro - | -help: remove from the surrounding `derive()` - --> $DIR/macro-namespace-reserved-2.rs:50:10 - | -LL | #[derive(crate::my_macro)] - | ^^^^^^^^^^^^^^^ - = help: add as non-Derive macro - `#[crate::my_macro]` error: cannot find macro `my_macro_attr` in this scope --> $DIR/macro-namespace-reserved-2.rs:28:5 diff --git a/tests/ui/proc-macro/match-expander.rs b/tests/ui/proc-macro/match-expander.rs new file mode 100644 index 00000000000..23e5746c540 --- /dev/null +++ b/tests/ui/proc-macro/match-expander.rs @@ -0,0 +1,12 @@ +//@ proc-macro: match-expander.rs +// Ensure that we don't point at macro invocation when providing inference contexts. + +#[macro_use] +extern crate match_expander; + +fn main() { + match_expander::matcher!(); + //~^ ERROR: mismatched types + //~| NOTE: expected `S`, found `bool` + //~| NOTE: in this expansion of match_expander::matcher! +} diff --git a/tests/ui/proc-macro/match-expander.stderr b/tests/ui/proc-macro/match-expander.stderr new file mode 100644 index 00000000000..b77468ec60a --- /dev/null +++ b/tests/ui/proc-macro/match-expander.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/match-expander.rs:8:5 + | +LL | match_expander::matcher!(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `S`, found `bool` + | + = note: this error originates in the macro `match_expander::matcher` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/proc-macro/proc-macro-attributes.rs b/tests/ui/proc-macro/proc-macro-attributes.rs index 455fcc56e58..f1270b896aa 100644 --- a/tests/ui/proc-macro/proc-macro-attributes.rs +++ b/tests/ui/proc-macro/proc-macro-attributes.rs @@ -4,17 +4,17 @@ extern crate derive_b; #[B] //~ ERROR `B` is ambiguous - //~| WARN derive helper attribute is used before it is introduced + //~| ERROR derive helper attribute is used before it is introduced //~| WARN this was previously accepted #[C] //~ ERROR cannot find attribute `C` in this scope #[B(D)] //~ ERROR `B` is ambiguous - //~| WARN derive helper attribute is used before it is introduced + //~| ERROR derive helper attribute is used before it is introduced //~| WARN this was previously accepted #[B(E = "foo")] //~ ERROR `B` is ambiguous - //~| WARN derive helper attribute is used before it is introduced + //~| ERROR derive helper attribute is used before it is introduced //~| WARN this was previously accepted #[B(arbitrary tokens)] //~ ERROR `B` is ambiguous - //~| WARN derive helper attribute is used before it is introduced + //~| ERROR derive helper attribute is used before it is introduced //~| WARN this was previously accepted #[derive(B)] struct B; diff --git a/tests/ui/proc-macro/proc-macro-attributes.stderr b/tests/ui/proc-macro/proc-macro-attributes.stderr index 140d8790690..892728901fb 100644 --- a/tests/ui/proc-macro/proc-macro-attributes.stderr +++ b/tests/ui/proc-macro/proc-macro-attributes.stderr @@ -2,7 +2,13 @@ error: cannot find attribute `C` in this scope --> $DIR/proc-macro-attributes.rs:9:3 | LL | #[C] - | ^ help: a derive helper attribute with a similar name exists: `B` + | ^ + | +help: the derive macro `B` accepts the similarly named `B` attribute + | +LL - #[C] +LL + #[B] + | error[E0659]: `B` is ambiguous --> $DIR/proc-macro-attributes.rs:6:3 @@ -76,7 +82,7 @@ note: `B` could also refer to the derive macro imported here LL | #[macro_use] | ^^^^^^^^^^^^ -warning: derive helper attribute is used before it is introduced +error: derive helper attribute is used before it is introduced --> $DIR/proc-macro-attributes.rs:6:3 | LL | #[B] @@ -87,9 +93,9 @@ LL | #[derive(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 #79202 <https://github.com/rust-lang/rust/issues/79202> - = note: `#[warn(legacy_derive_helpers)]` on by default + = note: `#[deny(legacy_derive_helpers)]` on by default -warning: derive helper attribute is used before it is introduced +error: derive helper attribute is used before it is introduced --> $DIR/proc-macro-attributes.rs:10:3 | LL | #[B(D)] @@ -101,7 +107,7 @@ LL | #[derive(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 #79202 <https://github.com/rust-lang/rust/issues/79202> -warning: derive helper attribute is used before it is introduced +error: derive helper attribute is used before it is introduced --> $DIR/proc-macro-attributes.rs:13:3 | LL | #[B(E = "foo")] @@ -113,7 +119,7 @@ LL | #[derive(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 #79202 <https://github.com/rust-lang/rust/issues/79202> -warning: derive helper attribute is used before it is introduced +error: derive helper attribute is used before it is introduced --> $DIR/proc-macro-attributes.rs:16:3 | LL | #[B(arbitrary tokens)] @@ -125,6 +131,62 @@ LL | #[derive(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 #79202 <https://github.com/rust-lang/rust/issues/79202> -error: aborting due to 5 previous errors; 4 warnings emitted +error: aborting due to 9 previous errors For more information about this error, try `rustc --explain E0659`. +Future incompatibility report: Future breakage diagnostic: +error: derive helper attribute is used before it is introduced + --> $DIR/proc-macro-attributes.rs:6:3 + | +LL | #[B] + | ^ +... +LL | #[derive(B)] + | - the attribute is introduced here + | + = 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 #79202 <https://github.com/rust-lang/rust/issues/79202> + = note: `#[deny(legacy_derive_helpers)]` on by default + +Future breakage diagnostic: +error: derive helper attribute is used before it is introduced + --> $DIR/proc-macro-attributes.rs:10:3 + | +LL | #[B(D)] + | ^ +... +LL | #[derive(B)] + | - the attribute is introduced here + | + = 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 #79202 <https://github.com/rust-lang/rust/issues/79202> + = note: `#[deny(legacy_derive_helpers)]` on by default + +Future breakage diagnostic: +error: derive helper attribute is used before it is introduced + --> $DIR/proc-macro-attributes.rs:13:3 + | +LL | #[B(E = "foo")] + | ^ +... +LL | #[derive(B)] + | - the attribute is introduced here + | + = 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 #79202 <https://github.com/rust-lang/rust/issues/79202> + = note: `#[deny(legacy_derive_helpers)]` on by default + +Future breakage diagnostic: +error: derive helper attribute is used before it is introduced + --> $DIR/proc-macro-attributes.rs:16:3 + | +LL | #[B(arbitrary tokens)] + | ^ +... +LL | #[derive(B)] + | - the attribute is introduced here + | + = 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 #79202 <https://github.com/rust-lang/rust/issues/79202> + = note: `#[deny(legacy_derive_helpers)]` on by default + diff --git a/tests/ui/proc-macro/quote/does-not-have-iter-interpolated-dup.stderr b/tests/ui/proc-macro/quote/does-not-have-iter-interpolated-dup.stderr index ecb12c1df3b..0bcea9b85f4 100644 --- a/tests/ui/proc-macro/quote/does-not-have-iter-interpolated-dup.stderr +++ b/tests/ui/proc-macro/quote/does-not-have-iter-interpolated-dup.stderr @@ -5,7 +5,6 @@ LL | quote!($($nonrep $nonrep)*); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | expected `HasIterator`, found `ThereIsNoIteratorInRepetition` - | expected due to this | here the type of `has_iter` is inferred to be `ThereIsNoIteratorInRepetition` error: aborting due to 1 previous error diff --git a/tests/ui/proc-macro/quote/does-not-have-iter-interpolated.stderr b/tests/ui/proc-macro/quote/does-not-have-iter-interpolated.stderr index 093e2ebc098..d945ab41a12 100644 --- a/tests/ui/proc-macro/quote/does-not-have-iter-interpolated.stderr +++ b/tests/ui/proc-macro/quote/does-not-have-iter-interpolated.stderr @@ -5,7 +5,6 @@ LL | quote!($($nonrep)*); | ^^^^^^^^^^^^^^^^^^^ | | | expected `HasIterator`, found `ThereIsNoIteratorInRepetition` - | expected due to this | here the type of `has_iter` is inferred to be `ThereIsNoIteratorInRepetition` error: aborting due to 1 previous error diff --git a/tests/ui/proc-macro/quote/does-not-have-iter-separated.stderr b/tests/ui/proc-macro/quote/does-not-have-iter-separated.stderr index 937209e675e..2d715f293d4 100644 --- a/tests/ui/proc-macro/quote/does-not-have-iter-separated.stderr +++ b/tests/ui/proc-macro/quote/does-not-have-iter-separated.stderr @@ -2,10 +2,7 @@ error[E0308]: mismatched types --> $DIR/does-not-have-iter-separated.rs:8:5 | LL | quote!($(a b),*); - | ^^^^^^^^^^^^^^^^ - | | - | expected `HasIterator`, found `ThereIsNoIteratorInRepetition` - | expected due to this + | ^^^^^^^^^^^^^^^^ expected `HasIterator`, found `ThereIsNoIteratorInRepetition` error: aborting due to 1 previous error diff --git a/tests/ui/proc-macro/quote/does-not-have-iter.stderr b/tests/ui/proc-macro/quote/does-not-have-iter.stderr index e74ea334899..ac8e725038a 100644 --- a/tests/ui/proc-macro/quote/does-not-have-iter.stderr +++ b/tests/ui/proc-macro/quote/does-not-have-iter.stderr @@ -2,10 +2,7 @@ error[E0308]: mismatched types --> $DIR/does-not-have-iter.rs:8:5 | LL | quote!($(a b)*); - | ^^^^^^^^^^^^^^^ - | | - | expected `HasIterator`, found `ThereIsNoIteratorInRepetition` - | expected due to this + | ^^^^^^^^^^^^^^^ expected `HasIterator`, found `ThereIsNoIteratorInRepetition` error: aborting due to 1 previous error diff --git a/tests/ui/proc-macro/span-from-proc-macro.stderr b/tests/ui/proc-macro/span-from-proc-macro.stderr index 452c04df877..c79ab04eadf 100644 --- a/tests/ui/proc-macro/span-from-proc-macro.stderr +++ b/tests/ui/proc-macro/span-from-proc-macro.stderr @@ -10,7 +10,7 @@ LL | field: MissingType ::: $DIR/span-from-proc-macro.rs:8:1 | LL | #[error_from_attribute] - | ----------------------- in this procedural macro expansion + | ----------------------- in this attribute macro expansion error[E0412]: cannot find type `OtherMissingType` in this scope --> $DIR/auxiliary/span-from-proc-macro.rs:42:21 diff --git a/tests/ui/process/multi-panic.rs b/tests/ui/process/multi-panic.rs index 481fe75c731..1fddffeb770 100644 --- a/tests/ui/process/multi-panic.rs +++ b/tests/ui/process/multi-panic.rs @@ -7,18 +7,27 @@ fn check_for_no_backtrace(test: std::process::Output) { let err = String::from_utf8_lossy(&test.stderr); let mut it = err.lines().filter(|l| !l.is_empty()); - assert_eq!(it.next().map(|l| l.starts_with("thread '<unnamed>' panicked")), Some(true)); - assert_eq!(it.next().is_some(), true); + assert_eq!( + it.next().map(|l| l.starts_with("thread '<unnamed>' (") && l.contains("panicked")), + Some(true), + "out: ```{err}```", + ); + assert_eq!(it.next().is_some(), true, "out: ```{err}```"); assert_eq!( it.next(), Some( "note: run with `RUST_BACKTRACE=1` \ environment variable to display a backtrace" - ) + ), + "out: ```{err}```", + ); + assert_eq!( + it.next().map(|l| l.starts_with("thread 'main' (") && l.contains("panicked at")), + Some(true), + "out: ```{err}```", ); - assert_eq!(it.next().map(|l| l.starts_with("thread 'main' panicked at")), Some(true)); - assert_eq!(it.next().is_some(), true); - assert_eq!(it.next(), None); + assert_eq!(it.next().is_some(), true, "out: ```{err}```"); + assert_eq!(it.next(), None, "out: ```{err}```"); } fn main() { diff --git a/tests/ui/process/println-with-broken-pipe.run.stderr b/tests/ui/process/println-with-broken-pipe.run.stderr index ab414994b56..c56793de525 100644 --- a/tests/ui/process/println-with-broken-pipe.run.stderr +++ b/tests/ui/process/println-with-broken-pipe.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at library/std/src/io/stdio.rs:LL:CC: +thread 'main' ($TID) panicked at library/std/src/io/stdio.rs:LL:CC: failed printing to stdout: Broken pipe (os error 32) note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/recursion/issue-23122-2.rs b/tests/ui/recursion/issue-23122-2.rs index 95e1f60d8b0..d4f13e9fa55 100644 --- a/tests/ui/recursion/issue-23122-2.rs +++ b/tests/ui/recursion/issue-23122-2.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Zwrite-long-types-to-disk=yes trait Next { type Next: Next; } diff --git a/tests/ui/recursion/issue-23122-2.stderr b/tests/ui/recursion/issue-23122-2.stderr index c5774cc1888..de402d65e6d 100644 --- a/tests/ui/recursion/issue-23122-2.stderr +++ b/tests/ui/recursion/issue-23122-2.stderr @@ -1,17 +1,19 @@ error[E0275]: overflow evaluating the requirement `<<<<<<<... as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next: Sized` - --> $DIR/issue-23122-2.rs:10:17 + --> $DIR/issue-23122-2.rs:11:17 | LL | type Next = <GetNext<T::Next> as Next>::Next; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_23122_2`) -note: required for `GetNext<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<T as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next>` to implement `Next` - --> $DIR/issue-23122-2.rs:9:15 +note: required for `GetNext<<<<... as Next>::Next as Next>::Next as Next>::Next>` to implement `Next` + --> $DIR/issue-23122-2.rs:10:15 | LL | impl<T: Next> Next for GetNext<T> { | - ^^^^ ^^^^^^^^^^ | | | unsatisfied trait bound introduced here + = note: the full name for the type has been written to '$TEST_BUILD_DIR/issue-23122-2.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error diff --git a/tests/ui/recursion/issue-38591-non-regular-dropck-recursion.rs b/tests/ui/recursion/issue-38591-non-regular-dropck-recursion.rs index 7b7b1a9580b..c219a920bb4 100644 --- a/tests/ui/recursion/issue-38591-non-regular-dropck-recursion.rs +++ b/tests/ui/recursion/issue-38591-non-regular-dropck-recursion.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Zwrite-long-types-to-disk=yes // `S` is infinitely recursing so it's not possible to generate a finite // drop impl. // diff --git a/tests/ui/recursion/issue-38591-non-regular-dropck-recursion.stderr b/tests/ui/recursion/issue-38591-non-regular-dropck-recursion.stderr index 409f63b91b6..cf3bc4578a7 100644 --- a/tests/ui/recursion/issue-38591-non-regular-dropck-recursion.stderr +++ b/tests/ui/recursion/issue-38591-non-regular-dropck-recursion.stderr @@ -1,10 +1,12 @@ error[E0320]: overflow while adding drop-check rules for `S<u32>` - --> $DIR/issue-38591-non-regular-dropck-recursion.rs:11:6 + --> $DIR/issue-38591-non-regular-dropck-recursion.rs:12:6 | LL | fn f(x: S<u32>) {} | ^ | - = note: overflowed on `S<fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(u32)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))>` + = note: overflowed on `S<fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(...))))))))))))))))>` + = note: the full name for the type has been written to '$TEST_BUILD_DIR/issue-38591-non-regular-dropck-recursion.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error diff --git a/tests/ui/recursion/issue-83150.rs b/tests/ui/recursion/issue-83150.rs index b720c168187..9194ce1ab17 100644 --- a/tests/ui/recursion/issue-83150.rs +++ b/tests/ui/recursion/issue-83150.rs @@ -1,6 +1,6 @@ //~ ERROR overflow evaluating the requirement `Map<&mut std::ops::Range<u8>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>: Iterator` //@ build-fail -//@ compile-flags: -Copt-level=0 +//@ compile-flags: -Copt-level=0 -Zwrite-long-types-to-disk=yes fn main() { let mut iter = 0u8..1; diff --git a/tests/ui/recursion/issue-83150.stderr b/tests/ui/recursion/issue-83150.stderr index 600922f1e57..a245b001bad 100644 --- a/tests/ui/recursion/issue-83150.stderr +++ b/tests/ui/recursion/issue-83150.stderr @@ -13,9 +13,11 @@ LL | func(&mut iter.map(|x| x + 1)) error[E0275]: overflow evaluating the requirement `Map<&mut std::ops::Range<u8>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>: Iterator` | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_83150`) - = note: required for `&mut Map<&mut std::ops::Range<u8>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>` to implement `Iterator` + = note: required for `&mut Map<&mut Range<u8>, {closure@issue-83150.rs:12:24}>` to implement `Iterator` = note: 65 redundant requirements hidden - = note: required for `&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut std::ops::Range<u8>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>` to implement `Iterator` + = note: required for `&mut Map<&mut Map<&mut Map<&mut Map<&mut ..., ...>, ...>, ...>, ...>` to implement `Iterator` + = note: the full name for the type has been written to '$TEST_BUILD_DIR/issue-83150.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/recursion/recursion.rs b/tests/ui/recursion/recursion.rs index 5cd4012a9d2..ae927b1b4c6 100644 --- a/tests/ui/recursion/recursion.rs +++ b/tests/ui/recursion/recursion.rs @@ -1,5 +1,5 @@ //@ build-fail -//@ compile-flags:-C overflow-checks=off +//@ compile-flags:-C overflow-checks=off --diagnostic-width=100 -Zwrite-long-types-to-disk=yes enum Nil {NilValue} struct Cons<T> {head:isize, tail:T} diff --git a/tests/ui/recursion/recursion.stderr b/tests/ui/recursion/recursion.stderr index f959805defc..974f18ed103 100644 --- a/tests/ui/recursion/recursion.stderr +++ b/tests/ui/recursion/recursion.stderr @@ -1,4 +1,4 @@ -error: reached the recursion limit while instantiating `test::<Cons<Cons<Cons<Cons<Cons<...>>>>>>` +error: reached the recursion limit while instantiating `test::<Cons<Cons<Cons<Cons<Cons<Cons<...>>>>>>>` --> $DIR/recursion.rs:17:11 | LL | _ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})} @@ -9,7 +9,8 @@ note: `test` defined here | LL | fn test<T:Dot> (n:isize, i:isize, first:T, second:T) ->isize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the full type name has been written to '$TEST_BUILD_DIR/recursion.long-type.txt' + = note: the full name for the type has been written to '$TEST_BUILD_DIR/recursion.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error diff --git a/tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.rs b/tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.rs index 0875d385ddc..4abca916423 100644 --- a/tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.rs +++ b/tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.rs @@ -1,5 +1,5 @@ //@ build-fail -//@ compile-flags: -Copt-level=0 +//@ compile-flags: -Copt-level=0 --diagnostic-width=100 -Zwrite-long-types-to-disk=yes fn main() { rec(Empty); diff --git a/tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.stderr b/tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.stderr index fe005984fab..8d6d44dcbe2 100644 --- a/tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.stderr +++ b/tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.stderr @@ -1,4 +1,4 @@ -error: reached the recursion limit while instantiating `rec::<&mut &mut &mut &mut &mut ...>` +error: reached the recursion limit while instantiating `rec::<&mut &mut &mut &mut &mut &mut &mut &mut ...>` --> $DIR/recursive-impl-trait-iterator-by-ref-67552.rs:28:9 | LL | rec(identity(&mut it)) @@ -11,7 +11,8 @@ LL | / fn rec<T>(mut it: T) LL | | where LL | | T: Iterator, | |________________^ - = note: the full type name has been written to '$TEST_BUILD_DIR/recursive-impl-trait-iterator-by-ref-67552.long-type.txt' + = note: the full name for the type has been written to '$TEST_BUILD_DIR/recursive-impl-trait-iterator-by-ref-67552.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error diff --git a/tests/ui/recursion_limit/invalid_digit_type.stderr b/tests/ui/recursion_limit/invalid_digit_type.stderr index 94442b5747f..a122262f1df 100644 --- a/tests/ui/recursion_limit/invalid_digit_type.stderr +++ b/tests/ui/recursion_limit/invalid_digit_type.stderr @@ -3,6 +3,8 @@ error: malformed `recursion_limit` attribute input | LL | #![recursion_limit = 123] | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![recursion_limit = "N"]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/limits.html#the-recursion_limit-attribute> error: aborting due to 1 previous error diff --git a/tests/ui/recursion_limit/invalid_macro.stderr b/tests/ui/recursion_limit/invalid_macro.stderr index aa4894ec4d8..b4dbc9fcb13 100644 --- a/tests/ui/recursion_limit/invalid_macro.stderr +++ b/tests/ui/recursion_limit/invalid_macro.stderr @@ -3,6 +3,8 @@ error: malformed `recursion_limit` attribute input | LL | #![recursion_limit = foo!()] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![recursion_limit = "N"]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/limits.html#the-recursion_limit-attribute> error: aborting due to 1 previous error diff --git a/tests/ui/recursion_limit/no-value.stderr b/tests/ui/recursion_limit/no-value.stderr index b2e8c46c372..4a0ad04f271 100644 --- a/tests/ui/recursion_limit/no-value.stderr +++ b/tests/ui/recursion_limit/no-value.stderr @@ -3,6 +3,8 @@ error: malformed `recursion_limit` attribute input | LL | #![recursion_limit] | ^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![recursion_limit = "N"]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/limits.html#the-recursion_limit-attribute> error: aborting due to 1 previous error diff --git a/tests/ui/repr/invalid_repr_list_help.stderr b/tests/ui/repr/invalid_repr_list_help.stderr index 763ad9c2795..f9d1593275e 100644 --- a/tests/ui/repr/invalid_repr_list_help.stderr +++ b/tests/ui/repr/invalid_repr_list_help.stderr @@ -5,6 +5,7 @@ LL | #[repr(uwu)] | ^^^ | = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` + = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html?highlight=repr#representations> error[E0552]: unrecognized representation hint --> $DIR/invalid_repr_list_help.rs:6:8 @@ -13,6 +14,7 @@ LL | #[repr(uwu = "a")] | ^^^^^^^^^ | = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` + = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html?highlight=repr#representations> error[E0552]: unrecognized representation hint --> $DIR/invalid_repr_list_help.rs:9:8 @@ -21,6 +23,7 @@ LL | #[repr(uwu(4))] | ^^^^^^ | = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` + = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html?highlight=repr#representations> error[E0552]: unrecognized representation hint --> $DIR/invalid_repr_list_help.rs:14:8 @@ -29,6 +32,7 @@ LL | #[repr(uwu, u8)] | ^^^ | = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` + = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html?highlight=repr#representations> error[E0552]: unrecognized representation hint --> $DIR/invalid_repr_list_help.rs:19:8 @@ -37,6 +41,7 @@ LL | #[repr(uwu)] | ^^^ | = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` + = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html?highlight=repr#representations> error: unknown `doc` attribute `owo` --> $DIR/invalid_repr_list_help.rs:20:7 diff --git a/tests/ui/repr/repr.stderr b/tests/ui/repr/repr.stderr index 9e581332278..d4faea12517 100644 --- a/tests/ui/repr/repr.stderr +++ b/tests/ui/repr/repr.stderr @@ -2,28 +2,66 @@ error[E0539]: malformed `repr` attribute input --> $DIR/repr.rs:1:1 | LL | #[repr] - | ^^^^^^^ - | | - | expected this to be a list - | help: must be of the form: `#[repr(C | Rust | align(...) | packed(...) | <integer type> | transparent)]` + | ^^^^^^^ expected this to be a list + | + = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations> +help: try changing it to one of the following valid forms of the attribute + | +LL | #[repr(<integer type>)] + | ++++++++++++++++ +LL | #[repr(C)] + | +++ +LL | #[repr(Rust)] + | ++++++ +LL | #[repr(align(...))] + | ++++++++++++ + = and 2 other candidates error[E0539]: malformed `repr` attribute input --> $DIR/repr.rs:4:1 | LL | #[repr = "B"] - | ^^^^^^^^^^^^^ - | | - | expected this to be a list - | help: must be of the form: `#[repr(C | Rust | align(...) | packed(...) | <integer type> | transparent)]` + | ^^^^^^^^^^^^^ expected this to be a list + | + = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[repr = "B"] +LL + #[repr(<integer type>)] + | +LL - #[repr = "B"] +LL + #[repr(C)] + | +LL - #[repr = "B"] +LL + #[repr(Rust)] + | +LL - #[repr = "B"] +LL + #[repr(align(...))] + | + = and 2 other candidates error[E0539]: malformed `repr` attribute input --> $DIR/repr.rs:7:1 | LL | #[repr = "C"] - | ^^^^^^^^^^^^^ - | | - | expected this to be a list - | help: must be of the form: `#[repr(C | Rust | align(...) | packed(...) | <integer type> | transparent)]` + | ^^^^^^^^^^^^^ expected this to be a list + | + = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html#representations> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[repr = "C"] +LL + #[repr(<integer type>)] + | +LL - #[repr = "C"] +LL + #[repr(C)] + | +LL - #[repr = "C"] +LL + #[repr(Rust)] + | +LL - #[repr = "C"] +LL + #[repr(align(...))] + | + = and 2 other candidates error: aborting due to 3 previous errors diff --git a/tests/ui/resolve/extern-prelude-speculative.rs b/tests/ui/resolve/extern-prelude-speculative.rs new file mode 100644 index 00000000000..afbc32d22ac --- /dev/null +++ b/tests/ui/resolve/extern-prelude-speculative.rs @@ -0,0 +1,10 @@ +// Non-existent path in `--extern` doesn't result in an error if it's shadowed by `extern crate`. + +//@ check-pass +//@ compile-flags: --extern something=/path/to/nowhere + +extern crate std as something; + +fn main() { + something::println!(); +} diff --git a/tests/ui/resolve/inner-attr-prelude-macro.rs b/tests/ui/resolve/inner-attr-prelude-macro.rs new file mode 100644 index 00000000000..1047c908ad1 --- /dev/null +++ b/tests/ui/resolve/inner-attr-prelude-macro.rs @@ -0,0 +1,11 @@ +//@ check-pass +//! This test checks that macro names resolved from the libstd prelude +//! still work even if there's a crate-level custom inner attribute. + +#![feature(custom_inner_attributes)] + +#![rustfmt::skip] + +fn main() { + let _ = todo!(); +} diff --git a/tests/ui/resolve/issue-104700-inner_scope.rs b/tests/ui/resolve/issue-104700-inner_scope.rs index e8f28c113e3..fb77ab2626b 100644 --- a/tests/ui/resolve/issue-104700-inner_scope.rs +++ b/tests/ui/resolve/issue-104700-inner_scope.rs @@ -7,5 +7,12 @@ fn main() { if bar == 2 { //~ ERROR cannot find value println!("yes"); } + { + let baz = 3; + struct S; + } + if baz == 3 { //~ ERROR cannot find value + println!("yes"); + } test_func(1); //~ ERROR cannot find function } diff --git a/tests/ui/resolve/issue-104700-inner_scope.stderr b/tests/ui/resolve/issue-104700-inner_scope.stderr index 051b234fc72..b579f8e76d9 100644 --- a/tests/ui/resolve/issue-104700-inner_scope.stderr +++ b/tests/ui/resolve/issue-104700-inner_scope.stderr @@ -10,12 +10,24 @@ help: the binding `bar` is available in a different scope in the same function LL | let bar = 2; | ^^^ +error[E0425]: cannot find value `baz` in this scope + --> $DIR/issue-104700-inner_scope.rs:14:8 + | +LL | if baz == 3 { + | ^^^ + | +help: the binding `baz` is available in a different scope in the same function + --> $DIR/issue-104700-inner_scope.rs:11:13 + | +LL | let baz = 3; + | ^^^ + error[E0425]: cannot find function `test_func` in this scope - --> $DIR/issue-104700-inner_scope.rs:10:5 + --> $DIR/issue-104700-inner_scope.rs:17:5 | LL | test_func(1); | ^^^^^^^^^ not found in this scope -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/resolve/multiple_definitions_attribute_merging.rs b/tests/ui/resolve/multiple_definitions_attribute_merging.rs index 155abafdd9d..519b989fbe8 100644 --- a/tests/ui/resolve/multiple_definitions_attribute_merging.rs +++ b/tests/ui/resolve/multiple_definitions_attribute_merging.rs @@ -5,7 +5,7 @@ //@known-bug: #120873 //@ failure-status: 101 //@ normalize-stderr: "note: .*\n\n" -> "" -//@ normalize-stderr: "thread 'rustc' panicked.*\n" -> "" +//@ normalize-stderr: "thread 'rustc'.*panicked.*\n" -> "" //@ normalize-stderr: "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " //@ rustc-env:RUST_BACKTRACE=0 diff --git a/tests/ui/resolve/path-attr-in-const-block.stderr b/tests/ui/resolve/path-attr-in-const-block.stderr index 0b5942a287d..f3ae5b60c4f 100644 --- a/tests/ui/resolve/path-attr-in-const-block.stderr +++ b/tests/ui/resolve/path-attr-in-const-block.stderr @@ -12,6 +12,8 @@ LL | #![path = foo!()] | | | | | expected a string literal here | help: must be of the form: `#[path = "file"]` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/modules.html#the-path-attribute> error: aborting due to 2 previous errors diff --git a/tests/ui/issues/issue-14254.rs b/tests/ui/resolve/pointer-type-impls-14254.rs index 90ad375c262..ea8fb6aa167 100644 --- a/tests/ui/issues/issue-14254.rs +++ b/tests/ui/resolve/pointer-type-impls-14254.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/14254 + //@ check-pass trait Foo: Sized { diff --git a/tests/ui/resolve/proc_macro_generated_packed.rs b/tests/ui/resolve/proc_macro_generated_packed.rs index 0cba3c1616d..41236c732bb 100644 --- a/tests/ui/resolve/proc_macro_generated_packed.rs +++ b/tests/ui/resolve/proc_macro_generated_packed.rs @@ -5,7 +5,7 @@ //@known-bug: #120873 //@ failure-status: 101 //@ normalize-stderr: "note: .*\n\n" -> "" -//@ normalize-stderr: "thread 'rustc' panicked.*\n" -> "" +//@ normalize-stderr: "thread 'rustc'.*panicked.*\n" -> "" //@ normalize-stderr: "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " //@ rustc-env:RUST_BACKTRACE=0 diff --git a/tests/ui/issues/issue-14082.rs b/tests/ui/resolve/use-shadowing-14082.rs index 16556e1d260..9d7df5ed1c6 100644 --- a/tests/ui/issues/issue-14082.rs +++ b/tests/ui/resolve/use-shadowing-14082.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/14082 + //@ check-pass #![allow(unused_imports, dead_code)] diff --git a/tests/ui/resolve/visibility-indeterminate.rs b/tests/ui/resolve/visibility-indeterminate.rs index 17e5fec4701..181bb290774 100644 --- a/tests/ui/resolve/visibility-indeterminate.rs +++ b/tests/ui/resolve/visibility-indeterminate.rs @@ -2,6 +2,6 @@ foo!(); //~ ERROR cannot find macro `foo` in this scope -pub(in ::bar) struct Baz {} //~ ERROR cannot determine resolution for the visibility +pub(in ::bar) struct Baz {} //~ ERROR failed to resolve: could not find `bar` in the list of imported crates fn main() {} diff --git a/tests/ui/resolve/visibility-indeterminate.stderr b/tests/ui/resolve/visibility-indeterminate.stderr index 84d82ce8522..bbe28747f7c 100644 --- a/tests/ui/resolve/visibility-indeterminate.stderr +++ b/tests/ui/resolve/visibility-indeterminate.stderr @@ -1,8 +1,8 @@ -error[E0578]: cannot determine resolution for the visibility - --> $DIR/visibility-indeterminate.rs:5:8 +error[E0433]: failed to resolve: could not find `bar` in the list of imported crates + --> $DIR/visibility-indeterminate.rs:5:10 | LL | pub(in ::bar) struct Baz {} - | ^^^^^ + | ^^^ could not find `bar` in the list of imported crates error: cannot find macro `foo` in this scope --> $DIR/visibility-indeterminate.rs:3:1 @@ -12,4 +12,4 @@ LL | foo!(); error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0578`. +For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/rfcs/rfc-0000-never_patterns/ICE-130779-never-arm-no-oatherwise-block.stderr b/tests/ui/rfcs/rfc-0000-never_patterns/ICE-130779-never-arm-no-oatherwise-block.stderr index 26731e29ffc..5f4a5f31e34 100644 --- a/tests/ui/rfcs/rfc-0000-never_patterns/ICE-130779-never-arm-no-oatherwise-block.stderr +++ b/tests/ui/rfcs/rfc-0000-never_patterns/ICE-130779-never-arm-no-oatherwise-block.stderr @@ -5,12 +5,6 @@ LL | ! | | - ^ | | | while parsing this or-pattern starting here - | -help: remove the `|` - | -LL - ! | -LL + ! - | error: a never pattern is always unreachable --> $DIR/ICE-130779-never-arm-no-oatherwise-block.rs:10:20 diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr index b89c5e8dda8..020c2e6f241 100644 --- a/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr +++ b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `f32: Termination` is not satisfied --> $DIR/termination-trait-test-wrong-type.rs:6:31 | LL | #[test] - | ------- in this procedural macro expansion + | ------- in this attribute macro expansion LL | fn can_parse_zero_as_f32() -> Result<f32, ParseFloatError> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Termination` is not implemented for `f32` | diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.rs index 143f9a3009b..b538a97280d 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.rs @@ -3,11 +3,11 @@ struct Foo; #[non_exhaustive] -//~^ ERROR attribute should be applied to a struct or enum [E0701] +//~^ ERROR attribute cannot be used on trait Bar { } #[non_exhaustive] -//~^ ERROR attribute should be applied to a struct or enum [E0701] +//~^ ERROR attribute cannot be used on union Baz { f1: u16, f2: u16 diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.stderr index 1ac017aa08b..3522c459977 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.stderr +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.stderr @@ -7,28 +7,22 @@ LL | #[non_exhaustive(anything)] | | didn't expect any arguments here | help: must be of the form: `#[non_exhaustive]` -error[E0701]: attribute should be applied to a struct or enum +error: `#[non_exhaustive]` attribute cannot be used on traits --> $DIR/invalid-attribute.rs:5:1 | LL | #[non_exhaustive] | ^^^^^^^^^^^^^^^^^ -LL | -LL | trait Bar { } - | ------------- not a struct or enum + | + = help: `#[non_exhaustive]` can be applied to data types, enum variants -error[E0701]: attribute should be applied to a struct or enum +error: `#[non_exhaustive]` attribute cannot be used on unions --> $DIR/invalid-attribute.rs:9:1 | -LL | #[non_exhaustive] - | ^^^^^^^^^^^^^^^^^ -LL | -LL | / union Baz { -LL | | f1: u16, -LL | | f2: u16 -LL | | } - | |_- not a struct or enum +LL | #[non_exhaustive] + | ^^^^^^^^^^^^^^^^^ + | + = help: `#[non_exhaustive]` can be applied to data types, enum variants error: aborting due to 3 previous errors -Some errors have detailed explanations: E0565, E0701. -For more information about an error, try `rustc --explain E0565`. +For more information about this error, try `rustc --explain E0565`. diff --git a/tests/ui/rfcs/rfc-2091-track-caller/only-for-fns.rs b/tests/ui/rfcs/rfc-2091-track-caller/only-for-fns.rs index 2d2b01b6f94..53a856e0df3 100644 --- a/tests/ui/rfcs/rfc-2091-track-caller/only-for-fns.rs +++ b/tests/ui/rfcs/rfc-2091-track-caller/only-for-fns.rs @@ -1,5 +1,5 @@ #[track_caller] struct S; -//~^^ ERROR attribute should be applied to a function definition +//~^^ ERROR attribute cannot be used on fn main() {} diff --git a/tests/ui/rfcs/rfc-2091-track-caller/only-for-fns.stderr b/tests/ui/rfcs/rfc-2091-track-caller/only-for-fns.stderr index f976b7f5210..6ff66be4e5c 100644 --- a/tests/ui/rfcs/rfc-2091-track-caller/only-for-fns.stderr +++ b/tests/ui/rfcs/rfc-2091-track-caller/only-for-fns.stderr @@ -1,11 +1,10 @@ -error[E0739]: attribute should be applied to a function definition +error: `#[track_caller]` attribute cannot be used on structs --> $DIR/only-for-fns.rs:1:1 | LL | #[track_caller] | ^^^^^^^^^^^^^^^ -LL | struct S; - | --------- not a function definition + | + = help: `#[track_caller]` can only be applied to functions error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0739`. diff --git a/tests/ui/rfcs/type-alias-impl-trait/higher-ranked-regions-basic.rs b/tests/ui/rfcs/type-alias-impl-trait/higher-ranked-regions-basic.rs index 4cf2d1ac4a6..80a4ab35527 100644 --- a/tests/ui/rfcs/type-alias-impl-trait/higher-ranked-regions-basic.rs +++ b/tests/ui/rfcs/type-alias-impl-trait/higher-ranked-regions-basic.rs @@ -41,6 +41,7 @@ mod capture_tait_complex_pass { #[define_opaque(Opq2)] fn test() -> Opq2 {} //~^ ERROR: expected generic lifetime parameter, found `'a` + //~| ERROR: expected generic lifetime parameter, found `'b` } // Same as the above, but make sure that different placeholder regions are not equal. @@ -80,6 +81,7 @@ mod constrain_pass { #[define_opaque(Opq2)] fn test() -> Opq2 {} //~^ ERROR: expected generic lifetime parameter, found `'a` + //~| ERROR: expected generic lifetime parameter, found `'a` } fn main() {} diff --git a/tests/ui/rfcs/type-alias-impl-trait/higher-ranked-regions-basic.stderr b/tests/ui/rfcs/type-alias-impl-trait/higher-ranked-regions-basic.stderr index 3614fc8f45c..665b9a91696 100644 --- a/tests/ui/rfcs/type-alias-impl-trait/higher-ranked-regions-basic.stderr +++ b/tests/ui/rfcs/type-alias-impl-trait/higher-ranked-regions-basic.stderr @@ -36,8 +36,17 @@ LL | type Opq1<'a> = impl for<'b> Trait<'b, Ty = Opq0<'b>>; // <- Note 'b LL | fn test() -> Opq2 {} | ^^ +error[E0792]: expected generic lifetime parameter, found `'b` + --> $DIR/higher-ranked-regions-basic.rs:42:23 + | +LL | type Opq0<'a> = impl Sized; + | -- this generic parameter must be used with a generic lifetime parameter +... +LL | fn test() -> Opq2 {} + | ^^ + error[E0700]: hidden type for `capture_tait_complex_fail::Opq0<'a>` captures lifetime that does not appear in bounds - --> $DIR/higher-ranked-regions-basic.rs:53:23 + --> $DIR/higher-ranked-regions-basic.rs:54:23 | LL | type Opq0<'a> = impl Sized; | ---------- opaque type defined here @@ -48,7 +57,7 @@ LL | fn test() -> Opq2 {} | ^^ error[E0792]: expected generic lifetime parameter, found `'a` - --> $DIR/higher-ranked-regions-basic.rs:62:65 + --> $DIR/higher-ranked-regions-basic.rs:63:65 | LL | type Opq0<'a, 'b> = impl Sized; | -- this generic parameter must be used with a generic lifetime parameter @@ -57,7 +66,7 @@ LL | fn test() -> impl for<'a> Trait<'a, Ty = Opq0<'a, 'static>> {} | ^^ error[E0792]: expected generic lifetime parameter, found `'a` - --> $DIR/higher-ranked-regions-basic.rs:71:60 + --> $DIR/higher-ranked-regions-basic.rs:72:60 | LL | type Opq0<'a, 'b> = impl Sized; | -- this generic parameter must be used with a generic lifetime parameter @@ -66,7 +75,7 @@ LL | fn test() -> impl for<'a> Trait<'a, Ty = Opq0<'a, 'a>> {} | ^^ error[E0792]: expected generic lifetime parameter, found `'a` - --> $DIR/higher-ranked-regions-basic.rs:81:23 + --> $DIR/higher-ranked-regions-basic.rs:82:23 | LL | type Opq1<'a> = impl for<'b> Trait<'b, Ty = Opq0<'a, 'b>>; | -- this generic parameter must be used with a generic lifetime parameter @@ -74,7 +83,16 @@ LL | type Opq1<'a> = impl for<'b> Trait<'b, Ty = Opq0<'a, 'b>>; LL | fn test() -> Opq2 {} | ^^ -error: aborting due to 8 previous errors +error[E0792]: expected generic lifetime parameter, found `'a` + --> $DIR/higher-ranked-regions-basic.rs:82:23 + | +LL | type Opq0<'a, 'b> = impl Sized; + | -- this generic parameter must be used with a generic lifetime parameter +... +LL | fn test() -> Opq2 {} + | ^^ + +error: aborting due to 10 previous errors Some errors have detailed explanations: E0700, E0792. For more information about an error, try `rustc --explain E0700`. diff --git a/tests/ui/rust-2018/uniform-paths/deadlock.rs b/tests/ui/rust-2018/uniform-paths/deadlock.rs index 4011ba3ee28..d2296c51bdd 100644 --- a/tests/ui/rust-2018/uniform-paths/deadlock.rs +++ b/tests/ui/rust-2018/uniform-paths/deadlock.rs @@ -2,7 +2,7 @@ //@ compile-flags:--extern foo --extern bar use bar::foo; //~ ERROR can't find crate for `bar` -use foo::bar; //~ ERROR can't find crate for `foo` +use foo::bar; //~^^ ERROR unresolved imports `bar::foo`, `foo::bar` fn main() {} diff --git a/tests/ui/rust-2018/uniform-paths/deadlock.stderr b/tests/ui/rust-2018/uniform-paths/deadlock.stderr index 8b9863948bd..c50bc16ac55 100644 --- a/tests/ui/rust-2018/uniform-paths/deadlock.stderr +++ b/tests/ui/rust-2018/uniform-paths/deadlock.stderr @@ -4,12 +4,6 @@ error[E0463]: can't find crate for `bar` LL | use bar::foo; | ^^^ can't find crate -error[E0463]: can't find crate for `foo` - --> $DIR/deadlock.rs:5:5 - | -LL | use foo::bar; - | ^^^ can't find crate - error[E0432]: unresolved imports `bar::foo`, `foo::bar` --> $DIR/deadlock.rs:4:5 | @@ -18,7 +12,7 @@ LL | use bar::foo; LL | use foo::bar; | ^^^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0432, E0463. For more information about an error, try `rustc --explain E0432`. diff --git a/tests/ui/rustc_public-ir-print/async-closure.stdout b/tests/ui/rustc_public-ir-print/async-closure.stdout index 4afb15af7a9..73e9b8fc097 100644 --- a/tests/ui/rustc_public-ir-print/async-closure.stdout +++ b/tests/ui/rustc_public-ir-print/async-closure.stdout @@ -63,7 +63,7 @@ fn foo::{closure#0}::{closure#0}(_1: Pin<&mut {async closure body@$DIR/async-clo StorageDead(_3); _0 = std::task::Poll::Ready(move _5); _10 = CopyForDeref((_1.0: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6})); - discriminant((*_10) = 1; + discriminant((*_10)) = 1; return; } bb2: { @@ -101,7 +101,7 @@ fn foo::{closure#0}::{synthetic#0}(_1: Pin<&mut {async closure body@$DIR/async-c StorageDead(_3); _0 = std::task::Poll::Ready(move _5); _10 = CopyForDeref((_1.0: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6})); - discriminant((*_10) = 1; + discriminant((*_10)) = 1; return; } bb2: { diff --git a/tests/ui/rustdoc/check-doc-alias-attr-location.stderr b/tests/ui/rustdoc/check-doc-alias-attr-location.stderr index 4244c11eb3e..23c93a4ed8b 100644 --- a/tests/ui/rustdoc/check-doc-alias-attr-location.stderr +++ b/tests/ui/rustdoc/check-doc-alias-attr-location.stderr @@ -10,13 +10,13 @@ error: `#[doc(alias = "...")]` isn't allowed on foreign module LL | #[doc(alias = "foo")] | ^^^^^^^^^^^^^ -error: `#[doc(alias = "...")]` isn't allowed on inherent implementation block +error: `#[doc(alias = "...")]` isn't allowed on implementation block --> $DIR/check-doc-alias-attr-location.rs:12:7 | LL | #[doc(alias = "bar")] | ^^^^^^^^^^^^^ -error: `#[doc(alias = "...")]` isn't allowed on trait implementation block +error: `#[doc(alias = "...")]` isn't allowed on implementation block --> $DIR/check-doc-alias-attr-location.rs:18:7 | LL | #[doc(alias = "foobar")] diff --git a/tests/ui/self/arbitrary_self_type_infinite_recursion.stderr b/tests/ui/self/arbitrary_self_type_infinite_recursion.stderr index 5e652efb364..2dadc5c2d33 100644 --- a/tests/ui/self/arbitrary_self_type_infinite_recursion.stderr +++ b/tests/ui/self/arbitrary_self_type_infinite_recursion.stderr @@ -32,7 +32,7 @@ LL | p.method(); | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`arbitrary_self_type_infinite_recursion`) -error[E0599]: no method named `method` found for struct `MySmartPtr` in the current scope +error[E0599]: no method named `method` found for struct `MySmartPtr<T>` in the current scope --> $DIR/arbitrary_self_type_infinite_recursion.rs:21:5 | LL | struct MySmartPtr<T>(T); diff --git a/tests/ui/self/arbitrary_self_types_not_allow_call_with_no_deref.stderr b/tests/ui/self/arbitrary_self_types_not_allow_call_with_no_deref.stderr index a30cf605829..5d7f6142093 100644 --- a/tests/ui/self/arbitrary_self_types_not_allow_call_with_no_deref.stderr +++ b/tests/ui/self/arbitrary_self_types_not_allow_call_with_no_deref.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `frobnicate_ref` found for struct `CppRef` in the current scope +error[E0599]: no method named `frobnicate_ref` found for struct `CppRef<T>` in the current scope --> $DIR/arbitrary_self_types_not_allow_call_with_no_deref.rs:29:17 | LL | struct CppRef<T>(T); @@ -16,7 +16,7 @@ help: there is a method `frobnicate_cpp_ref` with a similar name LL | foo_cpp_ref.frobnicate_cpp_ref(); | ++++ -error[E0599]: no method named `frobnicate_self` found for struct `CppRef` in the current scope +error[E0599]: no method named `frobnicate_self` found for struct `CppRef<T>` in the current scope --> $DIR/arbitrary_self_types_not_allow_call_with_no_deref.rs:32:17 | LL | struct CppRef<T>(T); diff --git a/tests/ui/self/arbitrary_self_types_pin_needing_borrow.rs b/tests/ui/self/arbitrary_self_types_pin_needing_borrow.rs index d877dbe6075..28845890278 100644 --- a/tests/ui/self/arbitrary_self_types_pin_needing_borrow.rs +++ b/tests/ui/self/arbitrary_self_types_pin_needing_borrow.rs @@ -9,5 +9,5 @@ impl S { fn main() { Pin::new(S).x(); //~^ ERROR the trait bound `S: Deref` is not satisfied - //~| ERROR no method named `x` found for struct `Pin` in the current scope + //~| ERROR no method named `x` found for struct `Pin<Ptr>` in the current scope } diff --git a/tests/ui/self/arbitrary_self_types_pin_needing_borrow.stderr b/tests/ui/self/arbitrary_self_types_pin_needing_borrow.stderr index 1811cd6753f..df226a9366a 100644 --- a/tests/ui/self/arbitrary_self_types_pin_needing_borrow.stderr +++ b/tests/ui/self/arbitrary_self_types_pin_needing_borrow.stderr @@ -15,7 +15,7 @@ LL | Pin::new(&S).x(); LL | Pin::new(&mut S).x(); | ++++ -error[E0599]: no method named `x` found for struct `Pin` in the current scope +error[E0599]: no method named `x` found for struct `Pin<Ptr>` in the current scope --> $DIR/arbitrary_self_types_pin_needing_borrow.rs:10:17 | LL | Pin::new(S).x(); diff --git a/tests/ui/simd/const-err-trumps-simd-err.stderr b/tests/ui/simd/const-err-trumps-simd-err.stderr index 93d1fce637f..6d25a28c92c 100644 --- a/tests/ui/simd/const-err-trumps-simd-err.stderr +++ b/tests/ui/simd/const-err-trumps-simd-err.stderr @@ -1,8 +1,8 @@ error[E0080]: evaluation panicked: assertion failed: LANE < 4 - --> $DIR/const-err-trumps-simd-err.rs:17:13 + --> $DIR/const-err-trumps-simd-err.rs:17:21 | LL | const { assert!(LANE < 4); } // the error should be here... - | ^^^^^^^^^^^^^^^^^ evaluation of `get_elem::<4>::{constant#0}` failed here + | ^^^^^^^^ evaluation of `get_elem::<4>::{constant#0}` failed here note: erroneous constant encountered --> $DIR/const-err-trumps-simd-err.rs:17:5 diff --git a/tests/ui/simd/libm_no_std_cant_float.stderr b/tests/ui/simd/libm_no_std_cant_float.stderr index 97e0b7efe2a..cc9aefaad5e 100644 --- a/tests/ui/simd/libm_no_std_cant_float.stderr +++ b/tests/ui/simd/libm_no_std_cant_float.stderr @@ -1,34 +1,34 @@ -error[E0599]: no method named `ceil` found for struct `Simd` in the current scope +error[E0599]: no method named `ceil` found for struct `Simd<T, N>` in the current scope --> $DIR/libm_no_std_cant_float.rs:15:17 | LL | let _xc = x.ceil(); | ^^^^ method not found in `Simd<f32, 4>` -error[E0599]: no method named `floor` found for struct `Simd` in the current scope +error[E0599]: no method named `floor` found for struct `Simd<T, N>` in the current scope --> $DIR/libm_no_std_cant_float.rs:16:17 | LL | let _xf = x.floor(); | ^^^^^ method not found in `Simd<f32, 4>` -error[E0599]: no method named `round` found for struct `Simd` in the current scope +error[E0599]: no method named `round` found for struct `Simd<T, N>` in the current scope --> $DIR/libm_no_std_cant_float.rs:17:17 | LL | let _xr = x.round(); | ^^^^^ method not found in `Simd<f32, 4>` -error[E0599]: no method named `trunc` found for struct `Simd` in the current scope +error[E0599]: no method named `trunc` found for struct `Simd<T, N>` in the current scope --> $DIR/libm_no_std_cant_float.rs:18:17 | LL | let _xt = x.trunc(); | ^^^^^ method not found in `Simd<f32, 4>` -error[E0599]: no method named `mul_add` found for struct `Simd` in the current scope +error[E0599]: no method named `mul_add` found for struct `Simd<T, N>` in the current scope --> $DIR/libm_no_std_cant_float.rs:19:19 | LL | let _xfma = x.mul_add(x, x); | ^^^^^^^ method not found in `Simd<f32, 4>` -error[E0599]: no method named `sqrt` found for struct `Simd` in the current scope +error[E0599]: no method named `sqrt` found for struct `Simd<T, N>` in the current scope --> $DIR/libm_no_std_cant_float.rs:20:20 | LL | let _xsqrt = x.sqrt(); diff --git a/tests/ui/span/E0539.stderr b/tests/ui/span/E0539.stderr index 01f091a2676..34d81b73cb5 100644 --- a/tests/ui/span/E0539.stderr +++ b/tests/ui/span/E0539.stderr @@ -6,10 +6,14 @@ LL | #[inline(unknown)] | | | valid arguments are `always` or `never` | + = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/codegen.html#the-inline-attribute> help: try changing it to one of the following valid forms of the attribute | LL - #[inline(unknown)] -LL + #[inline(always|never)] +LL + #[inline(always)] + | +LL - #[inline(unknown)] +LL + #[inline(never)] | LL - #[inline(unknown)] LL + #[inline] diff --git a/tests/ui/span/borrowck-call-is-borrow-issue-12224.stderr b/tests/ui/span/borrowck-call-is-borrow-issue-12224.stderr index f37dc320fa3..f7750884b4a 100644 --- a/tests/ui/span/borrowck-call-is-borrow-issue-12224.stderr +++ b/tests/ui/span/borrowck-call-is-borrow-issue-12224.stderr @@ -44,6 +44,7 @@ LL | LL | foo(f); | ^ move occurs because `f` has type `{closure@$DIR/borrowck-call-is-borrow-issue-12224.rs:52:17: 52:58}`, which does not implement the `Copy` trait | + = help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once help: consider cloning the value if the performance cost is acceptable | LL | foo(f.clone()); diff --git a/tests/ui/specialization/defaultimpl/validation.rs b/tests/ui/specialization/defaultimpl/validation.rs index 14771be8982..78f6099c3dd 100644 --- a/tests/ui/specialization/defaultimpl/validation.rs +++ b/tests/ui/specialization/defaultimpl/validation.rs @@ -4,7 +4,7 @@ struct S; struct Z; -default impl S {} //~ ERROR inherent impls cannot be `default` +default impl S {} //~ ERROR inherent impls cannot be default default unsafe impl Send for S {} //~^ ERROR impls of auto traits cannot be default diff --git a/tests/ui/specialization/defaultimpl/validation.stderr b/tests/ui/specialization/defaultimpl/validation.stderr index 82a33bf9cdc..a8dfef2dcfb 100644 --- a/tests/ui/specialization/defaultimpl/validation.stderr +++ b/tests/ui/specialization/defaultimpl/validation.stderr @@ -1,10 +1,10 @@ -error: inherent impls cannot be `default` +error: inherent impls cannot be default --> $DIR/validation.rs:7:14 | LL | default impl S {} | ------- ^ inherent impl for this type | | - | `default` because of this + | default because of this | = note: only trait implementations may be annotated with `default` diff --git a/tests/ui/issues/issue-9249.rs b/tests/ui/static/static-string-slice-9249.rs index b98ba050521..da099117bd4 100644 --- a/tests/ui/issues/issue-9249.rs +++ b/tests/ui/static/static-string-slice-9249.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/9249 //@ check-pass #![allow(dead_code)] diff --git a/tests/ui/issues/issue-16452.rs b/tests/ui/statics/conditional-static-declaration-16010.rs index 4ab74f09059..0bc5b0ee86f 100644 --- a/tests/ui/issues/issue-16452.rs +++ b/tests/ui/statics/conditional-static-declaration-16010.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/16010 + //@ run-pass #![allow(dead_code)] diff --git a/tests/ui/stats/macro-stats.rs b/tests/ui/stats/macro-stats.rs index d986904ddd6..1b7d58bf058 100644 --- a/tests/ui/stats/macro-stats.rs +++ b/tests/ui/stats/macro-stats.rs @@ -49,10 +49,32 @@ fn opt(x: Option<u32>) { } } -macro_rules! long_name_that_fits_on_a_single_line { - () => {} -} -long_name_that_fits_on_a_single_line!(); +macro_rules! long_name_that_fits_on_one_line { () => {} } +long_name_that_fits_on_one_line!(); +long_name_that_fits_on_one_line!(); +long_name_that_fits_on_one_line!(); +long_name_that_fits_on_one_line!(); +long_name_that_fits_on_one_line!(); +long_name_that_fits_on_one_line!(); +long_name_that_fits_on_one_line!(); +long_name_that_fits_on_one_line!(); +long_name_that_fits_on_one_line!(); +long_name_that_fits_on_one_line!(); + +macro_rules! long_name_that_fits_on_one_line_ { () => {} } +long_name_that_fits_on_one_line_!(); + +macro_rules! long_name_that_fits_on_one_line__ { () => {} } +long_name_that_fits_on_one_line__!(); + +macro_rules! long_name_that_fits_on_one_line___ { () => {} } +long_name_that_fits_on_one_line___!(); + +macro_rules! long_name_that_fits_on_one_line____ { () => {} } +long_name_that_fits_on_one_line____!(); + +macro_rules! long_name_that_fits_on_one_line_____ { () => {} } +long_name_that_fits_on_one_line_____!(); macro_rules! long_name_that_doesnt_fit_on_one_line { ($t:ty) => { diff --git a/tests/ui/stats/macro-stats.stderr b/tests/ui/stats/macro-stats.stderr index 8d0fdb8958a..75b90df6466 100644 --- a/tests/ui/stats/macro-stats.stderr +++ b/tests/ui/stats/macro-stats.stderr @@ -22,6 +22,11 @@ macro-stats trait_tys! 1 2 2.0 macro-stats n99! 2 2 1.0 4 2.0 macro-stats none! 1 1 1.0 4 4.0 macro-stats u32! 1 1 1.0 3 3.0 -macro-stats long_name_that_fits_on_a_single_line! 1 1 1.0 0 0.0 +macro-stats long_name_that_fits_on_one_line! 10 10 1.0 0 0.0 +macro-stats long_name_that_fits_on_one_line_____! 1 1 1.0 0 0.0 +macro-stats long_name_that_fits_on_one_line____! 1 1 1.0 0 0.0 +macro-stats long_name_that_fits_on_one_line___! 1 1 1.0 0 0.0 +macro-stats long_name_that_fits_on_one_line__! 1 1 1.0 0 0.0 +macro-stats long_name_that_fits_on_one_line_! 1 1 1.0 0 0.0 macro-stats #[test] 1 1 1.0 0 0.0 macro-stats =================================================================================== diff --git a/tests/ui/structs/default-field-values/auxiliary/struct_field_default.rs b/tests/ui/structs/default-field-values/auxiliary/struct_field_default.rs index b315df5dba2..a1c9645a1ae 100644 --- a/tests/ui/structs/default-field-values/auxiliary/struct_field_default.rs +++ b/tests/ui/structs/default-field-values/auxiliary/struct_field_default.rs @@ -3,3 +3,13 @@ pub struct A { pub a: isize = 42, } + +struct Priv; + +pub struct B { + pub a: Priv = Priv, +} + +pub struct C { + pub a: Priv, +} diff --git a/tests/ui/structs/default-field-values/non-exhaustive-ctor-2.rs b/tests/ui/structs/default-field-values/non-exhaustive-ctor-2.rs new file mode 100644 index 00000000000..047505c3f1c --- /dev/null +++ b/tests/ui/structs/default-field-values/non-exhaustive-ctor-2.rs @@ -0,0 +1,29 @@ +//@ aux-build:struct_field_default.rs +#![feature(default_field_values)] + +extern crate struct_field_default as xc; + +use m::S; + +mod m { + pub struct S { + pub field: () = (), + pub field1: Priv1 = Priv1 {}, + pub field2: Priv2 = Priv2, + } + struct Priv1 {} + struct Priv2; +} + +fn main() { + let _ = S { field: (), field1: m::Priv1 {} }; + //~^ ERROR missing field `field2` + //~| ERROR struct `Priv1` is private + let _ = S { field: (), field1: m::Priv1 {}, field2: m::Priv2 }; + //~^ ERROR struct `Priv1` is private + //~| ERROR unit struct `Priv2` is private + let _ = xc::B { a: xc::Priv }; + //~^ ERROR unit struct `Priv` is private + let _ = xc::C { a: xc::Priv }; + //~^ ERROR unit struct `Priv` is private +} diff --git a/tests/ui/structs/default-field-values/non-exhaustive-ctor-2.stderr b/tests/ui/structs/default-field-values/non-exhaustive-ctor-2.stderr new file mode 100644 index 00000000000..66de73561db --- /dev/null +++ b/tests/ui/structs/default-field-values/non-exhaustive-ctor-2.stderr @@ -0,0 +1,105 @@ +error[E0603]: struct `Priv1` is private + --> $DIR/non-exhaustive-ctor-2.rs:19:39 + | +LL | let _ = S { field: (), field1: m::Priv1 {} }; + | ------ ^^^^^ private struct + | | + | while setting this field + | +note: the struct `Priv1` is defined here + --> $DIR/non-exhaustive-ctor-2.rs:14:4 + | +LL | struct Priv1 {} + | ^^^^^^^^^^^^ +help: the type `Priv1` of field `field1` is private, but you can construct the default value defined for it in `S` using `..` in the struct initializer expression + | +LL - let _ = S { field: (), field1: m::Priv1 {} }; +LL + let _ = S { field: (), .. }; + | + +error[E0603]: struct `Priv1` is private + --> $DIR/non-exhaustive-ctor-2.rs:22:39 + | +LL | let _ = S { field: (), field1: m::Priv1 {}, field2: m::Priv2 }; + | ------ ^^^^^ private struct + | | + | while setting this field + | +note: the struct `Priv1` is defined here + --> $DIR/non-exhaustive-ctor-2.rs:14:4 + | +LL | struct Priv1 {} + | ^^^^^^^^^^^^ +help: the type `Priv1` of field `field1` is private, but you can construct the default value defined for it in `S` using `..` in the struct initializer expression + | +LL - let _ = S { field: (), field1: m::Priv1 {}, field2: m::Priv2 }; +LL + let _ = S { field: (), field2: m::Priv2, .. }; + | + +error[E0603]: unit struct `Priv2` is private + --> $DIR/non-exhaustive-ctor-2.rs:22:60 + | +LL | let _ = S { field: (), field1: m::Priv1 {}, field2: m::Priv2 }; + | ------ ^^^^^ private unit struct + | | + | while setting this field + | +note: the unit struct `Priv2` is defined here + --> $DIR/non-exhaustive-ctor-2.rs:15:4 + | +LL | struct Priv2; + | ^^^^^^^^^^^^^ +help: the type `Priv2` of field `field2` is private, but you can construct the default value defined for it in `S` using `..` in the struct initializer expression + | +LL - let _ = S { field: (), field1: m::Priv1 {}, field2: m::Priv2 }; +LL + let _ = S { field: (), field1: m::Priv1 {}, .. }; + | + +error[E0603]: unit struct `Priv` is private + --> $DIR/non-exhaustive-ctor-2.rs:25:28 + | +LL | let _ = xc::B { a: xc::Priv }; + | - ^^^^ private unit struct + | | + | while setting this field + | +note: the unit struct `Priv` is defined here + --> $DIR/auxiliary/struct_field_default.rs:7:1 + | +LL | struct Priv; + | ^^^^^^^^^^^ +help: the type `Priv` of field `a` is private, but you can construct the default value defined for it in `B` using `..` in the struct initializer expression + | +LL - let _ = xc::B { a: xc::Priv }; +LL + let _ = xc::B { .. }; + | + +error[E0603]: unit struct `Priv` is private + --> $DIR/non-exhaustive-ctor-2.rs:27:28 + | +LL | let _ = xc::C { a: xc::Priv }; + | - ^^^^ private unit struct + | | + | while setting this field + | +note: the unit struct `Priv` is defined here + --> $DIR/auxiliary/struct_field_default.rs:7:1 + | +LL | struct Priv; + | ^^^^^^^^^^^ + +error[E0063]: missing field `field2` in initializer of `S` + --> $DIR/non-exhaustive-ctor-2.rs:19:13 + | +LL | let _ = S { field: (), field1: m::Priv1 {} }; + | ^ missing `field2` + | +help: all remaining fields have default values, you can use those values with `..` + | +LL | let _ = S { field: (), field1: m::Priv1 {}, .. }; + | ++++ + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0063, E0603. +For more information about an error, try `rustc --explain E0063`. diff --git a/tests/ui/issues/issue-24365.rs b/tests/ui/structs/struct-field-access-errors-24365.rs index da195116047..13a95cd1cca 100644 --- a/tests/ui/issues/issue-24365.rs +++ b/tests/ui/structs/struct-field-access-errors-24365.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/24365 pub enum Attribute { Code {attr_name_idx: u16}, } diff --git a/tests/ui/issues/issue-24365.stderr b/tests/ui/structs/struct-field-access-errors-24365.stderr index 3f6ed0231d8..65275af4701 100644 --- a/tests/ui/issues/issue-24365.stderr +++ b/tests/ui/structs/struct-field-access-errors-24365.stderr @@ -1,17 +1,17 @@ error[E0609]: no field `b` on type `Foo` - --> $DIR/issue-24365.rs:10:22 + --> $DIR/struct-field-access-errors-24365.rs:11:22 | LL | println!("{}", a.b); | ^ unknown field error[E0609]: no field `attr_name_idx` on type `&Attribute` - --> $DIR/issue-24365.rs:17:18 + --> $DIR/struct-field-access-errors-24365.rs:18:18 | LL | let z = (&x).attr_name_idx; | ^^^^^^^^^^^^^ unknown field error[E0609]: no field `attr_name_idx` on type `Attribute` - --> $DIR/issue-24365.rs:18:15 + --> $DIR/struct-field-access-errors-24365.rs:19:15 | LL | let y = x.attr_name_idx; | ^^^^^^^^^^^^^ unknown field diff --git a/tests/ui/structs/tuple-struct-field-naming-47073.stderr b/tests/ui/structs/tuple-struct-field-naming-47073.stderr index efbdaeca4ea..09ba2fb406a 100644 --- a/tests/ui/structs/tuple-struct-field-naming-47073.stderr +++ b/tests/ui/structs/tuple-struct-field-naming-47073.stderr @@ -4,11 +4,7 @@ error[E0609]: no field `00` on type `Verdict` LL | let _condemned = justice.00; | ^^ unknown field | -help: a field with a similar name exists - | -LL - let _condemned = justice.00; -LL + let _condemned = justice.0; - | + = note: available fields are: `0`, `1` error[E0609]: no field `001` on type `Verdict` --> $DIR/tuple-struct-field-naming-47073.rs:11:31 diff --git a/tests/ui/suggestions/dont-suggest-ref/move-into-closure.rs b/tests/ui/suggestions/dont-suggest-ref/move-into-closure.rs index 44eac3691a3..34088f219b2 100644 --- a/tests/ui/suggestions/dont-suggest-ref/move-into-closure.rs +++ b/tests/ui/suggestions/dont-suggest-ref/move-into-closure.rs @@ -11,8 +11,55 @@ struct X(Y); struct Y; fn consume_fn<F: Fn()>(_f: F) { } +//~^ HELP `Fn` and `FnMut` closures +//~| HELP `Fn` and `FnMut` closures +//~| HELP `Fn` and `FnMut` closures +//~| HELP `Fn` and `FnMut` closures +//~| HELP `Fn` and `FnMut` closures +//~| HELP `Fn` and `FnMut` closures +//~| HELP `Fn` and `FnMut` closures +//~| HELP `Fn` and `FnMut` closures +//~| HELP `Fn` and `FnMut` closures +//~| HELP `Fn` and `FnMut` closures fn consume_fnmut<F: FnMut()>(_f: F) { } +//~^ HELP `Fn` and `FnMut` closures +//~| HELP `Fn` and `FnMut` closures +//~| HELP `Fn` and `FnMut` closures +//~| HELP `Fn` and `FnMut` closures +//~| HELP `Fn` and `FnMut` closures +//~| HELP `Fn` and `FnMut` closures +//~| HELP `Fn` and `FnMut` closures +//~| HELP `Fn` and `FnMut` closures +//~| HELP `Fn` and `FnMut` closures +//~| HELP `Fn` and `FnMut` closures +//~| HELP `Fn` and `FnMut` closures + +trait T { + fn consume_fn<F: Fn()>(_f: F) { } + //~^ HELP `Fn` and `FnMut` closures + //~| HELP `Fn` and `FnMut` closures + //~| HELP `Fn` and `FnMut` closures + //~| HELP `Fn` and `FnMut` closures + //~| HELP `Fn` and `FnMut` closures + //~| HELP `Fn` and `FnMut` closures + //~| HELP `Fn` and `FnMut` closures + //~| HELP `Fn` and `FnMut` closures + //~| HELP `Fn` and `FnMut` closures + //~| HELP `Fn` and `FnMut` closures + fn method_consume_fn<F: Fn()>(&self, _f: F) { } + //~^ HELP `Fn` and `FnMut` closures + //~| HELP `Fn` and `FnMut` closures + //~| HELP `Fn` and `FnMut` closures + //~| HELP `Fn` and `FnMut` closures + //~| HELP `Fn` and `FnMut` closures + //~| HELP `Fn` and `FnMut` closures + //~| HELP `Fn` and `FnMut` closures + //~| HELP `Fn` and `FnMut` closures + //~| HELP `Fn` and `FnMut` closures + //~| HELP `Fn` and `FnMut` closures +} +impl T for () {} pub fn main() { } @@ -73,6 +120,120 @@ fn move_into_fn() { }); } +fn move_into_assoc_fn() { + let e = Either::One(X(Y)); + let mut em = Either::One(X(Y)); + + let x = X(Y); + + // move into Fn + + <() as T>::consume_fn(|| { + let X(_t) = x; + //~^ ERROR cannot move + //~| HELP consider borrowing here + if let Either::One(_t) = e { } + //~^ ERROR cannot move + //~| HELP consider borrowing here + while let Either::One(_t) = e { } + //~^ ERROR cannot move + //~| HELP consider borrowing here + match e { + //~^ ERROR cannot move + //~| HELP consider borrowing here + Either::One(_t) + | Either::Two(_t) => (), + } + match e { + //~^ ERROR cannot move + //~| HELP consider borrowing here + Either::One(_t) => (), + Either::Two(ref _t) => (), + // FIXME: should suggest removing `ref` too + } + + let X(mut _t) = x; + //~^ ERROR cannot move + //~| HELP consider borrowing here + if let Either::One(mut _t) = em { } + //~^ ERROR cannot move + //~| HELP consider borrowing here + while let Either::One(mut _t) = em { } + //~^ ERROR cannot move + //~| HELP consider borrowing here + match em { + //~^ ERROR cannot move + //~| HELP consider borrowing here + Either::One(mut _t) + | Either::Two(mut _t) => (), + } + match em { + //~^ ERROR cannot move + //~| HELP consider borrowing here + Either::One(mut _t) => (), + Either::Two(ref _t) => (), + // FIXME: should suggest removing `ref` too + } + }); +} + +fn move_into_method() { + let e = Either::One(X(Y)); + let mut em = Either::One(X(Y)); + + let x = X(Y); + + // move into Fn + + ().method_consume_fn(|| { + let X(_t) = x; + //~^ ERROR cannot move + //~| HELP consider borrowing here + if let Either::One(_t) = e { } + //~^ ERROR cannot move + //~| HELP consider borrowing here + while let Either::One(_t) = e { } + //~^ ERROR cannot move + //~| HELP consider borrowing here + match e { + //~^ ERROR cannot move + //~| HELP consider borrowing here + Either::One(_t) + | Either::Two(_t) => (), + } + match e { + //~^ ERROR cannot move + //~| HELP consider borrowing here + Either::One(_t) => (), + Either::Two(ref _t) => (), + // FIXME: should suggest removing `ref` too + } + + let X(mut _t) = x; + //~^ ERROR cannot move + //~| HELP consider borrowing here + if let Either::One(mut _t) = em { } + //~^ ERROR cannot move + //~| HELP consider borrowing here + while let Either::One(mut _t) = em { } + //~^ ERROR cannot move + //~| HELP consider borrowing here + match em { + //~^ ERROR cannot move + //~| HELP consider borrowing here + Either::One(mut _t) + | Either::Two(mut _t) => (), + } + match em { + //~^ ERROR cannot move + //~| HELP consider borrowing here + Either::One(mut _t) => (), + Either::Two(ref _t) => (), + // FIXME: should suggest removing `ref` too + } + }); +} + fn move_into_fnmut() { let e = Either::One(X(Y)); let mut em = Either::One(X(Y)); diff --git a/tests/ui/suggestions/dont-suggest-ref/move-into-closure.stderr b/tests/ui/suggestions/dont-suggest-ref/move-into-closure.stderr index edda2cbc735..39c2fabf9eb 100644 --- a/tests/ui/suggestions/dont-suggest-ref/move-into-closure.stderr +++ b/tests/ui/suggestions/dont-suggest-ref/move-into-closure.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `Fn` closure - --> $DIR/move-into-closure.rs:28:21 + --> $DIR/move-into-closure.rs:75:21 | LL | let x = X(Y); | - captured outer variable @@ -12,13 +12,18 @@ LL | let X(_t) = x; | data moved here | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:13:18 + | +LL | fn consume_fn<F: Fn()>(_f: F) { } + | ^^^^ help: consider borrowing here | LL | let X(_t) = &x; | + error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure - --> $DIR/move-into-closure.rs:31:34 + --> $DIR/move-into-closure.rs:78:34 | LL | let e = Either::One(X(Y)); | - captured outer variable @@ -32,13 +37,18 @@ LL | if let Either::One(_t) = e { } | data moved here | move occurs because `_t` has type `X`, which does not implement the `Copy` trait | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:13:18 + | +LL | fn consume_fn<F: Fn()>(_f: F) { } + | ^^^^ help: consider borrowing here | LL | if let Either::One(_t) = &e { } | + error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure - --> $DIR/move-into-closure.rs:34:37 + --> $DIR/move-into-closure.rs:81:37 | LL | let e = Either::One(X(Y)); | - captured outer variable @@ -52,13 +62,18 @@ LL | while let Either::One(_t) = e { } | data moved here | move occurs because `_t` has type `X`, which does not implement the `Copy` trait | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:13:18 + | +LL | fn consume_fn<F: Fn()>(_f: F) { } + | ^^^^ help: consider borrowing here | LL | while let Either::One(_t) = &e { } | + error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure - --> $DIR/move-into-closure.rs:37:15 + --> $DIR/move-into-closure.rs:84:15 | LL | let e = Either::One(X(Y)); | - captured outer variable @@ -75,13 +90,18 @@ LL | Either::One(_t) | data moved here | move occurs because `_t` has type `X`, which does not implement the `Copy` trait | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:13:18 + | +LL | fn consume_fn<F: Fn()>(_f: F) { } + | ^^^^ help: consider borrowing here | LL | match &e { | + error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure - --> $DIR/move-into-closure.rs:43:15 + --> $DIR/move-into-closure.rs:90:15 | LL | let e = Either::One(X(Y)); | - captured outer variable @@ -98,13 +118,18 @@ LL | Either::One(_t) => (), | data moved here | move occurs because `_t` has type `X`, which does not implement the `Copy` trait | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:13:18 + | +LL | fn consume_fn<F: Fn()>(_f: F) { } + | ^^^^ help: consider borrowing here | LL | match &e { | + error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `Fn` closure - --> $DIR/move-into-closure.rs:51:25 + --> $DIR/move-into-closure.rs:98:25 | LL | let x = X(Y); | - captured outer variable @@ -118,13 +143,18 @@ LL | let X(mut _t) = x; | data moved here | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:13:18 + | +LL | fn consume_fn<F: Fn()>(_f: F) { } + | ^^^^ help: consider borrowing here | LL | let X(mut _t) = &x; | + error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure - --> $DIR/move-into-closure.rs:54:38 + --> $DIR/move-into-closure.rs:101:38 | LL | let mut em = Either::One(X(Y)); | ------ captured outer variable @@ -138,13 +168,18 @@ LL | if let Either::One(mut _t) = em { } | data moved here | move occurs because `_t` has type `X`, which does not implement the `Copy` trait | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:13:18 + | +LL | fn consume_fn<F: Fn()>(_f: F) { } + | ^^^^ help: consider borrowing here | LL | if let Either::One(mut _t) = &em { } | + error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure - --> $DIR/move-into-closure.rs:57:41 + --> $DIR/move-into-closure.rs:104:41 | LL | let mut em = Either::One(X(Y)); | ------ captured outer variable @@ -158,13 +193,18 @@ LL | while let Either::One(mut _t) = em { } | data moved here | move occurs because `_t` has type `X`, which does not implement the `Copy` trait | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:13:18 + | +LL | fn consume_fn<F: Fn()>(_f: F) { } + | ^^^^ help: consider borrowing here | LL | while let Either::One(mut _t) = &em { } | + error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure - --> $DIR/move-into-closure.rs:60:15 + --> $DIR/move-into-closure.rs:107:15 | LL | let mut em = Either::One(X(Y)); | ------ captured outer variable @@ -181,13 +221,18 @@ LL | Either::One(mut _t) | data moved here | move occurs because `_t` has type `X`, which does not implement the `Copy` trait | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:13:18 + | +LL | fn consume_fn<F: Fn()>(_f: F) { } + | ^^^^ help: consider borrowing here | LL | match &em { | + error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure - --> $DIR/move-into-closure.rs:66:15 + --> $DIR/move-into-closure.rs:113:15 | LL | let mut em = Either::One(X(Y)); | ------ captured outer variable @@ -204,13 +249,540 @@ LL | Either::One(mut _t) => (), | data moved here | move occurs because `_t` has type `X`, which does not implement the `Copy` trait | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:13:18 + | +LL | fn consume_fn<F: Fn()>(_f: F) { } + | ^^^^ +help: consider borrowing here + | +LL | match &em { + | + + +error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:132:21 + | +LL | let x = X(Y); + | - captured outer variable +... +LL | <() as T>::consume_fn(|| { + | -- captured by this `Fn` closure +LL | let X(_t) = x; + | -- ^ + | | + | data moved here + | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait + | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:39:22 + | +LL | fn consume_fn<F: Fn()>(_f: F) { } + | ^^^^ +help: consider borrowing here + | +LL | let X(_t) = &x; + | + + +error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:135:34 + | +LL | let e = Either::One(X(Y)); + | - captured outer variable +... +LL | <() as T>::consume_fn(|| { + | -- captured by this `Fn` closure +... +LL | if let Either::One(_t) = e { } + | -- ^ + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:39:22 + | +LL | fn consume_fn<F: Fn()>(_f: F) { } + | ^^^^ +help: consider borrowing here + | +LL | if let Either::One(_t) = &e { } + | + + +error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:138:37 + | +LL | let e = Either::One(X(Y)); + | - captured outer variable +... +LL | <() as T>::consume_fn(|| { + | -- captured by this `Fn` closure +... +LL | while let Either::One(_t) = e { } + | -- ^ + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:39:22 + | +LL | fn consume_fn<F: Fn()>(_f: F) { } + | ^^^^ +help: consider borrowing here + | +LL | while let Either::One(_t) = &e { } + | + + +error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:141:15 + | +LL | let e = Either::One(X(Y)); + | - captured outer variable +... +LL | <() as T>::consume_fn(|| { + | -- captured by this `Fn` closure +... +LL | match e { + | ^ +... +LL | Either::One(_t) + | -- + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:39:22 + | +LL | fn consume_fn<F: Fn()>(_f: F) { } + | ^^^^ +help: consider borrowing here + | +LL | match &e { + | + + +error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:147:15 + | +LL | let e = Either::One(X(Y)); + | - captured outer variable +... +LL | <() as T>::consume_fn(|| { + | -- captured by this `Fn` closure +... +LL | match e { + | ^ +... +LL | Either::One(_t) => (), + | -- + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:39:22 + | +LL | fn consume_fn<F: Fn()>(_f: F) { } + | ^^^^ +help: consider borrowing here + | +LL | match &e { + | + + +error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:155:25 + | +LL | let x = X(Y); + | - captured outer variable +... +LL | <() as T>::consume_fn(|| { + | -- captured by this `Fn` closure +... +LL | let X(mut _t) = x; + | ------ ^ + | | + | data moved here + | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait + | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:39:22 + | +LL | fn consume_fn<F: Fn()>(_f: F) { } + | ^^^^ +help: consider borrowing here + | +LL | let X(mut _t) = &x; + | + + +error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:158:38 + | +LL | let mut em = Either::One(X(Y)); + | ------ captured outer variable +... +LL | <() as T>::consume_fn(|| { + | -- captured by this `Fn` closure +... +LL | if let Either::One(mut _t) = em { } + | ------ ^^ + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:39:22 + | +LL | fn consume_fn<F: Fn()>(_f: F) { } + | ^^^^ +help: consider borrowing here + | +LL | if let Either::One(mut _t) = &em { } + | + + +error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:161:41 + | +LL | let mut em = Either::One(X(Y)); + | ------ captured outer variable +... +LL | <() as T>::consume_fn(|| { + | -- captured by this `Fn` closure +... +LL | while let Either::One(mut _t) = em { } + | ------ ^^ + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:39:22 + | +LL | fn consume_fn<F: Fn()>(_f: F) { } + | ^^^^ +help: consider borrowing here + | +LL | while let Either::One(mut _t) = &em { } + | + + +error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:164:15 + | +LL | let mut em = Either::One(X(Y)); + | ------ captured outer variable +... +LL | <() as T>::consume_fn(|| { + | -- captured by this `Fn` closure +... +LL | match em { + | ^^ +... +LL | Either::One(mut _t) + | ------ + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:39:22 + | +LL | fn consume_fn<F: Fn()>(_f: F) { } + | ^^^^ +help: consider borrowing here + | +LL | match &em { + | + + +error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:170:15 + | +LL | let mut em = Either::One(X(Y)); + | ------ captured outer variable +... +LL | <() as T>::consume_fn(|| { + | -- captured by this `Fn` closure +... +LL | match em { + | ^^ +... +LL | Either::One(mut _t) => (), + | ------ + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:39:22 + | +LL | fn consume_fn<F: Fn()>(_f: F) { } + | ^^^^ +help: consider borrowing here + | +LL | match &em { + | + + +error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:189:21 + | +LL | let x = X(Y); + | - captured outer variable +... +LL | ().method_consume_fn(|| { + | -- captured by this `Fn` closure +LL | let X(_t) = x; + | -- ^ + | | + | data moved here + | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait + | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:50:29 + | +LL | fn method_consume_fn<F: Fn()>(&self, _f: F) { } + | ^^^^ +help: consider borrowing here + | +LL | let X(_t) = &x; + | + + +error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:192:34 + | +LL | let e = Either::One(X(Y)); + | - captured outer variable +... +LL | ().method_consume_fn(|| { + | -- captured by this `Fn` closure +... +LL | if let Either::One(_t) = e { } + | -- ^ + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:50:29 + | +LL | fn method_consume_fn<F: Fn()>(&self, _f: F) { } + | ^^^^ +help: consider borrowing here + | +LL | if let Either::One(_t) = &e { } + | + + +error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:195:37 + | +LL | let e = Either::One(X(Y)); + | - captured outer variable +... +LL | ().method_consume_fn(|| { + | -- captured by this `Fn` closure +... +LL | while let Either::One(_t) = e { } + | -- ^ + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:50:29 + | +LL | fn method_consume_fn<F: Fn()>(&self, _f: F) { } + | ^^^^ +help: consider borrowing here + | +LL | while let Either::One(_t) = &e { } + | + + +error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:198:15 + | +LL | let e = Either::One(X(Y)); + | - captured outer variable +... +LL | ().method_consume_fn(|| { + | -- captured by this `Fn` closure +... +LL | match e { + | ^ +... +LL | Either::One(_t) + | -- + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:50:29 + | +LL | fn method_consume_fn<F: Fn()>(&self, _f: F) { } + | ^^^^ +help: consider borrowing here + | +LL | match &e { + | + + +error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:204:15 + | +LL | let e = Either::One(X(Y)); + | - captured outer variable +... +LL | ().method_consume_fn(|| { + | -- captured by this `Fn` closure +... +LL | match e { + | ^ +... +LL | Either::One(_t) => (), + | -- + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:50:29 + | +LL | fn method_consume_fn<F: Fn()>(&self, _f: F) { } + | ^^^^ +help: consider borrowing here + | +LL | match &e { + | + + +error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:212:25 + | +LL | let x = X(Y); + | - captured outer variable +... +LL | ().method_consume_fn(|| { + | -- captured by this `Fn` closure +... +LL | let X(mut _t) = x; + | ------ ^ + | | + | data moved here + | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait + | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:50:29 + | +LL | fn method_consume_fn<F: Fn()>(&self, _f: F) { } + | ^^^^ +help: consider borrowing here + | +LL | let X(mut _t) = &x; + | + + +error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:215:38 + | +LL | let mut em = Either::One(X(Y)); + | ------ captured outer variable +... +LL | ().method_consume_fn(|| { + | -- captured by this `Fn` closure +... +LL | if let Either::One(mut _t) = em { } + | ------ ^^ + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:50:29 + | +LL | fn method_consume_fn<F: Fn()>(&self, _f: F) { } + | ^^^^ +help: consider borrowing here + | +LL | if let Either::One(mut _t) = &em { } + | + + +error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:218:41 + | +LL | let mut em = Either::One(X(Y)); + | ------ captured outer variable +... +LL | ().method_consume_fn(|| { + | -- captured by this `Fn` closure +... +LL | while let Either::One(mut _t) = em { } + | ------ ^^ + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:50:29 + | +LL | fn method_consume_fn<F: Fn()>(&self, _f: F) { } + | ^^^^ +help: consider borrowing here + | +LL | while let Either::One(mut _t) = &em { } + | + + +error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:221:15 + | +LL | let mut em = Either::One(X(Y)); + | ------ captured outer variable +... +LL | ().method_consume_fn(|| { + | -- captured by this `Fn` closure +... +LL | match em { + | ^^ +... +LL | Either::One(mut _t) + | ------ + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:50:29 + | +LL | fn method_consume_fn<F: Fn()>(&self, _f: F) { } + | ^^^^ +help: consider borrowing here + | +LL | match &em { + | + + +error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure + --> $DIR/move-into-closure.rs:227:15 + | +LL | let mut em = Either::One(X(Y)); + | ------ captured outer variable +... +LL | ().method_consume_fn(|| { + | -- captured by this `Fn` closure +... +LL | match em { + | ^^ +... +LL | Either::One(mut _t) => (), + | ------ + | | + | data moved here + | move occurs because `_t` has type `X`, which does not implement the `Copy` trait + | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:50:29 + | +LL | fn method_consume_fn<F: Fn()>(&self, _f: F) { } + | ^^^^ help: consider borrowing here | LL | match &em { | + error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `FnMut` closure - --> $DIR/move-into-closure.rs:85:21 + --> $DIR/move-into-closure.rs:246:21 | LL | let x = X(Y); | - captured outer variable @@ -223,13 +795,18 @@ LL | let X(_t) = x; | data moved here | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:25:21 + | +LL | fn consume_fnmut<F: FnMut()>(_f: F) { } + | ^^^^^^^ help: consider borrowing here | LL | let X(_t) = &x; | + error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure - --> $DIR/move-into-closure.rs:88:34 + --> $DIR/move-into-closure.rs:249:34 | LL | let e = Either::One(X(Y)); | - captured outer variable @@ -243,13 +820,18 @@ LL | if let Either::One(_t) = e { } | data moved here | move occurs because `_t` has type `X`, which does not implement the `Copy` trait | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:25:21 + | +LL | fn consume_fnmut<F: FnMut()>(_f: F) { } + | ^^^^^^^ help: consider borrowing here | LL | if let Either::One(_t) = &e { } | + error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure - --> $DIR/move-into-closure.rs:91:37 + --> $DIR/move-into-closure.rs:252:37 | LL | let e = Either::One(X(Y)); | - captured outer variable @@ -263,13 +845,18 @@ LL | while let Either::One(_t) = e { } | data moved here | move occurs because `_t` has type `X`, which does not implement the `Copy` trait | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:25:21 + | +LL | fn consume_fnmut<F: FnMut()>(_f: F) { } + | ^^^^^^^ help: consider borrowing here | LL | while let Either::One(_t) = &e { } | + error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure - --> $DIR/move-into-closure.rs:94:15 + --> $DIR/move-into-closure.rs:255:15 | LL | let e = Either::One(X(Y)); | - captured outer variable @@ -286,13 +873,18 @@ LL | Either::One(_t) | data moved here | move occurs because `_t` has type `X`, which does not implement the `Copy` trait | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:25:21 + | +LL | fn consume_fnmut<F: FnMut()>(_f: F) { } + | ^^^^^^^ help: consider borrowing here | LL | match &e { | + error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure - --> $DIR/move-into-closure.rs:100:15 + --> $DIR/move-into-closure.rs:261:15 | LL | let e = Either::One(X(Y)); | - captured outer variable @@ -309,13 +901,18 @@ LL | Either::One(_t) => (), | data moved here | move occurs because `_t` has type `X`, which does not implement the `Copy` trait | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:25:21 + | +LL | fn consume_fnmut<F: FnMut()>(_f: F) { } + | ^^^^^^^ help: consider borrowing here | LL | match &e { | + error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `FnMut` closure - --> $DIR/move-into-closure.rs:108:25 + --> $DIR/move-into-closure.rs:269:25 | LL | let x = X(Y); | - captured outer variable @@ -329,13 +926,18 @@ LL | let X(mut _t) = x; | data moved here | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:25:21 + | +LL | fn consume_fnmut<F: FnMut()>(_f: F) { } + | ^^^^^^^ help: consider borrowing here | LL | let X(mut _t) = &x; | + error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure - --> $DIR/move-into-closure.rs:111:38 + --> $DIR/move-into-closure.rs:272:38 | LL | let mut em = Either::One(X(Y)); | ------ captured outer variable @@ -349,13 +951,18 @@ LL | if let Either::One(mut _t) = em { } | data moved here | move occurs because `_t` has type `X`, which does not implement the `Copy` trait | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:25:21 + | +LL | fn consume_fnmut<F: FnMut()>(_f: F) { } + | ^^^^^^^ help: consider borrowing here | LL | if let Either::One(mut _t) = &em { } | + error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure - --> $DIR/move-into-closure.rs:114:41 + --> $DIR/move-into-closure.rs:275:41 | LL | let mut em = Either::One(X(Y)); | ------ captured outer variable @@ -369,13 +976,18 @@ LL | while let Either::One(mut _t) = em { } | data moved here | move occurs because `_t` has type `X`, which does not implement the `Copy` trait | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:25:21 + | +LL | fn consume_fnmut<F: FnMut()>(_f: F) { } + | ^^^^^^^ help: consider borrowing here | LL | while let Either::One(mut _t) = &em { } | + error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure - --> $DIR/move-into-closure.rs:117:15 + --> $DIR/move-into-closure.rs:278:15 | LL | let mut em = Either::One(X(Y)); | ------ captured outer variable @@ -392,13 +1004,18 @@ LL | Either::One(mut _t) | data moved here | move occurs because `_t` has type `X`, which does not implement the `Copy` trait | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:25:21 + | +LL | fn consume_fnmut<F: FnMut()>(_f: F) { } + | ^^^^^^^ help: consider borrowing here | LL | match &em { | + error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure - --> $DIR/move-into-closure.rs:123:15 + --> $DIR/move-into-closure.rs:284:15 | LL | let mut em = Either::One(X(Y)); | ------ captured outer variable @@ -415,13 +1032,18 @@ LL | Either::One(mut _t) => (), | data moved here | move occurs because `_t` has type `X`, which does not implement the `Copy` trait | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:25:21 + | +LL | fn consume_fnmut<F: FnMut()>(_f: F) { } + | ^^^^^^^ help: consider borrowing here | LL | match &em { | + error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure - --> $DIR/move-into-closure.rs:130:15 + --> $DIR/move-into-closure.rs:291:15 | LL | let mut em = Either::One(X(Y)); | ------ captured outer variable @@ -438,11 +1060,16 @@ LL | Either::One(mut _t) => (), | data moved here | move occurs because `_t` has type `X`, which does not implement the `Copy` trait | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/move-into-closure.rs:25:21 + | +LL | fn consume_fnmut<F: FnMut()>(_f: F) { } + | ^^^^^^^ help: consider borrowing here | LL | match &em { | + -error: aborting due to 21 previous errors +error: aborting due to 41 previous errors For more information about this error, try `rustc --explain E0507`. diff --git a/tests/ui/suggestions/enum-method-probe.fixed b/tests/ui/suggestions/enum-method-probe.fixed index b7fd6f112d5..1ce6a943c5b 100644 --- a/tests/ui/suggestions/enum-method-probe.fixed +++ b/tests/ui/suggestions/enum-method-probe.fixed @@ -14,7 +14,7 @@ impl Foo { fn test_result_in_result() -> Result<(), ()> { let res: Result<_, ()> = Ok(Foo); res?.get(); - //~^ ERROR no method named `get` found for enum `Result` in the current scope + //~^ ERROR no method named `get` found for enum `Result<T, E>` in the current scope //~| HELP use the `?` operator Ok(()) } @@ -22,7 +22,7 @@ fn test_result_in_result() -> Result<(), ()> { async fn async_test_result_in_result() -> Result<(), ()> { let res: Result<_, ()> = Ok(Foo); res?.get(); - //~^ ERROR no method named `get` found for enum `Result` in the current scope + //~^ ERROR no method named `get` found for enum `Result<T, E>` in the current scope //~| HELP use the `?` operator Ok(()) } @@ -30,21 +30,21 @@ async fn async_test_result_in_result() -> Result<(), ()> { fn test_result_in_unit_return() { let res: Result<_, ()> = Ok(Foo); res.expect("REASON").get(); - //~^ ERROR no method named `get` found for enum `Result` in the current scope + //~^ ERROR no method named `get` found for enum `Result<T, E>` in the current scope //~| HELP consider using `Result::expect` to unwrap the `Foo` value, panicking if the value is a `Result::Err` } async fn async_test_result_in_unit_return() { let res: Result<_, ()> = Ok(Foo); res.expect("REASON").get(); - //~^ ERROR no method named `get` found for enum `Result` in the current scope + //~^ ERROR no method named `get` found for enum `Result<T, E>` in the current scope //~| HELP consider using `Result::expect` to unwrap the `Foo` value, panicking if the value is a `Result::Err` } fn test_option_in_option() -> Option<()> { let res: Option<_> = Some(Foo); res?.get(); - //~^ ERROR no method named `get` found for enum `Option` in the current scope + //~^ ERROR no method named `get` found for enum `Option<T>` in the current scope //~| HELP use the `?` operator Some(()) } @@ -52,7 +52,7 @@ fn test_option_in_option() -> Option<()> { fn test_option_in_unit_return() { let res: Option<_> = Some(Foo); res.expect("REASON").get(); - //~^ ERROR no method named `get` found for enum `Option` in the current scope + //~^ ERROR no method named `get` found for enum `Option<T>` in the current scope //~| HELP consider using `Option::expect` to unwrap the `Foo` value, panicking if the value is an `Option::None` } diff --git a/tests/ui/suggestions/enum-method-probe.rs b/tests/ui/suggestions/enum-method-probe.rs index cbb819b7c8c..dd3addbd0a3 100644 --- a/tests/ui/suggestions/enum-method-probe.rs +++ b/tests/ui/suggestions/enum-method-probe.rs @@ -14,7 +14,7 @@ impl Foo { fn test_result_in_result() -> Result<(), ()> { let res: Result<_, ()> = Ok(Foo); res.get(); - //~^ ERROR no method named `get` found for enum `Result` in the current scope + //~^ ERROR no method named `get` found for enum `Result<T, E>` in the current scope //~| HELP use the `?` operator Ok(()) } @@ -22,7 +22,7 @@ fn test_result_in_result() -> Result<(), ()> { async fn async_test_result_in_result() -> Result<(), ()> { let res: Result<_, ()> = Ok(Foo); res.get(); - //~^ ERROR no method named `get` found for enum `Result` in the current scope + //~^ ERROR no method named `get` found for enum `Result<T, E>` in the current scope //~| HELP use the `?` operator Ok(()) } @@ -30,21 +30,21 @@ async fn async_test_result_in_result() -> Result<(), ()> { fn test_result_in_unit_return() { let res: Result<_, ()> = Ok(Foo); res.get(); - //~^ ERROR no method named `get` found for enum `Result` in the current scope + //~^ ERROR no method named `get` found for enum `Result<T, E>` in the current scope //~| HELP consider using `Result::expect` to unwrap the `Foo` value, panicking if the value is a `Result::Err` } async fn async_test_result_in_unit_return() { let res: Result<_, ()> = Ok(Foo); res.get(); - //~^ ERROR no method named `get` found for enum `Result` in the current scope + //~^ ERROR no method named `get` found for enum `Result<T, E>` in the current scope //~| HELP consider using `Result::expect` to unwrap the `Foo` value, panicking if the value is a `Result::Err` } fn test_option_in_option() -> Option<()> { let res: Option<_> = Some(Foo); res.get(); - //~^ ERROR no method named `get` found for enum `Option` in the current scope + //~^ ERROR no method named `get` found for enum `Option<T>` in the current scope //~| HELP use the `?` operator Some(()) } @@ -52,7 +52,7 @@ fn test_option_in_option() -> Option<()> { fn test_option_in_unit_return() { let res: Option<_> = Some(Foo); res.get(); - //~^ ERROR no method named `get` found for enum `Option` in the current scope + //~^ ERROR no method named `get` found for enum `Option<T>` in the current scope //~| HELP consider using `Option::expect` to unwrap the `Foo` value, panicking if the value is an `Option::None` } diff --git a/tests/ui/suggestions/enum-method-probe.stderr b/tests/ui/suggestions/enum-method-probe.stderr index e66973d9d95..5aa0fc44c7b 100644 --- a/tests/ui/suggestions/enum-method-probe.stderr +++ b/tests/ui/suggestions/enum-method-probe.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `get` found for enum `Result` in the current scope +error[E0599]: no method named `get` found for enum `Result<T, E>` in the current scope --> $DIR/enum-method-probe.rs:24:9 | LL | res.get(); @@ -14,7 +14,7 @@ help: use the `?` operator to extract the `Foo` value, propagating a `Result::Er LL | res?.get(); | + -error[E0599]: no method named `get` found for enum `Result` in the current scope +error[E0599]: no method named `get` found for enum `Result<T, E>` in the current scope --> $DIR/enum-method-probe.rs:39:9 | LL | res.get(); @@ -30,7 +30,7 @@ help: consider using `Result::expect` to unwrap the `Foo` value, panicking if th LL | res.expect("REASON").get(); | +++++++++++++++++ -error[E0599]: no method named `get` found for enum `Result` in the current scope +error[E0599]: no method named `get` found for enum `Result<T, E>` in the current scope --> $DIR/enum-method-probe.rs:16:9 | LL | res.get(); @@ -46,7 +46,7 @@ help: use the `?` operator to extract the `Foo` value, propagating a `Result::Er LL | res?.get(); | + -error[E0599]: no method named `get` found for enum `Result` in the current scope +error[E0599]: no method named `get` found for enum `Result<T, E>` in the current scope --> $DIR/enum-method-probe.rs:32:9 | LL | res.get(); @@ -62,7 +62,7 @@ help: consider using `Result::expect` to unwrap the `Foo` value, panicking if th LL | res.expect("REASON").get(); | +++++++++++++++++ -error[E0599]: no method named `get` found for enum `Option` in the current scope +error[E0599]: no method named `get` found for enum `Option<T>` in the current scope --> $DIR/enum-method-probe.rs:46:9 | LL | res.get(); @@ -78,7 +78,7 @@ help: use the `?` operator to extract the `Foo` value, propagating an `Option::N LL | res?.get(); | + -error[E0599]: no method named `get` found for enum `Option` in the current scope +error[E0599]: no method named `get` found for enum `Option<T>` in the current scope --> $DIR/enum-method-probe.rs:54:9 | LL | res.get(); diff --git a/tests/ui/suggestions/field-has-method.rs b/tests/ui/suggestions/field-has-method.rs index d28b6ba546c..6e584d78338 100644 --- a/tests/ui/suggestions/field-has-method.rs +++ b/tests/ui/suggestions/field-has-method.rs @@ -17,7 +17,7 @@ struct InferOk<T> { fn foo(i: InferOk<Ty>) { let k = i.kind(); - //~^ ERROR no method named `kind` found for struct `InferOk` in the current scope + //~^ ERROR no method named `kind` found for struct `InferOk<T>` in the current scope } fn main() {} diff --git a/tests/ui/suggestions/field-has-method.stderr b/tests/ui/suggestions/field-has-method.stderr index daff2db6418..adcb723e4f1 100644 --- a/tests/ui/suggestions/field-has-method.stderr +++ b/tests/ui/suggestions/field-has-method.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `kind` found for struct `InferOk` in the current scope +error[E0599]: no method named `kind` found for struct `InferOk<T>` in the current scope --> $DIR/field-has-method.rs:19:15 | LL | struct InferOk<T> { diff --git a/tests/ui/suggestions/for-loop-missing-in.fixed b/tests/ui/suggestions/for-loop-missing-in.fixed index ff376b5a52c..396c3ff87ff 100644 --- a/tests/ui/suggestions/for-loop-missing-in.fixed +++ b/tests/ui/suggestions/for-loop-missing-in.fixed @@ -1,8 +1,7 @@ //@ run-rustfix fn main() { - for _i in 0..2 { //~ ERROR missing `in` - } - for _i in 0..2 { //~ ERROR missing `in` - } + for _i in 0..2 {} //~ ERROR missing `in` + for _i in 0..2 {} //~ ERROR missing `in` + for _i in 0..2 {} //~ ERROR missing `in` } diff --git a/tests/ui/suggestions/for-loop-missing-in.rs b/tests/ui/suggestions/for-loop-missing-in.rs index 28c12aec665..6c2092106cb 100644 --- a/tests/ui/suggestions/for-loop-missing-in.rs +++ b/tests/ui/suggestions/for-loop-missing-in.rs @@ -1,8 +1,7 @@ //@ run-rustfix fn main() { - for _i 0..2 { //~ ERROR missing `in` - } - for _i of 0..2 { //~ ERROR missing `in` - } + for _i 0..2 {} //~ ERROR missing `in` + for _i of 0..2 {} //~ ERROR missing `in` + for _i = 0..2 {} //~ ERROR missing `in` } diff --git a/tests/ui/suggestions/for-loop-missing-in.stderr b/tests/ui/suggestions/for-loop-missing-in.stderr index 4e0cb229d50..b9c8c393406 100644 --- a/tests/ui/suggestions/for-loop-missing-in.stderr +++ b/tests/ui/suggestions/for-loop-missing-in.stderr @@ -1,25 +1,37 @@ error: missing `in` in `for` loop --> $DIR/for-loop-missing-in.rs:4:11 | -LL | for _i 0..2 { +LL | for _i 0..2 {} | ^ | help: try adding `in` here | -LL | for _i in 0..2 { +LL | for _i in 0..2 {} | ++ error: missing `in` in `for` loop - --> $DIR/for-loop-missing-in.rs:6:12 + --> $DIR/for-loop-missing-in.rs:5:12 | -LL | for _i of 0..2 { +LL | for _i of 0..2 {} | ^^ | help: try using `in` here instead | -LL - for _i of 0..2 { -LL + for _i in 0..2 { +LL - for _i of 0..2 {} +LL + for _i in 0..2 {} + | + +error: missing `in` in `for` loop + --> $DIR/for-loop-missing-in.rs:6:12 + | +LL | for _i = 0..2 {} + | ^ + | +help: try using `in` here instead + | +LL - for _i = 0..2 {} +LL + for _i in 0..2 {} | -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/suggestions/inner_type.fixed b/tests/ui/suggestions/inner_type.fixed index 175a2a02acd..8174f8e204e 100644 --- a/tests/ui/suggestions/inner_type.fixed +++ b/tests/ui/suggestions/inner_type.fixed @@ -15,26 +15,26 @@ fn main() { let other_item = std::cell::RefCell::new(Struct { p: 42_u32 }); other_item.borrow().method(); - //~^ ERROR no method named `method` found for struct `RefCell` in the current scope [E0599] + //~^ ERROR no method named `method` found for struct `RefCell<T>` in the current scope [E0599] //~| HELP use `.borrow()` to borrow the `Struct<u32>`, panicking if a mutable borrow exists other_item.borrow_mut().some_mutable_method(); - //~^ ERROR no method named `some_mutable_method` found for struct `RefCell` in the current scope [E0599] + //~^ ERROR no method named `some_mutable_method` found for struct `RefCell<T>` in the current scope [E0599] //~| HELP .borrow_mut()` to mutably borrow the `Struct<u32>`, panicking if any borrows exist let another_item = std::sync::Mutex::new(Struct { p: 42_u32 }); another_item.lock().unwrap().method(); - //~^ ERROR no method named `method` found for struct `std::sync::Mutex` in the current scope [E0599] + //~^ ERROR no method named `method` found for struct `std::sync::Mutex<T>` in the current scope [E0599] //~| HELP use `.lock().unwrap()` to borrow the `Struct<u32>`, blocking the current thread until it can be acquired let another_item = std::sync::RwLock::new(Struct { p: 42_u32 }); another_item.read().unwrap().method(); - //~^ ERROR no method named `method` found for struct `RwLock` in the current scope [E0599] + //~^ ERROR no method named `method` found for struct `RwLock<T>` in the current scope [E0599] //~| HELP use `.read().unwrap()` to borrow the `Struct<u32>`, blocking the current thread until it can be acquired another_item.write().unwrap().some_mutable_method(); - //~^ ERROR no method named `some_mutable_method` found for struct `RwLock` in the current scope [E0599] + //~^ ERROR no method named `some_mutable_method` found for struct `RwLock<T>` in the current scope [E0599] //~| HELP use `.write().unwrap()` to mutably borrow the `Struct<u32>`, blocking the current thread until it can be acquired } diff --git a/tests/ui/suggestions/inner_type.rs b/tests/ui/suggestions/inner_type.rs index ab021414f56..e4eaf07ca8b 100644 --- a/tests/ui/suggestions/inner_type.rs +++ b/tests/ui/suggestions/inner_type.rs @@ -15,26 +15,26 @@ fn main() { let other_item = std::cell::RefCell::new(Struct { p: 42_u32 }); other_item.method(); - //~^ ERROR no method named `method` found for struct `RefCell` in the current scope [E0599] + //~^ ERROR no method named `method` found for struct `RefCell<T>` in the current scope [E0599] //~| HELP use `.borrow()` to borrow the `Struct<u32>`, panicking if a mutable borrow exists other_item.some_mutable_method(); - //~^ ERROR no method named `some_mutable_method` found for struct `RefCell` in the current scope [E0599] + //~^ ERROR no method named `some_mutable_method` found for struct `RefCell<T>` in the current scope [E0599] //~| HELP .borrow_mut()` to mutably borrow the `Struct<u32>`, panicking if any borrows exist let another_item = std::sync::Mutex::new(Struct { p: 42_u32 }); another_item.method(); - //~^ ERROR no method named `method` found for struct `std::sync::Mutex` in the current scope [E0599] + //~^ ERROR no method named `method` found for struct `std::sync::Mutex<T>` in the current scope [E0599] //~| HELP use `.lock().unwrap()` to borrow the `Struct<u32>`, blocking the current thread until it can be acquired let another_item = std::sync::RwLock::new(Struct { p: 42_u32 }); another_item.method(); - //~^ ERROR no method named `method` found for struct `RwLock` in the current scope [E0599] + //~^ ERROR no method named `method` found for struct `RwLock<T>` in the current scope [E0599] //~| HELP use `.read().unwrap()` to borrow the `Struct<u32>`, blocking the current thread until it can be acquired another_item.some_mutable_method(); - //~^ ERROR no method named `some_mutable_method` found for struct `RwLock` in the current scope [E0599] + //~^ ERROR no method named `some_mutable_method` found for struct `RwLock<T>` in the current scope [E0599] //~| HELP use `.write().unwrap()` to mutably borrow the `Struct<u32>`, blocking the current thread until it can be acquired } diff --git a/tests/ui/suggestions/inner_type.stderr b/tests/ui/suggestions/inner_type.stderr index 67ebb5789b7..017ddb5ad6d 100644 --- a/tests/ui/suggestions/inner_type.stderr +++ b/tests/ui/suggestions/inner_type.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `method` found for struct `RefCell` in the current scope +error[E0599]: no method named `method` found for struct `RefCell<T>` in the current scope --> $DIR/inner_type.rs:17:16 | LL | other_item.method(); @@ -14,7 +14,7 @@ help: use `.borrow()` to borrow the `Struct<u32>`, panicking if a mutable borrow LL | other_item.borrow().method(); | +++++++++ -error[E0599]: no method named `some_mutable_method` found for struct `RefCell` in the current scope +error[E0599]: no method named `some_mutable_method` found for struct `RefCell<T>` in the current scope --> $DIR/inner_type.rs:21:16 | LL | other_item.some_mutable_method(); @@ -30,7 +30,7 @@ help: use `.borrow_mut()` to mutably borrow the `Struct<u32>`, panicking if any LL | other_item.borrow_mut().some_mutable_method(); | +++++++++++++ -error[E0599]: no method named `method` found for struct `std::sync::Mutex` in the current scope +error[E0599]: no method named `method` found for struct `std::sync::Mutex<T>` in the current scope --> $DIR/inner_type.rs:27:18 | LL | another_item.method(); @@ -46,7 +46,7 @@ help: use `.lock().unwrap()` to borrow the `Struct<u32>`, blocking the current t LL | another_item.lock().unwrap().method(); | ++++++++++++++++ -error[E0599]: no method named `method` found for struct `RwLock` in the current scope +error[E0599]: no method named `method` found for struct `RwLock<T>` in the current scope --> $DIR/inner_type.rs:33:18 | LL | another_item.method(); @@ -62,7 +62,7 @@ help: use `.read().unwrap()` to borrow the `Struct<u32>`, blocking the current t LL | another_item.read().unwrap().method(); | ++++++++++++++++ -error[E0599]: no method named `some_mutable_method` found for struct `RwLock` in the current scope +error[E0599]: no method named `some_mutable_method` found for struct `RwLock<T>` in the current scope --> $DIR/inner_type.rs:37:18 | LL | another_item.some_mutable_method(); diff --git a/tests/ui/suggestions/inner_type2.rs b/tests/ui/suggestions/inner_type2.rs index fac68c053eb..7082862f409 100644 --- a/tests/ui/suggestions/inner_type2.rs +++ b/tests/ui/suggestions/inner_type2.rs @@ -16,11 +16,11 @@ thread_local! { fn main() { STRUCT.method(); - //~^ ERROR no method named `method` found for struct `LocalKey` in the current scope [E0599] + //~^ ERROR no method named `method` found for struct `LocalKey<T>` in the current scope [E0599] //~| HELP use `with` or `try_with` to access thread local storage let item = std::mem::MaybeUninit::new(Struct { p: 42_u32 }); item.method(); - //~^ ERROR no method named `method` found for union `MaybeUninit` in the current scope [E0599] + //~^ ERROR no method named `method` found for union `MaybeUninit<T>` in the current scope [E0599] //~| HELP if this `MaybeUninit<Struct<u32>>` has been initialized, use one of the `assume_init` methods to access the inner value } diff --git a/tests/ui/suggestions/inner_type2.stderr b/tests/ui/suggestions/inner_type2.stderr index 984366123c8..e6cb2048522 100644 --- a/tests/ui/suggestions/inner_type2.stderr +++ b/tests/ui/suggestions/inner_type2.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `method` found for struct `LocalKey` in the current scope +error[E0599]: no method named `method` found for struct `LocalKey<T>` in the current scope --> $DIR/inner_type2.rs:18:12 | LL | STRUCT.method(); @@ -11,7 +11,7 @@ note: the method `method` exists on the type `Struct<u32>` LL | pub fn method(&self) {} | ^^^^^^^^^^^^^^^^^^^^ -error[E0599]: no method named `method` found for union `MaybeUninit` in the current scope +error[E0599]: no method named `method` found for union `MaybeUninit<T>` in the current scope --> $DIR/inner_type2.rs:23:10 | LL | item.method(); diff --git a/tests/ui/suggestions/option-content-move2.stderr b/tests/ui/suggestions/option-content-move2.stderr index c73e874b403..5bcbdd711ae 100644 --- a/tests/ui/suggestions/option-content-move2.stderr +++ b/tests/ui/suggestions/option-content-move2.stderr @@ -14,6 +14,11 @@ LL | LL | var = Some(NotCopyable); | --- variable moved due to use in closure | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/option-content-move2.rs:5:12 + | +LL | fn func<F: FnMut() -> H, H: FnMut()>(_: F) {} + | ^^^^^^^^^^^^ note: if `NotCopyable` implemented `Clone`, you could clone the value --> $DIR/option-content-move2.rs:1:1 | @@ -38,6 +43,12 @@ LL | move || { LL | LL | var = Some(NotCopyableButCloneable); | --- variable moved due to use in closure + | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/option-content-move2.rs:5:12 + | +LL | fn func<F: FnMut() -> H, H: FnMut()>(_: F) {} + | ^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/suggestions/option-content-move3.stderr b/tests/ui/suggestions/option-content-move3.stderr index 68c52352a65..f78d3cf6786 100644 --- a/tests/ui/suggestions/option-content-move3.stderr +++ b/tests/ui/suggestions/option-content-move3.stderr @@ -9,6 +9,7 @@ LL | move || { LL | let x = var; | ^^^ move occurs because `var` has type `NotCopyable`, which does not implement the `Copy` trait | + = help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once note: if `NotCopyable` implemented `Clone`, you could clone the value --> $DIR/option-content-move3.rs:2:1 | @@ -37,6 +38,11 @@ LL | move || { LL | let x = var; | --- variable moved due to use in closure | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/option-content-move3.rs:6:12 + | +LL | fn func<F: FnMut() -> H, H: FnMut()>(_: F) {} + | ^^^^^^^^^^^^ note: if `NotCopyable` implemented `Clone`, you could clone the value --> $DIR/option-content-move3.rs:2:1 | @@ -57,6 +63,7 @@ LL | move || { LL | let x = var; | ^^^ move occurs because `var` has type `NotCopyableButCloneable`, which does not implement the `Copy` trait | + = help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once help: consider borrowing here | LL | let x = &var; @@ -77,6 +84,11 @@ LL | move || { LL | let x = var; | --- variable moved due to use in closure | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/option-content-move3.rs:6:12 + | +LL | fn func<F: FnMut() -> H, H: FnMut()>(_: F) {} + | ^^^^^^^^^^^^ help: consider cloning the value before moving it into the closure | LL ~ { diff --git a/tests/ui/target-feature/gate.rs b/tests/ui/target-feature/gate.rs index 9244a98d82f..fc3763820cb 100644 --- a/tests/ui/target-feature/gate.rs +++ b/tests/ui/target-feature/gate.rs @@ -1,17 +1,12 @@ //@ only-x86_64 // -// gate-test-sse4a_target_feature // gate-test-powerpc_target_feature -// gate-test-tbm_target_feature // gate-test-arm_target_feature // gate-test-hexagon_target_feature // gate-test-mips_target_feature +// gate-test-nvptx_target_feature // gate-test-wasm_target_feature -// gate-test-adx_target_feature -// gate-test-cmpxchg16b_target_feature -// gate-test-movbe_target_feature // gate-test-rtm_target_feature -// gate-test-f16c_target_feature // gate-test-riscv_target_feature // gate-test-ermsb_target_feature // gate-test-bpf_target_feature diff --git a/tests/ui/target-feature/gate.stderr b/tests/ui/target-feature/gate.stderr index 32d60ce4382..345dc2006d0 100644 --- a/tests/ui/target-feature/gate.stderr +++ b/tests/ui/target-feature/gate.stderr @@ -1,5 +1,5 @@ error[E0658]: the target feature `x87` is currently unstable - --> $DIR/gate.rs:29:18 + --> $DIR/gate.rs:24:18 | LL | #[target_feature(enable = "x87")] | ^^^^^^^^^^^^^^ diff --git a/tests/ui/target-feature/implied-features-nvptx.rs b/tests/ui/target-feature/implied-features-nvptx.rs new file mode 100644 index 00000000000..1550c99f67a --- /dev/null +++ b/tests/ui/target-feature/implied-features-nvptx.rs @@ -0,0 +1,28 @@ +//@ assembly-output: ptx-linker +//@ compile-flags: --crate-type cdylib -C target-cpu=sm_80 -Z unstable-options -Clinker-flavor=llbc +//@ only-nvptx64 +//@ build-pass +#![no_std] +#![allow(dead_code)] + +#[panic_handler] +pub fn panic(_info: &core::panic::PanicInfo) -> ! { + loop {} +} + +// -Ctarget-cpu=sm_80 directly enables sm_80 and ptx70 +#[cfg(not(all(target_feature = "sm_80", target_feature = "ptx70")))] +compile_error!("direct target features not enabled"); + +// -Ctarget-cpu=sm_80 implies all earlier sm_* and ptx* features. +#[cfg(not(all( + target_feature = "sm_60", + target_feature = "sm_70", + target_feature = "ptx50", + target_feature = "ptx60", +)))] +compile_error!("implied target features not enabled"); + +// -Ctarget-cpu=sm_80 implies all earlier sm_* and ptx* features. +#[cfg(target_feature = "ptx71")] +compile_error!("sm_80 requires only ptx70, but ptx71 enabled"); diff --git a/tests/ui/target-feature/invalid-attribute.rs b/tests/ui/target-feature/invalid-attribute.rs index d13098c3a6a..b34a48aba26 100644 --- a/tests/ui/target-feature/invalid-attribute.rs +++ b/tests/ui/target-feature/invalid-attribute.rs @@ -3,19 +3,16 @@ #![warn(unused_attributes)] #[target_feature(enable = "sse2")] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on extern crate alloc; -//~^ NOTE not a function #[target_feature(enable = "sse2")] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on use alloc::alloc::alloc; -//~^ NOTE not a function #[target_feature(enable = "sse2")] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on extern "Rust" {} -//~^ NOTE not a function #[target_feature = "+sse2"] //~^ ERROR malformed `target_feature` attribute @@ -32,42 +29,35 @@ extern "Rust" {} unsafe fn foo() {} #[target_feature(enable = "sse2")] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on mod another {} -//~^ NOTE not a function #[target_feature(enable = "sse2")] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on const FOO: usize = 7; -//~^ NOTE not a function #[target_feature(enable = "sse2")] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on struct Foo; -//~^ NOTE not a function #[target_feature(enable = "sse2")] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on enum Bar {} -//~^ NOTE not a function #[target_feature(enable = "sse2")] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on union Qux { - //~^ NOTE not a function - f1: u16, + f1: u16, f2: u16, } #[target_feature(enable = "sse2")] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on type Uwu = (); -//~^ NOTE not a function #[target_feature(enable = "sse2")] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on trait Baz {} -//~^ NOTE not a function #[inline(always)] //~^ ERROR: cannot use `#[inline(always)]` @@ -75,21 +65,18 @@ trait Baz {} unsafe fn test() {} #[target_feature(enable = "sse2")] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on static A: () = (); -//~^ NOTE not a function #[target_feature(enable = "sse2")] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on impl Quux for u8 {} -//~^ NOTE not a function -//~| NOTE missing `foo` in implementation +//~^ NOTE missing `foo` in implementation //~| ERROR missing: `foo` #[target_feature(enable = "sse2")] -//~^ ERROR attribute should be applied to a function +//~^ ERROR attribute cannot be used on impl Foo {} -//~^ NOTE not a function trait Quux { fn foo(); //~ NOTE `foo` from trait @@ -109,17 +96,15 @@ impl Quux for Foo { fn main() { #[target_feature(enable = "sse2")] - //~^ ERROR attribute should be applied to a function + //~^ ERROR attribute cannot be used on unsafe { foo(); } - //~^^^ NOTE not a function #[target_feature(enable = "sse2")] - //~^ ERROR attribute should be applied to a function + //~^ ERROR attribute cannot be used on || {}; - //~^ NOTE not a function -} + } #[target_feature(enable = "+sse2")] //~^ ERROR `+sse2` is not valid for this target diff --git a/tests/ui/target-feature/invalid-attribute.stderr b/tests/ui/target-feature/invalid-attribute.stderr index 113c0c3695a..a0117649a57 100644 --- a/tests/ui/target-feature/invalid-attribute.stderr +++ b/tests/ui/target-feature/invalid-attribute.stderr @@ -1,5 +1,29 @@ +error: `#[target_feature]` attribute cannot be used on extern crates + --> $DIR/invalid-attribute.rs:5:1 + | +LL | #[target_feature(enable = "sse2")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[target_feature]` can only be applied to functions + +error: `#[target_feature]` attribute cannot be used on use statements + --> $DIR/invalid-attribute.rs:9:1 + | +LL | #[target_feature(enable = "sse2")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[target_feature]` can only be applied to functions + +error: `#[target_feature]` attribute cannot be used on foreign modules + --> $DIR/invalid-attribute.rs:13:1 + | +LL | #[target_feature(enable = "sse2")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[target_feature]` can only be applied to functions + error[E0539]: malformed `target_feature` attribute input - --> $DIR/invalid-attribute.rs:20:1 + --> $DIR/invalid-attribute.rs:17:1 | LL | #[target_feature = "+sse2"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +32,7 @@ LL | #[target_feature = "+sse2"] | help: must be of the form: `#[target_feature(enable = "feat1, feat2")]` error[E0539]: malformed `target_feature` attribute input - --> $DIR/invalid-attribute.rs:26:1 + --> $DIR/invalid-attribute.rs:23:1 | LL | #[target_feature(bar)] | ^^^^^^^^^^^^^^^^^---^^ @@ -17,7 +41,7 @@ LL | #[target_feature(bar)] | help: must be of the form: `#[target_feature(enable = "feat1, feat2")]` error[E0539]: malformed `target_feature` attribute input - --> $DIR/invalid-attribute.rs:29:1 + --> $DIR/invalid-attribute.rs:26:1 | LL | #[target_feature(disable = "baz")] | ^^^^^^^^^^^^^^^^^-------^^^^^^^^^^ @@ -25,161 +49,116 @@ LL | #[target_feature(disable = "baz")] | | expected this to be of the form `enable = "..."` | help: must be of the form: `#[target_feature(enable = "feat1, feat2")]` -error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:5:1 +error: `#[target_feature]` attribute cannot be used on modules + --> $DIR/invalid-attribute.rs:31:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | extern crate alloc; - | ------------------- not a function definition - -error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:10:1 | -LL | #[target_feature(enable = "sse2")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | use alloc::alloc::alloc; - | ------------------------ not a function definition + = help: `#[target_feature]` can only be applied to functions -error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:15:1 +error: `#[target_feature]` attribute cannot be used on constants + --> $DIR/invalid-attribute.rs:35:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | extern "Rust" {} - | ---------------- not a function definition - -error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:34:1 | -LL | #[target_feature(enable = "sse2")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | mod another {} - | -------------- not a function definition + = help: `#[target_feature]` can only be applied to functions -error: attribute should be applied to a function definition +error: `#[target_feature]` attribute cannot be used on structs --> $DIR/invalid-attribute.rs:39:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | const FOO: usize = 7; - | --------------------- not a function definition + | + = help: `#[target_feature]` can only be applied to functions -error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:44:1 +error: `#[target_feature]` attribute cannot be used on enums + --> $DIR/invalid-attribute.rs:43:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | struct Foo; - | ----------- not a function definition + | + = help: `#[target_feature]` can only be applied to functions -error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:49:1 +error: `#[target_feature]` attribute cannot be used on unions + --> $DIR/invalid-attribute.rs:47:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | enum Bar {} - | ----------- not a function definition + | + = help: `#[target_feature]` can only be applied to functions -error: attribute should be applied to a function definition +error: `#[target_feature]` attribute cannot be used on type aliases --> $DIR/invalid-attribute.rs:54:1 | -LL | #[target_feature(enable = "sse2")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | / union Qux { -LL | | -LL | | f1: u16, -LL | | f2: u16, -LL | | } - | |_- not a function definition - -error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:62:1 - | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | type Uwu = (); - | -------------- not a function definition + | + = help: `#[target_feature]` can only be applied to functions -error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:67:1 +error: `#[target_feature]` attribute cannot be used on traits + --> $DIR/invalid-attribute.rs:58:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | trait Baz {} - | ------------ not a function definition - -error: cannot use `#[inline(always)]` with `#[target_feature]` - --> $DIR/invalid-attribute.rs:72:1 | -LL | #[inline(always)] - | ^^^^^^^^^^^^^^^^^ + = help: `#[target_feature]` can only be applied to functions -error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:77:1 +error: `#[target_feature]` attribute cannot be used on statics + --> $DIR/invalid-attribute.rs:67:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | static A: () = (); - | ------------------ not a function definition + | + = help: `#[target_feature]` can only be applied to functions -error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:82:1 +error: `#[target_feature]` attribute cannot be used on trait impl blocks + --> $DIR/invalid-attribute.rs:71:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | impl Quux for u8 {} - | ------------------- not a function definition + | + = help: `#[target_feature]` can only be applied to functions -error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:89:1 +error: `#[target_feature]` attribute cannot be used on inherent impl blocks + --> $DIR/invalid-attribute.rs:77:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | impl Foo {} - | ----------- not a function definition + | + = help: `#[target_feature]` can only be applied to functions -error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:111:5 +error: `#[target_feature]` attribute cannot be used on expressions + --> $DIR/invalid-attribute.rs:98:5 | -LL | #[target_feature(enable = "sse2")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | / unsafe { -LL | | foo(); -LL | | } - | |_____- not a function definition +LL | #[target_feature(enable = "sse2")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[target_feature]` can only be applied to functions -error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:118:5 +error: `#[target_feature]` attribute cannot be used on closures + --> $DIR/invalid-attribute.rs:104:5 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | || {}; - | ----- not a function definition + | + = help: `#[target_feature]` can be applied to methods, functions + +error: cannot use `#[inline(always)]` with `#[target_feature]` + --> $DIR/invalid-attribute.rs:62:1 + | +LL | #[inline(always)] + | ^^^^^^^^^^^^^^^^^ error: the feature named `foo` is not valid for this target - --> $DIR/invalid-attribute.rs:23:18 + --> $DIR/invalid-attribute.rs:20:18 | LL | #[target_feature(enable = "foo")] | ^^^^^^^^^^^^^^ `foo` is not valid for this target error[E0046]: not all trait items implemented, missing: `foo` - --> $DIR/invalid-attribute.rs:84:1 + --> $DIR/invalid-attribute.rs:73:1 | LL | impl Quux for u8 {} | ^^^^^^^^^^^^^^^^ missing `foo` in implementation @@ -188,7 +167,7 @@ LL | fn foo(); | --------- `foo` from trait error: `#[target_feature(..)]` cannot be applied to safe trait method - --> $DIR/invalid-attribute.rs:100:5 + --> $DIR/invalid-attribute.rs:87:5 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot be applied to safe trait method @@ -197,13 +176,13 @@ LL | fn foo() {} | -------- not an `unsafe` function error[E0053]: method `foo` has an incompatible type for trait - --> $DIR/invalid-attribute.rs:103:5 + --> $DIR/invalid-attribute.rs:90:5 | LL | fn foo() {} | ^^^^^^^^ expected safe fn, found unsafe fn | note: type in trait - --> $DIR/invalid-attribute.rs:95:5 + --> $DIR/invalid-attribute.rs:82:5 | LL | fn foo(); | ^^^^^^^^^ @@ -211,7 +190,7 @@ LL | fn foo(); found signature `#[target_features] fn()` error: the feature named `+sse2` is not valid for this target - --> $DIR/invalid-attribute.rs:124:18 + --> $DIR/invalid-attribute.rs:109:18 | LL | #[target_feature(enable = "+sse2")] | ^^^^^^^^^^^^^^^^ `+sse2` is not valid for this target diff --git a/tests/ui/test-attrs/issue-12997-2.stderr b/tests/ui/test-attrs/issue-12997-2.stderr index 1123630a4a1..41d0074ad1a 100644 --- a/tests/ui/test-attrs/issue-12997-2.stderr +++ b/tests/ui/test-attrs/issue-12997-2.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-12997-2.rs:8:1 | LL | #[bench] - | -------- in this procedural macro expansion + | -------- in this attribute macro expansion LL | fn bar(x: isize) { } | ^^^^^^^^^^^^^^^^^^^^ | | diff --git a/tests/ui/test-attrs/terse.run.stdout b/tests/ui/test-attrs/terse.run.stdout index ac1ac28c98d..381d3cbe675 100644 --- a/tests/ui/test-attrs/terse.run.stdout +++ b/tests/ui/test-attrs/terse.run.stdout @@ -10,18 +10,18 @@ failures: ---- abc stdout ---- -thread 'abc' panicked at $DIR/terse.rs:12:5: +thread 'abc' ($TID) panicked at $DIR/terse.rs:12:5: explicit panic note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ---- foo stdout ---- -thread 'foo' panicked at $DIR/terse.rs:17:5: +thread 'foo' ($TID) panicked at $DIR/terse.rs:17:5: explicit panic ---- foo2 stdout ---- -thread 'foo2' panicked at $DIR/terse.rs:22:5: +thread 'foo2' ($TID) panicked at $DIR/terse.rs:22:5: explicit panic diff --git a/tests/ui/test-attrs/test-function-signature.stderr b/tests/ui/test-attrs/test-function-signature.stderr index c025163c0bd..55d09970b32 100644 --- a/tests/ui/test-attrs/test-function-signature.stderr +++ b/tests/ui/test-attrs/test-function-signature.stderr @@ -26,7 +26,7 @@ error[E0277]: the trait bound `i32: Termination` is not satisfied --> $DIR/test-function-signature.rs:9:13 | LL | #[test] - | ------- in this procedural macro expansion + | ------- in this attribute macro expansion LL | fn bar() -> i32 { | ^^^ the trait `Termination` is not implemented for `i32` | diff --git a/tests/ui/test-attrs/test-panic-abort-nocapture.run.stderr b/tests/ui/test-attrs/test-panic-abort-nocapture.run.stderr index b9f267838b1..8d7c62f8ec7 100644 --- a/tests/ui/test-attrs/test-panic-abort-nocapture.run.stderr +++ b/tests/ui/test-attrs/test-panic-abort-nocapture.run.stderr @@ -1,11 +1,11 @@ -thread 'main' panicked at $DIR/test-panic-abort-nocapture.rs:32:5: +thread 'main' ($TID) panicked at $DIR/test-panic-abort-nocapture.rs:32:5: assertion `left == right` failed left: 2 right: 4 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread 'main' panicked at $DIR/test-panic-abort-nocapture.rs:26:5: +thread 'main' ($TID) panicked at $DIR/test-panic-abort-nocapture.rs:26:5: assertion `left == right` failed left: 2 right: 4 diff --git a/tests/ui/test-attrs/test-panic-abort.run.stdout b/tests/ui/test-attrs/test-panic-abort.run.stdout index 0faa7f0dfce..4d65c05b944 100644 --- a/tests/ui/test-attrs/test-panic-abort.run.stdout +++ b/tests/ui/test-attrs/test-panic-abort.run.stdout @@ -18,7 +18,7 @@ testing123 ---- it_fails stderr ---- testing321 -thread 'main' panicked at $DIR/test-panic-abort.rs:37:5: +thread 'main' ($TID) panicked at $DIR/test-panic-abort.rs:37:5: assertion `left == right` failed left: 2 right: 5 diff --git a/tests/ui/test-attrs/test-should-panic-attr.rs b/tests/ui/test-attrs/test-should-panic-attr.rs index df2893b63ed..e6de07d0094 100644 --- a/tests/ui/test-attrs/test-should-panic-attr.rs +++ b/tests/ui/test-attrs/test-should-panic-attr.rs @@ -1,4 +1,3 @@ -//@ check-pass //@ compile-flags: --test #[test] @@ -9,28 +8,36 @@ fn test1() { #[test] #[should_panic(expected)] -//~^ WARN: argument must be of the form: +//~^ ERROR malformed `should_panic` attribute input +//~| NOTE expected this to be of the form `expected = "..."` +//~| NOTE for more information, visit fn test2() { panic!(); } #[test] #[should_panic(expect)] -//~^ WARN: argument must be of the form: +//~^ ERROR malformed `should_panic` attribute input +//~| NOTE the only valid argument here is "expected" +//~| NOTE for more information, visit fn test3() { panic!(); } #[test] #[should_panic(expected(foo, bar))] -//~^ WARN: argument must be of the form: +//~^ ERROR malformed `should_panic` attribute input +//~| NOTE expected this to be of the form `expected = "..."` +//~| NOTE for more information, visit fn test4() { panic!(); } #[test] #[should_panic(expected = "foo", bar)] -//~^ WARN: argument must be of the form: +//~^ ERROR malformed `should_panic` attribute input +//~| NOTE expected a single argument here +//~| NOTE for more information, visit fn test5() { panic!(); } diff --git a/tests/ui/test-attrs/test-should-panic-attr.stderr b/tests/ui/test-attrs/test-should-panic-attr.stderr index 492d1d5e03a..475a55ad0cb 100644 --- a/tests/ui/test-attrs/test-should-panic-attr.stderr +++ b/tests/ui/test-attrs/test-should-panic-attr.stderr @@ -1,34 +1,86 @@ -warning: argument must be of the form: `expected = "error message"` - --> $DIR/test-should-panic-attr.rs:11:1 +error[E0539]: malformed `should_panic` attribute input + --> $DIR/test-should-panic-attr.rs:10:1 | LL | #[should_panic(expected)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^--------^^ + | | + | expected this to be of the form `expected = "..."` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/testing.html#the-should_panic-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[should_panic(expected)] +LL + #[should_panic = "reason"] + | +LL | #[should_panic(expected = "reason")] + | ++++++++++ +LL - #[should_panic(expected)] +LL + #[should_panic] | - = note: errors in this attribute were erroneously allowed and will become a hard error in a future release -warning: argument must be of the form: `expected = "error message"` - --> $DIR/test-should-panic-attr.rs:18:1 +error[E0539]: malformed `should_panic` attribute input + --> $DIR/test-should-panic-attr.rs:19:1 | LL | #[should_panic(expect)] - | ^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^--------^ + | | + | the only valid argument here is "expected" + | + = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/testing.html#the-should_panic-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[should_panic(expect)] +LL + #[should_panic = "reason"] + | +LL | #[should_panic(expected = "reason")] + | +++++++++++++ +LL - #[should_panic(expect)] +LL + #[should_panic] | - = note: errors in this attribute were erroneously allowed and will become a hard error in a future release -warning: argument must be of the form: `expected = "error message"` - --> $DIR/test-should-panic-attr.rs:25:1 +error[E0539]: malformed `should_panic` attribute input + --> $DIR/test-should-panic-attr.rs:28:1 | LL | #[should_panic(expected(foo, bar))] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^------------------^^ + | | + | expected this to be of the form `expected = "..."` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/testing.html#the-should_panic-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[should_panic(expected(foo, bar))] +LL + #[should_panic = "reason"] + | +LL - #[should_panic(expected(foo, bar))] +LL + #[should_panic(expected = "reason")] + | +LL - #[should_panic(expected(foo, bar))] +LL + #[should_panic] | - = note: errors in this attribute were erroneously allowed and will become a hard error in a future release -warning: argument must be of the form: `expected = "error message"` - --> $DIR/test-should-panic-attr.rs:32:1 +error[E0805]: malformed `should_panic` attribute input + --> $DIR/test-should-panic-attr.rs:37:1 | LL | #[should_panic(expected = "foo", bar)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^-----------------------^ + | | + | expected a single argument here + | + = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/testing.html#the-should_panic-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[should_panic(expected = "foo", bar)] +LL + #[should_panic = "reason"] + | +LL - #[should_panic(expected = "foo", bar)] +LL + #[should_panic(expected = "reason")] + | +LL - #[should_panic(expected = "foo", bar)] +LL + #[should_panic] | - = note: errors in this attribute were erroneously allowed and will become a hard error in a future release -warning: 4 warnings emitted +error: aborting due to 4 previous errors +Some errors have detailed explanations: E0539, E0805. +For more information about an error, try `rustc --explain E0539`. diff --git a/tests/ui/test-attrs/test-should-panic-failed-show-span.run.stderr b/tests/ui/test-attrs/test-should-panic-failed-show-span.run.stderr index db379a16b52..63bc10ef5ea 100644 --- a/tests/ui/test-attrs/test-should-panic-failed-show-span.run.stderr +++ b/tests/ui/test-attrs/test-should-panic-failed-show-span.run.stderr @@ -1,13 +1,13 @@ -thread 'should_panic_with_any_message' panicked at $DIR/test-should-panic-failed-show-span.rs:14:5: +thread 'should_panic_with_any_message' ($TID) panicked at $DIR/test-should-panic-failed-show-span.rs:14:5: Panic! note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread 'should_panic_with_message' panicked at $DIR/test-should-panic-failed-show-span.rs:20:5: +thread 'should_panic_with_message' ($TID) panicked at $DIR/test-should-panic-failed-show-span.rs:20:5: message -thread 'should_panic_with_substring_panics_with_incorrect_string' panicked at $DIR/test-should-panic-failed-show-span.rs:38:5: +thread 'should_panic_with_substring_panics_with_incorrect_string' ($TID) panicked at $DIR/test-should-panic-failed-show-span.rs:38:5: ZOMGWTFBBQ -thread 'should_panic_with_substring_panics_with_non_string_value' panicked at $DIR/test-should-panic-failed-show-span.rs:45:5: +thread 'should_panic_with_substring_panics_with_non_string_value' ($TID) panicked at $DIR/test-should-panic-failed-show-span.rs:45:5: Box<dyn Any> diff --git a/tests/ui/test-attrs/test-thread-capture.run.stdout b/tests/ui/test-attrs/test-thread-capture.run.stdout index f9b9757f861..bea3dcb1041 100644 --- a/tests/ui/test-attrs/test-thread-capture.run.stdout +++ b/tests/ui/test-attrs/test-thread-capture.run.stdout @@ -11,7 +11,7 @@ fie foe fum -thread 'thready_fail' panicked at $DIR/test-thread-capture.rs:32:5: +thread 'thready_fail' ($TID) panicked at $DIR/test-thread-capture.rs:32:5: explicit panic note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/test-attrs/test-thread-nocapture.run.stderr b/tests/ui/test-attrs/test-thread-nocapture.run.stderr index 59560015fca..b9905b0c2f9 100644 --- a/tests/ui/test-attrs/test-thread-nocapture.run.stderr +++ b/tests/ui/test-attrs/test-thread-nocapture.run.stderr @@ -1,4 +1,4 @@ -thread 'thready_fail' panicked at $DIR/test-thread-nocapture.rs:32:5: +thread 'thready_fail' ($TID) panicked at $DIR/test-thread-nocapture.rs:32:5: explicit panic note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/issues/issue-30756.rs b/tests/ui/thread-local/thread-local-with-attributes-30756.rs index d103776406c..fcf7bb813c8 100644 --- a/tests/ui/issues/issue-30756.rs +++ b/tests/ui/thread-local/thread-local-with-attributes-30756.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/30756 //@ run-pass #![forbid(unsafe_code)] diff --git a/tests/ui/track-diagnostics/track.rs b/tests/ui/track-diagnostics/track.rs index 1b2558c724b..9ce0a4a555a 100644 --- a/tests/ui/track-diagnostics/track.rs +++ b/tests/ui/track-diagnostics/track.rs @@ -13,6 +13,11 @@ // top of this file are present, then assume all args are present. //@ normalize-stderr: "note: compiler flags: .*-Z ui-testing.*-Z track-diagnostics" -> "note: compiler flags: ... -Z ui-testing ... -Z track-diagnostics" +// FIXME: this tests a crash in rustc. For stage1, rustc is built with the downloaded standard +// library which doesn't yet print the thread ID. Normalization can be removed at the stage bump. +// For the grep: cfg(bootstrap) +//@normalize-stderr: "thread 'rustc' panicked" -> "thread 'rustc' ($$TID) panicked" + fn main() { break rust //~^ ERROR cannot find value `rust` in this scope diff --git a/tests/ui/track-diagnostics/track.stderr b/tests/ui/track-diagnostics/track.stderr index f82764958d4..bc04ded379d 100644 --- a/tests/ui/track-diagnostics/track.stderr +++ b/tests/ui/track-diagnostics/track.stderr @@ -27,7 +27,7 @@ LL | break rust = note: compiler flags: ... -Z ui-testing ... -Z track-diagnostics -thread 'rustc' panicked at compiler/rustc_hir_typeck/src/lib.rs:LL:CC: +thread 'rustc' ($TID) 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 diff --git a/tests/ui/issues/issue-13775.rs b/tests/ui/trait-bounds/anonymous-parameters-13775.rs index 1477dab9e21..297d4b59587 100644 --- a/tests/ui/issues/issue-13775.rs +++ b/tests/ui/trait-bounds/anonymous-parameters-13775.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13775 + //@ edition: 2015 //@ check-pass diff --git a/tests/ui/trait-bounds/more_maybe_bounds.rs b/tests/ui/trait-bounds/more_maybe_bounds.rs index 47348b0a0dd..d367dd5b299 100644 --- a/tests/ui/trait-bounds/more_maybe_bounds.rs +++ b/tests/ui/trait-bounds/more_maybe_bounds.rs @@ -1,7 +1,7 @@ // FIXME(more_maybe_bounds): Even under `more_maybe_bounds` / `-Zexperimental-default-bounds`, // trying to relax non-default bounds should still be an error in all contexts! As you can see -// there are places like supertrait bounds and trait object types where we currently don't perform -// this check. +// there are places like supertrait bounds, trait object types or associated type bounds (ATB) +// where we currently don't perform this check. #![feature(auto_traits, more_maybe_bounds, negative_impls)] trait Trait1 {} @@ -13,11 +13,15 @@ trait Trait4 where Self: Trait1 {} // FIXME: `?Trait2` should be rejected, `Trait2` isn't marked `#[lang = "default_traitN"]`. fn foo(_: Box<(dyn Trait3 + ?Trait2)>) {} + fn bar<T: ?Sized + ?Trait2 + ?Trait1 + ?Trait4>(_: &T) {} //~^ ERROR bound modifier `?` can only be applied to default traits like `Sized` //~| ERROR bound modifier `?` can only be applied to default traits like `Sized` //~| ERROR bound modifier `?` can only be applied to default traits like `Sized` +// FIXME: `?Trait1` should be rejected, `Trait1` isn't marked `#[lang = "default_traitN"]`. +fn baz<T>() where T: Iterator<Item: ?Trait1> {} + struct S; impl !Trait2 for S {} impl Trait1 for S {} diff --git a/tests/ui/trait-bounds/more_maybe_bounds.stderr b/tests/ui/trait-bounds/more_maybe_bounds.stderr index 09c9fc31165..8dd83fc7728 100644 --- a/tests/ui/trait-bounds/more_maybe_bounds.stderr +++ b/tests/ui/trait-bounds/more_maybe_bounds.stderr @@ -1,17 +1,17 @@ error: bound modifier `?` can only be applied to default traits like `Sized` - --> $DIR/more_maybe_bounds.rs:16:20 + --> $DIR/more_maybe_bounds.rs:17:20 | LL | fn bar<T: ?Sized + ?Trait2 + ?Trait1 + ?Trait4>(_: &T) {} | ^^^^^^^ error: bound modifier `?` can only be applied to default traits like `Sized` - --> $DIR/more_maybe_bounds.rs:16:30 + --> $DIR/more_maybe_bounds.rs:17:30 | LL | fn bar<T: ?Sized + ?Trait2 + ?Trait1 + ?Trait4>(_: &T) {} | ^^^^^^^ error: bound modifier `?` can only be applied to default traits like `Sized` - --> $DIR/more_maybe_bounds.rs:16:40 + --> $DIR/more_maybe_bounds.rs:17:40 | LL | fn bar<T: ?Sized + ?Trait2 + ?Trait1 + ?Trait4>(_: &T) {} | ^^^^^^^ diff --git a/tests/ui/traits/alias/not-a-marker.rs b/tests/ui/traits/alias/not-a-marker.rs index b004b9ff9ae..633cc60554d 100644 --- a/tests/ui/traits/alias/not-a-marker.rs +++ b/tests/ui/traits/alias/not-a-marker.rs @@ -1,7 +1,7 @@ #![feature(trait_alias, marker_trait_attr)] #[marker] -//~^ ERROR attribute should be applied to a trait +//~^ ERROR attribute cannot be used on trait Foo = Send; fn main() {} diff --git a/tests/ui/traits/alias/not-a-marker.stderr b/tests/ui/traits/alias/not-a-marker.stderr index 2f3f6fea30f..8b0eba65b95 100644 --- a/tests/ui/traits/alias/not-a-marker.stderr +++ b/tests/ui/traits/alias/not-a-marker.stderr @@ -1,11 +1,10 @@ -error: attribute should be applied to a trait +error: `#[marker]` attribute cannot be used on trait aliases --> $DIR/not-a-marker.rs:3:1 | LL | #[marker] | ^^^^^^^^^ -LL | -LL | trait Foo = Send; - | ----------------- not a trait + | + = help: `#[marker]` can only be applied to traits error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/attr-misuse.rs b/tests/ui/traits/const-traits/attr-misuse.rs index 01ac74feff7..70dfcbf47d2 100644 --- a/tests/ui/traits/const-traits/attr-misuse.rs +++ b/tests/ui/traits/const-traits/attr-misuse.rs @@ -2,9 +2,9 @@ #[const_trait] trait A { - #[const_trait] //~ ERROR attribute should be applied + #[const_trait] //~ ERROR attribute cannot be used on fn foo(self); } -#[const_trait] //~ ERROR attribute should be applied +#[const_trait] //~ ERROR attribute cannot be used on fn main() {} diff --git a/tests/ui/traits/const-traits/attr-misuse.stderr b/tests/ui/traits/const-traits/attr-misuse.stderr index 998958cedf7..2f86efac4c9 100644 --- a/tests/ui/traits/const-traits/attr-misuse.stderr +++ b/tests/ui/traits/const-traits/attr-misuse.stderr @@ -1,18 +1,18 @@ -error: attribute should be applied to a trait +error: `#[const_trait]` attribute cannot be used on required trait methods + --> $DIR/attr-misuse.rs:5:5 + | +LL | #[const_trait] + | ^^^^^^^^^^^^^^ + | + = help: `#[const_trait]` can only be applied to traits + +error: `#[const_trait]` attribute cannot be used on functions --> $DIR/attr-misuse.rs:9:1 | LL | #[const_trait] | ^^^^^^^^^^^^^^ -LL | fn main() {} - | ------------ not a trait - -error: attribute should be applied to a trait - --> $DIR/attr-misuse.rs:5:5 | -LL | #[const_trait] - | ^^^^^^^^^^^^^^ -LL | fn foo(self); - | ------------- not a trait + = help: `#[const_trait]` can only be applied to traits error: aborting due to 2 previous errors diff --git a/tests/ui/traits/const-traits/const-and-non-const-impl.rs b/tests/ui/traits/const-traits/const-and-non-const-impl.rs index 85e2c5d3df6..560b740dc91 100644 --- a/tests/ui/traits/const-traits/const-and-non-const-impl.rs +++ b/tests/ui/traits/const-traits/const-and-non-const-impl.rs @@ -1,10 +1,9 @@ -//@ known-bug: #110395 - #![feature(const_trait_impl, const_ops)] pub struct Int(i32); impl const std::ops::Add for i32 { + //~^ ERROR only traits defined in the current crate can be implemented for primitive types type Output = Self; fn add(self, rhs: Self) -> Self { @@ -21,6 +20,7 @@ impl std::ops::Add for Int { } impl const std::ops::Add for Int { + //~^ ERROR conflicting implementations of trait type Output = Self; fn add(self, rhs: Self) -> Self { diff --git a/tests/ui/traits/const-traits/const-and-non-const-impl.stderr b/tests/ui/traits/const-traits/const-and-non-const-impl.stderr index 4eb15177347..26ed7d05324 100644 --- a/tests/ui/traits/const-traits/const-and-non-const-impl.stderr +++ b/tests/ui/traits/const-traits/const-and-non-const-impl.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `Add` for type `Int` - --> $DIR/const-and-non-const-impl.rs:23:1 + --> $DIR/const-and-non-const-impl.rs:22:1 | LL | impl std::ops::Add for Int { | -------------------------- first implementation here @@ -8,7 +8,7 @@ LL | impl const std::ops::Add for Int { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Int` error[E0117]: only traits defined in the current crate can be implemented for primitive types - --> $DIR/const-and-non-const-impl.rs:7:1 + --> $DIR/const-and-non-const-impl.rs:5:1 | LL | impl const std::ops::Add for i32 { | ^^^^^^^^^^^-------------^^^^^--- diff --git a/tests/ui/traits/const-traits/inherent-impl.rs b/tests/ui/traits/const-traits/inherent-impl.rs index 07b23adf9e1..5ca4c5d7863 100644 --- a/tests/ui/traits/const-traits/inherent-impl.rs +++ b/tests/ui/traits/const-traits/inherent-impl.rs @@ -5,9 +5,9 @@ struct S; trait T {} impl const S {} -//~^ ERROR inherent impls cannot be `const` +//~^ ERROR inherent impls cannot be const impl const dyn T {} -//~^ ERROR inherent impls cannot be `const` +//~^ ERROR inherent impls cannot be const fn main() {} diff --git a/tests/ui/traits/const-traits/inherent-impl.stderr b/tests/ui/traits/const-traits/inherent-impl.stderr index e4ec1e807b0..d828ecb6349 100644 --- a/tests/ui/traits/const-traits/inherent-impl.stderr +++ b/tests/ui/traits/const-traits/inherent-impl.stderr @@ -1,20 +1,20 @@ -error: inherent impls cannot be `const` +error: inherent impls cannot be const --> $DIR/inherent-impl.rs:7:12 | LL | impl const S {} | ----- ^ inherent impl for this type | | - | `const` because of this + | const because of this | = note: only trait implementations may be annotated with `const` -error: inherent impls cannot be `const` +error: inherent impls cannot be const --> $DIR/inherent-impl.rs:10:12 | LL | impl const dyn T {} | ----- ^^^^^ inherent impl for this type | | - | `const` because of this + | const because of this | = note: only trait implementations may be annotated with `const` diff --git a/tests/ui/traits/const-traits/macro-const-trait-bound-theoretical-regression.stderr b/tests/ui/traits/const-traits/macro-const-trait-bound-theoretical-regression.stderr index af160a45f3e..9fad260f0be 100644 --- a/tests/ui/traits/const-traits/macro-const-trait-bound-theoretical-regression.stderr +++ b/tests/ui/traits/const-traits/macro-const-trait-bound-theoretical-regression.stderr @@ -1,15 +1,4 @@ -error: macro expansion ignores keyword `dyn` and any tokens following - --> $DIR/macro-const-trait-bound-theoretical-regression.rs:14:31 - | -LL | (dyn $c:ident Trait) => { dyn $c Trait {} }; - | ^^^ -... -LL | demo! { dyn const Trait } - | ------------------------- caused by the macro expansion here - | - = note: the usage of `demo!` is likely invalid in item context - -error: inherent impls cannot be `const` +error: inherent impls cannot be const --> $DIR/macro-const-trait-bound-theoretical-regression.rs:10:40 | LL | (impl $c:ident Trait) => { impl $c Trait {} }; @@ -18,12 +7,23 @@ LL | (impl $c:ident Trait) => { impl $c Trait {} }; LL | demo! { impl const Trait } | -------------------------- | | | - | | `const` because of this + | | const because of this | in this macro invocation | = note: only trait implementations may be annotated with `const` = note: this error originates in the macro `demo` (in Nightly builds, run with -Z macro-backtrace for more info) +error: macro expansion ignores keyword `dyn` and any tokens following + --> $DIR/macro-const-trait-bound-theoretical-regression.rs:14:31 + | +LL | (dyn $c:ident Trait) => { dyn $c Trait {} }; + | ^^^ +... +LL | demo! { dyn const Trait } + | ------------------------- caused by the macro expansion here + | + = note: the usage of `demo!` is likely invalid in item context + error[E0658]: const trait impls are experimental --> $DIR/macro-const-trait-bound-theoretical-regression.rs:17:14 | diff --git a/tests/ui/traits/const-traits/span-bug-issue-121418.rs b/tests/ui/traits/const-traits/span-bug-issue-121418.rs index 50a7e12f2a7..593180ac094 100644 --- a/tests/ui/traits/const-traits/span-bug-issue-121418.rs +++ b/tests/ui/traits/const-traits/span-bug-issue-121418.rs @@ -4,7 +4,7 @@ struct S; trait T {} impl const dyn T { - //~^ ERROR inherent impls cannot be `const` + //~^ ERROR inherent impls cannot be const pub const fn new() -> std::sync::Mutex<dyn T> {} //~^ ERROR mismatched types //~| ERROR cannot be known at compilation time diff --git a/tests/ui/traits/const-traits/span-bug-issue-121418.stderr b/tests/ui/traits/const-traits/span-bug-issue-121418.stderr index f31129d9cb7..0c8ca918a3e 100644 --- a/tests/ui/traits/const-traits/span-bug-issue-121418.stderr +++ b/tests/ui/traits/const-traits/span-bug-issue-121418.stderr @@ -1,10 +1,10 @@ -error: inherent impls cannot be `const` +error: inherent impls cannot be const --> $DIR/span-bug-issue-121418.rs:6:12 | LL | impl const dyn T { | ----- ^^^^^ inherent impl for this type | | - | `const` because of this + | const because of this | = note: only trait implementations may be annotated with `const` diff --git a/tests/ui/issues/issue-15444.rs b/tests/ui/traits/fn-type-trait-impl-15444.rs index 14708c7733c..ab91e88b9cd 100644 --- a/tests/ui/issues/issue-15444.rs +++ b/tests/ui/traits/fn-type-trait-impl-15444.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15444 + //@ run-pass trait MyTrait { diff --git a/tests/ui/issues/issue-14229.rs b/tests/ui/traits/impl-trait-chain-14229.rs index eb6324da3b6..4a234f3a681 100644 --- a/tests/ui/issues/issue-14229.rs +++ b/tests/ui/traits/impl-trait-chain-14229.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/14229 + //@ run-pass trait Foo: Sized { fn foo(self) {} diff --git a/tests/ui/issues/issue-15734.rs b/tests/ui/traits/index-trait-multiple-impls-15734.rs index 26fb7061664..a2d5d7c87fc 100644 --- a/tests/ui/issues/issue-15734.rs +++ b/tests/ui/traits/index-trait-multiple-impls-15734.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15734 + //@ run-pass //@ revisions: current next //@ ignore-compare-mode-next-solver (explicit revisions) diff --git a/tests/ui/traits/inductive-overflow/supertrait-auto-trait.stderr b/tests/ui/traits/inductive-overflow/supertrait-auto-trait.stderr index 3a3b99f6c5b..45602d676b3 100644 --- a/tests/ui/traits/inductive-overflow/supertrait-auto-trait.stderr +++ b/tests/ui/traits/inductive-overflow/supertrait-auto-trait.stderr @@ -1,8 +1,8 @@ error[E0568]: auto traits cannot have super traits or lifetime bounds - --> $DIR/supertrait-auto-trait.rs:8:17 + --> $DIR/supertrait-auto-trait.rs:8:19 | LL | auto trait Magic: Copy {} - | -----^^^^^^ help: remove the super traits or lifetime bounds + | ----- ^^^^ | | | auto traits cannot have super traits or lifetime bounds diff --git a/tests/ui/traits/issue-91949-hangs-on-recursion.rs b/tests/ui/traits/issue-91949-hangs-on-recursion.rs index 7c9ae09349a..434cf00fc4b 100644 --- a/tests/ui/traits/issue-91949-hangs-on-recursion.rs +++ b/tests/ui/traits/issue-91949-hangs-on-recursion.rs @@ -1,6 +1,6 @@ //~ ERROR overflow evaluating the requirement `<std::iter::Empty<()> as Iterator>::Item == ()` //@ build-fail -//@ compile-flags: -Zinline-mir=no +//@ compile-flags: -Zinline-mir=no -Zwrite-long-types-to-disk=yes // Regression test for #91949. // This hanged *forever* on 1.56, fixed by #90423. diff --git a/tests/ui/traits/issue-91949-hangs-on-recursion.stderr b/tests/ui/traits/issue-91949-hangs-on-recursion.stderr index c2f09371cf7..a179107885a 100644 --- a/tests/ui/traits/issue-91949-hangs-on-recursion.stderr +++ b/tests/ui/traits/issue-91949-hangs-on-recursion.stderr @@ -24,7 +24,9 @@ LL | impl<T, I: Iterator<Item = T>> Iterator for IteratorOfWrapped<T, I> { | | | unsatisfied trait bound introduced here = note: 256 redundant requirements hidden - = note: required for `IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), std::iter::Empty<()>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>` to implement `Iterator` + = note: required for `IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<..., ...>>, ...>>` to implement `Iterator` + = note: the full name for the type has been written to '$TEST_BUILD_DIR/issue-91949-hangs-on-recursion.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/issues/issue-16048.rs b/tests/ui/traits/lifetime-mismatch-trait-impl-16048.rs index eaf6acff26b..9c36b231403 100644 --- a/tests/ui/issues/issue-16048.rs +++ b/tests/ui/traits/lifetime-mismatch-trait-impl-16048.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/16048 + trait NoLifetime { fn get<'p, T : Test<'p>>(&self) -> T; //~^ NOTE lifetimes in impl do not match this method in trait diff --git a/tests/ui/issues/issue-16048.stderr b/tests/ui/traits/lifetime-mismatch-trait-impl-16048.stderr index f97f13152bc..08b69184b7f 100644 --- a/tests/ui/issues/issue-16048.stderr +++ b/tests/ui/traits/lifetime-mismatch-trait-impl-16048.stderr @@ -1,5 +1,5 @@ error[E0195]: lifetime parameters or bounds on method `get` do not match the trait declaration - --> $DIR/issue-16048.rs:21:11 + --> $DIR/lifetime-mismatch-trait-impl-16048.rs:23:11 | LL | fn get<'p, T : Test<'p>>(&self) -> T; | ------------------ lifetimes in impl do not match this method in trait @@ -8,7 +8,7 @@ LL | fn get<'p, T: Test<'a> + From<Foo<'a>>>(&self) -> T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetimes do not match method in trait error[E0605]: non-primitive cast: `Foo<'a>` as `T` - --> $DIR/issue-16048.rs:24:16 + --> $DIR/lifetime-mismatch-trait-impl-16048.rs:26:16 | LL | return *self as T; | ^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object diff --git a/tests/ui/traits/safety-inherent-impl.stderr b/tests/ui/traits/safety-inherent-impl.stderr index 2513fef909e..45cdbe2b523 100644 --- a/tests/ui/traits/safety-inherent-impl.stderr +++ b/tests/ui/traits/safety-inherent-impl.stderr @@ -5,6 +5,8 @@ LL | unsafe impl SomeStruct { | ------ ^^^^^^^^^^ inherent impl for this type | | | unsafe because of this + | + = note: only trait implementations may be annotated with `unsafe` error: aborting due to 1 previous error diff --git a/tests/ui/traits/syntax-trait-polarity.stderr b/tests/ui/traits/syntax-trait-polarity.stderr index 1fd40fb6657..8ffcdc7d8b5 100644 --- a/tests/ui/traits/syntax-trait-polarity.stderr +++ b/tests/ui/traits/syntax-trait-polarity.stderr @@ -5,15 +5,8 @@ LL | impl !TestType {} | -^^^^^^^^ inherent impl for this type | | | negative because of this - -error[E0198]: negative impls cannot be unsafe - --> $DIR/syntax-trait-polarity.rs:12:13 | -LL | unsafe impl !Send for TestType {} - | ------ -^^^^ - | | | - | | negative because of this - | unsafe because of this + = note: only trait implementations may be annotated with `!` error: inherent impls cannot be negative --> $DIR/syntax-trait-polarity.rs:18:10 @@ -22,6 +15,17 @@ LL | impl<T> !TestType2<T> {} | -^^^^^^^^^^^^ inherent impl for this type | | | negative because of this + | + = note: only trait implementations may be annotated with `!` + +error[E0198]: negative impls cannot be unsafe + --> $DIR/syntax-trait-polarity.rs:12:13 + | +LL | unsafe impl !Send for TestType {} + | ------ -^^^^ + | | | + | | negative because of this + | unsafe because of this error[E0198]: negative impls cannot be unsafe --> $DIR/syntax-trait-polarity.rs:21:16 diff --git a/tests/ui/issues/issue-14853.rs b/tests/ui/traits/trait-bound-mismatch-14853.rs index 4ce6e3174d0..3f2a1408a13 100644 --- a/tests/ui/issues/issue-14853.rs +++ b/tests/ui/traits/trait-bound-mismatch-14853.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/14853 + use std::fmt::Debug; trait Str {} diff --git a/tests/ui/issues/issue-14853.stderr b/tests/ui/traits/trait-bound-mismatch-14853.stderr index 25dd1e3374d..8ee8f51a135 100644 --- a/tests/ui/issues/issue-14853.stderr +++ b/tests/ui/traits/trait-bound-mismatch-14853.stderr @@ -1,5 +1,5 @@ error[E0276]: impl has stricter requirements than trait - --> $DIR/issue-14853.rs:12:15 + --> $DIR/trait-bound-mismatch-14853.rs:14:15 | LL | fn yay<T: Debug>(_: Option<Self>, thing: &[T]); | ----------------------------------------------- definition of `yay` from trait diff --git a/tests/ui/traits/well-formed-recursion-limit.stderr b/tests/ui/traits/well-formed-recursion-limit.stderr index e0270ecabbd..a4c85c4fcbd 100644 --- a/tests/ui/traits/well-formed-recursion-limit.stderr +++ b/tests/ui/traits/well-formed-recursion-limit.stderr @@ -3,12 +3,16 @@ error[E0609]: no field `ab` on type `(Box<(dyn Fn(Option<A>) -> Option<B> + 'sta | LL | let (ab, ba) = (i.ab, i.ba); | ^^ unknown field + | + = note: available fields are: `0`, `1` error[E0609]: no field `ba` on type `(Box<(dyn Fn(Option<A>) -> Option<B> + 'static)>, Box<(dyn Fn(Option<B>) -> Option<A> + 'static)>)` --> $DIR/well-formed-recursion-limit.rs:12:29 | LL | let (ab, ba) = (i.ab, i.ba); | ^^ unknown field + | + = note: available fields are: `0`, `1` error[E0275]: overflow assigning `_` to `Option<_>` --> $DIR/well-formed-recursion-limit.rs:15:33 diff --git a/tests/ui/transmutability/uninhabited.stderr b/tests/ui/transmutability/uninhabited.stderr index 4757daec997..9f289852809 100644 --- a/tests/ui/transmutability/uninhabited.stderr +++ b/tests/ui/transmutability/uninhabited.stderr @@ -41,10 +41,10 @@ LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` error[E0080]: evaluation panicked: assertion failed: false - --> $DIR/uninhabited.rs:41:9 + --> $DIR/uninhabited.rs:41:17 | LL | assert!(false); - | ^^^^^^^^^^^^^^ evaluation of `yawning_void_struct::_` failed here + | ^^^^^ evaluation of `yawning_void_struct::_` failed here error[E0277]: `()` cannot be safely transmuted into `yawning_void_enum::Void` --> $DIR/uninhabited.rs:71:41 @@ -68,10 +68,10 @@ LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` error[E0080]: evaluation panicked: assertion failed: false - --> $DIR/uninhabited.rs:63:9 + --> $DIR/uninhabited.rs:63:17 | LL | assert!(false); - | ^^^^^^^^^^^^^^ evaluation of `yawning_void_enum::_` failed here + | ^^^^^ evaluation of `yawning_void_enum::_` failed here error[E0277]: `u128` cannot be safely transmuted into `DistantVoid` --> $DIR/uninhabited.rs:92:43 @@ -95,10 +95,10 @@ LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` error[E0080]: evaluation panicked: assertion failed: false - --> $DIR/uninhabited.rs:87:9 + --> $DIR/uninhabited.rs:87:17 | LL | assert!(false); - | ^^^^^^^^^^^^^^ evaluation of `distant_void::_` failed here + | ^^^^^ evaluation of `distant_void::_` failed here error[E0277]: `Src` cannot be safely transmuted into `issue_126267::Error` --> $DIR/uninhabited.rs:108:42 diff --git a/tests/ui/treat-err-as-bug/err.rs b/tests/ui/treat-err-as-bug/err.rs index 6f0e3c55fbb..f297a5773cb 100644 --- a/tests/ui/treat-err-as-bug/err.rs +++ b/tests/ui/treat-err-as-bug/err.rs @@ -1,7 +1,7 @@ //@ compile-flags: -Ztreat-err-as-bug //@ failure-status: 101 //@ normalize-stderr: "note: .*\n\n" -> "" -//@ normalize-stderr: "thread 'rustc' panicked.*:\n.*\n" -> "" +//@ normalize-stderr: "thread 'rustc'.*panicked.*:\n.*\n" -> "" //@ rustc-env:RUST_BACKTRACE=0 #![crate_type = "rlib"] diff --git a/tests/ui/treat-err-as-bug/span_delayed_bug.rs b/tests/ui/treat-err-as-bug/span_delayed_bug.rs index 4681a8fc1ee..ff5a595899a 100644 --- a/tests/ui/treat-err-as-bug/span_delayed_bug.rs +++ b/tests/ui/treat-err-as-bug/span_delayed_bug.rs @@ -1,7 +1,7 @@ //@ compile-flags: -Ztreat-err-as-bug -Zeagerly-emit-delayed-bugs //@ failure-status: 101 //@ normalize-stderr: "note: .*\n\n" -> "" -//@ normalize-stderr: "thread 'rustc' panicked.*:\n.*\n" -> "" +//@ normalize-stderr: "thread 'rustc'.*panicked.*:\n.*\n" -> "" //@ rustc-env:RUST_BACKTRACE=0 #![feature(rustc_attrs)] diff --git a/tests/ui/tuple/index-invalid.stderr b/tests/ui/tuple/index-invalid.stderr index ae2c275f52c..fee09b7947c 100644 --- a/tests/ui/tuple/index-invalid.stderr +++ b/tests/ui/tuple/index-invalid.stderr @@ -3,18 +3,24 @@ error[E0609]: no field `1` on type `(((),),)` | LL | let _ = (((),),).1.0; | ^ unknown field + | + = note: available field is: `0` error[E0609]: no field `1` on type `((),)` --> $DIR/index-invalid.rs:4:24 | LL | let _ = (((),),).0.1; | ^ unknown field + | + = note: available field is: `0` error[E0609]: no field `000` on type `(((),),)` --> $DIR/index-invalid.rs:6:22 | LL | let _ = (((),),).000.000; | ^^^ unknown field + | + = note: available field is: `0` error: aborting due to 3 previous errors diff --git a/tests/ui/tuple/missing-field-access.rs b/tests/ui/tuple/missing-field-access.rs new file mode 100644 index 00000000000..b94b7cf977c --- /dev/null +++ b/tests/ui/tuple/missing-field-access.rs @@ -0,0 +1,16 @@ +// Ensure that suggestions to search for missing intermediary field accesses are available for both +// tuple structs *and* regular tuples. +// Ensure that we do not suggest pinning the expression just because `Pin::get_ref` exists. +// https://github.com/rust-lang/rust/issues/144602 +use std::{fs::File, io::BufReader}; + +struct F(BufReader<File>); + +fn main() { + let f = F(BufReader::new(File::open("x").unwrap())); + let x = f.get_ref(); //~ ERROR E0599 + //~^ HELP one of the expressions' fields has a method of the same name + let f = (BufReader::new(File::open("x").unwrap()), ); + let x = f.get_ref(); //~ ERROR E0599 + //~^ HELP one of the expressions' fields has a method of the same name +} diff --git a/tests/ui/tuple/missing-field-access.stderr b/tests/ui/tuple/missing-field-access.stderr new file mode 100644 index 00000000000..fd9f01f8ff6 --- /dev/null +++ b/tests/ui/tuple/missing-field-access.stderr @@ -0,0 +1,28 @@ +error[E0599]: no method named `get_ref` found for struct `F` in the current scope + --> $DIR/missing-field-access.rs:11:15 + | +LL | struct F(BufReader<File>); + | -------- method `get_ref` not found for this struct +... +LL | let x = f.get_ref(); + | ^^^^^^^ method not found in `F` + | +help: one of the expressions' fields has a method of the same name + | +LL | let x = f.0.get_ref(); + | ++ + +error[E0599]: no method named `get_ref` found for tuple `(BufReader<File>,)` in the current scope + --> $DIR/missing-field-access.rs:14:15 + | +LL | let x = f.get_ref(); + | ^^^^^^^ method not found in `(BufReader<File>,)` + | +help: one of the expressions' fields has a method of the same name + | +LL | let x = f.0.get_ref(); + | ++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/tuple/tuple-index-out-of-bounds.stderr b/tests/ui/tuple/tuple-index-out-of-bounds.stderr index 8b3c835c3e3..2be9d5631f7 100644 --- a/tests/ui/tuple/tuple-index-out-of-bounds.stderr +++ b/tests/ui/tuple/tuple-index-out-of-bounds.stderr @@ -4,17 +4,15 @@ error[E0609]: no field `2` on type `Point` LL | origin.2; | ^ unknown field | -help: a field with a similar name exists - | -LL - origin.2; -LL + origin.0; - | + = note: available fields are: `0`, `1` error[E0609]: no field `2` on type `({integer}, {integer})` --> $DIR/tuple-index-out-of-bounds.rs:12:11 | LL | tuple.2; | ^ unknown field + | + = note: available fields are: `0`, `1` error: aborting due to 2 previous errors diff --git a/tests/ui/type-alias-impl-trait/hkl_forbidden.rs b/tests/ui/type-alias-impl-trait/hkl_forbidden.rs index 994adc476e2..72da2af96b8 100644 --- a/tests/ui/type-alias-impl-trait/hkl_forbidden.rs +++ b/tests/ui/type-alias-impl-trait/hkl_forbidden.rs @@ -8,7 +8,9 @@ type Opaque<'a> = impl Sized + 'a; #[define_opaque(Opaque)] fn test(s: &str) -> (impl Fn(&str) -> Opaque<'_>, impl Fn(&str) -> Opaque<'_>) { - (id, id) //~ ERROR expected generic lifetime parameter, found `'_` + (id, id) + //~^ ERROR expected generic lifetime parameter, found `'_` + //~| ERROR expected generic lifetime parameter, found `'_` } fn id2<'a, 'b>(s: (&'a str, &'b str)) -> (&'a str, &'b str) { @@ -19,7 +21,9 @@ type Opaque2<'a> = impl Sized + 'a; #[define_opaque(Opaque2)] fn test2() -> impl for<'a, 'b> Fn((&'a str, &'b str)) -> (Opaque2<'a>, Opaque2<'b>) { - id2 //~ ERROR expected generic lifetime parameter, found `'a` + id2 + //~^ ERROR expected generic lifetime parameter, found `'a` + //~| ERROR expected generic lifetime parameter, found `'b` } type Opaque3<'a> = impl Sized + 'a; diff --git a/tests/ui/type-alias-impl-trait/hkl_forbidden.stderr b/tests/ui/type-alias-impl-trait/hkl_forbidden.stderr index d404d60f31e..315bdfb2272 100644 --- a/tests/ui/type-alias-impl-trait/hkl_forbidden.stderr +++ b/tests/ui/type-alias-impl-trait/hkl_forbidden.stderr @@ -7,8 +7,28 @@ LL | type Opaque<'a> = impl Sized + 'a; LL | (id, id) | ^^^^^^^^ +error[E0792]: expected generic lifetime parameter, found `'_` + --> $DIR/hkl_forbidden.rs:11:5 + | +LL | type Opaque<'a> = impl Sized + 'a; + | -- this generic parameter must be used with a generic lifetime parameter +... +LL | (id, id) + | ^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0792]: expected generic lifetime parameter, found `'a` - --> $DIR/hkl_forbidden.rs:22:5 + --> $DIR/hkl_forbidden.rs:24:5 + | +LL | type Opaque2<'a> = impl Sized + 'a; + | -- this generic parameter must be used with a generic lifetime parameter +... +LL | id2 + | ^^^ + +error[E0792]: expected generic lifetime parameter, found `'b` + --> $DIR/hkl_forbidden.rs:24:5 | LL | type Opaque2<'a> = impl Sized + 'a; | -- this generic parameter must be used with a generic lifetime parameter @@ -17,7 +37,7 @@ LL | id2 | ^^^ error[E0792]: expected generic lifetime parameter, found `'_` - --> $DIR/hkl_forbidden.rs:29:5 + --> $DIR/hkl_forbidden.rs:33:5 | LL | type Opaque3<'a> = impl Sized + 'a; | -- this generic parameter must be used with a generic lifetime parameter @@ -26,7 +46,7 @@ LL | (id, s) | ^^^^^^^ error[E0792]: expected generic lifetime parameter, found `'_` - --> $DIR/hkl_forbidden.rs:35:5 + --> $DIR/hkl_forbidden.rs:39:5 | LL | type Opaque4<'a> = impl Sized + 'a; | -- this generic parameter must be used with a generic lifetime parameter @@ -35,7 +55,7 @@ LL | (s, id) | ^^^^^^^ error[E0792]: expected generic lifetime parameter, found `'a` - --> $DIR/hkl_forbidden.rs:41:5 + --> $DIR/hkl_forbidden.rs:45:5 | LL | type Inner<'a> = impl Sized; | -- this generic parameter must be used with a generic lifetime parameter @@ -43,6 +63,6 @@ LL | type Inner<'a> = impl Sized; LL | |x| x | ^^^^^ -error: aborting due to 5 previous errors +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/type-alias-impl-trait/param_mismatch2.rs b/tests/ui/type-alias-impl-trait/param_mismatch2.rs index f6a99711411..94c495cb330 100644 --- a/tests/ui/type-alias-impl-trait/param_mismatch2.rs +++ b/tests/ui/type-alias-impl-trait/param_mismatch2.rs @@ -11,7 +11,9 @@ type Opaque<'a> = impl Sized + 'a; #[define_opaque(Opaque)] fn test(s: &str) -> (impl Fn(&str) -> Opaque<'_>, impl Fn(&str) -> Opaque<'_>) { - (id, id) //~ ERROR: expected generic lifetime parameter, found `'_` + (id, id) + //~^ ERROR: expected generic lifetime parameter, found `'_` + //~| ERROR: expected generic lifetime parameter, found `'_` } fn main() {} diff --git a/tests/ui/type-alias-impl-trait/param_mismatch2.stderr b/tests/ui/type-alias-impl-trait/param_mismatch2.stderr index f5ecade2f02..5c8a8af6501 100644 --- a/tests/ui/type-alias-impl-trait/param_mismatch2.stderr +++ b/tests/ui/type-alias-impl-trait/param_mismatch2.stderr @@ -7,6 +7,17 @@ LL | type Opaque<'a> = impl Sized + 'a; LL | (id, id) | ^^^^^^^^ -error: aborting due to 1 previous error +error[E0792]: expected generic lifetime parameter, found `'_` + --> $DIR/param_mismatch2.rs:14:5 + | +LL | type Opaque<'a> = impl Sized + 'a; + | -- this generic parameter must be used with a generic lifetime parameter +... +LL | (id, id) + | ^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/type-alias-impl-trait/param_mismatch3.rs b/tests/ui/type-alias-impl-trait/param_mismatch3.rs index 17b6f8bce2a..1514dd66db9 100644 --- a/tests/ui/type-alias-impl-trait/param_mismatch3.rs +++ b/tests/ui/type-alias-impl-trait/param_mismatch3.rs @@ -11,7 +11,9 @@ type Opaque<'a> = impl Sized + 'a; #[define_opaque(Opaque)] fn test() -> impl for<'a, 'b> Fn((&'a str, &'b str)) -> (Opaque<'a>, Opaque<'b>) { - id2 //~ ERROR expected generic lifetime parameter, found `'a` + id2 + //~^ ERROR expected generic lifetime parameter, found `'a` + //~| ERROR expected generic lifetime parameter, found `'b` } fn id(s: &str) -> &str { diff --git a/tests/ui/type-alias-impl-trait/param_mismatch3.stderr b/tests/ui/type-alias-impl-trait/param_mismatch3.stderr index 7565bbfc6ff..76be07ce38f 100644 --- a/tests/ui/type-alias-impl-trait/param_mismatch3.stderr +++ b/tests/ui/type-alias-impl-trait/param_mismatch3.stderr @@ -7,8 +7,17 @@ LL | type Opaque<'a> = impl Sized + 'a; LL | id2 | ^^^ +error[E0792]: expected generic lifetime parameter, found `'b` + --> $DIR/param_mismatch3.rs:14:5 + | +LL | type Opaque<'a> = impl Sized + 'a; + | -- this generic parameter must be used with a generic lifetime parameter +... +LL | id2 + | ^^^ + error[E0792]: expected generic lifetime parameter, found `'_` - --> $DIR/param_mismatch3.rs:25:5 + --> $DIR/param_mismatch3.rs:27:5 | LL | type Opaque2<'a> = impl Sized + 'a; | -- this generic parameter must be used with a generic lifetime parameter @@ -16,6 +25,6 @@ LL | type Opaque2<'a> = impl Sized + 'a; LL | (id, s) | ^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/type-inference/float-type-inference-unification-14382.rs b/tests/ui/type-inference/float-type-inference-unification-14382.rs index 5bf497d2eab..a78dbe9d09c 100644 --- a/tests/ui/type-inference/float-type-inference-unification-14382.rs +++ b/tests/ui/type-inference/float-type-inference-unification-14382.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/14382 + //@ run-pass #[derive(Debug)] struct Matrix4<S>(#[allow(dead_code)] S); @@ -13,5 +15,3 @@ fn main() { let m : Matrix4<f32> = translate(x); println!("m: {:?}", m); } - -// https://github.com/rust-lang/rust/issues/14382 diff --git a/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.rs b/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.rs index c28fda6f91a..ff99ac98926 100644 --- a/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.rs +++ b/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.rs @@ -1,7 +1,7 @@ //@known-bug: #127972 //@ failure-status: 101 //@ normalize-stderr: "note: .*\n\n" -> "" -//@ normalize-stderr: "thread 'rustc' panicked.*\n" -> "" +//@ normalize-stderr: "thread 'rustc'.*panicked.*\n" -> "" //@ normalize-stderr: "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " //@ rustc-env:RUST_BACKTRACE=0 diff --git a/tests/ui/type/type-name-basic.rs b/tests/ui/type/type-name-basic.rs index 9381cb82578..6a9f772e542 100644 --- a/tests/ui/type/type-name-basic.rs +++ b/tests/ui/type/type-name-basic.rs @@ -6,12 +6,85 @@ #![allow(dead_code)] use std::any::type_name; +use std::borrow::Cow; -struct Foo<T> { - x: T, +struct Foo<T>(T); + +struct Bar<'a>(&'a u32); + +struct Baz<'a, T>(&'a T); + +trait TrL<'a> {} +trait TrLA<'a> { + type A; +} +trait TrLT<'a, T> {} +trait TrLTA<'a, T> { + type A; +} + +macro_rules! t { + ($ty:ty, $str:literal) => { + assert_eq!(type_name::<$ty>(), $str); + } } pub fn main() { - assert_eq!(type_name::<isize>(), "isize"); - assert_eq!(type_name::<Foo<usize>>(), "type_name_basic::Foo<usize>"); + t!(bool, "bool"); + t!(char, "char"); + + t!(u8, "u8"); + t!(u16, "u16"); + t!(u32, "u32"); + t!(u64, "u64"); + t!(u128, "u128"); + t!(usize, "usize"); + + t!(i8, "i8"); + t!(i16, "i16"); + t!(i32, "i32"); + t!(i64, "i64"); + t!(i128, "i128"); + t!(isize, "isize"); + + t!(String, "alloc::string::String"); + t!(str, "str"); + t!(&str, "&str"); + t!(&'static str, "&str"); + + t!((u16, u32, u64), "(u16, u32, u64)"); + t!([usize; 4], "[usize; 4]"); + t!([usize], "[usize]"); + t!(&[usize], "&[usize]"); + + t!(*const bool, "*const bool"); + t!(*mut u64, "*mut u64"); + + t!(Vec<Vec<u32>>, "alloc::vec::Vec<alloc::vec::Vec<u32>>"); + t!(Foo<usize>, "type_name_basic::Foo<usize>"); + t!(Bar<'static>, "type_name_basic::Bar"); + t!(Baz<'static, u32>, "type_name_basic::Baz<u32>"); + + // FIXME: lifetime omission means these all print badly. + t!(dyn TrL<'static>, "dyn type_name_basic::TrL<>"); + t!(dyn TrLA<'static, A = u32>, "dyn type_name_basic::TrLA<, A = u32>"); + t!( + dyn TrLT<'static, Cow<'static, ()>>, + "dyn type_name_basic::TrLT<, alloc::borrow::Cow<()>>" + ); + t!( + dyn TrLTA<'static, u32, A = Cow<'static, ()>>, + "dyn type_name_basic::TrLTA<, u32, A = alloc::borrow::Cow<()>>" + ); + + t!(fn(i32) -> i32, "fn(i32) -> i32"); + t!(dyn for<'a> Fn(&'a u32), "dyn core::ops::function::Fn(&u32)"); + + struct S<'a, T>(&'a T); + impl<'a, T: Clone> S<'a, T> { + fn test() { + t!(Cow<'a, T>, "alloc::borrow::Cow<u32>"); + } + } + S::<u32>::test(); } diff --git a/tests/ui/issues/issue-14721.rs b/tests/ui/typeck/str-no-field-desc-14721.rs index c015a6bab08..605807ac04f 100644 --- a/tests/ui/issues/issue-14721.rs +++ b/tests/ui/typeck/str-no-field-desc-14721.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/14721 + fn main() { let foo = "str"; println!("{}", foo.desc); //~ ERROR no field `desc` on type `&str` diff --git a/tests/ui/issues/issue-14721.stderr b/tests/ui/typeck/str-no-field-desc-14721.stderr index c71b0363eef..fc1ec7179d7 100644 --- a/tests/ui/issues/issue-14721.stderr +++ b/tests/ui/typeck/str-no-field-desc-14721.stderr @@ -1,5 +1,5 @@ error[E0609]: no field `desc` on type `&str` - --> $DIR/issue-14721.rs:3:24 + --> $DIR/str-no-field-desc-14721.rs:5:24 | LL | println!("{}", foo.desc); | ^^^^ unknown field diff --git a/tests/ui/typeck/suggestions/suggest-add-wrapper-issue-145294.rs b/tests/ui/typeck/suggestions/suggest-add-wrapper-issue-145294.rs new file mode 100644 index 00000000000..cfe167cf88d --- /dev/null +++ b/tests/ui/typeck/suggestions/suggest-add-wrapper-issue-145294.rs @@ -0,0 +1,26 @@ +// Suppress the suggestion that adding a wrapper. +// When expected_ty and expr_ty are the same ADT, +// we prefer to compare their internal generic params, +// so when the current variant corresponds to an unresolved infer, +// the suggestion is rejected. +// e.g. `Ok(Some("hi"))` is type of `Result<Option<&str>, _>`, +// where `E` is still an unresolved inference variable. + +fn foo() -> Result<Option<String>, ()> { + todo!() +} + +#[derive(PartialEq, Debug)] +enum Bar<T, E> { + A(T), + B(E), +} + +fn bar() -> Bar<String, ()> { + todo!() +} + +fn main() { + assert_eq!(Ok(Some("hi")), foo()); //~ ERROR mismatched types [E0308] + assert_eq!(Bar::A("hi"), bar()); //~ ERROR mismatched types [E0308] +} diff --git a/tests/ui/typeck/suggestions/suggest-add-wrapper-issue-145294.stderr b/tests/ui/typeck/suggestions/suggest-add-wrapper-issue-145294.stderr new file mode 100644 index 00000000000..5e4ad132210 --- /dev/null +++ b/tests/ui/typeck/suggestions/suggest-add-wrapper-issue-145294.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/suggest-add-wrapper-issue-145294.rs:24:32 + | +LL | assert_eq!(Ok(Some("hi")), foo()); + | ^^^^^ expected `Result<Option<&str>, _>`, found `Result<Option<String>, ()>` + | + = note: expected enum `Result<Option<&str>, _>` + found enum `Result<Option<String>, ()>` + +error[E0308]: mismatched types + --> $DIR/suggest-add-wrapper-issue-145294.rs:25:30 + | +LL | assert_eq!(Bar::A("hi"), bar()); + | ^^^^^ expected `Bar<&str, _>`, found `Bar<String, ()>` + | + = note: expected enum `Bar<&str, _>` + found enum `Bar<String, ()>` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/issues/issue-30236.rs b/tests/ui/typeck/unused-type-parameter-span-30236.rs index 08d08a54402..bcdc922a71b 100644 --- a/tests/ui/issues/issue-30236.rs +++ b/tests/ui/typeck/unused-type-parameter-span-30236.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/30236 type Foo< Unused //~ ERROR type parameter `Unused` is never used > = u8; diff --git a/tests/ui/issues/issue-30236.stderr b/tests/ui/typeck/unused-type-parameter-span-30236.stderr index bfe374a653f..038bd1ebd28 100644 --- a/tests/ui/issues/issue-30236.stderr +++ b/tests/ui/typeck/unused-type-parameter-span-30236.stderr @@ -1,5 +1,5 @@ error[E0091]: type parameter `Unused` is never used - --> $DIR/issue-30236.rs:2:5 + --> $DIR/unused-type-parameter-span-30236.rs:3:5 | LL | Unused | ^^^^^^ unused type parameter diff --git a/tests/ui/unboxed-closures/unboxed-closure-illegal-move.stderr b/tests/ui/unboxed-closures/unboxed-closure-illegal-move.stderr index 8d9a61cb681..266da54941d 100644 --- a/tests/ui/unboxed-closures/unboxed-closure-illegal-move.stderr +++ b/tests/ui/unboxed-closures/unboxed-closure-illegal-move.stderr @@ -10,6 +10,11 @@ LL | let f = to_fn(|| drop(x)); | | | captured by this `Fn` closure | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/unboxed-closure-illegal-move.rs:7:33 + | +LL | fn to_fn<A:std::marker::Tuple,F:Fn<A>>(f: F) -> F { f } + | ^^^^^ help: consider cloning the value if the performance cost is acceptable | LL | let f = to_fn(|| drop(x.clone())); @@ -27,6 +32,11 @@ LL | let f = to_fn_mut(|| drop(x)); | | | captured by this `FnMut` closure | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/unboxed-closure-illegal-move.rs:8:37 + | +LL | fn to_fn_mut<A:std::marker::Tuple,F:FnMut<A>>(f: F) -> F { f } + | ^^^^^^^^ help: consider cloning the value if the performance cost is acceptable | LL | let f = to_fn_mut(|| drop(x.clone())); @@ -43,6 +53,12 @@ LL | let f = to_fn(move || drop(x)); | ------- ^ `x` is moved here | | | captured by this `Fn` closure + | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/unboxed-closure-illegal-move.rs:7:33 + | +LL | fn to_fn<A:std::marker::Tuple,F:Fn<A>>(f: F) -> F { f } + | ^^^^^ error[E0507]: cannot move out of `x`, a captured variable in an `FnMut` closure --> $DIR/unboxed-closure-illegal-move.rs:32:40 @@ -55,6 +71,12 @@ LL | let f = to_fn_mut(move || drop(x)); | ------- ^ `x` is moved here | | | captured by this `FnMut` closure + | +help: `Fn` and `FnMut` closures require captured values to be able to be consumed multiple times, but `FnOnce` closures may consume them only once + --> $DIR/unboxed-closure-illegal-move.rs:8:37 + | +LL | fn to_fn_mut<A:std::marker::Tuple,F:FnMut<A>>(f: F) -> F { f } + | ^^^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/issues/issue-88150.rs b/tests/ui/uninhabited/uninhabited-type-layout-computation-88150.rs index 1dadba307c0..1387c5b6c10 100644 --- a/tests/ui/issues/issue-88150.rs +++ b/tests/ui/uninhabited/uninhabited-type-layout-computation-88150.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/88150 //@ run-pass //@ compile-flags:-C debuginfo=2 //@ edition:2018 diff --git a/tests/ui/unpretty/exhaustive.expanded.stdout b/tests/ui/unpretty/exhaustive.expanded.stdout index 6b08f3e1cd7..0327ad5f92b 100644 --- a/tests/ui/unpretty/exhaustive.expanded.stdout +++ b/tests/ui/unpretty/exhaustive.expanded.stdout @@ -34,9 +34,6 @@ extern crate std; #[prelude_import] use std::prelude::rust_2024::*; -#[prelude_import] -use self::prelude::*; - mod prelude { pub use std::prelude::rust_2024::*; @@ -47,6 +44,9 @@ mod prelude { } } +#[prelude_import] +use self::prelude::*; + mod attributes { //! inner single-line doc comment /*! diff --git a/tests/ui/unpretty/exhaustive.hir.stdout b/tests/ui/unpretty/exhaustive.hir.stdout index 9cfa65f5801..68356a33c9e 100644 --- a/tests/ui/unpretty/exhaustive.hir.stdout +++ b/tests/ui/unpretty/exhaustive.hir.stdout @@ -33,9 +33,6 @@ extern crate std; #[prelude_import] use std::prelude::rust_2024::*; -#[prelude_import] -use self::prelude::*; - mod prelude { use std::prelude::rust_2024::*; @@ -48,6 +45,9 @@ mod prelude { } } +#[prelude_import] +use self::prelude::*; + /// inner single-line doc comment /** * inner multi-line doc comment @@ -509,7 +509,7 @@ mod items { impl () { } impl <T> () { } impl Default for () { } - impl const <T> Default for () { } + impl <T> const Default for () { } } /// ItemKind::MacCall mod item_mac_call { } diff --git a/tests/ui/unpretty/exhaustive.rs b/tests/ui/unpretty/exhaustive.rs index 5292ddad4f6..b19d4f9fe2c 100644 --- a/tests/ui/unpretty/exhaustive.rs +++ b/tests/ui/unpretty/exhaustive.rs @@ -29,9 +29,6 @@ #![feature(yeet_expr)] #![allow(incomplete_features)] -#[prelude_import] -use self::prelude::*; - mod prelude { pub use std::prelude::rust_2024::*; @@ -42,6 +39,9 @@ mod prelude { } } +#[prelude_import] +use self::prelude::*; + mod attributes { //! inner single-line doc comment /*! diff --git a/tests/ui/unsized/relaxed-bounds-invalid-places.rs b/tests/ui/unsized/relaxed-bounds-invalid-places.rs index b8eda1e7786..4c1f242a01c 100644 --- a/tests/ui/unsized/relaxed-bounds-invalid-places.rs +++ b/tests/ui/unsized/relaxed-bounds-invalid-places.rs @@ -22,6 +22,10 @@ impl<T> S1<T> { fn f() where T: ?Sized {} //~ ERROR this relaxed bound is not permitted here } +// Test associated type bounds (ATB). +// issue: <https://github.com/rust-lang/rust/issues/135229> +struct S6<T>(T) where T: Iterator<Item: ?Sized>; //~ ERROR this relaxed bound is not permitted here + trait Tr: ?Sized {} //~ ERROR relaxed bounds are not permitted in supertrait bounds // Test that relaxed `Sized` bounds are rejected in trait object types: diff --git a/tests/ui/unsized/relaxed-bounds-invalid-places.stderr b/tests/ui/unsized/relaxed-bounds-invalid-places.stderr index 30285d62693..d3f0535e2f0 100644 --- a/tests/ui/unsized/relaxed-bounds-invalid-places.stderr +++ b/tests/ui/unsized/relaxed-bounds-invalid-places.stderr @@ -38,8 +38,16 @@ LL | fn f() where T: ?Sized {} | = note: in this context, relaxed bounds are only allowed on type parameters defined by the closest item +error: this relaxed bound is not permitted here + --> $DIR/relaxed-bounds-invalid-places.rs:27:41 + | +LL | struct S6<T>(T) where T: Iterator<Item: ?Sized>; + | ^^^^^^ + | + = note: in this context, relaxed bounds are only allowed on type parameters defined by the closest item + error: relaxed bounds are not permitted in supertrait bounds - --> $DIR/relaxed-bounds-invalid-places.rs:25:11 + --> $DIR/relaxed-bounds-invalid-places.rs:29:11 | LL | trait Tr: ?Sized {} | ^^^^^^ @@ -47,19 +55,19 @@ LL | trait Tr: ?Sized {} = note: traits are `?Sized` by default error: relaxed bounds are not permitted in trait object types - --> $DIR/relaxed-bounds-invalid-places.rs:29:20 + --> $DIR/relaxed-bounds-invalid-places.rs:33:20 | LL | type O1 = dyn Tr + ?Sized; | ^^^^^^ error: relaxed bounds are not permitted in trait object types - --> $DIR/relaxed-bounds-invalid-places.rs:30:15 + --> $DIR/relaxed-bounds-invalid-places.rs:34:15 | LL | type O2 = dyn ?Sized + ?Sized + Tr; | ^^^^^^ error: relaxed bounds are not permitted in trait object types - --> $DIR/relaxed-bounds-invalid-places.rs:30:24 + --> $DIR/relaxed-bounds-invalid-places.rs:34:24 | LL | type O2 = dyn ?Sized + ?Sized + Tr; | ^^^^^^ @@ -76,5 +84,5 @@ error: bound modifier `?` can only be applied to `Sized` LL | struct S5<T>(*const T) where T: ?Trait<'static> + ?Sized; | ^^^^^^^^^^^^^^^ -error: aborting due to 11 previous errors +error: aborting due to 12 previous errors diff --git a/tests/ui/unstable-feature-bound/unstable_feature_bound_on_trait.fail.stderr b/tests/ui/unstable-feature-bound/unstable_feature_bound_on_trait.fail.stderr new file mode 100644 index 00000000000..69be101a40d --- /dev/null +++ b/tests/ui/unstable-feature-bound/unstable_feature_bound_on_trait.fail.stderr @@ -0,0 +1,18 @@ +error: unstable feature `foo` is used without being enabled. + --> $DIR/unstable_feature_bound_on_trait.rs:28:5 + | +LL | Foo::bar(); + | ^^^^^^^^^^ + | + = help: The feature can be enabled by marking the current item with `#[unstable_feature_bound(foo)]` +note: required by a bound in `Bar::bar` + --> $DIR/unstable_feature_bound_on_trait.rs:16:1 + | +LL | #[unstable_feature_bound(foo)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Bar::bar` +... +LL | fn bar() {} + | --- required by a bound in this associated function + +error: aborting due to 1 previous error + diff --git a/tests/ui/unstable-feature-bound/unstable_feature_bound_on_trait.rs b/tests/ui/unstable-feature-bound/unstable_feature_bound_on_trait.rs new file mode 100644 index 00000000000..0ee00d5e7fb --- /dev/null +++ b/tests/ui/unstable-feature-bound/unstable_feature_bound_on_trait.rs @@ -0,0 +1,33 @@ +//@ revisions: pass fail +//@[pass] check-pass + +#![allow(internal_features)] +#![feature(staged_api)] +#![stable(feature = "a", since = "1.1.1" )] + +/// Test the behaviour of marking a trait with #[unstable_feature_bound]. +/// In this testcase, even though the trait method `bar` and the `struct Foo` are +/// both stable, #[unstable_feature_bound] is still needed at the call site of Foo::bar(). + +#[stable(feature = "a", since = "1.1.1" )] +struct Foo; + +#[unstable(feature = "foo", issue = "none" )] +#[unstable_feature_bound(foo)] +trait Bar { + #[stable(feature = "a", since = "1.1.1" )] + fn bar() {} +} + +#[unstable_feature_bound(foo)] +impl Bar for Foo { +} + +#[cfg_attr(pass, unstable_feature_bound(foo))] +fn moo() { + Foo::bar(); + //[fail]~^ ERROR: unstable feature `foo` is used without being enabled. +} + + +fn main() {} diff --git a/tests/ui/unstable-feature-bound/unstable_inherent_method.rs b/tests/ui/unstable-feature-bound/unstable_inherent_method.rs index 5f3095430a8..cdd4178fc87 100644 --- a/tests/ui/unstable-feature-bound/unstable_inherent_method.rs +++ b/tests/ui/unstable-feature-bound/unstable_inherent_method.rs @@ -9,14 +9,14 @@ pub trait Trait { #[unstable(feature = "feat", issue = "none" )] #[unstable_feature_bound(foo)] - //~^ ERROR: attribute should be applied to `impl` or free function outside of any `impl` or trait + //~^ ERROR: attribute cannot be used on fn foo(); } #[stable(feature = "a", since = "1.1.1" )] impl Trait for u8 { #[unstable_feature_bound(foo)] - //~^ ERROR: attribute should be applied to `impl` or free function outside of any `impl` or trait + //~^ ERROR: attribute cannot be used on fn foo() {} } diff --git a/tests/ui/unstable-feature-bound/unstable_inherent_method.stderr b/tests/ui/unstable-feature-bound/unstable_inherent_method.stderr index fa1c39db259..2a1ae936cfe 100644 --- a/tests/ui/unstable-feature-bound/unstable_inherent_method.stderr +++ b/tests/ui/unstable-feature-bound/unstable_inherent_method.stderr @@ -1,20 +1,18 @@ -error: attribute should be applied to `impl` or free function outside of any `impl` or trait +error: `#[unstable_feature_bound]` attribute cannot be used on required trait methods --> $DIR/unstable_inherent_method.rs:11:5 | LL | #[unstable_feature_bound(foo)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | fn foo(); - | --------- not an `impl` or free function + | + = help: `#[unstable_feature_bound]` can be applied to functions, trait impl blocks, traits -error: attribute should be applied to `impl` or free function outside of any `impl` or trait +error: `#[unstable_feature_bound]` attribute cannot be used on trait methods in impl blocks --> $DIR/unstable_inherent_method.rs:18:5 | LL | #[unstable_feature_bound(foo)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | fn foo() {} - | ----------- not an `impl` or free function + | + = help: `#[unstable_feature_bound]` can be applied to functions, trait impl blocks, traits error: aborting due to 2 previous errors diff --git a/tests/ui/wf/hir-wf-check-erase-regions.stderr b/tests/ui/wf/hir-wf-check-erase-regions.nll.stderr index 07304cd448e..dcade3aa367 100644 --- a/tests/ui/wf/hir-wf-check-erase-regions.stderr +++ b/tests/ui/wf/hir-wf-check-erase-regions.nll.stderr @@ -1,5 +1,5 @@ error[E0277]: `&'a T` is not an iterator - --> $DIR/hir-wf-check-erase-regions.rs:7:21 + --> $DIR/hir-wf-check-erase-regions.rs:11:21 | LL | type IntoIter = std::iter::Flatten<std::slice::Iter<'a, T>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `&'a T` is not an iterator @@ -11,7 +11,7 @@ note: required by a bound in `std::iter::IntoIterator::IntoIter` --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL error[E0277]: `&'a T` is not an iterator - --> $DIR/hir-wf-check-erase-regions.rs:7:5 + --> $DIR/hir-wf-check-erase-regions.rs:11:5 | LL | type IntoIter = std::iter::Flatten<std::slice::Iter<'a, T>>; | ^^^^^^^^^^^^^ `&'a T` is not an iterator @@ -23,7 +23,7 @@ note: required by a bound in `Flatten` --> $SRC_DIR/core/src/iter/adapters/flatten.rs:LL:COL error[E0277]: `&'a T` is not an iterator - --> $DIR/hir-wf-check-erase-regions.rs:11:27 + --> $DIR/hir-wf-check-erase-regions.rs:15:27 | LL | fn into_iter(self) -> Self::IntoIter { | ^^^^^^^^^^^^^^ `&'a T` is not an iterator @@ -35,7 +35,7 @@ note: required by a bound in `Flatten` --> $SRC_DIR/core/src/iter/adapters/flatten.rs:LL:COL error[E0277]: `&T` is not an iterator - --> $DIR/hir-wf-check-erase-regions.rs:11:27 + --> $DIR/hir-wf-check-erase-regions.rs:15:27 | LL | fn into_iter(self) -> Self::IntoIter { | ^^^^^^^^^^^^^^ `&T` is not an iterator diff --git a/tests/ui/wf/hir-wf-check-erase-regions.polonius.stderr b/tests/ui/wf/hir-wf-check-erase-regions.polonius.stderr new file mode 100644 index 00000000000..55728aa642b --- /dev/null +++ b/tests/ui/wf/hir-wf-check-erase-regions.polonius.stderr @@ -0,0 +1,39 @@ +error[E0277]: `&'a T` is not an iterator + --> $DIR/hir-wf-check-erase-regions.rs:11:21 + | +LL | type IntoIter = std::iter::Flatten<std::slice::Iter<'a, T>>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `&'a T` is not an iterator + | + = help: the trait `Iterator` is not implemented for `&'a T` + = help: the trait `Iterator` is implemented for `&mut I` + = note: required for `Flatten<std::slice::Iter<'a, T>>` to implement `Iterator` +note: required by a bound in `std::iter::IntoIterator::IntoIter` + --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL + +error[E0277]: `&'a T` is not an iterator + --> $DIR/hir-wf-check-erase-regions.rs:11:5 + | +LL | type IntoIter = std::iter::Flatten<std::slice::Iter<'a, T>>; + | ^^^^^^^^^^^^^ `&'a T` is not an iterator + | + = help: the trait `Iterator` is not implemented for `&'a T` + = help: the trait `Iterator` is implemented for `&mut I` + = note: required for `&'a T` to implement `IntoIterator` +note: required by a bound in `Flatten` + --> $SRC_DIR/core/src/iter/adapters/flatten.rs:LL:COL + +error[E0277]: `&'a T` is not an iterator + --> $DIR/hir-wf-check-erase-regions.rs:15:27 + | +LL | fn into_iter(self) -> Self::IntoIter { + | ^^^^^^^^^^^^^^ `&'a T` is not an iterator + | + = help: the trait `Iterator` is not implemented for `&'a T` + = help: the trait `Iterator` is implemented for `&mut I` + = note: required for `&'a T` to implement `IntoIterator` +note: required by a bound in `Flatten` + --> $SRC_DIR/core/src/iter/adapters/flatten.rs:LL:COL + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/wf/hir-wf-check-erase-regions.rs b/tests/ui/wf/hir-wf-check-erase-regions.rs index 20cc1cfe730..ef9132697ef 100644 --- a/tests/ui/wf/hir-wf-check-erase-regions.rs +++ b/tests/ui/wf/hir-wf-check-erase-regions.rs @@ -1,6 +1,10 @@ // Regression test for #87549. //@ incremental +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: nll polonius +//@ [polonius] compile-flags: -Zpolonius=next + pub struct Table<T, const N: usize>([Option<T>; N]); impl<'a, T, const N: usize> IntoIterator for &'a Table<T, N> { @@ -10,7 +14,7 @@ impl<'a, T, const N: usize> IntoIterator for &'a Table<T, N> { fn into_iter(self) -> Self::IntoIter { //~^ ERROR `&'a T` is not an iterator - //~| ERROR `&T` is not an iterator + //[nll]~| ERROR `&T` is not an iterator unimplemented!() } } diff --git a/tests/ui/where-clauses/unsupported_attribute.rs b/tests/ui/where-clauses/unsupported_attribute.rs index 33128b383b9..75213e17661 100644 --- a/tests/ui/where-clauses/unsupported_attribute.rs +++ b/tests/ui/where-clauses/unsupported_attribute.rs @@ -13,18 +13,18 @@ fn foo<'a, T>() where #[doc = "doc"] T: Trait, //~ ERROR most attributes are not supported in `where` clauses #[doc = "doc"] 'a: 'static, //~ ERROR most attributes are not supported in `where` clauses - #[ignore] T: Trait, //~ ERROR most attributes are not supported in `where` clauses - #[ignore] 'a: 'static, //~ ERROR most attributes are not supported in `where` clauses - #[should_panic] T: Trait, //~ ERROR most attributes are not supported in `where` clauses - #[should_panic] 'a: 'static, //~ ERROR most attributes are not supported in `where` clauses - #[macro_use] T: Trait, //~ ERROR most attributes are not supported in `where` clauses - #[macro_use] 'a: 'static, //~ ERROR most attributes are not supported in `where` clauses + #[ignore] T: Trait, //~ ERROR attribute cannot be used on + #[ignore] 'a: 'static, //~ ERROR attribute cannot be used on + #[should_panic] T: Trait, //~ ERROR attribute cannot be used on + #[should_panic] 'a: 'static, //~ ERROR attribute cannot be used on + #[macro_use] T: Trait, //~ ERROR attribute cannot be used on + #[macro_use] 'a: 'static, //~ ERROR attribute cannot be used on #[allow(unused)] T: Trait, //~ ERROR most attributes are not supported in `where` clauses #[allow(unused)] 'a: 'static, //~ ERROR most attributes are not supported in `where` clauses - #[deprecated] T: Trait, //~ ERROR most attributes are not supported in `where` clauses - #[deprecated] 'a: 'static, //~ ERROR most attributes are not supported in `where` clauses - #[automatically_derived] T: Trait, //~ ERROR most attributes are not supported in `where` clauses - #[automatically_derived] 'a: 'static, //~ ERROR most attributes are not supported in `where` clauses + #[deprecated] T: Trait, //~ ERROR attribute cannot be used on + #[deprecated] 'a: 'static, //~ ERROR attribute cannot be used on + #[automatically_derived] T: Trait, //~ ERROR attribute cannot be used on + #[automatically_derived] 'a: 'static, //~ ERROR attribute cannot be used on #[derive(Clone)] T: Trait, //~^ ERROR most attributes are not supported in `where` clauses //~| ERROR expected non-macro attribute, found attribute macro `derive` diff --git a/tests/ui/where-clauses/unsupported_attribute.stderr b/tests/ui/where-clauses/unsupported_attribute.stderr index ecb28039f88..411c895ed87 100644 --- a/tests/ui/where-clauses/unsupported_attribute.stderr +++ b/tests/ui/where-clauses/unsupported_attribute.stderr @@ -10,115 +10,115 @@ error: expected non-macro attribute, found attribute macro `derive` LL | #[derive(Clone)] 'a: 'static, | ^^^^^^ not a non-macro attribute -error: most attributes are not supported in `where` clauses - --> $DIR/unsupported_attribute.rs:14:5 - | -LL | #[doc = "doc"] T: Trait, - | ^^^^^^^^^^^^^^ - | - = help: only `#[cfg]` and `#[cfg_attr]` are supported - -error: most attributes are not supported in `where` clauses - --> $DIR/unsupported_attribute.rs:15:5 - | -LL | #[doc = "doc"] 'a: 'static, - | ^^^^^^^^^^^^^^ - | - = help: only `#[cfg]` and `#[cfg_attr]` are supported - -error: most attributes are not supported in `where` clauses +error: `#[ignore]` attribute cannot be used on where predicates --> $DIR/unsupported_attribute.rs:16:5 | LL | #[ignore] T: Trait, | ^^^^^^^^^ | - = help: only `#[cfg]` and `#[cfg_attr]` are supported + = help: `#[ignore]` can only be applied to functions -error: most attributes are not supported in `where` clauses +error: `#[ignore]` attribute cannot be used on where predicates --> $DIR/unsupported_attribute.rs:17:5 | LL | #[ignore] 'a: 'static, | ^^^^^^^^^ | - = help: only `#[cfg]` and `#[cfg_attr]` are supported + = help: `#[ignore]` can only be applied to functions -error: most attributes are not supported in `where` clauses +error: `#[should_panic]` attribute cannot be used on where predicates --> $DIR/unsupported_attribute.rs:18:5 | LL | #[should_panic] T: Trait, | ^^^^^^^^^^^^^^^ | - = help: only `#[cfg]` and `#[cfg_attr]` are supported + = help: `#[should_panic]` can only be applied to functions -error: most attributes are not supported in `where` clauses +error: `#[should_panic]` attribute cannot be used on where predicates --> $DIR/unsupported_attribute.rs:19:5 | LL | #[should_panic] 'a: 'static, | ^^^^^^^^^^^^^^^ | - = help: only `#[cfg]` and `#[cfg_attr]` are supported + = help: `#[should_panic]` can only be applied to functions -error: most attributes are not supported in `where` clauses +error: `#[macro_use]` attribute cannot be used on where predicates --> $DIR/unsupported_attribute.rs:20:5 | LL | #[macro_use] T: Trait, | ^^^^^^^^^^^^ | - = help: only `#[cfg]` and `#[cfg_attr]` are supported + = help: `#[macro_use]` can be applied to modules, extern crates, crates -error: most attributes are not supported in `where` clauses +error: `#[macro_use]` attribute cannot be used on where predicates --> $DIR/unsupported_attribute.rs:21:5 | LL | #[macro_use] 'a: 'static, | ^^^^^^^^^^^^ | - = help: only `#[cfg]` and `#[cfg_attr]` are supported + = help: `#[macro_use]` can be applied to modules, extern crates, crates -error: most attributes are not supported in `where` clauses - --> $DIR/unsupported_attribute.rs:22:5 +error: `#[deprecated]` attribute cannot be used on where predicates + --> $DIR/unsupported_attribute.rs:24:5 | -LL | #[allow(unused)] T: Trait, - | ^^^^^^^^^^^^^^^^ +LL | #[deprecated] T: Trait, + | ^^^^^^^^^^^^^ | - = help: only `#[cfg]` and `#[cfg_attr]` are supported + = help: `#[deprecated]` can be applied to functions, data types, modules, unions, constants, statics, macro defs, type aliases, use statements, struct fields, traits, associated types, associated consts, enum variants, inherent impl blocks, crates -error: most attributes are not supported in `where` clauses - --> $DIR/unsupported_attribute.rs:23:5 +error: `#[deprecated]` attribute cannot be used on where predicates + --> $DIR/unsupported_attribute.rs:25:5 | -LL | #[allow(unused)] 'a: 'static, - | ^^^^^^^^^^^^^^^^ +LL | #[deprecated] 'a: 'static, + | ^^^^^^^^^^^^^ | - = help: only `#[cfg]` and `#[cfg_attr]` are supported + = help: `#[deprecated]` can be applied to functions, data types, modules, unions, constants, statics, macro defs, type aliases, use statements, struct fields, traits, associated types, associated consts, enum variants, inherent impl blocks, crates + +error: `#[automatically_derived]` attribute cannot be used on where predicates + --> $DIR/unsupported_attribute.rs:26:5 + | +LL | #[automatically_derived] T: Trait, + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[automatically_derived]` can only be applied to trait impl blocks + +error: `#[automatically_derived]` attribute cannot be used on where predicates + --> $DIR/unsupported_attribute.rs:27:5 + | +LL | #[automatically_derived] 'a: 'static, + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: `#[automatically_derived]` can only be applied to trait impl blocks error: most attributes are not supported in `where` clauses - --> $DIR/unsupported_attribute.rs:24:5 + --> $DIR/unsupported_attribute.rs:14:5 | -LL | #[deprecated] T: Trait, - | ^^^^^^^^^^^^^ +LL | #[doc = "doc"] T: Trait, + | ^^^^^^^^^^^^^^ | = help: only `#[cfg]` and `#[cfg_attr]` are supported error: most attributes are not supported in `where` clauses - --> $DIR/unsupported_attribute.rs:25:5 + --> $DIR/unsupported_attribute.rs:15:5 | -LL | #[deprecated] 'a: 'static, - | ^^^^^^^^^^^^^ +LL | #[doc = "doc"] 'a: 'static, + | ^^^^^^^^^^^^^^ | = help: only `#[cfg]` and `#[cfg_attr]` are supported error: most attributes are not supported in `where` clauses - --> $DIR/unsupported_attribute.rs:26:5 + --> $DIR/unsupported_attribute.rs:22:5 | -LL | #[automatically_derived] T: Trait, - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[allow(unused)] T: Trait, + | ^^^^^^^^^^^^^^^^ | = help: only `#[cfg]` and `#[cfg_attr]` are supported error: most attributes are not supported in `where` clauses - --> $DIR/unsupported_attribute.rs:27:5 + --> $DIR/unsupported_attribute.rs:23:5 | -LL | #[automatically_derived] 'a: 'static, - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[allow(unused)] 'a: 'static, + | ^^^^^^^^^^^^^^^^ | = help: only `#[cfg]` and `#[cfg_attr]` are supported |
