diff options
Diffstat (limited to 'tests')
812 files changed, 9729 insertions, 4506 deletions
diff --git a/tests/assembly/simd-bitmask.rs b/tests/assembly/simd-bitmask.rs index e4122461087..d3e20f6ae1a 100644 --- a/tests/assembly/simd-bitmask.rs +++ b/tests/assembly/simd-bitmask.rs @@ -65,8 +65,9 @@ pub unsafe extern "C" fn bitmask_m8x16(mask: m8x16) -> u16 { simd_bitmask(mask) } -// CHECK-LABEL: bitmask_m8x64 +// x86-avx512-LABEL: bitmask_m8x64 #[no_mangle] +#[cfg(x86_avx512)] pub unsafe extern "C" fn bitmask_m8x64(mask: m8x64) -> u64 { // The simd_bitmask intrinsic already uses the most significant bit, so no shift is necessary. // Note that x86 has no byte shift, llvm uses a word shift to move the least significant bit @@ -128,8 +129,10 @@ pub unsafe extern "C" fn bitmask_m64x2(mask: m64x2) -> u8 { simd_bitmask(mask) } -// CHECK-LABEL: bitmask_m64x4 +// x86-avx2-LABEL: bitmask_m64x4 +// x86-avx512-LABEL: bitmask_m64x4 #[no_mangle] +#[cfg(any(x86_avx2, x86_avx512))] pub unsafe extern "C" fn bitmask_m64x4(mask: m64x4) -> u8 { // The simd_bitmask intrinsic already uses the most significant bit, so no shift is necessary. // diff --git a/tests/assembly/simd-intrinsic-select.rs b/tests/assembly/simd-intrinsic-select.rs index 4f8d6b825b6..e7c7b0db0d5 100644 --- a/tests/assembly/simd-intrinsic-select.rs +++ b/tests/assembly/simd-intrinsic-select.rs @@ -99,8 +99,10 @@ pub unsafe extern "C" fn select_f64x2(mask: m64x2, a: f64x2, b: f64x2) -> f64x2 simd_select(mask, a, b) } -// CHECK-LABEL: select_f64x4 +// x86-avx2-LABEL: select_f64x4 +// x86-avx512-LABEL: select_f64x4 #[no_mangle] +#[cfg(any(x86_avx2, x86_avx512))] pub unsafe extern "C" fn select_f64x4(mask: m64x4, a: f64x4, b: f64x4) -> f64x4 { // The parameter is a 256 bit vector which in the C abi is only valid for avx targets. // @@ -113,8 +115,9 @@ pub unsafe extern "C" fn select_f64x4(mask: m64x4, a: f64x4, b: f64x4) -> f64x4 simd_select(mask, a, b) } -// CHECK-LABEL: select_f64x8 +// x86-avx512-LABEL: select_f64x8 #[no_mangle] +#[cfg(x86_avx512)] pub unsafe extern "C" fn select_f64x8(mask: m64x8, a: f64x8, b: f64x8) -> f64x8 { // The parameter is a 256 bit vector which in the C abi is only valid for avx512 targets. // diff --git a/tests/assembly/x86-return-float.rs b/tests/assembly/x86-return-float.rs index 2c39c830684..165c11d2280 100644 --- a/tests/assembly/x86-return-float.rs +++ b/tests/assembly/x86-return-float.rs @@ -35,6 +35,7 @@ use minicore::*; pub fn return_f32(x: f32) -> f32 { // CHECK: movss {{.*}}(%ebp), %xmm0 // CHECK-NEXT: popl %ebp + // linux-NEXT: .cfi_def_cfa // CHECK-NEXT: retl x } @@ -44,6 +45,7 @@ pub fn return_f32(x: f32) -> f32 { pub fn return_f64(x: f64) -> f64 { // CHECK: movsd {{.*}}(%ebp), %xmm0 // CHECK-NEXT: popl %ebp + // linux-NEXT: .cfi_def_cfa // CHECK-NEXT: retl x } @@ -313,9 +315,13 @@ pub unsafe fn call_other_f64(x: &mut (usize, f64)) { #[no_mangle] pub fn return_f16(x: f16) -> f16 { // CHECK: pushl %ebp + // linux-NEXT: .cfi_def_cfa_offset + // linux-NEXT: .cfi_offset // CHECK-NEXT: movl %esp, %ebp + // linux-NEXT: .cfi_def_cfa_register // CHECK-NEXT: pinsrw $0, 8(%ebp), %xmm0 // CHECK-NEXT: popl %ebp + // linux-NEXT: .cfi_def_cfa // CHECK-NEXT: retl x } @@ -324,10 +330,14 @@ pub fn return_f16(x: f16) -> f16 { #[no_mangle] pub fn return_f128(x: f128) -> f128 { // CHECK: pushl %ebp + // linux-NEXT: .cfi_def_cfa_offset + // linux-NEXT: .cfi_offset // CHECK-NEXT: movl %esp, %ebp + // linux-NEXT: .cfi_def_cfa_register // linux-NEXT: movaps 8(%ebp), %xmm0 // win-NEXT: movups 8(%ebp), %xmm0 // CHECK-NEXT: popl %ebp + // linux-NEXT: .cfi_def_cfa // CHECK-NEXT: retl x } diff --git a/tests/codegen/align-struct.rs b/tests/codegen/align-struct.rs index cc65b08a922..402a184d4c0 100644 --- a/tests/codegen/align-struct.rs +++ b/tests/codegen/align-struct.rs @@ -1,5 +1,7 @@ //@ compile-flags: -C no-prepopulate-passes -Z mir-opt-level=0 -// +// 32bit MSVC does not align things properly so we suppress high alignment annotations (#112480) +//@ ignore-i686-pc-windows-msvc +//@ ignore-i686-pc-windows-gnu #![crate_type = "lib"] diff --git a/tests/codegen/autodiff/identical_fnc.rs b/tests/codegen/autodiff/identical_fnc.rs new file mode 100644 index 00000000000..1c3277f52b4 --- /dev/null +++ b/tests/codegen/autodiff/identical_fnc.rs @@ -0,0 +1,45 @@ +//@ compile-flags: -Zautodiff=Enable -C opt-level=3 -Clto=fat +//@ no-prefer-dynamic +//@ needs-enzyme +// +// Each autodiff invocation creates a new placeholder function, which we will replace on llvm-ir +// level. If a user tries to differentiate two identical functions within the same compilation unit, +// then LLVM might merge them in release mode before AD. In that case we can't rewrite one of the +// merged placeholder function anymore, and compilation would fail. We prevent this by disabling +// LLVM's merge_function pass before AD. Here we implicetely test that our solution keeps working. +// We also explicetly test that we keep running merge_function after AD, by checking for two +// identical function calls in the LLVM-IR, while having two different calls in the Rust code. +#![feature(autodiff)] + +use std::autodiff::autodiff; + +#[autodiff(d_square, Reverse, Duplicated, Active)] +fn square(x: &f64) -> f64 { + x * x +} + +#[autodiff(d_square2, Reverse, Duplicated, Active)] +fn square2(x: &f64) -> f64 { + x * x +} + +// CHECK:; identical_fnc::main +// CHECK-NEXT:; Function Attrs: +// CHECK-NEXT:define internal void @_ZN13identical_fnc4main17hf4dbc69c8d2f9130E() +// 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) + +fn main() { + let x = std::hint::black_box(3.0); + let mut dx1 = std::hint::black_box(1.0); + let mut dx2 = std::hint::black_box(1.0); + let _ = d_square(&x, &mut dx1, 1.0); + let _ = d_square2(&x, &mut dx2, 1.0); + assert_eq!(dx1, 6.0); + assert_eq!(dx2, 6.0); +} diff --git a/tests/codegen/autodiff/inline.rs b/tests/codegen/autodiff/inline.rs new file mode 100644 index 00000000000..e90faa4aa38 --- /dev/null +++ b/tests/codegen/autodiff/inline.rs @@ -0,0 +1,23 @@ +//@ compile-flags: -Zautodiff=Enable -C opt-level=3 -Clto=fat -Zautodiff=NoPostopt +//@ no-prefer-dynamic +//@ needs-enzyme + +#![feature(autodiff)] + +use std::autodiff::autodiff; + +#[autodiff(d_square, Reverse, 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/const-vector.rs b/tests/codegen/const-vector.rs index 8343594e5d2..289b67371ce 100644 --- a/tests/codegen/const-vector.rs +++ b/tests/codegen/const-vector.rs @@ -8,6 +8,8 @@ #![feature(repr_simd)] #![feature(rustc_attrs)] #![feature(simd_ffi)] +#![feature(arm_target_feature)] +#![feature(mips_target_feature)] #![allow(non_camel_case_types)] // Setting up structs that can be used as const vectors @@ -28,33 +30,12 @@ pub struct Simd<T, const N: usize>([T; N]); extern "unadjusted" { fn test_i8x2(a: i8x2); -} - -extern "unadjusted" { fn test_i8x2_two_args(a: i8x2, b: i8x2); -} - -extern "unadjusted" { fn test_i8x2_mixed_args(a: i8x2, c: i32, b: i8x2); -} - -extern "unadjusted" { fn test_i8x2_arr(a: i8x2); -} - -extern "unadjusted" { fn test_f32x2(a: f32x2); -} - -extern "unadjusted" { fn test_f32x2_arr(a: f32x2); -} - -extern "unadjusted" { fn test_simd(a: Simd<i32, 4>); -} - -extern "unadjusted" { fn test_simd_unaligned(a: Simd<i32, 3>); } @@ -62,6 +43,10 @@ extern "unadjusted" { // if the size is not a power of 2 // CHECK: %"Simd<i32, 3>" = type { [3 x i32] } +#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))] +#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))] +#[cfg_attr(target_arch = "x86", target_feature(enable = "sse"))] +#[cfg_attr(target_arch = "mips", target_feature(enable = "msa"))] pub fn do_call() { unsafe { // CHECK: call void @test_i8x2(<2 x i8> <i8 32, i8 64> diff --git a/tests/codegen/intrinsics/select_unpredictable.rs b/tests/codegen/intrinsics/select_unpredictable.rs index 2db4ae174b3..ad7120c6fb8 100644 --- a/tests/codegen/intrinsics/select_unpredictable.rs +++ b/tests/codegen/intrinsics/select_unpredictable.rs @@ -1,7 +1,6 @@ //@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled #![feature(core_intrinsics)] -#![feature(select_unpredictable)] #![crate_type = "lib"] /* Test the intrinsic */ diff --git a/tests/codegen/issues/issue-56927.rs b/tests/codegen/issues/issue-56927.rs index a40718689b3..415ef073e03 100644 --- a/tests/codegen/issues/issue-56927.rs +++ b/tests/codegen/issues/issue-56927.rs @@ -1,4 +1,7 @@ //@ compile-flags: -C no-prepopulate-passes +// 32bit MSVC does not align things properly so we suppress high alignment annotations (#112480) +//@ ignore-i686-pc-windows-msvc +//@ ignore-i686-pc-windows-gnu #![crate_type = "rlib"] diff --git a/tests/codegen/regparm-inreg.rs b/tests/codegen/regparm-inreg.rs index 8dae3a83e4e..15702804dfd 100644 --- a/tests/codegen/regparm-inreg.rs +++ b/tests/codegen/regparm-inreg.rs @@ -3,7 +3,7 @@ // x86 only. //@ add-core-stubs -//@ compile-flags: --target i686-unknown-linux-gnu -Cno-prepopulate-passes -Copt-level=3 +//@ compile-flags: --target i686-unknown-linux-gnu -Cno-prepopulate-passes -Copt-level=3 -Ctarget-feature=+avx //@ needs-llvm-components: x86 //@ revisions:regparm0 regparm1 regparm2 regparm3 diff --git a/tests/codegen/repr/transparent.rs b/tests/codegen/repr/transparent.rs index e7e4c40a099..29b627462a4 100644 --- a/tests/codegen/repr/transparent.rs +++ b/tests/codegen/repr/transparent.rs @@ -9,7 +9,7 @@ // For LoongArch: see codegen/loongarch-abi #![crate_type = "lib"] -#![feature(repr_simd, transparent_unions)] +#![feature(repr_simd, transparent_unions, arm_target_feature, mips_target_feature)] use std::marker::PhantomData; @@ -139,6 +139,10 @@ pub struct Vector(f32x4); // CHECK: define{{.*}}<4 x float> @test_Vector(<4 x float> %_1) #[no_mangle] +#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))] +#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))] +#[cfg_attr(target_arch = "x86", target_feature(enable = "sse"))] +#[cfg_attr(target_arch = "mips", target_feature(enable = "msa"))] pub extern "C" fn test_Vector(_: Vector) -> Vector { loop {} } diff --git a/tests/codegen/simd/extract-insert-dyn.rs b/tests/codegen/simd/extract-insert-dyn.rs index 584e2c7887a..7d032c6bb3e 100644 --- a/tests/codegen/simd/extract-insert-dyn.rs +++ b/tests/codegen/simd/extract-insert-dyn.rs @@ -1,6 +1,6 @@ //@compile-flags: -C opt-level=3 -C no-prepopulate-passes -#![feature(core_intrinsics, repr_simd)] +#![feature(core_intrinsics, repr_simd, arm_target_feature, mips_target_feature)] #![no_std] #![crate_type = "lib"] #![allow(non_camel_case_types)] @@ -21,6 +21,10 @@ pub struct i8x16([i8; 16]); // CHECK-LABEL: dyn_simd_extract // CHECK: extractelement <16 x i8> %x, i32 %idx #[no_mangle] +#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))] +#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))] +#[cfg_attr(target_arch = "x86", target_feature(enable = "sse"))] +#[cfg_attr(target_arch = "mips", target_feature(enable = "msa"))] unsafe extern "C" fn dyn_simd_extract(x: i8x16, idx: u32) -> i8 { simd_extract_dyn(x, idx) } @@ -28,6 +32,10 @@ unsafe extern "C" fn dyn_simd_extract(x: i8x16, idx: u32) -> i8 { // CHECK-LABEL: literal_dyn_simd_extract // CHECK: extractelement <16 x i8> %x, i32 7 #[no_mangle] +#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))] +#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))] +#[cfg_attr(target_arch = "x86", target_feature(enable = "sse"))] +#[cfg_attr(target_arch = "mips", target_feature(enable = "msa"))] unsafe extern "C" fn literal_dyn_simd_extract(x: i8x16) -> i8 { simd_extract_dyn(x, 7) } @@ -35,6 +43,10 @@ unsafe extern "C" fn literal_dyn_simd_extract(x: i8x16) -> i8 { // CHECK-LABEL: const_dyn_simd_extract // CHECK: extractelement <16 x i8> %x, i32 7 #[no_mangle] +#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))] +#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))] +#[cfg_attr(target_arch = "x86", target_feature(enable = "sse"))] +#[cfg_attr(target_arch = "mips", target_feature(enable = "msa"))] unsafe extern "C" fn const_dyn_simd_extract(x: i8x16) -> i8 { simd_extract_dyn(x, const { 3 + 4 }) } @@ -42,6 +54,10 @@ unsafe extern "C" fn const_dyn_simd_extract(x: i8x16) -> i8 { // CHECK-LABEL: const_simd_extract // CHECK: extractelement <16 x i8> %x, i32 7 #[no_mangle] +#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))] +#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))] +#[cfg_attr(target_arch = "x86", target_feature(enable = "sse"))] +#[cfg_attr(target_arch = "mips", target_feature(enable = "msa"))] unsafe extern "C" fn const_simd_extract(x: i8x16) -> i8 { simd_extract(x, const { 3 + 4 }) } @@ -49,6 +65,10 @@ unsafe extern "C" fn const_simd_extract(x: i8x16) -> i8 { // CHECK-LABEL: dyn_simd_insert // CHECK: insertelement <16 x i8> %x, i8 %e, i32 %idx #[no_mangle] +#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))] +#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))] +#[cfg_attr(target_arch = "x86", target_feature(enable = "sse"))] +#[cfg_attr(target_arch = "mips", target_feature(enable = "msa"))] unsafe extern "C" fn dyn_simd_insert(x: i8x16, e: i8, idx: u32) -> i8x16 { simd_insert_dyn(x, idx, e) } @@ -56,6 +76,10 @@ unsafe extern "C" fn dyn_simd_insert(x: i8x16, e: i8, idx: u32) -> i8x16 { // CHECK-LABEL: literal_dyn_simd_insert // CHECK: insertelement <16 x i8> %x, i8 %e, i32 7 #[no_mangle] +#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))] +#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))] +#[cfg_attr(target_arch = "x86", target_feature(enable = "sse"))] +#[cfg_attr(target_arch = "mips", target_feature(enable = "msa"))] unsafe extern "C" fn literal_dyn_simd_insert(x: i8x16, e: i8) -> i8x16 { simd_insert_dyn(x, 7, e) } @@ -63,6 +87,10 @@ unsafe extern "C" fn literal_dyn_simd_insert(x: i8x16, e: i8) -> i8x16 { // CHECK-LABEL: const_dyn_simd_insert // CHECK: insertelement <16 x i8> %x, i8 %e, i32 7 #[no_mangle] +#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))] +#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))] +#[cfg_attr(target_arch = "x86", target_feature(enable = "sse"))] +#[cfg_attr(target_arch = "mips", target_feature(enable = "msa"))] unsafe extern "C" fn const_dyn_simd_insert(x: i8x16, e: i8) -> i8x16 { simd_insert_dyn(x, const { 3 + 4 }, e) } @@ -70,6 +98,10 @@ unsafe extern "C" fn const_dyn_simd_insert(x: i8x16, e: i8) -> i8x16 { // CHECK-LABEL: const_simd_insert // CHECK: insertelement <16 x i8> %x, i8 %e, i32 7 #[no_mangle] +#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))] +#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))] +#[cfg_attr(target_arch = "x86", target_feature(enable = "sse"))] +#[cfg_attr(target_arch = "mips", target_feature(enable = "msa"))] unsafe extern "C" fn const_simd_insert(x: i8x16, e: i8) -> i8x16 { simd_insert(x, const { 3 + 4 }, e) } diff --git a/tests/codegen/slice-as_chunks.rs b/tests/codegen/slice-as_chunks.rs index a90ee7c628e..337eb8981f6 100644 --- a/tests/codegen/slice-as_chunks.rs +++ b/tests/codegen/slice-as_chunks.rs @@ -2,7 +2,6 @@ //@ only-64bit (because the LLVM type of i64 for usize shows up) #![crate_type = "lib"] -#![feature(slice_as_chunks)] // CHECK-LABEL: @chunks4 #[no_mangle] diff --git a/tests/crashes/128695.rs b/tests/crashes/128695.rs deleted file mode 100644 index 661f427dc0e..00000000000 --- a/tests/crashes/128695.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ known-bug: rust-lang/rust#128695 -//@ edition: 2021 - -use core::pin::{pin, Pin}; - -fn main() { - let fut = pin!(async { - let async_drop_fut = pin!(core::future::async_drop(async {})); - (async_drop_fut).await; - }); -} diff --git a/tests/crashes/138156.rs b/tests/crashes/138156.rs new file mode 100644 index 00000000000..48c6455627f --- /dev/null +++ b/tests/crashes/138156.rs @@ -0,0 +1,42 @@ +//@ known-bug: #138156 + +#![feature(generic_const_exprs)] + +#[derive(Default)] +pub struct GenId<const IDX: usize>; + +pub trait IndexTrait: Default { + const IDX: usize; +} +pub trait ToplogyIndex { + type Idx: IndexTrait; +} + +#[derive(Default)] +pub struct Expression<T: ToplogyIndex> { + pub data: T, +} + +fn i<T: ToplogyIndex, const IDX0: usize, const IDX1: usize>(s: Expression<T>) -> + Expression<GenId<{ IDX0 | IDX1 }>> +where + GenId<{ IDX0 | IDX1 }>: ToplogyIndex, +{ + Expression::default() +} + +pub fn sum<In: ToplogyIndex>(s: Expression<In>) -> Expression<In> +where + [(); In::Idx::IDX]:, +{ + s +} + +fn param_position<In: ToplogyIndex>(s: Expression<In>) +where + GenId<{ 1 | 2 }>: ToplogyIndex, +{ + sum(i::<_, 1, 2>(s)); +} + +fn main() {} diff --git a/tests/crashes/138240.rs b/tests/crashes/138240.rs new file mode 100644 index 00000000000..6ffb7868bd5 --- /dev/null +++ b/tests/crashes/138240.rs @@ -0,0 +1,9 @@ +//@ known-bug: #138240 +//@edition:2024 +#![feature(min_generic_const_args)] +#![feature(inherent_associated_types)] +async fn _CF() -> Box<[u8; Box::b]> { + Box::new(true) +} + +fn main() {} diff --git a/tests/crashes/138265.rs b/tests/crashes/138265.rs new file mode 100644 index 00000000000..f6c8ea74889 --- /dev/null +++ b/tests/crashes/138265.rs @@ -0,0 +1,12 @@ +//@ known-bug: #138265 + +#![feature(coerce_unsized)] +#![crate_type = "lib"] +impl<A> std::ops::CoerceUnsized<A> for A {} +pub fn f() { + [0; { + let mut c = &0; + c = &0; + 0 + }] +} diff --git a/tests/crashes/138266.rs b/tests/crashes/138266.rs new file mode 100644 index 00000000000..9a4de9abcff --- /dev/null +++ b/tests/crashes/138266.rs @@ -0,0 +1,7 @@ +//@ known-bug: #138266 +//@compile-flags: --crate-type=lib +#![feature(min_generic_const_args)] +#![feature(inherent_associated_types)] +pub fn f(mut x: [u8; Box::b]) { + x[72] = 1; +} diff --git a/tests/crashes/138359.rs b/tests/crashes/138359.rs new file mode 100644 index 00000000000..d4376d536ee --- /dev/null +++ b/tests/crashes/138359.rs @@ -0,0 +1,8 @@ +//@ known-bug: #138359 +#![feature(min_generic_const_args)] +#![feature(inherent_associated_types)] +struct a(Box<[u8; Box::b]>); +impl a { + fn c(self) { self.0.da } +} +fn main() {} diff --git a/tests/crashes/138361.rs b/tests/crashes/138361.rs new file mode 100644 index 00000000000..8661ed37474 --- /dev/null +++ b/tests/crashes/138361.rs @@ -0,0 +1,6 @@ +//@ known-bug: #138361 + +fn main() { + [0; loop{}]; + std::mem::transmute(4) +} diff --git a/tests/crashes/138510.rs b/tests/crashes/138510.rs new file mode 100644 index 00000000000..f429e8bb33b --- /dev/null +++ b/tests/crashes/138510.rs @@ -0,0 +1,7 @@ +//@ known-bug: #138510 +fn main() +where + #[repr()] + _: Sized, +{ +} diff --git a/tests/crashes/138534.rs b/tests/crashes/138534.rs new file mode 100644 index 00000000000..80f9cd22518 --- /dev/null +++ b/tests/crashes/138534.rs @@ -0,0 +1,6 @@ +//@ known-bug: #138534 +//@compile-flags: -Zunpretty=expanded +#[repr(bool)] +pub enum TopFg { + Bar, +} diff --git a/tests/crashes/138564.rs b/tests/crashes/138564.rs new file mode 100644 index 00000000000..b10f75f8cdd --- /dev/null +++ b/tests/crashes/138564.rs @@ -0,0 +1,26 @@ +//@ known-bug: #138564 +//@compile-flags: -Copt-level=0 -Cdebuginfo=2 --crate-type lib +#![feature(unsize, dispatch_from_dyn, arbitrary_self_types)] + +use std::marker::Unsize; +use std::ops::{Deref, DispatchFromDyn}; + +#[repr(align(16))] +pub struct MyPointer<T: ?Sized>(*const T); + +impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<MyPointer<U>> for MyPointer<T> {} +impl<T: ?Sized> Deref for MyPointer<T> { + type Target = T; + fn deref(&self) -> &T { + unimplemented!() + } +} + +pub trait Trait { + fn foo(self: MyPointer<Self>) {} +} + +// make sure some usage of `<dyn Trait>::foo` makes it to codegen +pub fn user() -> *const () { + <dyn Trait>::foo as *const () +} diff --git a/tests/crashes/138707.rs b/tests/crashes/138707.rs new file mode 100644 index 00000000000..4d9a82500ec --- /dev/null +++ b/tests/crashes/138707.rs @@ -0,0 +1,37 @@ +//@ known-bug: #138707 +//@edition:2024 +//@compile-flags: --crate-type lib +use core::marker::PhantomData; + +struct LeftReflector<S> { + _phantom: PhantomData<S>, +} + +struct DefaultAllocator {} + +trait Allocator<R> { + type Buffer; +} + +struct U2 {} + +impl Allocator<U2> for DefaultAllocator { + type Buffer = [u8; 2]; +} + +impl<R> From<R> for LeftReflector<<DefaultAllocator as Allocator<R>>::Buffer> +where + DefaultAllocator: Allocator<R>, +{ + fn from(_: R) -> Self { + todo!() + } +} + +fn ice<D>(a: U2) +where + DefaultAllocator: Allocator<D>, +{ + // ICE + let _ = LeftReflector::from(a); +} diff --git a/tests/crashes/138738.rs b/tests/crashes/138738.rs new file mode 100644 index 00000000000..74e5effa56f --- /dev/null +++ b/tests/crashes/138738.rs @@ -0,0 +1,7 @@ +//@ known-bug: #138738 +//@ only-x86_64 + +#![feature(abi_ptx)] +fn main() { + let a = unsafe { core::mem::transmute::<usize, extern "ptx-kernel" fn(i32)>(4) }(2); +} diff --git a/tests/crashes/139089.rs b/tests/crashes/139089.rs new file mode 100644 index 00000000000..3326aa6ad98 --- /dev/null +++ b/tests/crashes/139089.rs @@ -0,0 +1,2 @@ +//@ known-bug: #139089 +pub fn foo3(x: &Vec<u8>) { x.push(0); } diff --git a/tests/crashes/139120.rs b/tests/crashes/139120.rs new file mode 100644 index 00000000000..f946f010c44 --- /dev/null +++ b/tests/crashes/139120.rs @@ -0,0 +1,29 @@ +//@ known-bug: #139120 + + + +pub trait Foo { + type Bar<'a>; +} + +pub struct FooImpl {} + +impl Foo for FooImpl { + type Bar<'a> = (); +} + +pub trait FooFn { + fn bar(&self); +} + +impl<T: Foo> FooFn for fn(T, T::Bar<'_>) { + fn bar(&self) {} +} + +fn foo<T: Foo>(f: fn(T, T::Bar<'_>)) { + let _: &dyn FooFn = &f; +} + +fn main() { + foo(|_: FooImpl, _| {}); +} diff --git a/tests/crashes/139381.rs b/tests/crashes/139381.rs new file mode 100644 index 00000000000..6757b584e82 --- /dev/null +++ b/tests/crashes/139381.rs @@ -0,0 +1,13 @@ +//@ known-bug: #139381 +//@ needs-rustc-debug-assertions +trait A<'a> { + type Assoc: ?Sized; +} + +impl<'a> A<'a> for () { + type Assoc = &'a (); +} + +fn hello() -> impl for<'a> A<'a, Assoc: Into<u8> + 'static + Copy> { + () +} diff --git a/tests/crashes/139387.rs b/tests/crashes/139387.rs new file mode 100644 index 00000000000..133643ad084 --- /dev/null +++ b/tests/crashes/139387.rs @@ -0,0 +1,15 @@ +//@ known-bug: #139387 +//@ needs-rustc-debug-assertions + +trait A { + fn method() -> impl Sized; +} +trait B { + fn method(Hash: Wrap<impl Beta<U: Copy + for<'a> Epsilon<'_, SI1: Eta>>>) -> impl Sized; +} + +fn ambiguous<T: A + B>() +where + T::method(..): Send, +{ +} diff --git a/tests/crashes/139409.rs b/tests/crashes/139409.rs new file mode 100644 index 00000000000..68cbfa153de --- /dev/null +++ b/tests/crashes/139409.rs @@ -0,0 +1,12 @@ +//@ known-bug: #139409 +//@ compile-flags: -Znext-solver=globally + +fn main() { + trait B<C> {} + impl<C> B<C> for () {} + trait D<C, E>: B<C> + B<E> { + fn f(&self) {} + } + impl<C, E> D<C, E> for () {} + (&() as &dyn D<&(), &()>).f() +} diff --git a/tests/crashes/139462.rs b/tests/crashes/139462.rs new file mode 100644 index 00000000000..05bb246d7be --- /dev/null +++ b/tests/crashes/139462.rs @@ -0,0 +1,8 @@ +//@ known-bug: #139462 +//@ compile-flags: -Cdebuginfo=2 +#![feature(unsafe_binders)] +use std::unsafe_binder::wrap_binder; +fn main() { + let foo = 0; + let foo: unsafe<'a> &'a u32 = unsafe { wrap_binder!(&foo) }; +} diff --git a/tests/crashes/139556.rs b/tests/crashes/139556.rs new file mode 100644 index 00000000000..60dc8d7c3af --- /dev/null +++ b/tests/crashes/139556.rs @@ -0,0 +1,13 @@ +//@ known-bug: #139556 + +trait T {} + +type Alias<'a> = impl T; + +struct S; +impl<'a> T for &'a S {} + +#[define_opaque(Alias)] +fn with_positive(fun: impl Fn(Alias<'_>)) { + with_positive(|&n| ()); +} diff --git a/tests/crashes/139570.rs b/tests/crashes/139570.rs new file mode 100644 index 00000000000..9c001aaf848 --- /dev/null +++ b/tests/crashes/139570.rs @@ -0,0 +1,4 @@ +//@ known-bug: #139570 +fn main() { + |(1, 42), ()| yield; +} diff --git a/tests/crashes/139596.rs b/tests/crashes/139596.rs new file mode 100644 index 00000000000..590cfddf83e --- /dev/null +++ b/tests/crashes/139596.rs @@ -0,0 +1,10 @@ +//@ known-bug: #139596 + +#![feature(min_generic_const_args)] +struct Colour; + +struct Led<const C: Colour>; + +fn main() { + Led::<{ Colour}>; +} diff --git a/tests/crashes/139659.rs b/tests/crashes/139659.rs new file mode 100644 index 00000000000..7fc33f7e6a7 --- /dev/null +++ b/tests/crashes/139659.rs @@ -0,0 +1,29 @@ +//@ known-bug: #139659 +//@compile-flags: -Cdebuginfo=2 -Copt-level=0 --crate-type lib +trait Trait { + type Output; +} + +impl<O, F: Fn() -> O> Trait for F { + type Output = O; +} + +struct Wrap<P>(P); +struct WrapOutput<O>(O); + +impl<P: Trait> Trait for Wrap<P> { + type Output = WrapOutput<P::Output>; +} + +fn wrap<P: Trait>(x: P) -> impl Trait { + Wrap(x) +} + +fn consume<P: Trait>(_: P) -> P::Output { + unimplemented!() +} + +pub fn recurse() -> impl Sized { + consume(wrap(recurse)) +} +pub fn main() {} diff --git a/tests/crashes/139738.rs b/tests/crashes/139738.rs new file mode 100644 index 00000000000..c0e7307de6c --- /dev/null +++ b/tests/crashes/139738.rs @@ -0,0 +1,3 @@ +//@ known-bug: #139738 +#![feature(generic_const_exprs)] +fn b<'a>() -> impl IntoIterator<[(); (|_: &'a u8| 0, 0).1]> {} diff --git a/tests/crashes/139815.rs b/tests/crashes/139815.rs new file mode 100644 index 00000000000..9094acdc94b --- /dev/null +++ b/tests/crashes/139815.rs @@ -0,0 +1,14 @@ +//@ known-bug: #139815 + +#![feature(generic_const_exprs)] +fn is_123<const N: usize>( + x: [u32; { + N + 1; + 5 + }], +) -> bool { + match x { + [1, 2] => true, + _ => false, + } +} diff --git a/tests/crashes/139817.rs b/tests/crashes/139817.rs new file mode 100644 index 00000000000..d439ed4cacb --- /dev/null +++ b/tests/crashes/139817.rs @@ -0,0 +1,8 @@ +//@ known-bug: #139817 +fn enum_upvar() { + type T = impl Copy; + let foo: T = Some((42, std::marker::PhantomData::<T>)); + let x = move || match foo { + None => (), + }; +} diff --git a/tests/crashes/139825.rs b/tests/crashes/139825.rs new file mode 100644 index 00000000000..8c5b6b80f0b --- /dev/null +++ b/tests/crashes/139825.rs @@ -0,0 +1,5 @@ +//@ known-bug: #139825 +//@compile-flags: --check-cfg=cfg(docsrs,test) --crate-type lib +struct a +where + for<#[cfg(b)] c> u8:; diff --git a/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{closure#0}.built.after.mir b/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{closure#0}.built.after.mir index 0c8a17ff70b..b43af549b23 100644 --- a/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{closure#0}.built.after.mir +++ b/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{closure#0}.built.after.mir @@ -68,14 +68,18 @@ yields () } bb10: { - drop(_1) -> [return: bb11, unwind: bb12]; + drop(_1) -> [return: bb11, unwind: bb13, drop: bb12]; } bb11: { return; } - bb12 (cleanup): { + bb12: { + coroutine_drop; + } + + bb13 (cleanup): { resume; } } diff --git a/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{synthetic#0}.built.after.mir b/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{synthetic#0}.built.after.mir index 9070c95bca4..5623b6d64e9 100644 --- a/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{synthetic#0}.built.after.mir +++ b/tests/mir-opt/async_closure_fake_read_for_by_move.foo-{closure#0}-{synthetic#0}.built.after.mir @@ -51,14 +51,18 @@ yields () } bb6: { - drop(_1) -> [return: bb7, unwind: bb8]; + drop(_1) -> [return: bb7, unwind: bb9, drop: bb8]; } bb7: { return; } - bb8 (cleanup): { + bb8: { + coroutine_drop; + } + + bb9 (cleanup): { resume; } } diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}-{closure#0}.built.after.mir b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}-{closure#0}.built.after.mir index 8a584853e00..4d484b16b50 100644 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}-{closure#0}.built.after.mir +++ b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}-{closure#0}.built.after.mir @@ -34,14 +34,18 @@ yields () StorageDead(_5); StorageDead(_4); StorageDead(_3); - drop(_1) -> [return: bb1, unwind: bb2]; + drop(_1) -> [return: bb1, unwind: bb3, drop: bb2]; } bb1: { return; } - bb2 (cleanup): { + bb2: { + coroutine_drop; + } + + bb3 (cleanup): { resume; } } diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}-{synthetic#0}.built.after.mir b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}-{synthetic#0}.built.after.mir index c5f538e5ecd..ace780f773e 100644 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}-{synthetic#0}.built.after.mir +++ b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}-{synthetic#0}.built.after.mir @@ -34,14 +34,18 @@ yields () StorageDead(_5); StorageDead(_4); StorageDead(_3); - drop(_1) -> [return: bb1, unwind: bb2]; + drop(_1) -> [return: bb1, unwind: bb3, drop: bb2]; } bb1: { return; } - bb2 (cleanup): { + bb2: { + coroutine_drop; + } + + bb3 (cleanup): { resume; } } diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}-{closure#0}.built.after.mir b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}-{closure#0}.built.after.mir index c6721085eb2..f50ad689f44 100644 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}-{closure#0}.built.after.mir +++ b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}-{closure#0}.built.after.mir @@ -34,14 +34,18 @@ yields () StorageDead(_5); StorageDead(_4); StorageDead(_3); - drop(_1) -> [return: bb1, unwind: bb2]; + drop(_1) -> [return: bb1, unwind: bb3, drop: bb2]; } bb1: { return; } - bb2 (cleanup): { + bb2: { + coroutine_drop; + } + + bb3 (cleanup): { resume; } } diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}-{synthetic#0}.built.after.mir b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}-{synthetic#0}.built.after.mir index e295f9b3cf1..62d8adeedcb 100644 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}-{synthetic#0}.built.after.mir +++ b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#1}-{synthetic#0}.built.after.mir @@ -34,14 +34,18 @@ yields () StorageDead(_5); StorageDead(_4); StorageDead(_3); - drop(_1) -> [return: bb1, unwind: bb2]; + drop(_1) -> [return: bb1, unwind: bb3, drop: bb2]; } bb1: { return; } - bb2 (cleanup): { + bb2: { + coroutine_drop; + } + + bb3 (cleanup): { resume; } } diff --git a/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff index a1df868cde0..33f1ad9bef4 100644 --- a/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff +++ b/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff @@ -121,7 +121,7 @@ StorageDead(_18); _16 = &_17; _15 = &(*_16); - _11 = Arguments::<'_>::new_v1::<3, 2>(move _12, move _15) -> [return: bb5, unwind unreachable]; + _11 = core::fmt::rt::<impl Arguments<'_>>::new_v1::<3, 2>(move _12, move _15) -> [return: bb5, unwind unreachable]; } bb5: { diff --git a/tests/pretty/hir-delegation.pp b/tests/pretty/hir-delegation.pp index 872a6a45aed..e452cee6365 100644 --- a/tests/pretty/hir-delegation.pp +++ b/tests/pretty/hir-delegation.pp @@ -2,7 +2,8 @@ //@ pretty-mode:hir //@ pp-exact:hir-delegation.pp -#![allow(incomplete_features)]#![feature(fn_delegation)] +#![allow(incomplete_features)] +#![feature(fn_delegation)] #[prelude_import] use ::std::prelude::rust_2015::*; #[macro_use] diff --git a/tests/pretty/hir-if-else.pp b/tests/pretty/hir-if-else.pp new file mode 100644 index 00000000000..200e34ac4f5 --- /dev/null +++ b/tests/pretty/hir-if-else.pp @@ -0,0 +1,39 @@ +#[prelude_import] +use ::std::prelude::rust_2015::*; +#[macro_use] +extern crate std; +//@ pretty-compare-only +//@ pretty-mode:hir +//@ pp-exact:hir-if-else.pp + +fn f(x: u32, + y: + u32) { + let mut a = 0; + if x > y { a = 1; } else { a = 2; } + + if x < 1 { + a = 1; + } else if x < 2 { + a = 2; + } else if x < 3 { a = 3; } else if x < 4 { a = 4; } else { a = 5; } + + if x < y { + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + } else { a += 1; a += 1; a += 1; a += 1; a += 1; a += 1; } + + if x < 1 { + if x < 2 { + if x < 3 { + a += 1; + } else if x < 4 { a += 1; if x < 5 { a += 1; } } + } else if x < 6 { a += 1; } + } +} + +fn main() { f(3, 4); } diff --git a/tests/pretty/hir-if-else.rs b/tests/pretty/hir-if-else.rs new file mode 100644 index 00000000000..a1cc7504f89 --- /dev/null +++ b/tests/pretty/hir-if-else.rs @@ -0,0 +1,59 @@ +//@ pretty-compare-only +//@ pretty-mode:hir +//@ pp-exact:hir-if-else.pp + +fn f(x: u32, y: u32) { + let mut a = 0; + if x > y { + a = 1; + } else { + a = 2; + } + + if x < 1 { + a = 1; + } else if x < 2 { + a = 2; + } else if x < 3 { + a = 3; + } else if x < 4 { + a = 4; + } else { + a = 5; + } + + if x < y { + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + } else { + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + } + + if x < 1 { + if x < 2 { + if x < 3 { + a += 1; + } else if x < 4 { + a += 1; + if x < 5 { + a += 1; + } + } + } else if x < 6 { + a += 1; + } + } +} + +fn main() { + f(3, 4); +} diff --git a/tests/pretty/if-else.pp b/tests/pretty/if-else.pp new file mode 100644 index 00000000000..d4ff02c5441 --- /dev/null +++ b/tests/pretty/if-else.pp @@ -0,0 +1,52 @@ +#![feature(prelude_import)] +#![no_std] +#[prelude_import] +use ::std::prelude::rust_2015::*; +#[macro_use] +extern crate std; +//@ pretty-compare-only +//@ pretty-mode:expanded +//@ pp-exact:if-else.pp + +fn f(x: u32, y: u32) { + let mut a = 0; + if x > y { a = 1; } else { a = 2; } + + if x < 1 { + a = 1; + } else if x < 2 { + a = 2; + } else if x < 3 { a = 3; } else if x < 4 { a = 4; } else { a = 5; } + + if x < y { + a += 1; + a += 1; + a += 1; + } else { + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + } + + if x < 1 { + if x < 2 { + if x < 3 { + a += 1; + } else if x < 4 { a += 1; if x < 5 { a += 1; } } + } else if x < 6 { a += 1; } + } +} + +fn main() { f(3, 4); } diff --git a/tests/pretty/if-else.rs b/tests/pretty/if-else.rs new file mode 100644 index 00000000000..b4085ea5606 --- /dev/null +++ b/tests/pretty/if-else.rs @@ -0,0 +1,65 @@ +//@ pretty-compare-only +//@ pretty-mode:expanded +//@ pp-exact:if-else.pp + +fn f(x: u32, y: u32) { + let mut a = 0; + if x > y { + a = 1; + } else { + a = 2; + } + + if x < 1 { + a = 1; + } else if x < 2 { + a = 2; + } else if x < 3 { + a = 3; + } else if x < 4 { + a = 4; + } else { + a = 5; + } + + if x < y { + a += 1; + a += 1; + a += 1; + } else { + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + a += 1; + } + + if x < 1 { + if x < 2 { + if x < 3 { + a += 1; + } else if x < 4 { + a += 1; + if x < 5 { + a += 1; + } + } + } else if x < 6 { + a += 1; + } + } +} + +fn main() { + f(3, 4); +} diff --git a/tests/pretty/issue-4264.pp b/tests/pretty/issue-4264.pp index fa958d9f1e8..eb808f7122a 100644 --- a/tests/pretty/issue-4264.pp +++ b/tests/pretty/issue-4264.pp @@ -31,14 +31,12 @@ fn bar() ({ ((::alloc::__export::must_use as fn(String) -> String {must_use::<String>})(({ - let res = - ((::alloc::fmt::format as - for<'a> fn(Arguments<'a>) -> String {format})(((format_arguments::new_const - as - fn(&[&'static str; 1]) -> Arguments<'_> {Arguments::<'_>::new_const::<1>})((&([("test" - as &str)] as [&str; 1]) as &[&str; 1])) as Arguments<'_>)) - as String); - (res as String) + ((::alloc::fmt::format as + for<'a> fn(Arguments<'a>) -> String {format})(((format_arguments::new_const + as + fn(&[&'static str; 1]) -> Arguments<'_> {core::fmt::rt::<impl Arguments<'_>>::new_const::<1>})((&([("test" + as &str)] as [&str; 1]) as &[&str; 1])) as Arguments<'_>)) + as String) } as String)) as String); } as ()) type Foo = [i32; (3 as usize)]; diff --git a/tests/pretty/never-pattern.pp b/tests/pretty/never-pattern.pp new file mode 100644 index 00000000000..923ad9b82c7 --- /dev/null +++ b/tests/pretty/never-pattern.pp @@ -0,0 +1,17 @@ +#![feature(prelude_import)] +#![no_std] +//@ pretty-mode:expanded +//@ pp-exact:never-pattern.pp +//@ only-x86_64 + +#![allow(incomplete_features)] +#![feature(never_patterns)] +#![feature(never_type)] +#[prelude_import] +use ::std::prelude::rust_2015::*; +#[macro_use] +extern crate std; + +fn f(x: Result<u32, !>) { _ = match x { Ok(x) => x, Err(!) , }; } + +fn main() {} diff --git a/tests/pretty/never-pattern.rs b/tests/pretty/never-pattern.rs new file mode 100644 index 00000000000..fe170bafc66 --- /dev/null +++ b/tests/pretty/never-pattern.rs @@ -0,0 +1,16 @@ +//@ pretty-mode:expanded +//@ pp-exact:never-pattern.pp +//@ only-x86_64 + +#![allow(incomplete_features)] +#![feature(never_patterns)] +#![feature(never_type)] + +fn f(x: Result<u32, !>) { + _ = match x { + Ok(x) => x, + Err(!), + }; +} + +fn main() {} diff --git a/tests/pretty/shebang-at-top.pp b/tests/pretty/shebang-at-top.pp new file mode 100644 index 00000000000..a2797252636 --- /dev/null +++ b/tests/pretty/shebang-at-top.pp @@ -0,0 +1,12 @@ +#!/usr/bin/env rust +#![feature(prelude_import)] +#![no_std] +#[prelude_import] +use ::std::prelude::rust_2015::*; +#[macro_use] +extern crate std; +//@ pretty-mode:expanded +//@ pp-exact:shebang-at-top.pp +//@ pretty-compare-only + +fn main() {} diff --git a/tests/pretty/shebang-at-top.rs b/tests/pretty/shebang-at-top.rs new file mode 100644 index 00000000000..8bfa925fa1a --- /dev/null +++ b/tests/pretty/shebang-at-top.rs @@ -0,0 +1,6 @@ +#!/usr/bin/env rust +//@ pretty-mode:expanded +//@ pp-exact:shebang-at-top.pp +//@ pretty-compare-only + +fn main() {} diff --git a/tests/run-make/amdgpu-kd/rmake.rs b/tests/run-make/amdgpu-kd/rmake.rs index a787fa1da93..cba9030641d 100644 --- a/tests/run-make/amdgpu-kd/rmake.rs +++ b/tests/run-make/amdgpu-kd/rmake.rs @@ -6,13 +6,19 @@ //@ needs-llvm-components: amdgpu //@ needs-rust-lld +use run_make_support::targets::is_windows_gnu; use run_make_support::{llvm_readobj, rustc}; fn main() { + // FIXME(#115985): rust-lld on gnu targets may spuriously fail with + // STATUS_HEAP_CORRUPTION (0xc0000374). + // To try to mitigate this we pass --threads=1 to the linker. + let extra_args: &[&str] = if is_windows_gnu() { &["-C", "link-arg=--threads=1"] } else { &[] }; rustc() .crate_name("foo") .target("amdgcn-amd-amdhsa") .arg("-Ctarget-cpu=gfx900") + .args(&extra_args) .crate_type("cdylib") .input("foo.rs") .run(); diff --git a/tests/run-make/c-link-to-rust-dylib/rmake.rs b/tests/run-make/c-link-to-rust-dylib/rmake.rs index ab9aa445402..3a48af8a366 100644 --- a/tests/run-make/c-link-to-rust-dylib/rmake.rs +++ b/tests/run-make/c-link-to-rust-dylib/rmake.rs @@ -23,7 +23,11 @@ fn main() { if path.is_file() && path.extension().is_some_and(|ext| ext == expected_extension) && path.file_name().and_then(|name| name.to_str()).is_some_and(|name| { - name.ends_with(".so") || name.ends_with(".dll") || name.ends_with(".dylib") + if cfg!(target_os = "aix") { + name.ends_with(".a") + } else { + name.ends_with(".so") || name.ends_with(".dll") || name.ends_with(".dylib") + } }) { rfs::remove_file(path); diff --git a/tests/run-make/doctests-runtool/rmake.rs b/tests/run-make/doctests-runtool/rmake.rs index c7be829c215..817001c514b 100644 --- a/tests/run-make/doctests-runtool/rmake.rs +++ b/tests/run-make/doctests-runtool/rmake.rs @@ -1,4 +1,4 @@ -// Tests behavior of rustdoc `--runtool`. +// Tests behavior of rustdoc `--test-runtool`. use std::path::PathBuf; @@ -11,7 +11,7 @@ fn mkdir(name: &str) -> PathBuf { dir } -// Behavior with --runtool with relative paths and --test-run-directory. +// Behavior with --test-runtool with relative paths and --test-run-directory. fn main() { let run_dir_name = "rundir"; let run_dir = mkdir(run_dir_name); @@ -27,7 +27,7 @@ fn main() { .arg("--test") .arg("--test-run-directory") .arg(run_dir_name) - .arg("--runtool") + .arg("--test-runtool") .arg(&run_tool_binary) .extern_("t", "libt.rlib") .run(); diff --git a/tests/run-make/rustc-help/help-v.diff b/tests/run-make/rustc-help/help-v.diff index 0ea79f3e557..60a9dfbe201 100644 --- a/tests/run-make/rustc-help/help-v.diff +++ b/tests/run-make/rustc-help/help-v.diff @@ -1,22 +1,23 @@ -@@ -63,10 +63,27 @@ +@@ -65,10 +65,28 @@ Set a codegen option -V, --version Print version info and exit -v, --verbose Use verbose output -+ --extern NAME[=PATH] ++ --extern <NAME>[=<PATH>] + Specify where an external rust library is located -+ --sysroot PATH Override the system root -+ --error-format human|json|short ++ --sysroot <PATH> ++ Override the system root ++ --error-format <human|json|short> + How errors and other messages are produced -+ --json CONFIG Configure the JSON output of the compiler -+ --color auto|always|never ++ --json <CONFIG> Configure the JSON output of the compiler ++ --color <auto|always|never> + Configure coloring of output: -+ auto = colorize, if output goes to a tty (default); -+ always = always colorize output; -+ never = never colorize output -+ --diagnostic-width WIDTH ++ * auto = colorize, if output goes to a tty (default); ++ * always = always colorize output; ++ * never = never colorize output ++ --diagnostic-width <WIDTH> + Inform rustc of the width of the output so that + diagnostics can be truncated to fit -+ --remap-path-prefix FROM=TO ++ --remap-path-prefix <FROM>=<TO> + Remap source names in all output (compiler messages + and output files) + @path Read newline separated options from `path` diff --git a/tests/run-make/rustc-help/help-v.stdout b/tests/run-make/rustc-help/help-v.stdout index 744453d6e85..3fc297fb08e 100644 --- a/tests/run-make/rustc-help/help-v.stdout +++ b/tests/run-make/rustc-help/help-v.stdout @@ -2,31 +2,32 @@ Usage: rustc [OPTIONS] INPUT Options: -h, --help Display this message - --cfg SPEC Configure the compilation environment. - SPEC supports the syntax `NAME[="VALUE"]`. - --check-cfg SPEC + --cfg <SPEC> Configure the compilation environment. + SPEC supports the syntax `<NAME>[="<VALUE>"]`. + --check-cfg <SPEC> Provide list of expected cfgs for checking - -L [KIND=]PATH Add a directory to the library search path. The - optional KIND can be one of dependency, crate, native, - framework, or all (the default). - -l [KIND[:MODIFIERS]=]NAME[:RENAME] + -L [<KIND>=]<PATH> Add a directory to the library search path. The + optional KIND can be one of + <dependency|crate|native|framework|all> (default: + all). + -l [<KIND>[:<MODIFIERS>]=]<NAME>[:<RENAME>] Link the generated crate(s) to the specified native library NAME. The optional KIND can be one of - static, framework, or dylib (the default). + <static|framework|dylib> (default: dylib). Optional comma separated MODIFIERS - (bundle|verbatim|whole-archive|as-needed) + <bundle|verbatim|whole-archive|as-needed> may be specified each with a prefix of either '+' to enable or '-' to disable. - --crate-type [bin|lib|rlib|dylib|cdylib|staticlib|proc-macro] + --crate-type <bin|lib|rlib|dylib|cdylib|staticlib|proc-macro> Comma separated list of types of crates for the compiler to emit - --crate-name NAME + --crate-name <NAME> Specify the name of the crate being built - --edition 2015|2018|2021|2024 + --edition <2015|2018|2021|2024|future> Specify which edition of the compiler to use when compiling code. The default is 2015 and the latest stable edition is 2024. - --emit TYPE[=FILE] + --emit <TYPE>[=<FILE>] Comma separated list of types of output for the compiler to emit. Each TYPE has the default FILE name: @@ -39,45 +40,47 @@ Options: * mir - CRATE_NAME.mir * obj - CRATE_NAME.o * thin-link-bitcode - CRATE_NAME.indexing.o - --print INFO[=FILE] + --print <INFO>[=<FILE>] Compiler information to print on stdout (or to a file) INFO may be one of - (all-target-specs-json|calling-conventions|cfg|check-cfg|code-models|crate-name|crate-root-lint-levels|deployment-target|file-names|host-tuple|link-args|native-static-libs|relocation-models|split-debuginfo|stack-protector-strategies|supported-crate-types|sysroot|target-cpus|target-features|target-libdir|target-list|target-spec-json|tls-models). + <all-target-specs-json|calling-conventions|cfg|check-cfg|code-models|crate-name|crate-root-lint-levels|deployment-target|file-names|host-tuple|link-args|native-static-libs|relocation-models|split-debuginfo|stack-protector-strategies|supported-crate-types|sysroot|target-cpus|target-features|target-libdir|target-list|target-spec-json|tls-models>. -g Equivalent to -C debuginfo=2 -O Equivalent to -C opt-level=3 - -o FILENAME Write output to <filename> - --out-dir DIR Write output to compiler-chosen filename in <dir> - --explain OPT Provide a detailed explanation of an error message + -o <FILENAME> Write output to FILENAME + --out-dir <DIR> Write output to compiler-chosen filename in DIR + --explain <OPT> Provide a detailed explanation of an error message --test Build a test harness - --target TARGET Target triple for which the code is compiled - -A, --allow LINT Set lint allowed - -W, --warn LINT Set lint warnings - --force-warn LINT + --target <TARGET> + Target triple for which the code is compiled + -A, --allow <LINT> Set lint allowed + -W, --warn <LINT> Set lint warnings + --force-warn <LINT> Set lint force-warn - -D, --deny LINT Set lint denied - -F, --forbid LINT Set lint forbidden - --cap-lints LEVEL + -D, --deny <LINT> Set lint denied + -F, --forbid <LINT> Set lint forbidden + --cap-lints <LEVEL> Set the most restrictive lint level. More restrictive lints are capped at this level - -C, --codegen OPT[=VALUE] + -C, --codegen <OPT>[=<VALUE>] Set a codegen option -V, --version Print version info and exit -v, --verbose Use verbose output - --extern NAME[=PATH] + --extern <NAME>[=<PATH>] Specify where an external rust library is located - --sysroot PATH Override the system root - --error-format human|json|short + --sysroot <PATH> + Override the system root + --error-format <human|json|short> How errors and other messages are produced - --json CONFIG Configure the JSON output of the compiler - --color auto|always|never + --json <CONFIG> Configure the JSON output of the compiler + --color <auto|always|never> Configure coloring of output: - auto = colorize, if output goes to a tty (default); - always = always colorize output; - never = never colorize output - --diagnostic-width WIDTH + * auto = colorize, if output goes to a tty (default); + * always = always colorize output; + * never = never colorize output + --diagnostic-width <WIDTH> Inform rustc of the width of the output so that diagnostics can be truncated to fit - --remap-path-prefix FROM=TO + --remap-path-prefix <FROM>=<TO> Remap source names in all output (compiler messages and output files) @path Read newline separated options from `path` diff --git a/tests/run-make/rustc-help/help.stdout b/tests/run-make/rustc-help/help.stdout index 3043755207a..caffe28f498 100644 --- a/tests/run-make/rustc-help/help.stdout +++ b/tests/run-make/rustc-help/help.stdout @@ -2,31 +2,32 @@ Usage: rustc [OPTIONS] INPUT Options: -h, --help Display this message - --cfg SPEC Configure the compilation environment. - SPEC supports the syntax `NAME[="VALUE"]`. - --check-cfg SPEC + --cfg <SPEC> Configure the compilation environment. + SPEC supports the syntax `<NAME>[="<VALUE>"]`. + --check-cfg <SPEC> Provide list of expected cfgs for checking - -L [KIND=]PATH Add a directory to the library search path. The - optional KIND can be one of dependency, crate, native, - framework, or all (the default). - -l [KIND[:MODIFIERS]=]NAME[:RENAME] + -L [<KIND>=]<PATH> Add a directory to the library search path. The + optional KIND can be one of + <dependency|crate|native|framework|all> (default: + all). + -l [<KIND>[:<MODIFIERS>]=]<NAME>[:<RENAME>] Link the generated crate(s) to the specified native library NAME. The optional KIND can be one of - static, framework, or dylib (the default). + <static|framework|dylib> (default: dylib). Optional comma separated MODIFIERS - (bundle|verbatim|whole-archive|as-needed) + <bundle|verbatim|whole-archive|as-needed> may be specified each with a prefix of either '+' to enable or '-' to disable. - --crate-type [bin|lib|rlib|dylib|cdylib|staticlib|proc-macro] + --crate-type <bin|lib|rlib|dylib|cdylib|staticlib|proc-macro> Comma separated list of types of crates for the compiler to emit - --crate-name NAME + --crate-name <NAME> Specify the name of the crate being built - --edition 2015|2018|2021|2024 + --edition <2015|2018|2021|2024|future> Specify which edition of the compiler to use when compiling code. The default is 2015 and the latest stable edition is 2024. - --emit TYPE[=FILE] + --emit <TYPE>[=<FILE>] Comma separated list of types of output for the compiler to emit. Each TYPE has the default FILE name: @@ -39,27 +40,28 @@ Options: * mir - CRATE_NAME.mir * obj - CRATE_NAME.o * thin-link-bitcode - CRATE_NAME.indexing.o - --print INFO[=FILE] + --print <INFO>[=<FILE>] Compiler information to print on stdout (or to a file) INFO may be one of - (all-target-specs-json|calling-conventions|cfg|check-cfg|code-models|crate-name|crate-root-lint-levels|deployment-target|file-names|host-tuple|link-args|native-static-libs|relocation-models|split-debuginfo|stack-protector-strategies|supported-crate-types|sysroot|target-cpus|target-features|target-libdir|target-list|target-spec-json|tls-models). + <all-target-specs-json|calling-conventions|cfg|check-cfg|code-models|crate-name|crate-root-lint-levels|deployment-target|file-names|host-tuple|link-args|native-static-libs|relocation-models|split-debuginfo|stack-protector-strategies|supported-crate-types|sysroot|target-cpus|target-features|target-libdir|target-list|target-spec-json|tls-models>. -g Equivalent to -C debuginfo=2 -O Equivalent to -C opt-level=3 - -o FILENAME Write output to <filename> - --out-dir DIR Write output to compiler-chosen filename in <dir> - --explain OPT Provide a detailed explanation of an error message + -o <FILENAME> Write output to FILENAME + --out-dir <DIR> Write output to compiler-chosen filename in DIR + --explain <OPT> Provide a detailed explanation of an error message --test Build a test harness - --target TARGET Target triple for which the code is compiled - -A, --allow LINT Set lint allowed - -W, --warn LINT Set lint warnings - --force-warn LINT + --target <TARGET> + Target triple for which the code is compiled + -A, --allow <LINT> Set lint allowed + -W, --warn <LINT> Set lint warnings + --force-warn <LINT> Set lint force-warn - -D, --deny LINT Set lint denied - -F, --forbid LINT Set lint forbidden - --cap-lints LEVEL + -D, --deny <LINT> Set lint denied + -F, --forbid <LINT> Set lint forbidden + --cap-lints <LEVEL> Set the most restrictive lint level. More restrictive lints are capped at this level - -C, --codegen OPT[=VALUE] + -C, --codegen <OPT>[=<VALUE>] Set a codegen option -V, --version Print version info and exit -v, --verbose Use verbose output diff --git a/tests/run-make/rustdoc-default-output/output-default.stdout b/tests/run-make/rustdoc-default-output/output-default.stdout index 01f470f6e16..78ca8c863eb 100644 --- a/tests/run-make/rustdoc-default-output/output-default.stdout +++ b/tests/run-make/rustdoc-default-output/output-default.stdout @@ -11,7 +11,7 @@ Options: -o, --out-dir PATH which directory to place the output --crate-name NAME specify the name of this crate - --crate-type [bin|lib|rlib|dylib|cdylib|staticlib|proc-macro] + --crate-type <bin|lib|rlib|dylib|cdylib|staticlib|proc-macro> Comma separated list of types of crates for the compiler to emit -L, --library-path DIR @@ -138,12 +138,9 @@ Options: --show-coverage calculate percentage of public items with documentation - --enable-per-target-ignores - parse ignore-foo for ignoring doctests on a per-target - basis - --runtool The tool to run tests with when building for a different target than host + --test-runtool The tool to run tests with when building for a different target than host - --runtool-arg One (of possibly many) arguments to pass to the runtool + --test-runtool-arg One argument (of possibly many) to pass to the runtool --test-builder PATH The rustc-like binary to use as the test builder diff --git a/tests/run-make/simd-ffi/rmake.rs b/tests/run-make/simd-ffi/rmake.rs index ef71dfa4c30..c6315073fa8 100644 --- a/tests/run-make/simd-ffi/rmake.rs +++ b/tests/run-make/simd-ffi/rmake.rs @@ -52,11 +52,20 @@ fn main() { // enabled by-default for i686 and ARM; these features will be invalid // on some platforms, but LLVM just prints a warning so that's fine for // now. + let target_feature = if target.starts_with("i686") || target.starts_with("x86") { + "+sse2" + } else if target.starts_with("arm") || target.starts_with("aarch64") { + "-soft-float,+neon" + } else if target.starts_with("mips") { + "+msa,+fp64" + } else { + panic!("missing target_feature case for {target}"); + }; rustc() .target(&target) .emit("llvm-ir,asm") .input("simd.rs") - .arg("-Ctarget-feature=-soft-float,+neon,+sse") + .arg(format!("-Ctarget-feature={target_feature}")) .arg(&format!("-Cextra-filename=-{target}")) .run(); } diff --git a/tests/rustdoc-gui/docblock-table-overflow.goml b/tests/rustdoc-gui/docblock-table-overflow.goml index 18e5b4d7f35..e603c3a4d22 100644 --- a/tests/rustdoc-gui/docblock-table-overflow.goml +++ b/tests/rustdoc-gui/docblock-table-overflow.goml @@ -11,7 +11,7 @@ assert-property: (".top-doc .docblock table", {"scrollWidth": "1572"}) // Checking it works on other doc blocks as well... // Logically, the ".docblock" and the "<p>" should have the same scroll width (if we exclude the margin). -assert-property: ("#implementations-list > details .docblock", {"scrollWidth": 816}) +assert-property: ("#implementations-list > details .docblock", {"scrollWidth": 835}) assert-property: ("#implementations-list > details .docblock > p", {"scrollWidth": 835}) // However, since there is overflow in the <table>, its scroll width is bigger. assert-property: ("#implementations-list > details .docblock table", {"scrollWidth": "1572"}) diff --git a/tests/rustdoc-gui/impl-doc-indent.goml b/tests/rustdoc-gui/impl-doc-indent.goml new file mode 100644 index 00000000000..d647fec6d73 --- /dev/null +++ b/tests/rustdoc-gui/impl-doc-indent.goml @@ -0,0 +1,16 @@ +// Checks the impl block docs have the correct indent. +go-to: "file://" + |DOC_PATH| + "/test_docs/impls_indent/struct.Context.html" + +// First we ensure that the impl items are indent (more on the right of the screen) than the +// impl itself. +store-position: ("#impl-Context", {"x": impl_x}) +store-position: ("#impl-Context > .item-info", {"x": impl_item_x}) +assert: |impl_x| < |impl_item_x| + +// And we ensure that all impl items have the same indent. +assert-position: ("#impl-Context > .docblock", {"x": |impl_item_x|}) +assert-position: ("#impl-Context + .docblock", {"x": |impl_item_x|}) + +// Same with the collapsible impl block. +assert-position: ("#impl-Context-1 > .docblock", {"x": |impl_item_x|}) +assert-position: (".implementors-toggle > summary + .docblock", {"x": |impl_item_x|}) diff --git a/tests/rustdoc-gui/item-info-overflow.goml b/tests/rustdoc-gui/item-info-overflow.goml index c325beb6d06..2c4e06e297c 100644 --- a/tests/rustdoc-gui/item-info-overflow.goml +++ b/tests/rustdoc-gui/item-info-overflow.goml @@ -21,7 +21,7 @@ compare-elements-property: ( ) assert-property: ( "#impl-SimpleTrait-for-LongItemInfo2 .item-info", - {"scrollWidth": "916"}, + {"scrollWidth": "935"}, ) // Just to be sure we're comparing the correct "item-info": assert-text: ( diff --git a/tests/rustdoc-gui/src/test_docs/lib.rs b/tests/rustdoc-gui/src/test_docs/lib.rs index 31f6b7f09b7..bb0015b8f9c 100644 --- a/tests/rustdoc-gui/src/test_docs/lib.rs +++ b/tests/rustdoc-gui/src/test_docs/lib.rs @@ -740,3 +740,29 @@ pub mod SidebarSort { impl Sort for Cell<u8> {} impl<'a> Sort for &'a str {} } + +pub mod impls_indent { + pub struct Context; + + /// Working with objects. + /// + /// # Safety + /// + /// Functions that take indices of locals do not check bounds on these indices; + /// the caller must ensure that the indices are less than the number of locals + /// in the current stack frame. + impl Context { + } + + /// Working with objects. + /// + /// # Safety + /// + /// Functions that take indices of locals do not check bounds on these indices; + /// the caller must ensure that the indices are less than the number of locals + /// in the current stack frame. + impl Context { + /// bla + pub fn bar() {} + } +} diff --git a/tests/rustdoc-json/attrs/automatically_derived.rs b/tests/rustdoc-json/attrs/automatically_derived.rs index 4e1ab3d145e..6c90d638649 100644 --- a/tests/rustdoc-json/attrs/automatically_derived.rs +++ b/tests/rustdoc-json/attrs/automatically_derived.rs @@ -9,5 +9,5 @@ impl Default for Manual { } } -//@ is '$.index[?(@.inner.impl.for.resolved_path.path == "Derive" && @.inner.impl.trait.path == "Default")].attrs' '["#[automatically_derived]"]' +//@ is '$.index[?(@.inner.impl.for.resolved_path.path == "Derive" && @.inner.impl.trait.path == "Default")].attrs' '["#[automatically_derived]\n"]' //@ is '$.index[?(@.inner.impl.for.resolved_path.path == "Manual" && @.inner.impl.trait.path == "Default")].attrs' '[]' diff --git a/tests/rustdoc-json/attrs/export_name_2021.rs b/tests/rustdoc-json/attrs/export_name_2021.rs index 254e9f6ef5b..4e6526419bd 100644 --- a/tests/rustdoc-json/attrs/export_name_2021.rs +++ b/tests/rustdoc-json/attrs/export_name_2021.rs @@ -1,6 +1,6 @@ //@ edition: 2021 #![no_std] -//@ is "$.index[?(@.name=='example')].attrs" '["#[export_name = \"altered\"]"]' +//@ is "$.index[?(@.name=='example')].attrs" '["#[export_name = \"altered\"]\n"]' #[export_name = "altered"] pub extern "C" fn example() {} diff --git a/tests/rustdoc-json/attrs/export_name_2024.rs b/tests/rustdoc-json/attrs/export_name_2024.rs index 8129c109306..f6a2a92b5bc 100644 --- a/tests/rustdoc-json/attrs/export_name_2024.rs +++ b/tests/rustdoc-json/attrs/export_name_2024.rs @@ -4,6 +4,6 @@ // The representation of `#[unsafe(export_name = ..)]` in rustdoc in edition 2024 // is still `#[export_name = ..]` without the `unsafe` attribute wrapper. -//@ is "$.index[?(@.name=='example')].attrs" '["#[export_name = \"altered\"]"]' +//@ is "$.index[?(@.name=='example')].attrs" '["#[export_name = \"altered\"]\n"]' #[unsafe(export_name = "altered")] pub extern "C" fn example() {} diff --git a/tests/rustdoc-json/attrs/must_use.rs b/tests/rustdoc-json/attrs/must_use.rs index 64df8e5f509..20696dce712 100644 --- a/tests/rustdoc-json/attrs/must_use.rs +++ b/tests/rustdoc-json/attrs/must_use.rs @@ -1,9 +1,9 @@ #![no_std] -//@ is "$.index[?(@.name=='example')].attrs" '["#[must_use]"]' +//@ is "$.index[?(@.name=='example')].attrs" '["#[must_use]\n"]' #[must_use] pub fn example() -> impl Iterator<Item = i64> {} -//@ is "$.index[?(@.name=='explicit_message')].attrs" '["#[must_use = \"does nothing if you do not use it\"]"]' +//@ is "$.index[?(@.name=='explicit_message')].attrs" '["#[must_use = \"does nothing if you do not use it\"]\n"]' #[must_use = "does nothing if you do not use it"] pub fn explicit_message() -> impl Iterator<Item = i64> {} diff --git a/tests/rustdoc-json/attrs/no_mangle_2021.rs b/tests/rustdoc-json/attrs/no_mangle_2021.rs index 588be7256db..10a372572ae 100644 --- a/tests/rustdoc-json/attrs/no_mangle_2021.rs +++ b/tests/rustdoc-json/attrs/no_mangle_2021.rs @@ -1,6 +1,6 @@ //@ edition: 2021 #![no_std] -//@ is "$.index[?(@.name=='example')].attrs" '["#[no_mangle]"]' +//@ is "$.index[?(@.name=='example')].attrs" '["#[no_mangle]\n"]' #[no_mangle] pub extern "C" fn example() {} diff --git a/tests/rustdoc-json/attrs/no_mangle_2024.rs b/tests/rustdoc-json/attrs/no_mangle_2024.rs index 0d500e20e6c..8f3a14cbecb 100644 --- a/tests/rustdoc-json/attrs/no_mangle_2024.rs +++ b/tests/rustdoc-json/attrs/no_mangle_2024.rs @@ -4,6 +4,6 @@ // The representation of `#[unsafe(no_mangle)]` in rustdoc in edition 2024 // is still `#[no_mangle]` without the `unsafe` attribute wrapper. -//@ is "$.index[?(@.name=='example')].attrs" '["#[no_mangle]"]' +//@ is "$.index[?(@.name=='example')].attrs" '["#[no_mangle]\n"]' #[unsafe(no_mangle)] pub extern "C" fn example() {} diff --git a/tests/rustdoc-json/attrs/non_exhaustive.rs b/tests/rustdoc-json/attrs/non_exhaustive.rs index b95f1a8171f..3064b86422d 100644 --- a/tests/rustdoc-json/attrs/non_exhaustive.rs +++ b/tests/rustdoc-json/attrs/non_exhaustive.rs @@ -1,18 +1,18 @@ #![no_std] -//@ is "$.index[?(@.name=='MyEnum')].attrs" '["#[non_exhaustive]"]' +//@ is "$.index[?(@.name=='MyEnum')].attrs" '["#[non_exhaustive]\n"]' #[non_exhaustive] pub enum MyEnum { First, } pub enum NonExhaustiveVariant { - //@ is "$.index[?(@.name=='Variant')].attrs" '["#[non_exhaustive]"]' + //@ is "$.index[?(@.name=='Variant')].attrs" '["#[non_exhaustive]\n"]' #[non_exhaustive] Variant(i64), } -//@ is "$.index[?(@.name=='MyStruct')].attrs" '["#[non_exhaustive]"]' +//@ is "$.index[?(@.name=='MyStruct')].attrs" '["#[non_exhaustive]\n"]' #[non_exhaustive] pub struct MyStruct { pub x: i64, diff --git a/tests/rustdoc-json/keyword_private.rs b/tests/rustdoc-json/keyword_private.rs index fea546c9fb6..5e9a2c10163 100644 --- a/tests/rustdoc-json/keyword_private.rs +++ b/tests/rustdoc-json/keyword_private.rs @@ -5,7 +5,7 @@ //@ !has "$.index[?(@.name=='match')]" //@ has "$.index[?(@.name=='foo')]" -//@ is "$.index[?(@.name=='foo')].attrs" '["#[doc(keyword = \"match\")]"]' +//@ is "$.index[?(@.name=='foo')].attrs" '["#[doc(keyword = \"match\")]\n"]' //@ is "$.index[?(@.name=='foo')].docs" '"this is a test!"' #[doc(keyword = "match")] /// this is a test! @@ -13,7 +13,7 @@ pub mod foo {} //@ !has "$.index[?(@.name=='break')]" //@ has "$.index[?(@.name=='bar')]" -//@ is "$.index[?(@.name=='bar')].attrs" '["#[doc(keyword = \"break\")]"]' +//@ is "$.index[?(@.name=='bar')].attrs" '["#[doc(keyword = \"break\")]\n"]' //@ is "$.index[?(@.name=='bar')].docs" '"hello"' #[doc(keyword = "break")] /// hello diff --git a/tests/rustdoc-ui/doctest/auxiliary/items.rs b/tests/rustdoc-ui/doctest/auxiliary/items.rs new file mode 100644 index 00000000000..40d4eb261e5 --- /dev/null +++ b/tests/rustdoc-ui/doctest/auxiliary/items.rs @@ -0,0 +1 @@ +fn item() {} diff --git a/tests/rustdoc-ui/doctest/edition-2024-error-output.stdout b/tests/rustdoc-ui/doctest/edition-2024-error-output.stdout index 8f056a5f703..273d7071237 100644 --- a/tests/rustdoc-ui/doctest/edition-2024-error-output.stdout +++ b/tests/rustdoc-ui/doctest/edition-2024-error-output.stdout @@ -5,6 +5,9 @@ test $DIR/edition-2024-error-output.rs - (line 12) ... FAILED failures: ---- $DIR/edition-2024-error-output.rs - (line 12) stdout ---- +Test executable failed (exit status: 101). + +stderr: thread 'main' panicked at $TMP:6:1: assertion `left == right` failed @@ -13,6 +16,7 @@ assertion `left == right` failed note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace + failures: $DIR/edition-2024-error-output.rs - (line 12) diff --git a/tests/rustdoc-ui/doctest/failed-doctest-extra-semicolon-on-item.rs b/tests/rustdoc-ui/doctest/failed-doctest-extra-semicolon-on-item.rs index 508faadcf67..ca5dd787467 100644 --- a/tests/rustdoc-ui/doctest/failed-doctest-extra-semicolon-on-item.rs +++ b/tests/rustdoc-ui/doctest/failed-doctest-extra-semicolon-on-item.rs @@ -4,12 +4,12 @@ //@ compile-flags:--test //@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR" //@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" -//@ failure-status: 101 +//@ check-pass /// <https://github.com/rust-lang/rust/issues/91014> /// /// ```rust -/// struct S {}; // unexpected semicolon after struct def +/// struct S {}; /// /// fn main() { /// assert_eq!(0, 1); diff --git a/tests/rustdoc-ui/doctest/failed-doctest-extra-semicolon-on-item.stdout b/tests/rustdoc-ui/doctest/failed-doctest-extra-semicolon-on-item.stdout index 9eb8b391e78..1068b98cb0f 100644 --- a/tests/rustdoc-ui/doctest/failed-doctest-extra-semicolon-on-item.stdout +++ b/tests/rustdoc-ui/doctest/failed-doctest-extra-semicolon-on-item.stdout @@ -1,29 +1,6 @@ running 1 test -test $DIR/failed-doctest-extra-semicolon-on-item.rs - m (line 11) ... FAILED +test $DIR/failed-doctest-extra-semicolon-on-item.rs - m (line 11) ... ok -failures: - ----- $DIR/failed-doctest-extra-semicolon-on-item.rs - m (line 11) stdout ---- -error: expected item, found `;` - --> $DIR/failed-doctest-extra-semicolon-on-item.rs:12:12 - | -LL | struct S {}; // unexpected semicolon after struct def - | ^ - | - = help: braced struct declarations are not followed by a semicolon -help: remove this semicolon - | -LL - struct S {}; // unexpected semicolon after struct def -LL + struct S {} // unexpected semicolon after struct def - | - -error: aborting due to 1 previous error - -Couldn't compile the test. - -failures: - $DIR/failed-doctest-extra-semicolon-on-item.rs - m (line 11) - -test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/tests/rustdoc-ui/doctest/main-alongside-macro-calls.fail.stdout b/tests/rustdoc-ui/doctest/main-alongside-macro-calls.fail.stdout new file mode 100644 index 00000000000..65989a8ef47 --- /dev/null +++ b/tests/rustdoc-ui/doctest/main-alongside-macro-calls.fail.stdout @@ -0,0 +1,60 @@ + +running 4 tests +test $DIR/main-alongside-macro-calls.rs - (line 19) ... ok +test $DIR/main-alongside-macro-calls.rs - (line 24) ... ok +test $DIR/main-alongside-macro-calls.rs - (line 28) ... FAILED +test $DIR/main-alongside-macro-calls.rs - (line 33) ... FAILED + +failures: + +---- $DIR/main-alongside-macro-calls.rs - (line 28) stdout ---- +error: macros that expand to items must be delimited with braces or followed by a semicolon + --> $DIR/main-alongside-macro-calls.rs:30:1 + | +LL | println!(); + | ^^^^^^^^^^ + | + = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: macro expansion ignores `{` and any tokens following + --> $SRC_DIR/std/src/macros.rs:LL:COL + | + ::: $DIR/main-alongside-macro-calls.rs:30:1 + | +LL | println!(); + | ---------- caused by the macro expansion here + | + = note: the usage of `print!` is likely invalid in item context + +error: aborting due to 2 previous errors + +Couldn't compile the test. +---- $DIR/main-alongside-macro-calls.rs - (line 33) stdout ---- +error: macros that expand to items must be delimited with braces or followed by a semicolon + --> $DIR/main-alongside-macro-calls.rs:34:1 + | +LL | println!(); + | ^^^^^^^^^^ + | + = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: macro expansion ignores `{` and any tokens following + --> $SRC_DIR/std/src/macros.rs:LL:COL + | + ::: $DIR/main-alongside-macro-calls.rs:34:1 + | +LL | println!(); + | ---------- caused by the macro expansion here + | + = note: the usage of `print!` is likely invalid in item context + +error: aborting due to 2 previous errors + +Couldn't compile the test. + +failures: + $DIR/main-alongside-macro-calls.rs - (line 28) + $DIR/main-alongside-macro-calls.rs - (line 33) + +test result: FAILED. 2 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME + diff --git a/tests/rustdoc-ui/doctest/main-alongside-macro-calls.pass.stdout b/tests/rustdoc-ui/doctest/main-alongside-macro-calls.pass.stdout new file mode 100644 index 00000000000..93a4bbd8736 --- /dev/null +++ b/tests/rustdoc-ui/doctest/main-alongside-macro-calls.pass.stdout @@ -0,0 +1,9 @@ + +running 4 tests +test $DIR/main-alongside-macro-calls.rs - (line 19) ... ok +test $DIR/main-alongside-macro-calls.rs - (line 24) ... ok +test $DIR/main-alongside-macro-calls.rs - (line 28) - compile fail ... ok +test $DIR/main-alongside-macro-calls.rs - (line 33) - compile fail ... ok + +test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME + diff --git a/tests/rustdoc-ui/doctest/main-alongside-macro-calls.rs b/tests/rustdoc-ui/doctest/main-alongside-macro-calls.rs new file mode 100644 index 00000000000..b455d8b0cc3 --- /dev/null +++ b/tests/rustdoc-ui/doctest/main-alongside-macro-calls.rs @@ -0,0 +1,44 @@ +// This test ensures that if there is are any macro calls alongside a `main` function, +// it will indeed consider the `main` function as the program entry point and *won't* +// generate its own `main` function to wrap everything even though macro calls are +// valid in statement contexts, too, and could just as well expand to statements or +// expressions (we don't perform any macro expansion to find `main`, see also +// <https://github.com/rust-lang/rust/issues/57415>). +// +// See <./main-alongside-stmts.rs> for comparison. +// +//@ compile-flags:--test --test-args --test-threads=1 +//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR" +//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" +//@ revisions: pass fail +//@[pass] check-pass +//@[fail] failure-status: 101 + +// Regression test for <https://github.com/rust-lang/rust/pull/140220#issuecomment-2831872920>: + +//! ``` +//! fn main() {} +//! include!("./auxiliary/items.rs"); +//! ``` +//! +//! ``` +//! include!("./auxiliary/items.rs"); +//! fn main() {} +//! ``` + +// Regression test for <https://github.com/rust-lang/rust/issues/140412>: +// We test the "same" thing twice: Once via `compile_fail` to more closely mirror the reported +// regression and once without it to make sure that it leads to the expected rustc errors, +// namely `println!(…)` not being valid in item contexts. + +#![cfg_attr(pass, doc = " ```compile_fail")] +#![cfg_attr(fail, doc = " ```")] +//! fn main() {} +//! println!(); +//! ``` +//! +#![cfg_attr(pass, doc = " ```compile_fail")] +#![cfg_attr(fail, doc = " ```")] +//! println!(); +//! fn main() {} +//! ``` diff --git a/tests/rustdoc-ui/doctest/main-alongside-stmts.rs b/tests/rustdoc-ui/doctest/main-alongside-stmts.rs new file mode 100644 index 00000000000..5965f928cdd --- /dev/null +++ b/tests/rustdoc-ui/doctest/main-alongside-stmts.rs @@ -0,0 +1,33 @@ +// This test ensures that if there is are any statements alongside a `main` function, +// it will not consider the `main` function as the program entry point but instead +// will generate its own `main` function to wrap everything as it needs to reside in a +// module where only *items* are permitted syntactically. +// +// See <./main-alongside-macro-calls.rs> for comparison. +// +// This is a regression test for: +// * <https://github.com/rust-lang/rust/issues/140162> +// * <https://github.com/rust-lang/rust/issues/139651> +// +//@ compile-flags:--test --test-args --test-threads=1 +//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR" +//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" +//@ check-pass + +//! ``` +//! # if cfg!(miri) { return; } +//! use std::ops::Deref; +//! +//! fn main() { +//! assert!(false); +//! } +//! ``` +//! +//! ``` +//! let x = 2; +//! assert_eq!(x, 2); +//! +//! fn main() { +//! assert!(false); +//! } +//! ``` diff --git a/tests/rustdoc-ui/doctest/main-alongside-stmts.stdout b/tests/rustdoc-ui/doctest/main-alongside-stmts.stdout new file mode 100644 index 00000000000..9b9a3fe8a68 --- /dev/null +++ b/tests/rustdoc-ui/doctest/main-alongside-stmts.stdout @@ -0,0 +1,7 @@ + +running 2 tests +test $DIR/main-alongside-stmts.rs - (line 17) ... ok +test $DIR/main-alongside-stmts.rs - (line 26) ... ok + +test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME + diff --git a/tests/rustdoc-ui/doctest/stdout-and-stderr.rs b/tests/rustdoc-ui/doctest/stdout-and-stderr.rs new file mode 100644 index 00000000000..9b0c69d8839 --- /dev/null +++ b/tests/rustdoc-ui/doctest/stdout-and-stderr.rs @@ -0,0 +1,26 @@ +// This test ensures that the output is correctly generated when the +// doctest fails. It checks when there is stderr and stdout, no stdout +// and no stderr/stdout. +// +// This is a regression test for <https://github.com/rust-lang/rust/issues/140289>. + +//@ edition: 2024 +//@ compile-flags:--test --test-args=--test-threads=1 +//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR" +//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" +//@ normalize-stdout: "panicked at .+rs:" -> "panicked at $$TMP:" +//@ failure-status: 101 +//@ rustc-env:RUST_BACKTRACE=0 + +//! ``` +//! println!("######## from a DOC TEST ########"); +//! assert_eq!("doc", "test"); +//! ``` +//! +//! ``` +//! assert_eq!("doc", "test"); +//! ``` +//! +//! ``` +//! std::process::exit(1); +//! ``` diff --git a/tests/rustdoc-ui/doctest/stdout-and-stderr.stdout b/tests/rustdoc-ui/doctest/stdout-and-stderr.stdout new file mode 100644 index 00000000000..b2febe1344f --- /dev/null +++ b/tests/rustdoc-ui/doctest/stdout-and-stderr.stdout @@ -0,0 +1,46 @@ + +running 3 tests +test $DIR/stdout-and-stderr.rs - (line 15) ... FAILED +test $DIR/stdout-and-stderr.rs - (line 20) ... FAILED +test $DIR/stdout-and-stderr.rs - (line 24) ... FAILED + +failures: + +---- $DIR/stdout-and-stderr.rs - (line 15) stdout ---- +Test executable failed (exit status: 101). + +stdout: +######## from a DOC TEST ######## + +stderr: + +thread 'main' panicked at $TMP:7:1: +assertion `left == right` failed + left: "doc" + right: "test" +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace + + +---- $DIR/stdout-and-stderr.rs - (line 20) stdout ---- +Test executable failed (exit status: 101). + +stderr: + +thread 'main' panicked at $TMP:15:1: +assertion `left == right` failed + left: "doc" + right: "test" +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace + + +---- $DIR/stdout-and-stderr.rs - (line 24) stdout ---- +Test executable failed (exit status: 1). + + +failures: + $DIR/stdout-and-stderr.rs - (line 15) + $DIR/stdout-and-stderr.rs - (line 20) + $DIR/stdout-and-stderr.rs - (line 24) + +test result: FAILED. 0 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME + diff --git a/tests/rustdoc-ui/issues/ice-generic-type-alias-105742.rs b/tests/rustdoc-ui/issues/ice-generic-type-alias-105742.rs index 73a68777c6d..33f3c2ff506 100644 --- a/tests/rustdoc-ui/issues/ice-generic-type-alias-105742.rs +++ b/tests/rustdoc-ui/issues/ice-generic-type-alias-105742.rs @@ -1,12 +1,14 @@ //@ compile-flags: -Znormalize-docs +//@ dont-require-annotations: NOTE + // https://github.com/rust-lang/rust/issues/105742 use std::ops::Index; pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) { - //~^ expected 1 lifetime argument - //~| expected 1 generic argument + //~^ NOTE expected 1 lifetime argument + //~| NOTE expected 1 generic argument //~| ERROR the trait `SVec` is not dyn compatible - //~| `SVec` is not dyn compatible + //~| NOTE `SVec` is not dyn compatible //~| ERROR missing generics for associated type `SVec::Item` //~| ERROR missing generics for associated type `SVec::Item` let _ = s; @@ -14,8 +16,8 @@ pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) { pub trait SVec: Index< <Self as SVec>::Item, - //~^ expected 1 lifetime argument - //~| expected 1 generic argument + //~^ NOTE expected 1 lifetime argument + //~| NOTE expected 1 generic argument //~| ERROR missing generics for associated type `SVec::Item` //~| ERROR missing generics for associated type `SVec::Item` //~| ERROR missing generics for associated type `SVec::Item` @@ -25,8 +27,8 @@ pub trait SVec: Index< //~| ERROR missing generics for associated type `SVec::Item` //~| ERROR missing generics for associated type `SVec::Item` Output = <Index<<Self as SVec>::Item, - //~^ expected 1 lifetime argument - //~| expected 1 generic argument + //~^ NOTE expected 1 lifetime argument + //~| NOTE expected 1 generic argument //~| ERROR missing generics for associated type `SVec::Item` //~| ERROR missing generics for associated type `SVec::Item` //~| ERROR missing generics for associated type `SVec::Item` @@ -36,16 +38,16 @@ pub trait SVec: Index< //~| ERROR missing generics for associated type `SVec::Item` //~| ERROR missing generics for associated type `SVec::Item` Output = <Self as SVec>::Item> as SVec>::Item, - //~^ expected 1 lifetime argument - //~| expected 1 generic argument - //~| expected 1 lifetime argument + //~^ NOTE expected 1 lifetime argument + //~| NOTE expected 1 generic argument + //~| NOTE expected 1 lifetime argument //~| ERROR missing generics for associated type `SVec::Item` //~| ERROR missing generics for associated type `SVec::Item` //~| ERROR missing generics for associated type `SVec::Item` //~| ERROR missing generics for associated type `SVec::Item` //~| ERROR missing generics for associated type `SVec::Item` //~| ERROR missing generics for associated type `SVec::Item` - //~| expected 1 generic argument + //~| NOTE expected 1 generic argument //~| ERROR missing generics for associated type `SVec::Item` //~| ERROR missing generics for associated type `SVec::Item` //~| ERROR missing generics for associated type `SVec::Item` @@ -60,8 +62,8 @@ pub trait SVec: Index< type Item<'a, T>; fn len(&self) -> <Self as SVec>::Item; - //~^ expected 1 lifetime argument + //~^ NOTE expected 1 lifetime argument //~| ERROR missing generics for associated type `SVec::Item` - //~| expected 1 generic argument + //~| NOTE expected 1 generic argument //~| ERROR missing generics for associated type `SVec::Item` } diff --git a/tests/rustdoc-ui/issues/ice-generic-type-alias-105742.stderr b/tests/rustdoc-ui/issues/ice-generic-type-alias-105742.stderr index e4a84655486..642847733a8 100644 --- a/tests/rustdoc-ui/issues/ice-generic-type-alias-105742.stderr +++ b/tests/rustdoc-ui/issues/ice-generic-type-alias-105742.stderr @@ -1,11 +1,11 @@ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:16:21 + --> $DIR/ice-generic-type-alias-105742.rs:18:21 | LL | <Self as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -15,13 +15,13 @@ LL | <Self as SVec>::Item<'a>, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:16:21 + --> $DIR/ice-generic-type-alias-105742.rs:18:21 | LL | <Self as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ - @@ -31,13 +31,13 @@ LL | <Self as SVec>::Item<T>, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:27:37 + --> $DIR/ice-generic-type-alias-105742.rs:29:37 | LL | Output = <Index<<Self as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -47,13 +47,13 @@ LL | Output = <Index<<Self as SVec>::Item<'a>, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:27:37 + --> $DIR/ice-generic-type-alias-105742.rs:29:37 | LL | Output = <Index<<Self as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ - @@ -63,13 +63,13 @@ LL | Output = <Index<<Self as SVec>::Item<T>, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:38:30 + --> $DIR/ice-generic-type-alias-105742.rs:40:30 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -79,13 +79,13 @@ LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:38:30 + --> $DIR/ice-generic-type-alias-105742.rs:40:30 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ - @@ -95,13 +95,13 @@ LL | Output = <Self as SVec>::Item<T>> as SVec>::Item, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:38:46 + --> $DIR/ice-generic-type-alias-105742.rs:40:46 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -111,13 +111,13 @@ LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:38:46 + --> $DIR/ice-generic-type-alias-105742.rs:40:46 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ - @@ -127,13 +127,13 @@ LL | Output = <Self as SVec>::Item> as SVec>::Item<T>, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:5:40 + --> $DIR/ice-generic-type-alias-105742.rs:7:40 | LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) { | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -143,13 +143,13 @@ LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item<'_> = T, Output = T>) { | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:5:40 + --> $DIR/ice-generic-type-alias-105742.rs:7:40 | LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) { | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ - @@ -159,13 +159,13 @@ LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item<T> = T, Output = T>) { | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:16:21 + --> $DIR/ice-generic-type-alias-105742.rs:18:21 | LL | <Self as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -176,13 +176,13 @@ LL | <Self as SVec>::Item<'a>, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:16:21 + --> $DIR/ice-generic-type-alias-105742.rs:18:21 | LL | <Self as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ - @@ -193,13 +193,13 @@ LL | <Self as SVec>::Item<T>, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:27:37 + --> $DIR/ice-generic-type-alias-105742.rs:29:37 | LL | Output = <Index<<Self as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -210,13 +210,13 @@ LL | Output = <Index<<Self as SVec>::Item<'a>, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:27:37 + --> $DIR/ice-generic-type-alias-105742.rs:29:37 | LL | Output = <Index<<Self as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ - @@ -227,13 +227,13 @@ LL | Output = <Index<<Self as SVec>::Item<T>, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:38:30 + --> $DIR/ice-generic-type-alias-105742.rs:40:30 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -244,13 +244,13 @@ LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:38:30 + --> $DIR/ice-generic-type-alias-105742.rs:40:30 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ - @@ -261,13 +261,13 @@ LL | Output = <Self as SVec>::Item<T>> as SVec>::Item, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:38:46 + --> $DIR/ice-generic-type-alias-105742.rs:40:46 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -278,13 +278,13 @@ LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:38:46 + --> $DIR/ice-generic-type-alias-105742.rs:40:46 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ - @@ -295,14 +295,14 @@ LL | Output = <Self as SVec>::Item> as SVec>::Item<T>, | +++ error[E0038]: the trait `SVec` is not dyn compatible - --> $DIR/ice-generic-type-alias-105742.rs:5:35 + --> $DIR/ice-generic-type-alias-105742.rs:7:35 | LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `SVec` is not dyn compatible | note: for a trait to be dyn compatible it needs to allow building a vtable for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/ice-generic-type-alias-105742.rs:15:17 + --> $DIR/ice-generic-type-alias-105742.rs:17:17 | LL | pub trait SVec: Index< | ____________----__^ @@ -324,13 +324,13 @@ LL + pub fn next<'a, T>(s: &'a mut impl SVec<Item = T, Output = T>) { | error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:16:21 + --> $DIR/ice-generic-type-alias-105742.rs:18:21 | LL | <Self as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -341,13 +341,13 @@ LL | <Self as SVec>::Item<'a>, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:16:21 + --> $DIR/ice-generic-type-alias-105742.rs:18:21 | LL | <Self as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ - @@ -358,13 +358,13 @@ LL | <Self as SVec>::Item<T>, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:27:37 + --> $DIR/ice-generic-type-alias-105742.rs:29:37 | LL | Output = <Index<<Self as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -375,13 +375,13 @@ LL | Output = <Index<<Self as SVec>::Item<'a>, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:27:37 + --> $DIR/ice-generic-type-alias-105742.rs:29:37 | LL | Output = <Index<<Self as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ - @@ -392,13 +392,13 @@ LL | Output = <Index<<Self as SVec>::Item<T>, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:38:30 + --> $DIR/ice-generic-type-alias-105742.rs:40:30 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -409,13 +409,13 @@ LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:38:30 + --> $DIR/ice-generic-type-alias-105742.rs:40:30 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ - @@ -426,13 +426,13 @@ LL | Output = <Self as SVec>::Item<T>> as SVec>::Item, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:38:46 + --> $DIR/ice-generic-type-alias-105742.rs:40:46 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -443,13 +443,13 @@ LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:38:46 + --> $DIR/ice-generic-type-alias-105742.rs:40:46 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ - @@ -460,13 +460,13 @@ LL | Output = <Self as SVec>::Item> as SVec>::Item<T>, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:16:21 + --> $DIR/ice-generic-type-alias-105742.rs:18:21 | LL | <Self as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -477,13 +477,13 @@ LL | <Self as SVec>::Item<'a>, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:16:21 + --> $DIR/ice-generic-type-alias-105742.rs:18:21 | LL | <Self as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ - @@ -494,13 +494,13 @@ LL | <Self as SVec>::Item<T>, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:27:37 + --> $DIR/ice-generic-type-alias-105742.rs:29:37 | LL | Output = <Index<<Self as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -511,13 +511,13 @@ LL | Output = <Index<<Self as SVec>::Item<'a>, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:27:37 + --> $DIR/ice-generic-type-alias-105742.rs:29:37 | LL | Output = <Index<<Self as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ - @@ -528,13 +528,13 @@ LL | Output = <Index<<Self as SVec>::Item<T>, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:38:30 + --> $DIR/ice-generic-type-alias-105742.rs:40:30 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -545,13 +545,13 @@ LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:38:30 + --> $DIR/ice-generic-type-alias-105742.rs:40:30 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ - @@ -562,13 +562,13 @@ LL | Output = <Self as SVec>::Item<T>> as SVec>::Item, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:38:46 + --> $DIR/ice-generic-type-alias-105742.rs:40:46 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -579,13 +579,13 @@ LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:38:46 + --> $DIR/ice-generic-type-alias-105742.rs:40:46 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ - @@ -596,13 +596,13 @@ LL | Output = <Self as SVec>::Item> as SVec>::Item<T>, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:62:38 + --> $DIR/ice-generic-type-alias-105742.rs:64:38 | LL | fn len(&self) -> <Self as SVec>::Item; | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -612,13 +612,13 @@ LL | fn len(&self) -> <Self as SVec>::Item<'_>; | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/ice-generic-type-alias-105742.rs:62:38 + --> $DIR/ice-generic-type-alias-105742.rs:64:38 | LL | fn len(&self) -> <Self as SVec>::Item; | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/ice-generic-type-alias-105742.rs:60:10 + --> $DIR/ice-generic-type-alias-105742.rs:62:10 | LL | type Item<'a, T>; | ^^^^ - diff --git a/tests/rustdoc/doctest/auxiliary/doctest-runtool.rs b/tests/rustdoc/doctest/auxiliary/doctest-runtool.rs new file mode 100644 index 00000000000..a21ae0664fe --- /dev/null +++ b/tests/rustdoc/doctest/auxiliary/doctest-runtool.rs @@ -0,0 +1,21 @@ +// For some reason on Windows, the PATH to the libstd dylib doesn't seem to +// carry over to running the runtool. +//@ no-prefer-dynamic + +use std::path::Path; +use std::process::Command; + +fn main() { + let args: Vec<_> = std::env::args().collect(); + eprintln!("{args:#?}"); + assert_eq!(args.len(), 4); + assert_eq!(args[1], "arg1"); + assert_eq!(args[2], "arg2 with space"); + let path = Path::new(&args[3]); + let output = Command::new(path).output().unwrap(); + // Should fail without env var. + assert!(!output.status.success()); + let output = Command::new(path).env("DOCTEST_RUNTOOL_CHECK", "xyz").output().unwrap(); + // Should pass with env var. + assert!(output.status.success()); +} diff --git a/tests/rustdoc/doctest/doctest-runtool.rs b/tests/rustdoc/doctest/doctest-runtool.rs new file mode 100644 index 00000000000..c4fb02e5228 --- /dev/null +++ b/tests/rustdoc/doctest/doctest-runtool.rs @@ -0,0 +1,13 @@ +// Tests that the --test-runtool argument works. + +//@ ignore-cross-compile +//@ aux-bin: doctest-runtool.rs +//@ compile-flags: --test +//@ compile-flags: --test-runtool=auxiliary/bin/doctest-runtool +//@ compile-flags: --test-runtool-arg=arg1 --test-runtool-arg +//@ compile-flags: 'arg2 with space' + +/// ``` +/// assert_eq!(std::env::var("DOCTEST_RUNTOOL_CHECK"), Ok("xyz".to_string())); +/// ``` +pub fn main() {} diff --git a/tests/ui-fulldeps/auxiliary/parser.rs b/tests/ui-fulldeps/auxiliary/parser.rs index 4ea0d814b1f..be51bd29008 100644 --- a/tests/ui-fulldeps/auxiliary/parser.rs +++ b/tests/ui-fulldeps/auxiliary/parser.rs @@ -39,8 +39,6 @@ pub fn parse_expr(psess: &ParseSess, source_code: &str) -> Option<P<Expr>> { struct Normalize; impl MutVisitor for Normalize { - const VISIT_TOKENS: bool = true; - fn visit_id(&mut self, id: &mut NodeId) { *id = DUMMY_NODE_ID; } diff --git a/tests/ui-fulldeps/stable-mir/check_abi.rs b/tests/ui-fulldeps/stable-mir/check_abi.rs index ebf2e333f08..71edf813a7b 100644 --- a/tests/ui-fulldeps/stable-mir/check_abi.rs +++ b/tests/ui-fulldeps/stable-mir/check_abi.rs @@ -145,7 +145,7 @@ fn get_item<'a>( fn main() { let path = "alloc_input.rs"; generate_input(&path).unwrap(); - let args = vec![ + let args = &[ "rustc".to_string(), "--crate-type=lib".to_string(), "--crate-name".to_string(), diff --git a/tests/ui-fulldeps/stable-mir/check_allocation.rs b/tests/ui-fulldeps/stable-mir/check_allocation.rs index ae2609bbc12..692c24f0544 100644 --- a/tests/ui-fulldeps/stable-mir/check_allocation.rs +++ b/tests/ui-fulldeps/stable-mir/check_allocation.rs @@ -219,7 +219,7 @@ fn get_item<'a>( fn main() { let path = "alloc_input.rs"; generate_input(&path).unwrap(); - let args = vec![ + let args = &[ "rustc".to_string(), "--edition=2021".to_string(), "--crate-name".to_string(), diff --git a/tests/ui-fulldeps/stable-mir/check_assoc_items.rs b/tests/ui-fulldeps/stable-mir/check_assoc_items.rs index 9d611543b5a..755bec8747b 100644 --- a/tests/ui-fulldeps/stable-mir/check_assoc_items.rs +++ b/tests/ui-fulldeps/stable-mir/check_assoc_items.rs @@ -85,7 +85,7 @@ fn check_items<T: CrateDef>(items: &[T], expected: &[&str]) { fn main() { let path = "assoc_items.rs"; generate_input(&path).unwrap(); - let args = vec![ + let args = &[ "rustc".to_string(), "--crate-type=lib".to_string(), "--crate-name".to_string(), diff --git a/tests/ui-fulldeps/stable-mir/check_attribute.rs b/tests/ui-fulldeps/stable-mir/check_attribute.rs index 4148fc0cb6a..e4cc7b104b6 100644 --- a/tests/ui-fulldeps/stable-mir/check_attribute.rs +++ b/tests/ui-fulldeps/stable-mir/check_attribute.rs @@ -35,12 +35,12 @@ fn test_stable_mir() -> ControlFlow<()> { fn test_tool(items: &CrateItems) { let rustfmt_fn = *get_item(&items, "do_not_format").unwrap(); let rustfmt_attrs = rustfmt_fn.tool_attrs(&["rustfmt".to_string(), "skip".to_string()]); - assert_eq!(rustfmt_attrs[0].as_str(), "#[rustfmt::skip]"); + assert_eq!(rustfmt_attrs[0].as_str(), "#[rustfmt::skip]\n"); let clippy_fn = *get_item(&items, "complex_fn").unwrap(); let clippy_attrs = clippy_fn.tool_attrs(&["clippy".to_string(), "cyclomatic_complexity".to_string()]); - assert_eq!(clippy_attrs[0].as_str(), "#[clippy::cyclomatic_complexity = \"100\"]"); + assert_eq!(clippy_attrs[0].as_str(), "#[clippy::cyclomatic_complexity = \"100\"]\n"); } fn get_item<'a>( @@ -57,7 +57,7 @@ fn get_item<'a>( fn main() { let path = "attribute_input.rs"; generate_input(&path).unwrap(); - let args = vec![ + let args = &[ "rustc".to_string(), "--crate-type=lib".to_string(), "--crate-name".to_string(), diff --git a/tests/ui-fulldeps/stable-mir/check_binop.rs b/tests/ui-fulldeps/stable-mir/check_binop.rs index 6a141e9c577..f9559d9958d 100644 --- a/tests/ui-fulldeps/stable-mir/check_binop.rs +++ b/tests/ui-fulldeps/stable-mir/check_binop.rs @@ -81,7 +81,7 @@ impl<'a> MirVisitor for Visitor<'a> { fn main() { let path = "binop_input.rs"; generate_input(&path).unwrap(); - let args = vec!["rustc".to_string(), "--crate-type=lib".to_string(), path.to_string()]; + let args = &["rustc".to_string(), "--crate-type=lib".to_string(), path.to_string()]; run!(args, test_binops).unwrap(); } diff --git a/tests/ui-fulldeps/stable-mir/check_crate_defs.rs b/tests/ui-fulldeps/stable-mir/check_crate_defs.rs index 31c47192d09..6863242f225 100644 --- a/tests/ui-fulldeps/stable-mir/check_crate_defs.rs +++ b/tests/ui-fulldeps/stable-mir/check_crate_defs.rs @@ -84,7 +84,7 @@ fn contains<T: CrateDef + std::fmt::Debug>(items: &[T], expected: &[&str]) { fn main() { let path = "crate_definitions.rs"; generate_input(&path).unwrap(); - let args = vec![ + let args = &[ "rustc".to_string(), "--crate-type=lib".to_string(), "--crate-name".to_string(), diff --git a/tests/ui-fulldeps/stable-mir/check_def_ty.rs b/tests/ui-fulldeps/stable-mir/check_def_ty.rs index 00a34f13867..f86a8e0ae61 100644 --- a/tests/ui-fulldeps/stable-mir/check_def_ty.rs +++ b/tests/ui-fulldeps/stable-mir/check_def_ty.rs @@ -76,7 +76,7 @@ fn check_fn_def(ty: Ty) { fn main() { let path = "defs_ty_input.rs"; generate_input(&path).unwrap(); - let args = vec![ + let args = &[ "rustc".to_string(), "-Cpanic=abort".to_string(), "--crate-name".to_string(), diff --git a/tests/ui-fulldeps/stable-mir/check_defs.rs b/tests/ui-fulldeps/stable-mir/check_defs.rs index 1ba73377d6e..ab741378bb7 100644 --- a/tests/ui-fulldeps/stable-mir/check_defs.rs +++ b/tests/ui-fulldeps/stable-mir/check_defs.rs @@ -112,7 +112,7 @@ fn get_instances(body: mir::Body) -> Vec<Instance> { fn main() { let path = "defs_input.rs"; generate_input(&path).unwrap(); - let args = vec![ + let args = &[ "rustc".to_string(), "-Cpanic=abort".to_string(), "--crate-name".to_string(), diff --git a/tests/ui-fulldeps/stable-mir/check_foreign.rs b/tests/ui-fulldeps/stable-mir/check_foreign.rs index 4419050ceb2..398024c4ff0 100644 --- a/tests/ui-fulldeps/stable-mir/check_foreign.rs +++ b/tests/ui-fulldeps/stable-mir/check_foreign.rs @@ -58,7 +58,7 @@ fn test_foreign() -> ControlFlow<()> { fn main() { let path = "foreign_input.rs"; generate_input(&path).unwrap(); - let args = vec![ + let args = &[ "rustc".to_string(), "-Cpanic=abort".to_string(), "--crate-type=lib".to_string(), diff --git a/tests/ui-fulldeps/stable-mir/check_instance.rs b/tests/ui-fulldeps/stable-mir/check_instance.rs index 1510a622cdf..b19e5b033c4 100644 --- a/tests/ui-fulldeps/stable-mir/check_instance.rs +++ b/tests/ui-fulldeps/stable-mir/check_instance.rs @@ -87,7 +87,7 @@ fn test_body(body: mir::Body) { fn main() { let path = "instance_input.rs"; generate_input(&path).unwrap(); - let args = vec![ + let args = &[ "rustc".to_string(), "-Cpanic=abort".to_string(), "--crate-type=lib".to_string(), diff --git a/tests/ui-fulldeps/stable-mir/check_intrinsics.rs b/tests/ui-fulldeps/stable-mir/check_intrinsics.rs index 3f04abbb9d7..52424857dc1 100644 --- a/tests/ui-fulldeps/stable-mir/check_intrinsics.rs +++ b/tests/ui-fulldeps/stable-mir/check_intrinsics.rs @@ -115,7 +115,7 @@ impl<'a> MirVisitor for CallsVisitor<'a> { fn main() { let path = "binop_input.rs"; generate_input(&path).unwrap(); - let args = vec!["rustc".to_string(), "--crate-type=lib".to_string(), path.to_string()]; + let args = &["rustc".to_string(), "--crate-type=lib".to_string(), path.to_string()]; run!(args, test_intrinsics).unwrap(); } diff --git a/tests/ui-fulldeps/stable-mir/check_item_kind.rs b/tests/ui-fulldeps/stable-mir/check_item_kind.rs index bb8c00c64c9..d1124c75a89 100644 --- a/tests/ui-fulldeps/stable-mir/check_item_kind.rs +++ b/tests/ui-fulldeps/stable-mir/check_item_kind.rs @@ -47,7 +47,7 @@ fn test_item_kind() -> ControlFlow<()> { fn main() { let path = "item_kind_input.rs"; generate_input(&path).unwrap(); - let args = vec![ + let args = &[ "rustc".to_string(), "-Cpanic=abort".to_string(), "--crate-type=lib".to_string(), diff --git a/tests/ui-fulldeps/stable-mir/check_normalization.rs b/tests/ui-fulldeps/stable-mir/check_normalization.rs index 797cb4cd5d0..16e8c0339ed 100644 --- a/tests/ui-fulldeps/stable-mir/check_normalization.rs +++ b/tests/ui-fulldeps/stable-mir/check_normalization.rs @@ -61,7 +61,7 @@ fn check_ty(ty: Ty) { fn main() { let path = "normalization_input.rs"; generate_input(&path).unwrap(); - let args = vec![ + let args = &[ "rustc".to_string(), "-Cpanic=abort".to_string(), "--crate-type=lib".to_string(), diff --git a/tests/ui-fulldeps/stable-mir/check_trait_queries.rs b/tests/ui-fulldeps/stable-mir/check_trait_queries.rs index d9170d0c408..fcf04a1fc3a 100644 --- a/tests/ui-fulldeps/stable-mir/check_trait_queries.rs +++ b/tests/ui-fulldeps/stable-mir/check_trait_queries.rs @@ -72,7 +72,7 @@ fn assert_impl(impl_names: &HashSet<String>, target: &str) { fn main() { let path = "trait_queries.rs"; generate_input(&path).unwrap(); - let args = vec![ + let args = &[ "rustc".to_string(), "--crate-type=lib".to_string(), "--crate-name".to_string(), diff --git a/tests/ui-fulldeps/stable-mir/check_transform.rs b/tests/ui-fulldeps/stable-mir/check_transform.rs index 604cc72c341..9087c1cf450 100644 --- a/tests/ui-fulldeps/stable-mir/check_transform.rs +++ b/tests/ui-fulldeps/stable-mir/check_transform.rs @@ -120,7 +120,7 @@ fn get_item<'a>( fn main() { let path = "transform_input.rs"; generate_input(&path).unwrap(); - let args = vec![ + let args = &[ "rustc".to_string(), "--crate-type=lib".to_string(), "--crate-name".to_string(), diff --git a/tests/ui-fulldeps/stable-mir/check_ty_fold.rs b/tests/ui-fulldeps/stable-mir/check_ty_fold.rs index 23233f8406c..18b9e32e4e8 100644 --- a/tests/ui-fulldeps/stable-mir/check_ty_fold.rs +++ b/tests/ui-fulldeps/stable-mir/check_ty_fold.rs @@ -78,7 +78,7 @@ impl<'a> MirVisitor for PlaceVisitor<'a> { fn main() { let path = "ty_fold_input.rs"; generate_input(&path).unwrap(); - let args = vec![ + let args = &[ "rustc".to_string(), "-Cpanic=abort".to_string(), "--crate-name".to_string(), diff --git a/tests/ui-fulldeps/stable-mir/compilation-result.rs b/tests/ui-fulldeps/stable-mir/compilation-result.rs index 39416636fd6..19b9c8b7de5 100644 --- a/tests/ui-fulldeps/stable-mir/compilation-result.rs +++ b/tests/ui-fulldeps/stable-mir/compilation-result.rs @@ -25,40 +25,42 @@ use std::io::Write; fn main() { let path = "input_compilation_result_test.rs"; generate_input(&path).unwrap(); - let args = vec!["rustc".to_string(), path.to_string()]; - test_continue(args.clone()); - test_break(args.clone()); - test_failed(args.clone()); - test_skipped(args.clone()); + let args = &["rustc".to_string(), path.to_string()]; + test_continue(args); + test_break(args); + test_failed(args); + test_skipped(args); test_captured(args) } -fn test_continue(args: Vec<String>) { +fn test_continue(args: &[String]) { let result = run!(args, || ControlFlow::Continue::<(), bool>(true)); assert_eq!(result, Ok(true)); } -fn test_break(args: Vec<String>) { +fn test_break(args: &[String]) { let result = run!(args, || ControlFlow::Break::<bool, i32>(false)); assert_eq!(result, Err(stable_mir::CompilerError::Interrupted(false))); } #[allow(unreachable_code)] -fn test_skipped(mut args: Vec<String>) { +fn test_skipped(args: &[String]) { + let mut args = args.to_vec(); args.push("--version".to_string()); - let result = run!(args, || unreachable!() as ControlFlow<()>); + let result = run!(&args, || unreachable!() as ControlFlow<()>); assert_eq!(result, Err(stable_mir::CompilerError::Skipped)); } #[allow(unreachable_code)] -fn test_failed(mut args: Vec<String>) { +fn test_failed(args: &[String]) { + let mut args = args.to_vec(); args.push("--cfg=broken".to_string()); - let result = run!(args, || unreachable!() as ControlFlow<()>); + let result = run!(&args, || unreachable!() as ControlFlow<()>); assert_eq!(result, Err(stable_mir::CompilerError::Failed)); } /// Test that we are able to pass a closure and set the return according to the captured value. -fn test_captured(args: Vec<String>) { +fn test_captured(args: &[String]) { let captured = "10".to_string(); let result = run!(args, || ControlFlow::Continue::<(), usize>(captured.len())); assert_eq!(result, Ok(captured.len())); diff --git a/tests/ui-fulldeps/stable-mir/crate-info.rs b/tests/ui-fulldeps/stable-mir/crate-info.rs index e2086d5e579..7fc4edafb93 100644 --- a/tests/ui-fulldeps/stable-mir/crate-info.rs +++ b/tests/ui-fulldeps/stable-mir/crate-info.rs @@ -186,7 +186,7 @@ fn get_item<'a>( fn main() { let path = "input.rs"; generate_input(&path).unwrap(); - let args = vec![ + let args = &[ "rustc".to_string(), "--crate-type=lib".to_string(), "--crate-name".to_string(), diff --git a/tests/ui-fulldeps/stable-mir/projections.rs b/tests/ui-fulldeps/stable-mir/projections.rs index f3bd894ac69..103c97bc48e 100644 --- a/tests/ui-fulldeps/stable-mir/projections.rs +++ b/tests/ui-fulldeps/stable-mir/projections.rs @@ -146,7 +146,7 @@ fn get_item<'a>( fn main() { let path = "input.rs"; generate_input(&path).unwrap(); - let args = vec![ + let args = &[ "rustc".to_string(), "--crate-type=lib".to_string(), "--crate-name".to_string(), diff --git a/tests/ui-fulldeps/stable-mir/smir_internal.rs b/tests/ui-fulldeps/stable-mir/smir_internal.rs index f9972dc27e3..0519b9de680 100644 --- a/tests/ui-fulldeps/stable-mir/smir_internal.rs +++ b/tests/ui-fulldeps/stable-mir/smir_internal.rs @@ -40,7 +40,7 @@ fn test_translation(tcx: TyCtxt<'_>) -> ControlFlow<()> { fn main() { let path = "internal_input.rs"; generate_input(&path).unwrap(); - let args = vec![ + let args = &[ "rustc".to_string(), "--crate-name".to_string(), CRATE_NAME.to_string(), diff --git a/tests/ui-fulldeps/stable-mir/smir_serde.rs b/tests/ui-fulldeps/stable-mir/smir_serde.rs index 3b3d743ad32..0b39ec05002 100644 --- a/tests/ui-fulldeps/stable-mir/smir_serde.rs +++ b/tests/ui-fulldeps/stable-mir/smir_serde.rs @@ -46,7 +46,7 @@ fn serialize_to_json(_tcx: TyCtxt<'_>) -> ControlFlow<()> { fn main() { let path = "internal_input.rs"; generate_input(&path).unwrap(); - let args = vec![ + let args = &[ "rustc".to_string(), "--crate-name".to_string(), CRATE_NAME.to_string(), diff --git a/tests/ui-fulldeps/stable-mir/smir_visitor.rs b/tests/ui-fulldeps/stable-mir/smir_visitor.rs index d225d9773fe..caf71de2556 100644 --- a/tests/ui-fulldeps/stable-mir/smir_visitor.rs +++ b/tests/ui-fulldeps/stable-mir/smir_visitor.rs @@ -183,14 +183,14 @@ impl mir::MutMirVisitor for TestMutVisitor { fn main() { let path = "sim_visitor_input.rs"; generate_input(&path).unwrap(); - let args = vec![ + let args = &[ "rustc".to_string(), "-Cpanic=abort".to_string(), "--crate-name".to_string(), CRATE_NAME.to_string(), path.to_string(), ]; - run!(args.clone(), test_visitor).unwrap(); + run!(args, test_visitor).unwrap(); run!(args, test_mut_visitor).unwrap(); } diff --git a/tests/ui/abi/compatibility.rs b/tests/ui/abi/compatibility.rs index be649029c86..68706f1e821 100644 --- a/tests/ui/abi/compatibility.rs +++ b/tests/ui/abi/compatibility.rs @@ -40,7 +40,6 @@ //@ revisions: loongarch64 //@[loongarch64] compile-flags: --target loongarch64-unknown-linux-gnu //@[loongarch64] needs-llvm-components: loongarch -//@[loongarch64] min-llvm-version: 20 //FIXME: wasm is disabled due to <https://github.com/rust-lang/rust/issues/115666>. //FIXME @ revisions: wasm //FIXME @[wasm] compile-flags: --target wasm32-unknown-unknown diff --git a/tests/ui/abi/simd-abi-checks-avx.rs b/tests/ui/abi/simd-abi-checks-avx.rs index c31af6460fc..772512702ec 100644 --- a/tests/ui/abi/simd-abi-checks-avx.rs +++ b/tests/ui/abi/simd-abi-checks-avx.rs @@ -1,6 +1,5 @@ //@ only-x86_64 -//@ build-pass -//@ ignore-pass (test emits codegen-time warnings) +//@ build-fail //@ compile-flags: -C target-feature=-avx #![feature(avx512_target_feature)] @@ -14,20 +13,17 @@ use std::arch::x86_64::*; struct Wrapper(__m256); unsafe extern "C" fn w(_: Wrapper) { - //~^ WARN requires the `avx` target feature, which is not enabled - //~| WARNING this was previously accepted by the compiler + //~^ ERROR: requires the `avx` target feature, which is not enabled todo!() } unsafe extern "C" fn f(_: __m256) { - //~^ WARN requires the `avx` target feature, which is not enabled - //~| WARNING this was previously accepted by the compiler + //~^ ERROR: requires the `avx` target feature, which is not enabled todo!() } unsafe extern "C" fn g() -> __m256 { - //~^ WARN requires the `avx` target feature, which is not enabled - //~| WARNING this was previously accepted by the compiler + //~^ ERROR: requires the `avx` target feature, which is not enabled todo!() } @@ -56,25 +52,20 @@ unsafe fn test() { unsafe fn in_closure() -> impl FnOnce() -> __m256 { #[inline(always)] // this disables target-feature inheritance || g() - //~^ WARNING requires the `avx` target feature, which is not enabled in the caller - //~| WARNING this was previously accepted by the compiler + //~^ ERROR requires the `avx` target feature, which is not enabled in the caller } fn main() { unsafe { f(g()); - //~^ WARNING requires the `avx` target feature, which is not enabled in the caller - //~| WARNING requires the `avx` target feature, which is not enabled in the caller - //~| WARNING this was previously accepted by the compiler - //~| WARNING this was previously accepted by the compiler + //~^ ERROR requires the `avx` target feature, which is not enabled in the caller + //~| ERROR requires the `avx` target feature, which is not enabled in the caller } unsafe { gavx(favx()); - //~^ WARNING requires the `avx` target feature, which is not enabled in the caller - //~| WARNING requires the `avx` target feature, which is not enabled in the caller - //~| WARNING this was previously accepted by the compiler - //~| WARNING this was previously accepted by the compiler + //~^ ERROR requires the `avx` target feature, which is not enabled in the caller + //~| ERROR requires the `avx` target feature, which is not enabled in the caller } unsafe { @@ -83,10 +74,8 @@ fn main() { unsafe { w(Wrapper(g())); - //~^ WARNING requires the `avx` target feature, which is not enabled in the caller - //~| WARNING requires the `avx` target feature, which is not enabled in the caller - //~| WARNING this was previously accepted by the compiler - //~| WARNING this was previously accepted by the compiler + //~^ ERROR requires the `avx` target feature, which is not enabled in the caller + //~| ERROR requires the `avx` target feature, which is not enabled in the caller } unsafe { @@ -99,8 +88,7 @@ fn main() { fn some_extern() -> __m256; } some_extern(); - //~^ WARNING requires the `avx` target feature, which is not enabled in the caller - //~| WARNING this was previously accepted by the compiler + //~^ ERROR requires the `avx` target feature, which is not enabled in the caller } } diff --git a/tests/ui/abi/simd-abi-checks-avx.stderr b/tests/ui/abi/simd-abi-checks-avx.stderr index 5419970f809..48db30bf453 100644 --- a/tests/ui/abi/simd-abi-checks-avx.stderr +++ b/tests/ui/abi/simd-abi-checks-avx.stderr @@ -1,245 +1,96 @@ -warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks-avx.rs:65:11 +error: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller + --> $DIR/simd-abi-checks-avx.rs:60:11 | LL | f(g()); | ^^^ function called 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) - = note: `#[warn(abi_unsupported_vector_types)]` on by default -warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks-avx.rs:65:9 +error: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller + --> $DIR/simd-abi-checks-avx.rs:60:9 | LL | f(g()); | ^^^^^^ function called 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) -warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks-avx.rs:73:14 +error: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller + --> $DIR/simd-abi-checks-avx.rs:66:14 | LL | gavx(favx()); | ^^^^^^ function called 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) -warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks-avx.rs:73:9 +error: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller + --> $DIR/simd-abi-checks-avx.rs:66:9 | LL | gavx(favx()); | ^^^^^^^^^^^^ function called 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) -warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks-avx.rs:85:19 +error: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller + --> $DIR/simd-abi-checks-avx.rs:76:19 | LL | w(Wrapper(g())); | ^^^ function called 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) -warning: this function call uses SIMD vector type `Wrapper` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks-avx.rs:85:9 +error: this function call uses SIMD vector type `Wrapper` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller + --> $DIR/simd-abi-checks-avx.rs:76:9 | LL | w(Wrapper(g())); | ^^^^^^^^^^^^^^^ function called 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) -warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks-avx.rs:101:9 +error: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller + --> $DIR/simd-abi-checks-avx.rs:90:9 | LL | some_extern(); | ^^^^^^^^^^^^^ function called 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) -warning: this function definition uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled - --> $DIR/simd-abi-checks-avx.rs:28:1 +error: this function definition uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled + --> $DIR/simd-abi-checks-avx.rs:25:1 | LL | unsafe extern "C" fn g() -> __m256 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) -warning: this function definition uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled - --> $DIR/simd-abi-checks-avx.rs:22:1 +error: this function definition uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled + --> $DIR/simd-abi-checks-avx.rs:20:1 | LL | unsafe extern "C" fn f(_: __m256) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) -warning: this function definition uses SIMD vector type `Wrapper` which (with the chosen ABI) requires the `avx` target feature, which is not enabled - --> $DIR/simd-abi-checks-avx.rs:16:1 +error: this function definition uses SIMD vector type `Wrapper` which (with the chosen ABI) requires the `avx` target feature, which is not enabled + --> $DIR/simd-abi-checks-avx.rs:15:1 | LL | unsafe extern "C" fn w(_: Wrapper) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) -warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks-avx.rs:58:8 +error: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller + --> $DIR/simd-abi-checks-avx.rs:54:8 | LL | || g() | ^^^ function called 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) -warning: 11 warnings emitted - -Future incompatibility report: Future breakage diagnostic: -warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks-avx.rs:65:11 - | -LL | f(g()); - | ^^^ function called 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) - = note: `#[warn(abi_unsupported_vector_types)]` on by default - -Future breakage diagnostic: -warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks-avx.rs:65:9 - | -LL | f(g()); - | ^^^^^^ function called 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) - = note: `#[warn(abi_unsupported_vector_types)]` on by default - -Future breakage diagnostic: -warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks-avx.rs:73:14 - | -LL | gavx(favx()); - | ^^^^^^ function called 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) - = note: `#[warn(abi_unsupported_vector_types)]` on by default - -Future breakage diagnostic: -warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks-avx.rs:73:9 - | -LL | gavx(favx()); - | ^^^^^^^^^^^^ function called 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) - = note: `#[warn(abi_unsupported_vector_types)]` on by default - -Future breakage diagnostic: -warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks-avx.rs:85:19 - | -LL | w(Wrapper(g())); - | ^^^ function called 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) - = note: `#[warn(abi_unsupported_vector_types)]` on by default - -Future breakage diagnostic: -warning: this function call uses SIMD vector type `Wrapper` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks-avx.rs:85:9 - | -LL | w(Wrapper(g())); - | ^^^^^^^^^^^^^^^ function called 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) - = note: `#[warn(abi_unsupported_vector_types)]` on by default - -Future breakage diagnostic: -warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks-avx.rs:101:9 - | -LL | some_extern(); - | ^^^^^^^^^^^^^ function called 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) - = note: `#[warn(abi_unsupported_vector_types)]` on by default - -Future breakage diagnostic: -warning: this function definition uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled - --> $DIR/simd-abi-checks-avx.rs:28:1 - | -LL | unsafe extern "C" fn g() -> __m256 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) - = note: `#[warn(abi_unsupported_vector_types)]` on by default - -Future breakage diagnostic: -warning: this function definition uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled - --> $DIR/simd-abi-checks-avx.rs:22:1 - | -LL | unsafe extern "C" fn f(_: __m256) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) - = note: `#[warn(abi_unsupported_vector_types)]` on by default - -Future breakage diagnostic: -warning: this function definition uses SIMD vector type `Wrapper` which (with the chosen ABI) requires the `avx` target feature, which is not enabled - --> $DIR/simd-abi-checks-avx.rs:16:1 - | -LL | unsafe extern "C" fn w(_: Wrapper) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here +note: the above error was encountered while instantiating `fn in_closure::{closure#0}` + --> $DIR/simd-abi-checks-avx.rs:82:9 | - = 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) - = note: `#[warn(abi_unsupported_vector_types)]` on by default +LL | in_closure()(); + | ^^^^^^^^^^^^^^ -Future breakage diagnostic: -warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks-avx.rs:58:8 - | -LL | || g() - | ^^^ function called 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) - = note: `#[warn(abi_unsupported_vector_types)]` on by default +error: aborting due to 11 previous errors diff --git a/tests/ui/abi/simd-abi-checks-empty-list.rs b/tests/ui/abi/simd-abi-checks-empty-list.rs index ba1b38af5b3..d00445b29e0 100644 --- a/tests/ui/abi/simd-abi-checks-empty-list.rs +++ b/tests/ui/abi/simd-abi-checks-empty-list.rs @@ -1,8 +1,9 @@ +//! At the time of writing, the list of "which target feature enables which vector size" is empty +//! for SPARC. Ensure that this leads to all vector sizes causing an error. //@ add-core-stubs //@ needs-llvm-components: sparc //@ compile-flags: --target=sparc-unknown-none-elf --crate-type=rlib -//@ build-pass -//@ ignore-pass (test emits codegen-time warnings) +//@ build-fail #![no_core] #![feature(no_core, repr_simd)] #![allow(improper_ctypes_definitions)] @@ -14,5 +15,4 @@ use minicore::*; pub struct SimdVec([i32; 4]); pub extern "C" fn pass_by_vec(_: SimdVec) {} -//~^ WARN this function definition uses SIMD vector type `SimdVec` which is not currently supported with the chosen ABI -//~| WARNING this was previously accepted by the compiler +//~^ ERROR: this function definition uses SIMD vector type `SimdVec` which is not currently supported with the chosen ABI diff --git a/tests/ui/abi/simd-abi-checks-empty-list.stderr b/tests/ui/abi/simd-abi-checks-empty-list.stderr index 111dda42f33..780afb3844f 100644 --- a/tests/ui/abi/simd-abi-checks-empty-list.stderr +++ b/tests/ui/abi/simd-abi-checks-empty-list.stderr @@ -1,23 +1,8 @@ -warning: this function definition uses SIMD vector type `SimdVec` which is not currently supported with the chosen ABI - --> $DIR/simd-abi-checks-empty-list.rs:16:1 +error: this function definition uses SIMD vector type `SimdVec` which is not currently supported with the chosen ABI + --> $DIR/simd-abi-checks-empty-list.rs:17:1 | LL | pub extern "C" fn pass_by_vec(_: SimdVec) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = note: `#[warn(abi_unsupported_vector_types)]` on by default - -warning: 1 warning emitted -Future incompatibility report: Future breakage diagnostic: -warning: this function definition uses SIMD vector type `SimdVec` which is not currently supported with the chosen ABI - --> $DIR/simd-abi-checks-empty-list.rs:16:1 - | -LL | pub extern "C" fn pass_by_vec(_: SimdVec) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = note: `#[warn(abi_unsupported_vector_types)]` on by default +error: aborting due to 1 previous error diff --git a/tests/ui/abi/simd-abi-checks-s390x.rs b/tests/ui/abi/simd-abi-checks-s390x.rs index 3743c75bf1e..2d4eb7a350f 100644 --- a/tests/ui/abi/simd-abi-checks-s390x.rs +++ b/tests/ui/abi/simd-abi-checks-s390x.rs @@ -13,7 +13,6 @@ #![no_core] #![crate_type = "lib"] #![allow(non_camel_case_types, improper_ctypes_definitions)] -#![deny(abi_unsupported_vector_types)] extern crate minicore; use minicore::*; @@ -38,13 +37,11 @@ impl<T: Copy> Copy for TransparentWrapper<T> {} #[no_mangle] extern "C" fn vector_ret_small(x: &i8x8) -> i8x8 { //~^ ERROR requires the `vector` target feature, which is not enabled - //~^^ WARN this was previously accepted *x } #[no_mangle] extern "C" fn vector_ret(x: &i8x16) -> i8x16 { //~^ ERROR requires the `vector` target feature, which is not enabled - //~^^ WARN this was previously accepted *x } #[no_mangle] @@ -93,7 +90,6 @@ extern "C" fn vector_transparent_wrapper_ret_small( x: &TransparentWrapper<i8x8>, ) -> TransparentWrapper<i8x8> { //~^^^ ERROR requires the `vector` target feature, which is not enabled - //~^^^^ WARN this was previously accepted *x } #[no_mangle] @@ -101,7 +97,6 @@ extern "C" fn vector_transparent_wrapper_ret( x: &TransparentWrapper<i8x16>, ) -> TransparentWrapper<i8x16> { //~^^^ ERROR requires the `vector` target feature, which is not enabled - //~^^^^ WARN this was previously accepted *x } #[no_mangle] @@ -115,13 +110,11 @@ extern "C" fn vector_transparent_wrapper_ret_large( #[no_mangle] extern "C" fn vector_arg_small(x: i8x8) -> i64 { //~^ ERROR requires the `vector` target feature, which is not enabled - //~^^ WARN this was previously accepted unsafe { *(&x as *const i8x8 as *const i64) } } #[no_mangle] extern "C" fn vector_arg(x: i8x16) -> i64 { //~^ ERROR requires the `vector` target feature, which is not enabled - //~^^ WARN this was previously accepted unsafe { *(&x as *const i8x16 as *const i64) } } #[no_mangle] @@ -133,13 +126,11 @@ extern "C" fn vector_arg_large(x: i8x32) -> i64 { #[no_mangle] extern "C" fn vector_wrapper_arg_small(x: Wrapper<i8x8>) -> i64 { //~^ ERROR requires the `vector` target feature, which is not enabled - //~^^ WARN this was previously accepted unsafe { *(&x as *const Wrapper<i8x8> as *const i64) } } #[no_mangle] extern "C" fn vector_wrapper_arg(x: Wrapper<i8x16>) -> i64 { //~^ ERROR requires the `vector` target feature, which is not enabled - //~^^ WARN this was previously accepted unsafe { *(&x as *const Wrapper<i8x16> as *const i64) } } #[no_mangle] @@ -151,13 +142,11 @@ extern "C" fn vector_wrapper_arg_large(x: Wrapper<i8x32>) -> i64 { #[no_mangle] extern "C" fn vector_transparent_wrapper_arg_small(x: TransparentWrapper<i8x8>) -> i64 { //~^ ERROR requires the `vector` target feature, which is not enabled - //~^^ WARN this was previously accepted unsafe { *(&x as *const TransparentWrapper<i8x8> as *const i64) } } #[no_mangle] extern "C" fn vector_transparent_wrapper_arg(x: TransparentWrapper<i8x16>) -> i64 { //~^ ERROR requires the `vector` target feature, which is not enabled - //~^^ WARN this was previously accepted unsafe { *(&x as *const TransparentWrapper<i8x16> as *const i64) } } #[no_mangle] diff --git a/tests/ui/abi/simd-abi-checks-s390x.z10.stderr b/tests/ui/abi/simd-abi-checks-s390x.z10.stderr index d2f7abb7c32..c1c4e90f3cf 100644 --- a/tests/ui/abi/simd-abi-checks-s390x.z10.stderr +++ b/tests/ui/abi/simd-abi-checks-s390x.z10.stderr @@ -1,275 +1,86 @@ error: this function definition uses SIMD vector type `i8x8` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:39:1 + --> $DIR/simd-abi-checks-s390x.rs:38:1 | LL | extern "C" fn vector_ret_small(x: &i8x8) -> i8x8 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this function definition uses SIMD vector type `i8x16` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:45:1 + --> $DIR/simd-abi-checks-s390x.rs:43:1 | LL | extern "C" fn vector_ret(x: &i8x16) -> i8x16 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: this function definition uses SIMD vector type `TransparentWrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:92:1 + --> $DIR/simd-abi-checks-s390x.rs:89:1 | LL | / extern "C" fn vector_transparent_wrapper_ret_small( LL | | x: &TransparentWrapper<i8x8>, LL | | ) -> TransparentWrapper<i8x8> { | |_____________________________^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: this function definition uses SIMD vector type `TransparentWrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:100:1 + --> $DIR/simd-abi-checks-s390x.rs:96:1 | LL | / extern "C" fn vector_transparent_wrapper_ret( LL | | x: &TransparentWrapper<i8x16>, LL | | ) -> TransparentWrapper<i8x16> { | |______________________________^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: this function definition uses SIMD vector type `i8x8` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:116:1 + --> $DIR/simd-abi-checks-s390x.rs:111:1 | LL | extern "C" fn vector_arg_small(x: i8x8) -> i64 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: this function definition uses SIMD vector type `i8x16` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:122:1 + --> $DIR/simd-abi-checks-s390x.rs:116:1 | LL | extern "C" fn vector_arg(x: i8x16) -> i64 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: this function definition uses SIMD vector type `Wrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:134:1 + --> $DIR/simd-abi-checks-s390x.rs:127:1 | LL | extern "C" fn vector_wrapper_arg_small(x: Wrapper<i8x8>) -> i64 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: this function definition uses SIMD vector type `Wrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:140:1 + --> $DIR/simd-abi-checks-s390x.rs:132:1 | LL | extern "C" fn vector_wrapper_arg(x: Wrapper<i8x16>) -> i64 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: this function definition uses SIMD vector type `TransparentWrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:152:1 + --> $DIR/simd-abi-checks-s390x.rs:143:1 | LL | extern "C" fn vector_transparent_wrapper_arg_small(x: TransparentWrapper<i8x8>) -> i64 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: this function definition uses SIMD vector type `TransparentWrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:158:1 + --> $DIR/simd-abi-checks-s390x.rs:148:1 | LL | extern "C" fn vector_transparent_wrapper_arg(x: TransparentWrapper<i8x16>) -> i64 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: aborting due to 10 previous errors -Future incompatibility report: Future breakage diagnostic: -error: this function definition uses SIMD vector type `i8x8` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:39:1 - | -LL | extern "C" fn vector_ret_small(x: &i8x8) -> i8x8 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `i8x16` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:45:1 - | -LL | extern "C" fn vector_ret(x: &i8x16) -> i8x16 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `TransparentWrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:92:1 - | -LL | / extern "C" fn vector_transparent_wrapper_ret_small( -LL | | x: &TransparentWrapper<i8x8>, -LL | | ) -> TransparentWrapper<i8x8> { - | |_____________________________^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `TransparentWrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:100:1 - | -LL | / extern "C" fn vector_transparent_wrapper_ret( -LL | | x: &TransparentWrapper<i8x16>, -LL | | ) -> TransparentWrapper<i8x16> { - | |______________________________^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `i8x8` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:116:1 - | -LL | extern "C" fn vector_arg_small(x: i8x8) -> i64 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `i8x16` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:122:1 - | -LL | extern "C" fn vector_arg(x: i8x16) -> i64 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `Wrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:134:1 - | -LL | extern "C" fn vector_wrapper_arg_small(x: Wrapper<i8x8>) -> i64 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `Wrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:140:1 - | -LL | extern "C" fn vector_wrapper_arg(x: Wrapper<i8x16>) -> i64 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `TransparentWrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:152:1 - | -LL | extern "C" fn vector_transparent_wrapper_arg_small(x: TransparentWrapper<i8x8>) -> i64 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `TransparentWrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:158:1 - | -LL | extern "C" fn vector_transparent_wrapper_arg(x: TransparentWrapper<i8x16>) -> i64 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - diff --git a/tests/ui/abi/simd-abi-checks-s390x.z13_no_vector.stderr b/tests/ui/abi/simd-abi-checks-s390x.z13_no_vector.stderr index d2f7abb7c32..c1c4e90f3cf 100644 --- a/tests/ui/abi/simd-abi-checks-s390x.z13_no_vector.stderr +++ b/tests/ui/abi/simd-abi-checks-s390x.z13_no_vector.stderr @@ -1,275 +1,86 @@ error: this function definition uses SIMD vector type `i8x8` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:39:1 + --> $DIR/simd-abi-checks-s390x.rs:38:1 | LL | extern "C" fn vector_ret_small(x: &i8x8) -> i8x8 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this function definition uses SIMD vector type `i8x16` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:45:1 + --> $DIR/simd-abi-checks-s390x.rs:43:1 | LL | extern "C" fn vector_ret(x: &i8x16) -> i8x16 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: this function definition uses SIMD vector type `TransparentWrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:92:1 + --> $DIR/simd-abi-checks-s390x.rs:89:1 | LL | / extern "C" fn vector_transparent_wrapper_ret_small( LL | | x: &TransparentWrapper<i8x8>, LL | | ) -> TransparentWrapper<i8x8> { | |_____________________________^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: this function definition uses SIMD vector type `TransparentWrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:100:1 + --> $DIR/simd-abi-checks-s390x.rs:96:1 | LL | / extern "C" fn vector_transparent_wrapper_ret( LL | | x: &TransparentWrapper<i8x16>, LL | | ) -> TransparentWrapper<i8x16> { | |______________________________^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: this function definition uses SIMD vector type `i8x8` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:116:1 + --> $DIR/simd-abi-checks-s390x.rs:111:1 | LL | extern "C" fn vector_arg_small(x: i8x8) -> i64 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: this function definition uses SIMD vector type `i8x16` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:122:1 + --> $DIR/simd-abi-checks-s390x.rs:116:1 | LL | extern "C" fn vector_arg(x: i8x16) -> i64 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: this function definition uses SIMD vector type `Wrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:134:1 + --> $DIR/simd-abi-checks-s390x.rs:127:1 | LL | extern "C" fn vector_wrapper_arg_small(x: Wrapper<i8x8>) -> i64 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: this function definition uses SIMD vector type `Wrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:140:1 + --> $DIR/simd-abi-checks-s390x.rs:132:1 | LL | extern "C" fn vector_wrapper_arg(x: Wrapper<i8x16>) -> i64 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: this function definition uses SIMD vector type `TransparentWrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:152:1 + --> $DIR/simd-abi-checks-s390x.rs:143:1 | LL | extern "C" fn vector_transparent_wrapper_arg_small(x: TransparentWrapper<i8x8>) -> i64 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: this function definition uses SIMD vector type `TransparentWrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:158:1 + --> $DIR/simd-abi-checks-s390x.rs:148:1 | LL | extern "C" fn vector_transparent_wrapper_arg(x: TransparentWrapper<i8x16>) -> i64 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: aborting due to 10 previous errors -Future incompatibility report: Future breakage diagnostic: -error: this function definition uses SIMD vector type `i8x8` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:39:1 - | -LL | extern "C" fn vector_ret_small(x: &i8x8) -> i8x8 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `i8x16` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:45:1 - | -LL | extern "C" fn vector_ret(x: &i8x16) -> i8x16 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `TransparentWrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:92:1 - | -LL | / extern "C" fn vector_transparent_wrapper_ret_small( -LL | | x: &TransparentWrapper<i8x8>, -LL | | ) -> TransparentWrapper<i8x8> { - | |_____________________________^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `TransparentWrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:100:1 - | -LL | / extern "C" fn vector_transparent_wrapper_ret( -LL | | x: &TransparentWrapper<i8x16>, -LL | | ) -> TransparentWrapper<i8x16> { - | |______________________________^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `i8x8` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:116:1 - | -LL | extern "C" fn vector_arg_small(x: i8x8) -> i64 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `i8x16` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:122:1 - | -LL | extern "C" fn vector_arg(x: i8x16) -> i64 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `Wrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:134:1 - | -LL | extern "C" fn vector_wrapper_arg_small(x: Wrapper<i8x8>) -> i64 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `Wrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:140:1 - | -LL | extern "C" fn vector_wrapper_arg(x: Wrapper<i8x16>) -> i64 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `TransparentWrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:152:1 - | -LL | extern "C" fn vector_transparent_wrapper_arg_small(x: TransparentWrapper<i8x8>) -> i64 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `TransparentWrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:158:1 - | -LL | extern "C" fn vector_transparent_wrapper_arg(x: TransparentWrapper<i8x16>) -> i64 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - diff --git a/tests/ui/abi/simd-abi-checks-s390x.z13_soft_float.stderr b/tests/ui/abi/simd-abi-checks-s390x.z13_soft_float.stderr index d2f7abb7c32..c1c4e90f3cf 100644 --- a/tests/ui/abi/simd-abi-checks-s390x.z13_soft_float.stderr +++ b/tests/ui/abi/simd-abi-checks-s390x.z13_soft_float.stderr @@ -1,275 +1,86 @@ error: this function definition uses SIMD vector type `i8x8` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:39:1 + --> $DIR/simd-abi-checks-s390x.rs:38:1 | LL | extern "C" fn vector_ret_small(x: &i8x8) -> i8x8 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this function definition uses SIMD vector type `i8x16` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:45:1 + --> $DIR/simd-abi-checks-s390x.rs:43:1 | LL | extern "C" fn vector_ret(x: &i8x16) -> i8x16 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: this function definition uses SIMD vector type `TransparentWrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:92:1 + --> $DIR/simd-abi-checks-s390x.rs:89:1 | LL | / extern "C" fn vector_transparent_wrapper_ret_small( LL | | x: &TransparentWrapper<i8x8>, LL | | ) -> TransparentWrapper<i8x8> { | |_____________________________^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: this function definition uses SIMD vector type `TransparentWrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:100:1 + --> $DIR/simd-abi-checks-s390x.rs:96:1 | LL | / extern "C" fn vector_transparent_wrapper_ret( LL | | x: &TransparentWrapper<i8x16>, LL | | ) -> TransparentWrapper<i8x16> { | |______________________________^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: this function definition uses SIMD vector type `i8x8` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:116:1 + --> $DIR/simd-abi-checks-s390x.rs:111:1 | LL | extern "C" fn vector_arg_small(x: i8x8) -> i64 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: this function definition uses SIMD vector type `i8x16` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:122:1 + --> $DIR/simd-abi-checks-s390x.rs:116:1 | LL | extern "C" fn vector_arg(x: i8x16) -> i64 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: this function definition uses SIMD vector type `Wrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:134:1 + --> $DIR/simd-abi-checks-s390x.rs:127:1 | LL | extern "C" fn vector_wrapper_arg_small(x: Wrapper<i8x8>) -> i64 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: this function definition uses SIMD vector type `Wrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:140:1 + --> $DIR/simd-abi-checks-s390x.rs:132:1 | LL | extern "C" fn vector_wrapper_arg(x: Wrapper<i8x16>) -> i64 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: this function definition uses SIMD vector type `TransparentWrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:152:1 + --> $DIR/simd-abi-checks-s390x.rs:143:1 | LL | extern "C" fn vector_transparent_wrapper_arg_small(x: TransparentWrapper<i8x8>) -> i64 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: this function definition uses SIMD vector type `TransparentWrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:158:1 + --> $DIR/simd-abi-checks-s390x.rs:148:1 | LL | extern "C" fn vector_transparent_wrapper_arg(x: TransparentWrapper<i8x16>) -> i64 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) error: aborting due to 10 previous errors -Future incompatibility report: Future breakage diagnostic: -error: this function definition uses SIMD vector type `i8x8` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:39:1 - | -LL | extern "C" fn vector_ret_small(x: &i8x8) -> i8x8 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `i8x16` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:45:1 - | -LL | extern "C" fn vector_ret(x: &i8x16) -> i8x16 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `TransparentWrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:92:1 - | -LL | / extern "C" fn vector_transparent_wrapper_ret_small( -LL | | x: &TransparentWrapper<i8x8>, -LL | | ) -> TransparentWrapper<i8x8> { - | |_____________________________^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `TransparentWrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:100:1 - | -LL | / extern "C" fn vector_transparent_wrapper_ret( -LL | | x: &TransparentWrapper<i8x16>, -LL | | ) -> TransparentWrapper<i8x16> { - | |______________________________^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `i8x8` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:116:1 - | -LL | extern "C" fn vector_arg_small(x: i8x8) -> i64 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `i8x16` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:122:1 - | -LL | extern "C" fn vector_arg(x: i8x16) -> i64 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `Wrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:134:1 - | -LL | extern "C" fn vector_wrapper_arg_small(x: Wrapper<i8x8>) -> i64 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `Wrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:140:1 - | -LL | extern "C" fn vector_wrapper_arg(x: Wrapper<i8x16>) -> i64 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `TransparentWrapper<i8x8>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:152:1 - | -LL | extern "C" fn vector_transparent_wrapper_arg_small(x: TransparentWrapper<i8x8>) -> i64 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: this function definition uses SIMD vector type `TransparentWrapper<i8x16>` which (with the chosen ABI) requires the `vector` target feature, which is not enabled - --> $DIR/simd-abi-checks-s390x.rs:158:1 - | -LL | extern "C" fn vector_transparent_wrapper_arg(x: TransparentWrapper<i8x16>) -> i64 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+vector`) or locally (`#[target_feature(enable="vector")]`) -note: the lint level is defined here - --> $DIR/simd-abi-checks-s390x.rs:16:9 - | -LL | #![deny(abi_unsupported_vector_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - diff --git a/tests/ui/abi/simd-abi-checks-sse.rs b/tests/ui/abi/simd-abi-checks-sse.rs index d5fa9c0c0a3..817f9b6d13b 100644 --- a/tests/ui/abi/simd-abi-checks-sse.rs +++ b/tests/ui/abi/simd-abi-checks-sse.rs @@ -3,8 +3,7 @@ //@ compile-flags: --crate-type=rlib --target=i586-unknown-linux-gnu //@ compile-flags: -Ctarget-cpu=pentium4 -C target-feature=-sse,-sse2 //@ add-core-stubs -//@ build-pass -//@ ignore-pass (test emits codegen-time warnings) +//@ build-fail //@ needs-llvm-components: x86 #![feature(no_core, repr_simd)] #![no_core] @@ -18,6 +17,5 @@ pub struct SseVector([i64; 2]); #[no_mangle] pub unsafe extern "C" fn f(_: SseVector) { - //~^ WARN this function definition uses SIMD vector type `SseVector` which (with the chosen ABI) requires the `sse` target feature, which is not enabled - //~| WARNING this was previously accepted by the compiler + //~^ ERROR: this function definition uses SIMD vector type `SseVector` which (with the chosen ABI) requires the `sse` target feature, which is not enabled } diff --git a/tests/ui/abi/simd-abi-checks-sse.stderr b/tests/ui/abi/simd-abi-checks-sse.stderr index c0f2e6e1e1b..a5a2ba808c6 100644 --- a/tests/ui/abi/simd-abi-checks-sse.stderr +++ b/tests/ui/abi/simd-abi-checks-sse.stderr @@ -1,25 +1,10 @@ -warning: this function definition uses SIMD vector type `SseVector` which (with the chosen ABI) requires the `sse` target feature, which is not enabled - --> $DIR/simd-abi-checks-sse.rs:20:1 +error: this function definition uses SIMD vector type `SseVector` which (with the chosen ABI) requires the `sse` target feature, which is not enabled + --> $DIR/simd-abi-checks-sse.rs:19:1 | LL | pub unsafe extern "C" fn f(_: SseVector) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> = help: consider enabling it globally (`-C target-feature=+sse`) or locally (`#[target_feature(enable="sse")]`) - = note: `#[warn(abi_unsupported_vector_types)]` on by default -warning: 1 warning emitted - -Future incompatibility report: Future breakage diagnostic: -warning: this function definition uses SIMD vector type `SseVector` which (with the chosen ABI) requires the `sse` target feature, which is not enabled - --> $DIR/simd-abi-checks-sse.rs:20:1 - | -LL | pub unsafe extern "C" fn f(_: SseVector) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined 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 #116558 <https://github.com/rust-lang/rust/issues/116558> - = help: consider enabling it globally (`-C target-feature=+sse`) or locally (`#[target_feature(enable="sse")]`) - = note: `#[warn(abi_unsupported_vector_types)]` on by default +error: aborting due to 1 previous error diff --git a/tests/ui/array-slice-vec/array-not-vector.rs b/tests/ui/array-slice-vec/array-not-vector.rs index d8b5b10d591..7345f721918 100644 --- a/tests/ui/array-slice-vec/array-not-vector.rs +++ b/tests/ui/array-slice-vec/array-not-vector.rs @@ -1,12 +1,14 @@ +//@ dont-require-annotations: NOTE + fn main() { let _x: i32 = [1, 2, 3]; //~^ ERROR mismatched types - //~| expected `i32`, found `[{integer}; 3]` + //~| NOTE expected `i32`, found `[{integer}; 3]` let x: &[i32] = &[1, 2, 3]; let _y: &i32 = x; //~^ ERROR mismatched types - //~| expected reference `&i32` - //~| found reference `&[i32]` - //~| expected `&i32`, found `&[i32]` + //~| NOTE expected reference `&i32` + //~| NOTE found reference `&[i32]` + //~| NOTE expected `&i32`, found `&[i32]` } diff --git a/tests/ui/array-slice-vec/array-not-vector.stderr b/tests/ui/array-slice-vec/array-not-vector.stderr index f20d99524dc..686c5dfe787 100644 --- a/tests/ui/array-slice-vec/array-not-vector.stderr +++ b/tests/ui/array-slice-vec/array-not-vector.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/array-not-vector.rs:2:19 + --> $DIR/array-not-vector.rs:4:19 | LL | let _x: i32 = [1, 2, 3]; | --- ^^^^^^^^^ expected `i32`, found `[{integer}; 3]` @@ -7,7 +7,7 @@ LL | let _x: i32 = [1, 2, 3]; | expected due to this error[E0308]: mismatched types - --> $DIR/array-not-vector.rs:7:20 + --> $DIR/array-not-vector.rs:9:20 | LL | let _y: &i32 = x; | ---- ^ expected `&i32`, found `&[i32]` diff --git a/tests/ui/array-slice-vec/slice-mut.rs b/tests/ui/array-slice-vec/slice-mut.rs index e9989f0f481..baa05c36a9d 100644 --- a/tests/ui/array-slice-vec/slice-mut.rs +++ b/tests/ui/array-slice-vec/slice-mut.rs @@ -6,7 +6,8 @@ fn main() { let y: &mut[_] = &x[2..4]; //~^ ERROR mismatched types - //~| expected mutable reference `&mut [_]` - //~| found reference `&[isize]` - //~| types differ in mutability + //~| NOTE expected mutable reference `&mut [_]` + //~| NOTE found reference `&[isize]` + //~| NOTE types differ in mutability + //~| NOTE expected due to this } diff --git a/tests/ui/asm/loongarch/bad-reg.loongarch64_lp64d.stderr b/tests/ui/asm/loongarch/bad-reg.loongarch64_lp64d.stderr index c88f3af7642..0e544119650 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:23:18 + --> $DIR/bad-reg.rs:22:18 | LL | asm!("", out("$r0") _); | ^^^^^^^^^^^^ error: invalid register `$tp`: reserved for TLS - --> $DIR/bad-reg.rs:25:18 + --> $DIR/bad-reg.rs:24: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:27:18 + --> $DIR/bad-reg.rs:26:18 | LL | asm!("", out("$sp") _); | ^^^^^^^^^^^^ error: invalid register `$r21`: reserved by the ABI - --> $DIR/bad-reg.rs:29:18 + --> $DIR/bad-reg.rs:28: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:31:18 + --> $DIR/bad-reg.rs:30: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:33:18 + --> $DIR/bad-reg.rs:32: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 cb8e55a9722..6d0410dc6a1 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:23:18 + --> $DIR/bad-reg.rs:22:18 | LL | asm!("", out("$r0") _); | ^^^^^^^^^^^^ error: invalid register `$tp`: reserved for TLS - --> $DIR/bad-reg.rs:25:18 + --> $DIR/bad-reg.rs:24: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:27:18 + --> $DIR/bad-reg.rs:26:18 | LL | asm!("", out("$sp") _); | ^^^^^^^^^^^^ error: invalid register `$r21`: reserved by the ABI - --> $DIR/bad-reg.rs:29:18 + --> $DIR/bad-reg.rs:28: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:31:18 + --> $DIR/bad-reg.rs:30: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:33:18 + --> $DIR/bad-reg.rs:32:18 | LL | asm!("", out("$r31") _); | ^^^^^^^^^^^^^ error: register class `freg` requires at least one of the following target features: d, f - --> $DIR/bad-reg.rs:37:26 + --> $DIR/bad-reg.rs:36: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:39:26 + --> $DIR/bad-reg.rs:38:26 | LL | asm!("/* {} */", out(freg) _); | ^^^^^^^^^^^ error: register class `freg` requires at least one of the following target features: d, f - --> $DIR/bad-reg.rs:41:26 + --> $DIR/bad-reg.rs:40: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:43:26 + --> $DIR/bad-reg.rs:42: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 db1c778e5a2..685b460bc92 100644 --- a/tests/ui/asm/loongarch/bad-reg.rs +++ b/tests/ui/asm/loongarch/bad-reg.rs @@ -1,7 +1,6 @@ //@ add-core-stubs //@ needs-asm-support //@ revisions: loongarch64_lp64d loongarch64_lp64s -//@ min-llvm-version: 20 //@[loongarch64_lp64d] compile-flags: --target loongarch64-unknown-linux-gnu //@[loongarch64_lp64d] needs-llvm-components: loongarch //@[loongarch64_lp64s] compile-flags: --target loongarch64-unknown-none-softfloat diff --git a/tests/ui/asm/naked-functions.rs b/tests/ui/asm/naked-functions.rs index 1eeb716e98a..cb5fde9a80b 100644 --- a/tests/ui/asm/naked-functions.rs +++ b/tests/ui/asm/naked-functions.rs @@ -2,7 +2,7 @@ //@ ignore-nvptx64 //@ ignore-spirv -#![feature(asm_unwind, linkage)] +#![feature(asm_unwind, linkage, rustc_attrs)] #![crate_type = "lib"] use std::arch::{asm, naked_asm}; @@ -225,3 +225,9 @@ pub extern "C" fn compatible_doc_attributes() { pub extern "C" fn compatible_linkage() { naked_asm!("", options(raw)); } + +#[rustc_std_internal_symbol] +#[unsafe(naked)] +pub extern "C" fn rustc_std_internal_symbol() { + naked_asm!("", options(raw)); +} diff --git a/tests/ui/asm/naked-invalid-attr.rs b/tests/ui/asm/naked-invalid-attr.rs index c3a3131ee46..6ac9cb9e3a9 100644 --- a/tests/ui/asm/naked-invalid-attr.rs +++ b/tests/ui/asm/naked-invalid-attr.rs @@ -51,3 +51,12 @@ fn main() { #[unsafe(naked)] //~ ERROR should be applied to a function definition || {}; } + +// Check that the path of an attribute without a name is printed correctly (issue #140082) +#[::a] +//~^ ERROR attribute incompatible with `#[unsafe(naked)]` +//~| ERROR failed to resolve: use of unresolved module or unlinked crate `a` +#[unsafe(naked)] +extern "C" fn issue_140082() { + naked_asm!("") +} diff --git a/tests/ui/asm/naked-invalid-attr.stderr b/tests/ui/asm/naked-invalid-attr.stderr index 81d30e6475d..ef389e7d921 100644 --- a/tests/ui/asm/naked-invalid-attr.stderr +++ b/tests/ui/asm/naked-invalid-attr.stderr @@ -1,3 +1,9 @@ +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `a` + --> $DIR/naked-invalid-attr.rs:56:5 + | +LL | #[::a] + | ^ use of unresolved module or unlinked crate `a` + error: attribute should be applied to a function definition --> $DIR/naked-invalid-attr.rs:13:1 | @@ -27,6 +33,15 @@ LL | #[unsafe(naked)] LL | || {}; | ----- not a function definition +error[E0736]: attribute incompatible with `#[unsafe(naked)]` + --> $DIR/naked-invalid-attr.rs:56:1 + | +LL | #[::a] + | ^^^^^^ the `{{root}}::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:22:5 | @@ -49,5 +64,7 @@ error: attribute should be applied to a function definition LL | #![unsafe(naked)] | ^^^^^^^^^^^^^^^^^ cannot be applied to crates -error: aborting due to 6 previous errors +error: aborting due to 8 previous errors +Some errors have detailed explanations: E0433, E0736. +For more information about an error, try `rustc --explain E0433`. diff --git a/tests/ui/asm/named_const_simd_vec_len.rs b/tests/ui/asm/named_const_simd_vec_len.rs index 7df4d922d5c..7fedeb7d4d1 100644 --- a/tests/ui/asm/named_const_simd_vec_len.rs +++ b/tests/ui/asm/named_const_simd_vec_len.rs @@ -3,6 +3,9 @@ //@ only-x86_64 //@ check-pass +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver #![feature(repr_simd)] diff --git a/tests/ui/asm/normalizable-asm-ty.rs b/tests/ui/asm/normalizable-asm-ty.rs new file mode 100644 index 00000000000..c1f3f3ecd61 --- /dev/null +++ b/tests/ui/asm/normalizable-asm-ty.rs @@ -0,0 +1,16 @@ +//@ check-pass +//@ needs-asm-support +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver + +fn invoke(pc_section: &[usize]) { + unsafe { + std::arch::asm!( + "/* {} */", + in(reg) pc_section[0] + ); + } +} + +fn main() {} diff --git a/tests/ui/associated-consts/defaults-not-assumed-fail.rs b/tests/ui/associated-consts/defaults-not-assumed-fail.rs index 3dc709cf633..830fd4ab0e9 100644 --- a/tests/ui/associated-consts/defaults-not-assumed-fail.rs +++ b/tests/ui/associated-consts/defaults-not-assumed-fail.rs @@ -1,4 +1,5 @@ //@ build-fail +//@ dont-require-annotations: NOTE trait Tr { const A: u8 = 255; @@ -31,7 +32,7 @@ impl Tr for u32 { fn main() { assert_eq!(<() as Tr>::A, 255); assert_eq!(<() as Tr>::B, 0); // causes the error above - //~^ constant + //~^ NOTE constant assert_eq!(<u8 as Tr>::A, 254); assert_eq!(<u8 as Tr>::B, 255); diff --git a/tests/ui/associated-consts/defaults-not-assumed-fail.stderr b/tests/ui/associated-consts/defaults-not-assumed-fail.stderr index 4b53603cfe8..3386e81dc98 100644 --- a/tests/ui/associated-consts/defaults-not-assumed-fail.stderr +++ b/tests/ui/associated-consts/defaults-not-assumed-fail.stderr @@ -1,17 +1,17 @@ error[E0080]: evaluation of `<() as Tr>::B` failed - --> $DIR/defaults-not-assumed-fail.rs:8:19 + --> $DIR/defaults-not-assumed-fail.rs:9:19 | LL | const B: u8 = Self::A + 1; | ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow note: erroneous constant encountered - --> $DIR/defaults-not-assumed-fail.rs:33:16 + --> $DIR/defaults-not-assumed-fail.rs:34:16 | LL | assert_eq!(<() as Tr>::B, 0); // causes the error above | ^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/defaults-not-assumed-fail.rs:33:16 + --> $DIR/defaults-not-assumed-fail.rs:34:16 | LL | assert_eq!(<() as Tr>::B, 0); // causes the error above | ^^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | assert_eq!(<() as Tr>::B, 0); // causes the error above = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` note: erroneous constant encountered - --> $DIR/defaults-not-assumed-fail.rs:33:5 + --> $DIR/defaults-not-assumed-fail.rs:34:5 | LL | assert_eq!(<() as Tr>::B, 0); // causes the error above | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -27,7 +27,7 @@ LL | assert_eq!(<() as Tr>::B, 0); // causes the error above = note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) note: erroneous constant encountered - --> $DIR/defaults-not-assumed-fail.rs:33:5 + --> $DIR/defaults-not-assumed-fail.rs:34:5 | LL | assert_eq!(<() as Tr>::B, 0); // causes the error above | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/associated-types/associated-types-eq-3.rs b/tests/ui/associated-types/associated-types-eq-3.rs index 380d0e95c13..082a7325466 100644 --- a/tests/ui/associated-types/associated-types-eq-3.rs +++ b/tests/ui/associated-types/associated-types-eq-3.rs @@ -1,6 +1,8 @@ // Test equality constraints on associated types. Check we get type errors // where we should. +//@ dont-require-annotations: NOTE + pub trait Foo { type A; fn boo(&self) -> <Self as Foo>::A; @@ -22,9 +24,9 @@ fn foo1<I: Foo<A=Bar>>(x: I) { fn foo2<I: Foo>(x: I) { let _: Bar = x.boo(); //~^ ERROR mismatched types - //~| found associated type `<I as Foo>::A` - //~| expected `Bar`, found - //~| expected struct `Bar` + //~| NOTE found associated type `<I as Foo>::A` + //~| NOTE expected `Bar`, found + //~| NOTE expected struct `Bar` } diff --git a/tests/ui/associated-types/associated-types-eq-3.stderr b/tests/ui/associated-types/associated-types-eq-3.stderr index c3377eed20a..5fef2a020b8 100644 --- a/tests/ui/associated-types/associated-types-eq-3.stderr +++ b/tests/ui/associated-types/associated-types-eq-3.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/associated-types-eq-3.rs:23:18 + --> $DIR/associated-types-eq-3.rs:25:18 | LL | let _: Bar = x.boo(); | --- ^^^^^^^ expected `Bar`, found associated type @@ -14,7 +14,7 @@ LL | fn foo2<I: Foo<A = Bar>>(x: I) { | +++++++++ error[E0271]: type mismatch resolving `<isize as Foo>::A == Bar` - --> $DIR/associated-types-eq-3.rs:38:10 + --> $DIR/associated-types-eq-3.rs:40:10 | LL | foo1(a); | ---- ^ type mismatch resolving `<isize as Foo>::A == Bar` @@ -22,24 +22,24 @@ LL | foo1(a); | required by a bound introduced by this call | note: expected this to be `Bar` - --> $DIR/associated-types-eq-3.rs:12:14 + --> $DIR/associated-types-eq-3.rs:14:14 | LL | type A = usize; | ^^^^^ note: required by a bound in `foo1` - --> $DIR/associated-types-eq-3.rs:18:16 + --> $DIR/associated-types-eq-3.rs:20:16 | LL | fn foo1<I: Foo<A=Bar>>(x: I) { | ^^^^^ required by this bound in `foo1` error[E0271]: type mismatch resolving `<isize as Foo>::A == Bar` - --> $DIR/associated-types-eq-3.rs:40:9 + --> $DIR/associated-types-eq-3.rs:42:9 | LL | baz(&a); | ^^ type mismatch resolving `<isize as Foo>::A == Bar` | note: expected this to be `Bar` - --> $DIR/associated-types-eq-3.rs:12:14 + --> $DIR/associated-types-eq-3.rs:14:14 | LL | type A = usize; | ^^^^^ diff --git a/tests/ui/associated-types/associated-types-path-2.rs b/tests/ui/associated-types/associated-types-path-2.rs index c993e1d2720..b81aa990bcd 100644 --- a/tests/ui/associated-types/associated-types-path-2.rs +++ b/tests/ui/associated-types/associated-types-path-2.rs @@ -1,5 +1,7 @@ // Test type checking of uses of associated types via sugary paths. +//@ dont-require-annotations: NOTE + pub trait Foo { type A; @@ -18,7 +20,7 @@ pub fn f2<T: Foo>(a: T) -> T::A { pub fn f1_int_int() { f1(2i32, 4i32); //~^ ERROR mismatched types - //~| expected `u32`, found `i32` + //~| NOTE expected `u32`, found `i32` } pub fn f1_int_uint() { @@ -40,7 +42,7 @@ pub fn f1_uint_int() { pub fn f2_int() { let _: i32 = f2(2i32); //~^ ERROR mismatched types - //~| expected `i32`, found `u32` + //~| NOTE expected `i32`, found `u32` } pub fn main() { } diff --git a/tests/ui/associated-types/associated-types-path-2.stderr b/tests/ui/associated-types/associated-types-path-2.stderr index 897eb75e3e3..46e34b0809f 100644 --- a/tests/ui/associated-types/associated-types-path-2.stderr +++ b/tests/ui/associated-types/associated-types-path-2.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/associated-types-path-2.rs:19:14 + --> $DIR/associated-types-path-2.rs:21:14 | LL | f1(2i32, 4i32); | -- ^^^^ expected `u32`, found `i32` @@ -7,7 +7,7 @@ LL | f1(2i32, 4i32); | arguments to this function are incorrect | note: function defined here - --> $DIR/associated-types-path-2.rs:13:8 + --> $DIR/associated-types-path-2.rs:15:8 | LL | pub fn f1<T: Foo>(a: T, x: T::A) {} | ^^ ------- @@ -18,7 +18,7 @@ LL + f1(2i32, 4u32); | error[E0277]: the trait bound `u32: Foo` is not satisfied - --> $DIR/associated-types-path-2.rs:29:8 + --> $DIR/associated-types-path-2.rs:31:8 | LL | f1(2u32, 4u32); | -- ^^^^ the trait `Foo` is not implemented for `u32` @@ -27,13 +27,13 @@ LL | f1(2u32, 4u32); | = help: the trait `Foo` is implemented for `i32` note: required by a bound in `f1` - --> $DIR/associated-types-path-2.rs:13:14 + --> $DIR/associated-types-path-2.rs:15:14 | LL | pub fn f1<T: Foo>(a: T, x: T::A) {} | ^^^ required by this bound in `f1` error[E0277]: the trait bound `u32: Foo` is not satisfied - --> $DIR/associated-types-path-2.rs:29:14 + --> $DIR/associated-types-path-2.rs:31:14 | LL | f1(2u32, 4u32); | ^^^^ the trait `Foo` is not implemented for `u32` @@ -41,7 +41,7 @@ LL | f1(2u32, 4u32); = help: the trait `Foo` is implemented for `i32` error[E0277]: the trait bound `u32: Foo` is not satisfied - --> $DIR/associated-types-path-2.rs:35:8 + --> $DIR/associated-types-path-2.rs:37:8 | LL | f1(2u32, 4i32); | -- ^^^^ the trait `Foo` is not implemented for `u32` @@ -50,13 +50,13 @@ LL | f1(2u32, 4i32); | = help: the trait `Foo` is implemented for `i32` note: required by a bound in `f1` - --> $DIR/associated-types-path-2.rs:13:14 + --> $DIR/associated-types-path-2.rs:15:14 | LL | pub fn f1<T: Foo>(a: T, x: T::A) {} | ^^^ required by this bound in `f1` error[E0277]: the trait bound `u32: Foo` is not satisfied - --> $DIR/associated-types-path-2.rs:35:14 + --> $DIR/associated-types-path-2.rs:37:14 | LL | f1(2u32, 4i32); | ^^^^ the trait `Foo` is not implemented for `u32` @@ -64,7 +64,7 @@ LL | f1(2u32, 4i32); = help: the trait `Foo` is implemented for `i32` error[E0308]: mismatched types - --> $DIR/associated-types-path-2.rs:41:18 + --> $DIR/associated-types-path-2.rs:43:18 | LL | let _: i32 = f2(2i32); | --- ^^^^^^^^ expected `i32`, found `u32` diff --git a/tests/ui/associated-types/mismatch-two-relevant-impls.rs b/tests/ui/associated-types/mismatch-two-relevant-impls.rs new file mode 100644 index 00000000000..58fd567c278 --- /dev/null +++ b/tests/ui/associated-types/mismatch-two-relevant-impls.rs @@ -0,0 +1,20 @@ +trait Tr { + type Assoc; +} + +struct W<T>(T); + +impl Tr for W<i32> { + type Assoc = u32; +} + +impl Tr for W<u32> { + type Assoc = i32; +} + +fn needs_unit<T: Tr<Assoc = ()>>() {} + +fn main() { + needs_unit::<W<i32>>(); + //~^ ERROR type mismatch resolving `<W<i32> as Tr>::Assoc == ()` +} diff --git a/tests/ui/associated-types/mismatch-two-relevant-impls.stderr b/tests/ui/associated-types/mismatch-two-relevant-impls.stderr new file mode 100644 index 00000000000..2a1f3ef23ca --- /dev/null +++ b/tests/ui/associated-types/mismatch-two-relevant-impls.stderr @@ -0,0 +1,20 @@ +error[E0271]: type mismatch resolving `<W<i32> as Tr>::Assoc == ()` + --> $DIR/mismatch-two-relevant-impls.rs:18:18 + | +LL | needs_unit::<W<i32>>(); + | ^^^^^^ type mismatch resolving `<W<i32> as Tr>::Assoc == ()` + | +note: expected this to be `()` + --> $DIR/mismatch-two-relevant-impls.rs:8:18 + | +LL | type Assoc = u32; + | ^^^ +note: required by a bound in `needs_unit` + --> $DIR/mismatch-two-relevant-impls.rs:15:21 + | +LL | fn needs_unit<T: Tr<Assoc = ()>>() {} + | ^^^^^^^^^^ required by this bound in `needs_unit` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/associated-types/substs-ppaux.normal.stderr b/tests/ui/associated-types/substs-ppaux.normal.stderr index 1ea8ab23556..aa2aca7426e 100644 --- a/tests/ui/associated-types/substs-ppaux.normal.stderr +++ b/tests/ui/associated-types/substs-ppaux.normal.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/substs-ppaux.rs:23:17 + --> $DIR/substs-ppaux.rs:22:17 | LL | / fn bar<'a, T>() LL | | where @@ -19,7 +19,7 @@ LL | let x: () = <i8 as Foo<'static, 'static, u8>>::bar::<'static, char>(); | ++ error[E0308]: mismatched types - --> $DIR/substs-ppaux.rs:31:17 + --> $DIR/substs-ppaux.rs:30:17 | LL | / fn bar<'a, T>() LL | | where @@ -39,7 +39,7 @@ LL | let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>(); | ++ error[E0308]: mismatched types - --> $DIR/substs-ppaux.rs:39:17 + --> $DIR/substs-ppaux.rs:38:17 | LL | fn baz() {} | -------- associated function `baz` defined here @@ -57,7 +57,7 @@ LL | let x: () = <i8 as Foo<'static, 'static, u8>>::baz(); | ++ error[E0308]: mismatched types - --> $DIR/substs-ppaux.rs:47:17 + --> $DIR/substs-ppaux.rs:46:17 | LL | / fn foo<'z>() LL | | where @@ -77,13 +77,13 @@ LL | let x: () = foo::<'static>(); | ++ error[E0277]: the trait bound `str: Foo<'_, '_, u8>` is not satisfied - --> $DIR/substs-ppaux.rs:55:6 + --> $DIR/substs-ppaux.rs:54:6 | LL | <str as Foo<u8>>::bar; | ^^^ the trait `Sized` is not implemented for `str` | note: required for `str` to implement `Foo<'_, '_, u8>` - --> $DIR/substs-ppaux.rs:15:20 + --> $DIR/substs-ppaux.rs:14:20 | LL | impl<'a, 'b, T, S> Foo<'a, 'b, S> for T {} | - ^^^^^^^^^^^^^^ ^ diff --git a/tests/ui/associated-types/substs-ppaux.rs b/tests/ui/associated-types/substs-ppaux.rs index 302a6b345e4..ceec9978b1c 100644 --- a/tests/ui/associated-types/substs-ppaux.rs +++ b/tests/ui/associated-types/substs-ppaux.rs @@ -1,7 +1,6 @@ -// //@ revisions: verbose normal -// //@[verbose] compile-flags: -Z verbose-internals +//@ dont-require-annotations: NOTE trait Foo<'b, 'c, S = u32> { fn bar<'a, T>() @@ -22,35 +21,35 @@ where { let x: () = <i8 as Foo<'static, 'static, u8>>::bar::<'static, char>; //[verbose]~^ ERROR mismatched types - //[verbose]~| expected unit type `()` - //[verbose]~| found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::bar::<'static, char>}` + //[verbose]~| NOTE expected unit type `()` + //[verbose]~| NOTE found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::bar::<'static, char>}` //[normal]~^^^^ ERROR mismatched types - //[normal]~| expected unit type `()` - //[normal]~| found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::bar::<'static, char>}` + //[normal]~| NOTE expected unit type `()` + //[normal]~| NOTE found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::bar::<'static, char>}` let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>; //[verbose]~^ ERROR mismatched types - //[verbose]~| expected unit type `()` - //[verbose]~| found fn item `fn() {<i8 as Foo<'static, 'static>>::bar::<'static, char>}` + //[verbose]~| NOTE expected unit type `()` + //[verbose]~| NOTE found fn item `fn() {<i8 as Foo<'static, 'static>>::bar::<'static, char>}` //[normal]~^^^^ ERROR mismatched types - //[normal]~| expected unit type `()` - //[normal]~| found fn item `fn() {<i8 as Foo<'static, 'static>>::bar::<'static, char>}` + //[normal]~| NOTE expected unit type `()` + //[normal]~| NOTE found fn item `fn() {<i8 as Foo<'static, 'static>>::bar::<'static, char>}` let x: () = <i8 as Foo<'static, 'static, u8>>::baz; //[verbose]~^ ERROR mismatched types - //[verbose]~| expected unit type `()` - //[verbose]~| found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::baz}` + //[verbose]~| NOTE expected unit type `()` + //[verbose]~| NOTE found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::baz}` //[normal]~^^^^ ERROR mismatched types - //[normal]~| expected unit type `()` - //[normal]~| found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::baz}` + //[normal]~| NOTE expected unit type `()` + //[normal]~| NOTE found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::baz}` let x: () = foo::<'static>; //[verbose]~^ ERROR mismatched types - //[verbose]~| expected unit type `()` - //[verbose]~| found fn item `fn() {foo::<'static>}` + //[verbose]~| NOTE expected unit type `()` + //[verbose]~| NOTE found fn item `fn() {foo::<'static>}` //[normal]~^^^^ ERROR mismatched types - //[normal]~| expected unit type `()` - //[normal]~| found fn item `fn() {foo::<'static>}` + //[normal]~| NOTE expected unit type `()` + //[normal]~| NOTE found fn item `fn() {foo::<'static>}` <str as Foo<u8>>::bar; //[verbose]~^ ERROR the trait bound `str: Foo<'?0, '?1, u8>` is not satisfied diff --git a/tests/ui/associated-types/substs-ppaux.verbose.stderr b/tests/ui/associated-types/substs-ppaux.verbose.stderr index 05cd971c882..23cf222a1d3 100644 --- a/tests/ui/associated-types/substs-ppaux.verbose.stderr +++ b/tests/ui/associated-types/substs-ppaux.verbose.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/substs-ppaux.rs:23:17 + --> $DIR/substs-ppaux.rs:22:17 | LL | / fn bar<'a, T>() LL | | where @@ -19,7 +19,7 @@ LL | let x: () = <i8 as Foo<'static, 'static, u8>>::bar::<'static, char>(); | ++ error[E0308]: mismatched types - --> $DIR/substs-ppaux.rs:31:17 + --> $DIR/substs-ppaux.rs:30:17 | LL | / fn bar<'a, T>() LL | | where @@ -39,7 +39,7 @@ LL | let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>(); | ++ error[E0308]: mismatched types - --> $DIR/substs-ppaux.rs:39:17 + --> $DIR/substs-ppaux.rs:38:17 | LL | fn baz() {} | -------- associated function `baz` defined here @@ -57,7 +57,7 @@ LL | let x: () = <i8 as Foo<'static, 'static, u8>>::baz(); | ++ error[E0308]: mismatched types - --> $DIR/substs-ppaux.rs:47:17 + --> $DIR/substs-ppaux.rs:46:17 | LL | / fn foo<'z>() LL | | where @@ -77,13 +77,13 @@ LL | let x: () = foo::<'static>(); | ++ error[E0277]: the trait bound `str: Foo<'?0, '?1, u8>` is not satisfied - --> $DIR/substs-ppaux.rs:55:6 + --> $DIR/substs-ppaux.rs:54:6 | LL | <str as Foo<u8>>::bar; | ^^^ the trait `Sized` is not implemented for `str` | note: required for `str` to implement `Foo<'?0, '?1, u8>` - --> $DIR/substs-ppaux.rs:15:20 + --> $DIR/substs-ppaux.rs:14:20 | LL | impl<'a, 'b, T, S> Foo<'a, 'b, S> for T {} | - ^^^^^^^^^^^^^^ ^ diff --git a/tests/ui/async-await/async-closures/is-not-fn.next.stderr b/tests/ui/async-await/async-closures/is-not-fn.next.stderr index 0fab1c15f27..970970a9151 100644 --- a/tests/ui/async-await/async-closures/is-not-fn.next.stderr +++ b/tests/ui/async-await/async-closures/is-not-fn.next.stderr @@ -1,13 +1,11 @@ -error[E0271]: expected `{async closure@is-not-fn.rs:8:14}` to return `()`, but it returns `{async closure body@$DIR/is-not-fn.rs:8:23: 8:25}` +error[E0271]: type mismatch resolving `{async closure body@$DIR/is-not-fn.rs:8:23: 8:25} == ()` --> $DIR/is-not-fn.rs:8:14 | LL | needs_fn(async || {}); - | -------- ^^^^^^^^^^^ expected `()`, found `async` closure body + | -------- ^^^^^^^^^^^ types differ | | | required by a bound introduced by this call | - = note: expected unit type `()` - found `async` closure body `{async closure body@$DIR/is-not-fn.rs:8:23: 8:25}` note: required by a bound in `needs_fn` --> $DIR/is-not-fn.rs:7:25 | diff --git a/tests/ui/async-await/async-closures/is-not-fn.rs b/tests/ui/async-await/async-closures/is-not-fn.rs index e5ab4742dab..c09ccb3fc2b 100644 --- a/tests/ui/async-await/async-closures/is-not-fn.rs +++ b/tests/ui/async-await/async-closures/is-not-fn.rs @@ -6,5 +6,6 @@ fn main() { fn needs_fn(x: impl FnOnce()) {} needs_fn(async || {}); - //~^ ERROR expected `{async closure@is-not-fn.rs:8:14}` to return `()` + //[current]~^ ERROR expected `{async closure@is-not-fn.rs:8:14}` to return `()` + //[next]~^^ ERROR type mismatch resolving `{async closure body@$DIR/is-not-fn.rs:8:23: 8:25} == ()` } diff --git a/tests/ui/async-await/async-closures/kind-due-to-arg-with-box-wrap.rs b/tests/ui/async-await/async-closures/kind-due-to-arg-with-box-wrap.rs new file mode 100644 index 00000000000..650fb10d94b --- /dev/null +++ b/tests/ui/async-await/async-closures/kind-due-to-arg-with-box-wrap.rs @@ -0,0 +1,22 @@ +//@ edition: 2024 + +// Regression test for <https://github.com/rust-lang/rust/issues/140292>. + +struct Test; + +impl Test { + async fn an_async_fn(&mut self) { + todo!() + } + + pub async fn uses_takes_asyncfn(&mut self) { + takes_asyncfn(Box::new(async || self.an_async_fn().await)); + //~^ ERROR expected a closure that implements the `AsyncFn` trait, but this closure only implements `AsyncFnMut` + } +} + +async fn takes_asyncfn(_: impl AsyncFn()) { + todo!() +} + +fn main() {} diff --git a/tests/ui/async-await/async-closures/kind-due-to-arg-with-box-wrap.stderr b/tests/ui/async-await/async-closures/kind-due-to-arg-with-box-wrap.stderr new file mode 100644 index 00000000000..e79f95c197b --- /dev/null +++ b/tests/ui/async-await/async-closures/kind-due-to-arg-with-box-wrap.stderr @@ -0,0 +1,21 @@ +error[E0525]: expected a closure that implements the `AsyncFn` trait, but this closure only implements `AsyncFnMut` + --> $DIR/kind-due-to-arg-with-box-wrap.rs:13:32 + | +LL | takes_asyncfn(Box::new(async || self.an_async_fn().await)); + | ------------- ---------^^^^^^^^-------------------------- + | | | | | + | | | | closure is `AsyncFnMut` because it mutates the variable `*self` here + | | | this closure implements `AsyncFnMut`, not `AsyncFn` + | | the requirement to implement `AsyncFn` derives from here + | required by a bound introduced by this call + | + = note: required for `Box<{async closure@$DIR/kind-due-to-arg-with-box-wrap.rs:13:32: 13:40}>` to implement `AsyncFn()` +note: required by a bound in `takes_asyncfn` + --> $DIR/kind-due-to-arg-with-box-wrap.rs:18:32 + | +LL | async fn takes_asyncfn(_: impl AsyncFn()) { + | ^^^^^^^^^ required by this bound in `takes_asyncfn` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0525`. diff --git a/tests/ui/async-await/async-drop/async-drop-future-from-future.rs b/tests/ui/async-await/async-drop/async-drop-future-from-future.rs new file mode 100644 index 00000000000..44dcbd14f48 --- /dev/null +++ b/tests/ui/async-await/async-drop/async-drop-future-from-future.rs @@ -0,0 +1,101 @@ +//@ run-pass +//@ check-run-results +// Future `bar` with internal async drop `Foo` will have async drop itself. +// And we trying to drop this future in sync context (`block_on` func) + +#![feature(async_drop)] +#![allow(incomplete_features)] + +use std::mem::ManuallyDrop; + +//@ edition: 2021 + +use std::{ + future::{Future, async_drop_in_place, AsyncDrop}, + pin::{pin, Pin}, + sync::{mpsc, Arc}, + task::{Context, Poll, Wake, Waker}, +}; + +struct Foo { + my_resource_handle: usize, +} + +impl Foo { + fn new(my_resource_handle: usize) -> Self { + let out = Foo { + my_resource_handle, + }; + println!("Foo::new({})", my_resource_handle); + out + } +} + +impl Drop for Foo { + fn drop(&mut self) { + println!("Foo::drop({})", self.my_resource_handle); + } +} + +impl AsyncDrop for Foo { + async fn drop(self: Pin<&mut Self>) { + println!("Foo::async drop({})", self.my_resource_handle); + } +} + +fn main() { + block_on(bar(10)); + println!("done") +} + +async fn baz(ident_base: usize) { + let mut _first = Foo::new(ident_base); +} + +async fn bar(ident_base: usize) { + let mut _first = Foo::new(ident_base); + baz(ident_base + 1).await; +} + +fn block_on<F>(fut_unpin: F) -> F::Output +where + F: Future, +{ + let mut fut_pin = pin!(ManuallyDrop::new(fut_unpin)); + let mut fut: Pin<&mut F> = unsafe { + Pin::map_unchecked_mut(fut_pin.as_mut(), |x| &mut **x) + }; + let (waker, rx) = simple_waker(); + let mut context = Context::from_waker(&waker); + let rv = loop { + match fut.as_mut().poll(&mut context) { + Poll::Ready(out) => break out, + // expect wake in polls + Poll::Pending => rx.try_recv().unwrap(), + } + }; + let drop_fut_unpin = unsafe { async_drop_in_place(fut.get_unchecked_mut()) }; + let mut drop_fut: Pin<&mut _> = pin!(drop_fut_unpin); + loop { + match drop_fut.as_mut().poll(&mut context) { + Poll::Ready(()) => break, + Poll::Pending => rx.try_recv().unwrap(), + } + } + rv +} + +fn simple_waker() -> (Waker, mpsc::Receiver<()>) { + struct SimpleWaker { + tx: std::sync::mpsc::Sender<()>, + } + + impl Wake for SimpleWaker { + fn wake(self: Arc<Self>) { + self.tx.send(()).unwrap(); + } + } + + let (tx, rx) = mpsc::channel(); + (Waker::from(Arc::new(SimpleWaker { tx })), rx) +} diff --git a/tests/ui/async-await/async-drop/async-drop-future-from-future.run.stdout b/tests/ui/async-await/async-drop/async-drop-future-from-future.run.stdout new file mode 100644 index 00000000000..c2663b3f238 --- /dev/null +++ b/tests/ui/async-await/async-drop/async-drop-future-from-future.run.stdout @@ -0,0 +1,5 @@ +Foo::new(10) +Foo::new(11) +Foo::async drop(11) +Foo::async drop(10) +done diff --git a/tests/ui/async-await/async-drop/async-drop-future-in-sync-context.rs b/tests/ui/async-await/async-drop/async-drop-future-in-sync-context.rs new file mode 100644 index 00000000000..417dce62dba --- /dev/null +++ b/tests/ui/async-await/async-drop/async-drop-future-in-sync-context.rs @@ -0,0 +1,82 @@ +//@ run-pass +//@ check-run-results +// Future `bar` with internal async drop `Foo` will have async drop itself. +// And we trying to drop this future in sync context (`block_on` func) + +#![feature(async_drop)] +#![allow(incomplete_features)] + +//@ edition: 2021 + +use std::{ + future::{Future, AsyncDrop}, + pin::{pin, Pin}, + sync::{mpsc, Arc}, + task::{Context, Poll, Wake, Waker}, +}; + +struct Foo { + my_resource_handle: usize, +} + +impl Foo { + fn new(my_resource_handle: usize) -> Self { + let out = Foo { + my_resource_handle, + }; + println!("Foo::new({})", my_resource_handle); + out + } +} + +impl Drop for Foo { + fn drop(&mut self) { + println!("Foo::drop({})", self.my_resource_handle); + } +} + +impl AsyncDrop for Foo { + async fn drop(self: Pin<&mut Self>) { + println!("Foo::async drop({})", self.my_resource_handle); + } +} + +fn main() { + block_on(bar(10)); + println!("done") +} + +async fn bar(ident_base: usize) { + let mut _first = Foo::new(ident_base); +} + +fn block_on<F>(fut: F) -> F::Output +where + F: Future, +{ + let mut fut = pin!(fut); + let (waker, rx) = simple_waker(); + let mut context = Context::from_waker(&waker); + loop { + match fut.as_mut().poll(&mut context) { + Poll::Ready(out) => break out, + // expect wake in polls + Poll::Pending => rx.try_recv().unwrap(), + } + } +} + +fn simple_waker() -> (Waker, mpsc::Receiver<()>) { + struct SimpleWaker { + tx: std::sync::mpsc::Sender<()>, + } + + impl Wake for SimpleWaker { + fn wake(self: Arc<Self>) { + self.tx.send(()).unwrap(); + } + } + + let (tx, rx) = mpsc::channel(); + (Waker::from(Arc::new(SimpleWaker { tx })), rx) +} diff --git a/tests/ui/async-await/async-drop/async-drop-future-in-sync-context.run.stdout b/tests/ui/async-await/async-drop/async-drop-future-in-sync-context.run.stdout new file mode 100644 index 00000000000..ad0b083ca09 --- /dev/null +++ b/tests/ui/async-await/async-drop/async-drop-future-in-sync-context.run.stdout @@ -0,0 +1,3 @@ +Foo::new(10) +Foo::async drop(10) +done diff --git a/tests/ui/async-await/async-drop/async-drop-glue-array.rs b/tests/ui/async-await/async-drop/async-drop-glue-array.rs new file mode 100644 index 00000000000..21c08da2337 --- /dev/null +++ b/tests/ui/async-await/async-drop/async-drop-glue-array.rs @@ -0,0 +1,112 @@ +//@ run-pass +//@ check-run-results +// struct `Foo` has both sync and async drop. +// Struct `Complex` contains three `Foo` fields and has complex async drop glue. + +#![feature(async_drop)] +#![allow(incomplete_features)] + +use std::mem::ManuallyDrop; + +//@ edition: 2021 + +#[inline(never)] +fn myprintln(msg: &str, my_resource_handle: usize) { + println!("{} : {}", msg, my_resource_handle); +} + +use std::{ + future::{Future, async_drop_in_place, AsyncDrop}, + pin::{pin, Pin}, + sync::{mpsc, Arc}, + task::{Context, Poll, Wake, Waker}, +}; + +struct Foo { + my_resource_handle: usize, +} + +impl Foo { + fn new(my_resource_handle: usize) -> Self { + let out = Foo { + my_resource_handle, + }; + myprintln("Foo::new()", my_resource_handle); + out + } +} + +impl Drop for Foo { + fn drop(&mut self) { + myprintln("Foo::drop()", self.my_resource_handle); + } +} + +impl AsyncDrop for Foo { + async fn drop(self: Pin<&mut Self>) { + myprintln("Foo::async drop()", self.my_resource_handle); + } +} + +fn main() { + { + let _ = Foo::new(7); + } + println!("Middle"); + { + block_on(bar(10)); + } + println!("Done") +} + +async fn bar(ident_base: usize) { + let _vec: [Foo; 4] = [ + Foo::new(ident_base), + Foo::new(ident_base + 1), + Foo::new(ident_base + 2), + Foo::new(ident_base + 3) + ]; +} + +fn block_on<F>(fut_unpin: F) -> F::Output +where + F: Future, +{ + let mut fut_pin = pin!(ManuallyDrop::new(fut_unpin)); + let mut fut: Pin<&mut F> = unsafe { + Pin::map_unchecked_mut(fut_pin.as_mut(), |x| &mut **x) + }; + let (waker, rx) = simple_waker(); + let mut context = Context::from_waker(&waker); + let rv = loop { + match fut.as_mut().poll(&mut context) { + Poll::Ready(out) => break out, + // expect wake in polls + Poll::Pending => rx.try_recv().unwrap(), + } + }; + let drop_fut_unpin = unsafe { async_drop_in_place(fut.get_unchecked_mut()) }; + let mut drop_fut: Pin<&mut _> = pin!(drop_fut_unpin); + loop { + match drop_fut.as_mut().poll(&mut context) { + Poll::Ready(()) => break, + Poll::Pending => rx.try_recv().unwrap(), + } + } + rv +} + +fn simple_waker() -> (Waker, mpsc::Receiver<()>) { + struct SimpleWaker { + tx: std::sync::mpsc::Sender<()>, + } + + impl Wake for SimpleWaker { + fn wake(self: Arc<Self>) { + self.tx.send(()).unwrap(); + } + } + + let (tx, rx) = mpsc::channel(); + (Waker::from(Arc::new(SimpleWaker { tx })), rx) +} diff --git a/tests/ui/async-await/async-drop/async-drop-glue-array.run.stdout b/tests/ui/async-await/async-drop/async-drop-glue-array.run.stdout new file mode 100644 index 00000000000..56b61103cc4 --- /dev/null +++ b/tests/ui/async-await/async-drop/async-drop-glue-array.run.stdout @@ -0,0 +1,12 @@ +Foo::new() : 7 +Foo::drop() : 7 +Middle +Foo::new() : 10 +Foo::new() : 11 +Foo::new() : 12 +Foo::new() : 13 +Foo::async drop() : 10 +Foo::async drop() : 11 +Foo::async drop() : 12 +Foo::async drop() : 13 +Done diff --git a/tests/ui/async-await/async-drop/async-drop-glue-generic.rs b/tests/ui/async-await/async-drop/async-drop-glue-generic.rs new file mode 100644 index 00000000000..9e8ae130324 --- /dev/null +++ b/tests/ui/async-await/async-drop/async-drop-glue-generic.rs @@ -0,0 +1,111 @@ +//@ run-pass +//@ check-run-results +// struct `Foo` has both sync and async drop. + +#![feature(async_drop)] +#![allow(incomplete_features)] + +use std::mem::ManuallyDrop; + +//@ edition: 2021 + +#[inline(never)] +fn myprintln(msg: &str, my_resource_handle: usize) { + println!("{} : {}", msg, my_resource_handle); +} + +use std::{ + future::{Future, async_drop_in_place, AsyncDrop}, + pin::{pin, Pin}, + sync::{mpsc, Arc}, + task::{Context, Poll, Wake, Waker}, +}; + +struct Foo { + my_resource_handle: usize, +} + +impl Foo { + fn new(my_resource_handle: usize) -> Self { + let out = Foo { + my_resource_handle, + }; + myprintln("Foo::new()", my_resource_handle); + out + } +} + +impl Drop for Foo { + fn drop(&mut self) { + myprintln("Foo::drop()", self.my_resource_handle); + } +} + +impl AsyncDrop for Foo { + async fn drop(self: Pin<&mut Self>) { + myprintln("Foo::async drop()", self.my_resource_handle); + } +} + +fn main() { + { + let _ = Foo::new(7); + } + println!("Middle"); + { + block_on(bar(6, 10)); + } + println!("Done") +} + +async fn bar<T>(_arg: T, ident_base: usize) { + let _vec: [Foo; 4] = [ + Foo::new(ident_base), + Foo::new(ident_base + 1), + Foo::new(ident_base + 2), + Foo::new(ident_base + 3) + ]; +} + +fn block_on<F>(fut_unpin: F) -> F::Output +where + F: Future, +{ + let mut fut_pin = pin!(ManuallyDrop::new(fut_unpin)); + let mut fut: Pin<&mut F> = unsafe { + Pin::map_unchecked_mut(fut_pin.as_mut(), |x| &mut **x) + }; + let (waker, rx) = simple_waker(); + let mut context = Context::from_waker(&waker); + let rv = loop { + match fut.as_mut().poll(&mut context) { + Poll::Ready(out) => break out, + // expect wake in polls + Poll::Pending => rx.try_recv().unwrap(), + } + }; + let drop_fut_unpin = unsafe { async_drop_in_place(fut.get_unchecked_mut()) }; + let mut drop_fut: Pin<&mut _> = pin!(drop_fut_unpin); + loop { + match drop_fut.as_mut().poll(&mut context) { + Poll::Ready(()) => break, + Poll::Pending => rx.try_recv().unwrap(), + } + } + rv +} + +fn simple_waker() -> (Waker, mpsc::Receiver<()>) { + struct SimpleWaker { + tx: std::sync::mpsc::Sender<()>, + } + + impl Wake for SimpleWaker { + fn wake(self: Arc<Self>) { + self.tx.send(()).unwrap(); + } + } + + let (tx, rx) = mpsc::channel(); + (Waker::from(Arc::new(SimpleWaker { tx })), rx) +} diff --git a/tests/ui/async-await/async-drop/async-drop-glue-generic.run.stdout b/tests/ui/async-await/async-drop/async-drop-glue-generic.run.stdout new file mode 100644 index 00000000000..56b61103cc4 --- /dev/null +++ b/tests/ui/async-await/async-drop/async-drop-glue-generic.run.stdout @@ -0,0 +1,12 @@ +Foo::new() : 7 +Foo::drop() : 7 +Middle +Foo::new() : 10 +Foo::new() : 11 +Foo::new() : 12 +Foo::new() : 13 +Foo::async drop() : 10 +Foo::async drop() : 11 +Foo::async drop() : 12 +Foo::async drop() : 13 +Done diff --git a/tests/ui/async-await/async-drop/async-drop-glue.rs b/tests/ui/async-await/async-drop/async-drop-glue.rs new file mode 100644 index 00000000000..dc4bb527a51 --- /dev/null +++ b/tests/ui/async-await/async-drop/async-drop-glue.rs @@ -0,0 +1,124 @@ +//@ run-pass +//@ check-run-results +// struct `Foo` has both sync and async drop. +// Struct `Complex` contains three `Foo` fields and has complex async drop glue. + +#![feature(async_drop)] +#![allow(incomplete_features)] + +use std::mem::ManuallyDrop; + +//@ edition: 2021 + +#[inline(never)] +fn myprintln(msg: &str, my_resource_handle: usize) { + println!("{} : {}", msg, my_resource_handle); +} + +use std::{ + future::{Future, async_drop_in_place, AsyncDrop}, + pin::{pin, Pin}, + sync::{mpsc, Arc}, + task::{Context, Poll, Wake, Waker}, +}; + +struct Foo { + my_resource_handle: usize, +} + +#[allow(dead_code)] +struct Complex { + field1: Foo, + field2: Foo, + field3: Foo, +} + +impl Complex { + fn new(my_resource_handle: usize) -> Self { + myprintln("Complex::new()", my_resource_handle); + let field1 = Foo::new(my_resource_handle); + let field2 = Foo::new(my_resource_handle + 1); + let field3 = Foo::new(my_resource_handle + 2); + Complex { field1, field2, field3 } + } +} + +impl Foo { + fn new(my_resource_handle: usize) -> Self { + let out = Foo { + my_resource_handle, + }; + myprintln("Foo::new()", my_resource_handle); + out + } +} + +impl Drop for Foo { + fn drop(&mut self) { + myprintln("Foo::drop()", self.my_resource_handle); + } +} + +impl AsyncDrop for Foo { + async fn drop(self: Pin<&mut Self>) { + myprintln("Foo::async drop()", self.my_resource_handle); + } +} + +fn main() { + { + let _ = Foo::new(7); + } + println!("Middle"); + { + block_on(bar(10)); + } + println!("Done") +} + +async fn bar(ident_base: usize) { + let _complex = Complex::new(ident_base); +} + +fn block_on<F>(fut_unpin: F) -> F::Output +where + F: Future, +{ + let mut fut_pin = pin!(ManuallyDrop::new(fut_unpin)); + let mut fut: Pin<&mut F> = unsafe { + Pin::map_unchecked_mut(fut_pin.as_mut(), |x| &mut **x) + }; + let (waker, rx) = simple_waker(); + let mut context = Context::from_waker(&waker); + let rv = loop { + match fut.as_mut().poll(&mut context) { + Poll::Ready(out) => break out, + // expect wake in polls + Poll::Pending => rx.try_recv().unwrap(), + } + }; + let drop_fut_unpin = unsafe { async_drop_in_place(fut.get_unchecked_mut()) }; + let mut drop_fut: Pin<&mut _> = pin!(drop_fut_unpin); + loop { + match drop_fut.as_mut().poll(&mut context) { + Poll::Ready(()) => break, + Poll::Pending => rx.try_recv().unwrap(), + } + } + rv +} + +fn simple_waker() -> (Waker, mpsc::Receiver<()>) { + struct SimpleWaker { + tx: std::sync::mpsc::Sender<()>, + } + + impl Wake for SimpleWaker { + fn wake(self: Arc<Self>) { + self.tx.send(()).unwrap(); + } + } + + let (tx, rx) = mpsc::channel(); + (Waker::from(Arc::new(SimpleWaker { tx })), rx) +} diff --git a/tests/ui/async-await/async-drop/async-drop-glue.run.stdout b/tests/ui/async-await/async-drop/async-drop-glue.run.stdout new file mode 100644 index 00000000000..e21a9dd34fa --- /dev/null +++ b/tests/ui/async-await/async-drop/async-drop-glue.run.stdout @@ -0,0 +1,11 @@ +Foo::new() : 7 +Foo::drop() : 7 +Middle +Complex::new() : 10 +Foo::new() : 10 +Foo::new() : 11 +Foo::new() : 12 +Foo::async drop() : 10 +Foo::async drop() : 11 +Foo::async drop() : 12 +Done diff --git a/tests/ui/async-await/async-drop.rs b/tests/ui/async-await/async-drop/async-drop-initial.rs index b1af81423ce..80b34840c8b 100644 --- a/tests/ui/async-await/async-drop.rs +++ b/tests/ui/async-await/async-drop/async-drop-initial.rs @@ -52,21 +52,20 @@ fn main() { let i = 13; let fut = pin!(async { - test_async_drop(Int(0), 0).await; - // FIXME(#63818): niches in coroutines are disabled. - // Some of these sizes should be smaller, as indicated in comments. - test_async_drop(AsyncInt(0), /*104*/ 112).await; - test_async_drop([AsyncInt(1), AsyncInt(2)], /*152*/ 168).await; - test_async_drop((AsyncInt(3), AsyncInt(4)), /*488*/ 528).await; - test_async_drop(5, 0).await; + test_async_drop(Int(0), 16).await; + test_async_drop(AsyncInt(0), 32).await; + test_async_drop([AsyncInt(1), AsyncInt(2)], 104).await; + test_async_drop((AsyncInt(3), AsyncInt(4)), 120).await; + test_async_drop(5, 16).await; let j = 42; - test_async_drop(&i, 0).await; - test_async_drop(&j, 0).await; - test_async_drop(AsyncStruct { b: AsyncInt(8), a: AsyncInt(7), i: 6 }, /*1688*/ 1792).await; - test_async_drop(ManuallyDrop::new(AsyncInt(9)), 0).await; + test_async_drop(&i, 16).await; + test_async_drop(&j, 16).await; + test_async_drop(AsyncStruct { b: AsyncInt(8), a: AsyncInt(7), i: 6 }, 168).await; + test_async_drop(ManuallyDrop::new(AsyncInt(9)), 16).await; let foo = AsyncInt(10); - test_async_drop(AsyncReference { foo: &foo }, /*104*/ 112).await; + test_async_drop(AsyncReference { foo: &foo }, 32).await; + let _ = ManuallyDrop::new(foo); let foo = AsyncInt(11); test_async_drop( @@ -75,21 +74,22 @@ fn main() { let foo = AsyncInt(10); foo }, - /*120*/ 136, + 48, ) .await; - test_async_drop(AsyncEnum::A(AsyncInt(12)), /*680*/ 736).await; - test_async_drop(AsyncEnum::B(SyncInt(13)), /*680*/ 736).await; + test_async_drop(AsyncEnum::A(AsyncInt(12)), 104).await; + test_async_drop(AsyncEnum::B(SyncInt(13)), 104).await; - test_async_drop(SyncInt(14), /*16*/ 24).await; + test_async_drop(SyncInt(14), 16).await; test_async_drop( SyncThenAsync { i: 15, a: AsyncInt(16), b: SyncInt(17), c: AsyncInt(18) }, - /*3064*/ 3296, + 120, ) .await; - let async_drop_fut = pin!(core::future::async_drop(AsyncInt(19))); + let mut ptr19 = mem::MaybeUninit::new(AsyncInt(19)); + let async_drop_fut = pin!(unsafe { async_drop_in_place(ptr19.as_mut_ptr()) }); test_idempotency(async_drop_fut).await; let foo = AsyncInt(20); @@ -101,11 +101,11 @@ fn main() { black_box(core::future::ready(())).await; foo }, - /*120*/ 136, + 48, ) .await; - test_async_drop(AsyncUnion { signed: 21 }, /*32*/ 40).await; + test_async_drop(AsyncUnion { signed: 21 }, 32).await; }); let res = fut.poll(&mut cx); assert_eq!(res, Poll::Ready(())); @@ -113,13 +113,14 @@ fn main() { struct AsyncInt(i32); +impl Drop for AsyncInt { + fn drop(&mut self) { + println!("AsyncInt::drop: {}", self.0); + } +} impl AsyncDrop for AsyncInt { - type Dropper<'a> = impl Future<Output = ()>; - - fn async_drop(self: Pin<&mut Self>) -> Self::Dropper<'_> { - async move { - println!("AsyncInt::Dropper::poll: {}", self.0); - } + async fn drop(self: Pin<&mut Self>) { + println!("AsyncInt::Dropper::poll: {}", self.0); } } @@ -148,13 +149,15 @@ struct AsyncReference<'a> { foo: &'a AsyncInt, } -impl AsyncDrop for AsyncReference<'_> { - type Dropper<'a> = impl Future<Output = ()> where Self: 'a; +impl Drop for AsyncReference<'_> { + fn drop(&mut self) { + println!("AsyncReference::drop: {}", self.foo.0); + } +} - fn async_drop(self: Pin<&mut Self>) -> Self::Dropper<'_> { - async move { - println!("AsyncReference::Dropper::poll: {}", self.foo.0); - } +impl AsyncDrop for AsyncReference<'_> { + async fn drop(self: Pin<&mut Self>) { + println!("AsyncReference::Dropper::poll: {}", self.foo.0); } } @@ -166,13 +169,15 @@ struct AsyncStruct { b: AsyncInt, } -impl AsyncDrop for AsyncStruct { - type Dropper<'a> = impl Future<Output = ()>; +impl Drop for AsyncStruct { + fn drop(&mut self) { + println!("AsyncStruct::drop: {}", self.i); + } +} - fn async_drop(self: Pin<&mut Self>) -> Self::Dropper<'_> { - async move { - println!("AsyncStruct::Dropper::poll: {}", self.i); - } +impl AsyncDrop for AsyncStruct { + async fn drop(self: Pin<&mut Self>) { + println!("AsyncStruct::Dropper::poll: {}", self.i); } } @@ -181,23 +186,34 @@ enum AsyncEnum { B(SyncInt), } +impl Drop for AsyncEnum { + fn drop(&mut self) { + let new_self = match self { + AsyncEnum::A(foo) => { + println!("AsyncEnum(A)::drop: {}", foo.0); + AsyncEnum::B(SyncInt(foo.0)) + } + AsyncEnum::B(foo) => { + println!("AsyncEnum(B)::drop: {}", foo.0); + AsyncEnum::A(AsyncInt(foo.0)) + } + }; + mem::forget(mem::replace(&mut *self, new_self)); + } +} impl AsyncDrop for AsyncEnum { - type Dropper<'a> = impl Future<Output = ()>; - - fn async_drop(mut self: Pin<&mut Self>) -> Self::Dropper<'_> { - async move { - let new_self = match &*self { - AsyncEnum::A(foo) => { - println!("AsyncEnum(A)::Dropper::poll: {}", foo.0); - AsyncEnum::B(SyncInt(foo.0)) - } - AsyncEnum::B(foo) => { - println!("AsyncEnum(B)::Dropper::poll: {}", foo.0); - AsyncEnum::A(AsyncInt(foo.0)) - } - }; - mem::forget(mem::replace(&mut *self, new_self)); - } + async fn drop(mut self: Pin<&mut Self>) { + let new_self = match &*self { + AsyncEnum::A(foo) => { + println!("AsyncEnum(A)::Dropper::poll: {}", foo.0); + AsyncEnum::B(SyncInt(foo.0)) + } + AsyncEnum::B(foo) => { + println!("AsyncEnum(B)::Dropper::poll: {}", foo.0); + AsyncEnum::A(AsyncInt(foo.0)) + } + }; + mem::forget(mem::replace(&mut *self, new_self)); } } @@ -207,16 +223,21 @@ union AsyncUnion { unsigned: u32, } +impl Drop for AsyncUnion { + fn drop(&mut self) { + println!( + "AsyncUnion::drop: {}, {}", + unsafe { self.signed }, + unsafe { self.unsigned }, + ); + } +} impl AsyncDrop for AsyncUnion { - type Dropper<'a> = impl Future<Output = ()>; - - fn async_drop(self: Pin<&mut Self>) -> Self::Dropper<'_> { - async move { - println!( - "AsyncUnion::Dropper::poll: {}, {}", - unsafe { self.signed }, - unsafe { self.unsigned }, - ); - } + async fn drop(self: Pin<&mut Self>) { + println!( + "AsyncUnion::Dropper::poll: {}, {}", + unsafe { self.signed }, + unsafe { self.unsigned }, + ); } } diff --git a/tests/ui/async-await/async-drop.run.stdout b/tests/ui/async-await/async-drop/async-drop-initial.run.stdout index 9cae4331caf..9cae4331caf 100644 --- a/tests/ui/async-await/async-drop.run.stdout +++ b/tests/ui/async-await/async-drop/async-drop-initial.run.stdout diff --git a/tests/ui/async-await/async-drop/async-drop-middle-drop.rs b/tests/ui/async-await/async-drop/async-drop-middle-drop.rs new file mode 100644 index 00000000000..772a853fe1e --- /dev/null +++ b/tests/ui/async-await/async-drop/async-drop-middle-drop.rs @@ -0,0 +1,110 @@ +//@ run-pass +//@ check-run-results +// Test async drop of coroutine `bar` (with internal async drop), +// stopped at the middle of execution, with AsyncDrop object Foo active. + +#![feature(async_drop)] +#![allow(incomplete_features)] + +//@ edition: 2021 + +use std::mem::ManuallyDrop; + +use std::{ + future::{Future, async_drop_in_place, AsyncDrop}, + pin::{pin, Pin}, + sync::{mpsc, Arc}, + task::{Context, Poll, Wake, Waker}, +}; + +struct Foo { + my_resource_handle: usize, +} + +impl Foo { + fn new(my_resource_handle: usize) -> Self { + let out = Foo { + my_resource_handle, + }; + println!("Foo::new({})", my_resource_handle); + out + } +} + +impl Drop for Foo { + fn drop(&mut self) { + println!("Foo::drop({})", self.my_resource_handle); + } +} + +impl AsyncDrop for Foo { + async fn drop(self: Pin<&mut Self>) { + println!("Foo::async drop({})", self.my_resource_handle); + } +} + +fn main() { + block_on_and_drop_in_the_middle(bar(10)); + println!("done") +} + +pub struct MiddleFuture { + first_call: bool, +} +impl Future for MiddleFuture { + type Output = (); + fn poll(mut self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Self::Output> { + if self.first_call { + println!("MiddleFuture first poll"); + self.first_call = false; + Poll::Pending + } else { + println!("MiddleFuture Ready"); + Poll::Ready(()) + } + } +} + +async fn bar(ident_base: usize) { + let middle = MiddleFuture { first_call: true }; + let mut _first = Foo::new(ident_base); + middle.await; // Hanging `bar` future before Foo drop +} + +fn block_on_and_drop_in_the_middle<F>(fut_unpin: F) -> F::Output +where + F: Future<Output = ()>, +{ + let mut fut_pin = pin!(ManuallyDrop::new(fut_unpin)); + let mut fut: Pin<&mut F> = unsafe { + Pin::map_unchecked_mut(fut_pin.as_mut(), |x| &mut **x) + }; + let (waker, rx) = simple_waker(); + let mut context = Context::from_waker(&waker); + let poll1 = fut.as_mut().poll(&mut context); + assert!(poll1.is_pending()); + + let drop_fut_unpin = unsafe { async_drop_in_place(fut.get_unchecked_mut()) }; + let mut drop_fut: Pin<&mut _> = pin!(drop_fut_unpin); + loop { + match drop_fut.as_mut().poll(&mut context) { + Poll::Ready(()) => break, + Poll::Pending => rx.try_recv().unwrap(), + } + } +} + +fn simple_waker() -> (Waker, mpsc::Receiver<()>) { + struct SimpleWaker { + tx: std::sync::mpsc::Sender<()>, + } + + impl Wake for SimpleWaker { + fn wake(self: Arc<Self>) { + self.tx.send(()).unwrap(); + } + } + + let (tx, rx) = mpsc::channel(); + (Waker::from(Arc::new(SimpleWaker { tx })), rx) +} diff --git a/tests/ui/async-await/async-drop/async-drop-middle-drop.run.stdout b/tests/ui/async-await/async-drop/async-drop-middle-drop.run.stdout new file mode 100644 index 00000000000..60df7674d0a --- /dev/null +++ b/tests/ui/async-await/async-drop/async-drop-middle-drop.run.stdout @@ -0,0 +1,4 @@ +Foo::new(10) +MiddleFuture first poll +Foo::async drop(10) +done diff --git a/tests/ui/async-await/async-drop/async-drop-open.rs b/tests/ui/async-await/async-drop/async-drop-open.rs new file mode 100644 index 00000000000..d14eff874ae --- /dev/null +++ b/tests/ui/async-await/async-drop/async-drop-open.rs @@ -0,0 +1,127 @@ +//@ run-pass +//@ check-run-results +// struct `Foo` has both sync and async drop. +// Struct `Complex` contains three `Foo` fields and one of them is moved out. + +#![feature(async_drop)] +#![allow(incomplete_features)] + +use std::mem::ManuallyDrop; + +//@ edition: 2021 + +#[inline(never)] +fn myprintln(msg: &str, my_resource_handle: usize) { + println!("{} : {}", msg, my_resource_handle); +} + +use std::{ + future::{Future, async_drop_in_place, AsyncDrop}, + pin::{pin, Pin}, + sync::{mpsc, Arc}, + task::{Context, Poll, Wake, Waker}, +}; + +struct Foo { + my_resource_handle: usize, +} + +#[allow(dead_code)] +struct Complex { + field1: Foo, + field2: Foo, + field3: Foo, +} + +impl Complex { + fn new(my_resource_handle: usize) -> Self { + myprintln("Complex::new()", my_resource_handle); + let field1 = Foo::new(my_resource_handle); + let field2 = Foo::new(my_resource_handle + 1); + let field3 = Foo::new(my_resource_handle + 2); + Complex { field1, field2, field3 } + } +} + +impl Foo { + fn new(my_resource_handle: usize) -> Self { + let out = Foo { + my_resource_handle, + }; + myprintln("Foo::new()", my_resource_handle); + out + } +} + +impl Drop for Foo { + fn drop(&mut self) { + myprintln("Foo::drop()", self.my_resource_handle); + } +} + +impl AsyncDrop for Foo { + async fn drop(self: Pin<&mut Self>) { + myprintln("Foo::async drop()", self.my_resource_handle); + } +} + +fn main() { + { + let _ = Foo::new(7); + } + println!("Middle"); + // Inside field1 and field3 of Complex must be dropped (as async drop) + // field2 must be dropped here (as sync drop) + { + let _field2 = block_on(bar(10)); + } + println!("Done") +} + +async fn bar(ident_base: usize) -> Foo { + let complex = Complex::new(ident_base); + complex.field2 +} + +fn block_on<F>(fut_unpin: F) -> F::Output +where + F: Future, +{ + let mut fut_pin = pin!(ManuallyDrop::new(fut_unpin)); + let mut fut: Pin<&mut F> = unsafe { + Pin::map_unchecked_mut(fut_pin.as_mut(), |x| &mut **x) + }; + let (waker, rx) = simple_waker(); + let mut context = Context::from_waker(&waker); + let rv = loop { + match fut.as_mut().poll(&mut context) { + Poll::Ready(out) => break out, + // expect wake in polls + Poll::Pending => rx.try_recv().unwrap(), + } + }; + let drop_fut_unpin = unsafe { async_drop_in_place(fut.get_unchecked_mut()) }; + let mut drop_fut: Pin<&mut _> = pin!(drop_fut_unpin); + loop { + match drop_fut.as_mut().poll(&mut context) { + Poll::Ready(()) => break, + Poll::Pending => rx.try_recv().unwrap(), + } + } + rv +} + +fn simple_waker() -> (Waker, mpsc::Receiver<()>) { + struct SimpleWaker { + tx: std::sync::mpsc::Sender<()>, + } + + impl Wake for SimpleWaker { + fn wake(self: Arc<Self>) { + self.tx.send(()).unwrap(); + } + } + + let (tx, rx) = mpsc::channel(); + (Waker::from(Arc::new(SimpleWaker { tx })), rx) +} diff --git a/tests/ui/async-await/async-drop/async-drop-open.run.stdout b/tests/ui/async-await/async-drop/async-drop-open.run.stdout new file mode 100644 index 00000000000..e72dfd8a743 --- /dev/null +++ b/tests/ui/async-await/async-drop/async-drop-open.run.stdout @@ -0,0 +1,11 @@ +Foo::new() : 7 +Foo::drop() : 7 +Middle +Complex::new() : 10 +Foo::new() : 10 +Foo::new() : 11 +Foo::new() : 12 +Foo::async drop() : 10 +Foo::async drop() : 12 +Foo::drop() : 11 +Done diff --git a/tests/ui/async-await/async-drop/async-drop.rs b/tests/ui/async-await/async-drop/async-drop.rs new file mode 100644 index 00000000000..2d9c5934be5 --- /dev/null +++ b/tests/ui/async-await/async-drop/async-drop.rs @@ -0,0 +1,105 @@ +//@ run-pass +//@ check-run-results +// struct `Foo` has both sync and async drop. +// Sync version is called in sync context, async version is called in async function. + +#![feature(async_drop)] +#![allow(incomplete_features)] + +use std::mem::ManuallyDrop; + +//@ edition: 2021 + +#[inline(never)] +fn myprintln(msg: &str, my_resource_handle: usize) { + println!("{} : {}", msg, my_resource_handle); +} + +use std::{ + future::{Future, async_drop_in_place, AsyncDrop}, + pin::{pin, Pin}, + sync::{mpsc, Arc}, + task::{Context, Poll, Wake, Waker}, +}; + +struct Foo { + my_resource_handle: usize, +} + +impl Foo { + fn new(my_resource_handle: usize) -> Self { + let out = Foo { + my_resource_handle, + }; + myprintln("Foo::new()", my_resource_handle); + out + } +} + +impl Drop for Foo { + fn drop(&mut self) { + myprintln("Foo::drop()", self.my_resource_handle); + } +} + +impl AsyncDrop for Foo { + async fn drop(self: Pin<&mut Self>) { + myprintln("Foo::async drop()", self.my_resource_handle); + } +} + +fn main() { + { + let _ = Foo::new(7); + } + println!("Middle"); + block_on(bar(10)); + println!("Done") +} + +async fn bar(ident_base: usize) { + let mut _first = Foo::new(ident_base); +} + +fn block_on<F>(fut_unpin: F) -> F::Output +where + F: Future, +{ + let mut fut_pin = pin!(ManuallyDrop::new(fut_unpin)); + let mut fut: Pin<&mut F> = unsafe { + Pin::map_unchecked_mut(fut_pin.as_mut(), |x| &mut **x) + }; + let (waker, rx) = simple_waker(); + let mut context = Context::from_waker(&waker); + let rv = loop { + match fut.as_mut().poll(&mut context) { + Poll::Ready(out) => break out, + // expect wake in polls + Poll::Pending => rx.try_recv().unwrap(), + } + }; + let drop_fut_unpin = unsafe { async_drop_in_place(fut.get_unchecked_mut()) }; + let mut drop_fut: Pin<&mut _> = pin!(drop_fut_unpin); + loop { + match drop_fut.as_mut().poll(&mut context) { + Poll::Ready(()) => break, + Poll::Pending => rx.try_recv().unwrap(), + } + } + rv +} + +fn simple_waker() -> (Waker, mpsc::Receiver<()>) { + struct SimpleWaker { + tx: std::sync::mpsc::Sender<()>, + } + + impl Wake for SimpleWaker { + fn wake(self: Arc<Self>) { + self.tx.send(()).unwrap(); + } + } + + let (tx, rx) = mpsc::channel(); + (Waker::from(Arc::new(SimpleWaker { tx })), rx) +} diff --git a/tests/ui/async-await/async-drop/async-drop.run.stdout b/tests/ui/async-await/async-drop/async-drop.run.stdout new file mode 100644 index 00000000000..cb7d0b0fea5 --- /dev/null +++ b/tests/ui/async-await/async-drop/async-drop.run.stdout @@ -0,0 +1,6 @@ +Foo::new() : 7 +Foo::drop() : 7 +Middle +Foo::new() : 10 +Foo::async drop() : 10 +Done diff --git a/tests/crashes/132103.rs b/tests/ui/async-await/async-drop/ex-ice-132103.rs index e2d8378efe6..3d32cb14fb0 100644 --- a/tests/crashes/132103.rs +++ b/tests/ui/async-await/async-drop/ex-ice-132103.rs @@ -1,6 +1,11 @@ -//@ known-bug: #132103 +//@ run-pass +//! This test used to ICE: rust-lang/rust#132103 +//! Fixed when re-work async drop to shim drop glue coroutine scheme. //@ compile-flags: -Zvalidate-mir -Zinline-mir=yes //@ edition: 2018 +#![feature(async_drop)] +#![allow(incomplete_features)] + use core::future::{async_drop_in_place, Future}; use core::mem::{self}; use core::pin::pin; @@ -18,5 +23,5 @@ fn main() { let fut = pin!(async { test_async_drop(test_async_drop(0)).await; }); - fut.poll(&mut cx); + let _ = fut.poll(&mut cx); } diff --git a/tests/ui/async-await/async-drop/ex-ice1.rs b/tests/ui/async-await/async-drop/ex-ice1.rs new file mode 100644 index 00000000000..f514c57097a --- /dev/null +++ b/tests/ui/async-await/async-drop/ex-ice1.rs @@ -0,0 +1,13 @@ +//! This test used to ICE: rust-lang/rust#128695 +//! Fixed when re-work async drop to shim drop glue coroutine scheme. +//@ edition: 2021 + +use core::pin::{pin, Pin}; + +fn main() { + let fut = pin!(async { + let async_drop_fut = pin!(core::future::async_drop(async {})); //~ ERROR: expected function, found module `core::future::async_drop` + //~^ ERROR: module `async_drop` is private + (async_drop_fut).await; + }); +} diff --git a/tests/ui/async-await/async-drop/ex-ice1.stderr b/tests/ui/async-await/async-drop/ex-ice1.stderr new file mode 100644 index 00000000000..68533edeb08 --- /dev/null +++ b/tests/ui/async-await/async-drop/ex-ice1.stderr @@ -0,0 +1,19 @@ +error[E0423]: expected function, found module `core::future::async_drop` + --> $DIR/ex-ice1.rs:9:35 + | +LL | let async_drop_fut = pin!(core::future::async_drop(async {})); + | ^^^^^^^^^^^^^^^^^^^^^^^^ not a function + +error[E0603]: module `async_drop` is private + --> $DIR/ex-ice1.rs:9:49 + | +LL | let async_drop_fut = pin!(core::future::async_drop(async {})); + | ^^^^^^^^^^ private module + | +note: the module `async_drop` is defined here + --> $SRC_DIR/core/src/future/mod.rs:LL:COL + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0423, E0603. +For more information about an error, try `rustc --explain E0423`. diff --git a/tests/ui/async-await/async-drop/partly-dropped-tuple.rs b/tests/ui/async-await/async-drop/partly-dropped-tuple.rs new file mode 100644 index 00000000000..147caaf4cfd --- /dev/null +++ b/tests/ui/async-await/async-drop/partly-dropped-tuple.rs @@ -0,0 +1,11 @@ +//@ edition: 2024 +//@ build-pass +#![crate_type = "lib"] +#![allow(incomplete_features)] +#![feature(async_drop)] +async fn move_part_await_return_rest_tuple() -> Vec<usize> { + let x = (vec![3], vec![4, 4]); + drop(x.1); + + x.0 +} diff --git a/tests/ui/async-await/in-trait/cycle-if-impl-doesnt-apply.rs b/tests/ui/async-await/in-trait/cycle-if-impl-doesnt-apply.rs new file mode 100644 index 00000000000..54992c98655 --- /dev/null +++ b/tests/ui/async-await/in-trait/cycle-if-impl-doesnt-apply.rs @@ -0,0 +1,39 @@ +//@ check-pass +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@ edition: 2024 + +// Regression test for <https://github.com/rust-lang/trait-system-refactor-initiative/issues/185>. +// Avoid unnecessarily computing the RPITIT type of the first impl when checking the WF of the +// second impl, since the first impl relies on the hidden type of the second impl. + +use std::future::Future; + +trait Handler {} + +struct W<T>(T); + +trait SendTarget { + fn call(self) -> impl Future<Output = ()> + Send; +} + +impl<T> SendTarget for W<T> +where + T: Handler + Send, +{ + async fn call(self) { + todo!() + } +} + +impl<T> SendTarget for T +where + T: Handler + Send, +{ + async fn call(self) { + W(self).call().await + } +} + +fn main() {} diff --git a/tests/ui/auxiliary/default-ty-param-cross-crate-crate.rs b/tests/ui/auxiliary/default-ty-param-cross-crate-crate.rs deleted file mode 100644 index d722b78768a..00000000000 --- a/tests/ui/auxiliary/default-ty-param-cross-crate-crate.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![crate_type = "lib"] -#![crate_name = "default_param_test"] -#![feature(default_type_parameter_fallback)] - -use std::marker::PhantomData; - -pub struct Foo<A, B>(PhantomData<(A, B)>); - -pub fn bleh<A=i32, X=char>() -> Foo<A, X> { Foo(PhantomData) } diff --git a/tests/ui/auxiliary/edition-kw-macro-2015.rs b/tests/ui/auxiliary/edition-kw-macro-2015.rs deleted file mode 100644 index 7f479fa9370..00000000000 --- a/tests/ui/auxiliary/edition-kw-macro-2015.rs +++ /dev/null @@ -1,26 +0,0 @@ -//@ edition:2015 - -#[macro_export] -macro_rules! produces_async { - () => (pub fn async() {}) -} - -#[macro_export] -macro_rules! produces_async_raw { - () => (pub fn r#async() {}) -} - -#[macro_export] -macro_rules! consumes_async { - (async) => (1) -} - -#[macro_export] -macro_rules! consumes_async_raw { - (r#async) => (1) -} - -#[macro_export] -macro_rules! passes_ident { - ($i: ident) => ($i) -} diff --git a/tests/ui/auxiliary/edition-kw-macro-2018.rs b/tests/ui/auxiliary/edition-kw-macro-2018.rs deleted file mode 100644 index ba8ecc4d83b..00000000000 --- a/tests/ui/auxiliary/edition-kw-macro-2018.rs +++ /dev/null @@ -1,26 +0,0 @@ -//@ edition:2018 - -#[macro_export] -macro_rules! produces_async { - () => (pub fn async() {}) -} - -#[macro_export] -macro_rules! produces_async_raw { - () => (pub fn r#async() {}) -} - -#[macro_export] -macro_rules! consumes_async { - (async) => (1) -} - -#[macro_export] -macro_rules! consumes_async_raw { - (r#async) => (1) -} - -#[macro_export] -macro_rules! passes_ident { - ($i: ident) => ($i) -} diff --git a/tests/ui/auxiliary/removing-extern-crate.rs b/tests/ui/auxiliary/removing-extern-crate.rs deleted file mode 100644 index 65e2cc34045..00000000000 --- a/tests/ui/auxiliary/removing-extern-crate.rs +++ /dev/null @@ -1 +0,0 @@ -// intentionally blank diff --git a/tests/ui/binop/shift-various-bad-types.rs b/tests/ui/binop/shift-various-bad-types.rs index 31224bbca1e..025cd922d78 100644 --- a/tests/ui/binop/shift-various-bad-types.rs +++ b/tests/ui/binop/shift-various-bad-types.rs @@ -1,5 +1,7 @@ // Test that we can do shifts by any integral type. +//@ dont-require-annotations: NOTE + struct Panolpy { char: char, str: &'static str, @@ -24,7 +26,7 @@ fn foo(p: &Panolpy) { // Type of the result follows the LHS, not the RHS: let _: i32 = 22_i64 >> 1_i32; //~^ ERROR mismatched types - //~| expected `i32`, found `i64` + //~| NOTE expected `i32`, found `i64` } fn main() { diff --git a/tests/ui/binop/shift-various-bad-types.stderr b/tests/ui/binop/shift-various-bad-types.stderr index d7c9eb5f9df..5d16ed7e50b 100644 --- a/tests/ui/binop/shift-various-bad-types.stderr +++ b/tests/ui/binop/shift-various-bad-types.stderr @@ -1,5 +1,5 @@ error[E0277]: no implementation for `{integer} >> char` - --> $DIR/shift-various-bad-types.rs:9:8 + --> $DIR/shift-various-bad-types.rs:11:8 | LL | 22 >> p.char; | ^^ no implementation for `{integer} >> char` @@ -17,7 +17,7 @@ LL | 22 >> p.char; and 568 others error[E0277]: no implementation for `{integer} >> &str` - --> $DIR/shift-various-bad-types.rs:12:8 + --> $DIR/shift-various-bad-types.rs:14:8 | LL | 22 >> p.str; | ^^ no implementation for `{integer} >> &str` @@ -35,7 +35,7 @@ LL | 22 >> p.str; and 568 others error[E0277]: no implementation for `{integer} >> &Panolpy` - --> $DIR/shift-various-bad-types.rs:15:8 + --> $DIR/shift-various-bad-types.rs:17:8 | LL | 22 >> p; | ^^ no implementation for `{integer} >> &Panolpy` @@ -53,7 +53,7 @@ LL | 22 >> p; and 568 others error[E0308]: mismatched types - --> $DIR/shift-various-bad-types.rs:25:18 + --> $DIR/shift-various-bad-types.rs:27:18 | LL | let _: i32 = 22_i64 >> 1_i32; | --- ^^^^^^^^^^^^^^^ expected `i32`, found `i64` diff --git a/tests/ui/blind/blind-item-item-shadow.rs b/tests/ui/blind/blind-item-item-shadow.rs index 82d07ea7091..43841569417 100644 --- a/tests/ui/blind/blind-item-item-shadow.rs +++ b/tests/ui/blind/blind-item-item-shadow.rs @@ -1,7 +1,9 @@ +//@ dont-require-annotations: NOTE + mod foo { pub mod foo { } } use foo::foo; //~^ ERROR the name `foo` is defined multiple times -//~| `foo` reimported here +//~| NOTE `foo` reimported here fn main() {} diff --git a/tests/ui/blind/blind-item-item-shadow.stderr b/tests/ui/blind/blind-item-item-shadow.stderr index 08f5f5b47ed..7d13fbea37b 100644 --- a/tests/ui/blind/blind-item-item-shadow.stderr +++ b/tests/ui/blind/blind-item-item-shadow.stderr @@ -1,5 +1,5 @@ error[E0255]: the name `foo` is defined multiple times - --> $DIR/blind-item-item-shadow.rs:3:5 + --> $DIR/blind-item-item-shadow.rs:5:5 | LL | mod foo { pub mod foo { } } | ------- previous definition of the module `foo` here diff --git a/tests/ui/block-result/block-must-not-have-result-while.rs b/tests/ui/block-result/block-must-not-have-result-while.rs index 418059bf280..ada4e1778a5 100644 --- a/tests/ui/block-result/block-must-not-have-result-while.rs +++ b/tests/ui/block-result/block-must-not-have-result-while.rs @@ -1,6 +1,8 @@ +//@ dont-require-annotations: NOTE + fn main() { while true { //~ WARN denote infinite loops with true //~ ERROR mismatched types - //~| expected `()`, found `bool` + //~| NOTE expected `()`, found `bool` } } diff --git a/tests/ui/block-result/block-must-not-have-result-while.stderr b/tests/ui/block-result/block-must-not-have-result-while.stderr index 94a4b33da5d..0b9941ea96e 100644 --- a/tests/ui/block-result/block-must-not-have-result-while.stderr +++ b/tests/ui/block-result/block-must-not-have-result-while.stderr @@ -1,5 +1,5 @@ warning: denote infinite loops with `loop { ... }` - --> $DIR/block-must-not-have-result-while.rs:2:5 + --> $DIR/block-must-not-have-result-while.rs:4:5 | LL | while true { | ^^^^^^^^^^ help: use `loop` @@ -7,7 +7,7 @@ LL | while true { = note: `#[warn(while_true)]` on by default error[E0308]: mismatched types - --> $DIR/block-must-not-have-result-while.rs:3:9 + --> $DIR/block-must-not-have-result-while.rs:5:9 | LL | / while true { LL | | true diff --git a/tests/ui/block-result/issue-13624.rs b/tests/ui/block-result/issue-13624.rs index 8f93e5a356f..f9f7c33e411 100644 --- a/tests/ui/block-result/issue-13624.rs +++ b/tests/ui/block-result/issue-13624.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + mod a { pub enum Enum { EnumStructVariant { x: u8, y: u8, z: u8 } @@ -6,7 +8,7 @@ mod a { pub fn get_enum_struct_variant() -> () { Enum::EnumStructVariant { x: 1, y: 2, z: 3 } //~^ ERROR mismatched types - //~| expected `()`, found `Enum` + //~| NOTE expected `()`, found `Enum` } } @@ -19,7 +21,7 @@ mod b { match enum_struct_variant { a::Enum::EnumStructVariant { x, y, z } => { //~^ ERROR mismatched types - //~| expected `()`, found `Enum` + //~| NOTE expected `()`, found `Enum` } } } diff --git a/tests/ui/block-result/issue-13624.stderr b/tests/ui/block-result/issue-13624.stderr index d41bd057f82..16f5233a041 100644 --- a/tests/ui/block-result/issue-13624.stderr +++ b/tests/ui/block-result/issue-13624.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-13624.rs:7:5 + --> $DIR/issue-13624.rs:9:5 | LL | pub fn get_enum_struct_variant() -> () { | -- expected `()` because of return type @@ -7,7 +7,7 @@ LL | Enum::EnumStructVariant { x: 1, y: 2, z: 3 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `Enum` error[E0308]: mismatched types - --> $DIR/issue-13624.rs:20:9 + --> $DIR/issue-13624.rs:22:9 | LL | match enum_struct_variant { | ------------------- this expression has type `()` diff --git a/tests/ui/block-result/issue-5500.rs b/tests/ui/block-result/issue-5500.rs index de7fd39a20c..cbad6a27c1d 100644 --- a/tests/ui/block-result/issue-5500.rs +++ b/tests/ui/block-result/issue-5500.rs @@ -1,7 +1,7 @@ -fn main() { +fn main() { //~ NOTE expected `()` because of default return type &panic!() //~^ ERROR mismatched types - //~| expected unit type `()` - //~| found reference `&_` - //~| expected `()`, found `&_` + //~| NOTE expected unit type `()` + //~| NOTE found reference `&_` + //~| NOTE expected `()`, found `&_` } diff --git a/tests/ui/borrowck/borrowck-report-with-custom-diagnostic.rs b/tests/ui/borrowck/borrowck-report-with-custom-diagnostic.rs index 9d323bf0324..caa312edd71 100644 --- a/tests/ui/borrowck/borrowck-report-with-custom-diagnostic.rs +++ b/tests/ui/borrowck/borrowck-report-with-custom-diagnostic.rs @@ -1,11 +1,13 @@ +//@ dont-require-annotations: NOTE + #![allow(dead_code)] fn main() { // Original borrow ends at end of function let mut x = 1; let y = &mut x; - //~^ mutable borrow occurs here + //~^ NOTE mutable borrow occurs here let z = &x; //~ ERROR cannot borrow - //~^ immutable borrow occurs here + //~^ NOTE immutable borrow occurs here z.use_ref(); y.use_mut(); } @@ -16,9 +18,9 @@ fn foo() { // Original borrow ends at end of match arm let mut x = 1; let y = &x; - //~^ immutable borrow occurs here + //~^ NOTE immutable borrow occurs here let z = &mut x; //~ ERROR cannot borrow - //~^ mutable borrow occurs here + //~^ NOTE mutable borrow occurs here z.use_mut(); y.use_ref(); } @@ -31,9 +33,9 @@ fn bar() { || { let mut x = 1; let y = &mut x; - //~^ first mutable borrow occurs here + //~^ NOTE first mutable borrow occurs here let z = &mut x; //~ ERROR cannot borrow - //~^ second mutable borrow occurs here + //~^ NOTE second mutable borrow occurs here z.use_mut(); y.use_mut(); }; diff --git a/tests/ui/borrowck/borrowck-report-with-custom-diagnostic.stderr b/tests/ui/borrowck/borrowck-report-with-custom-diagnostic.stderr index 444a74cbfcf..e2474737aad 100644 --- a/tests/ui/borrowck/borrowck-report-with-custom-diagnostic.stderr +++ b/tests/ui/borrowck/borrowck-report-with-custom-diagnostic.stderr @@ -1,5 +1,5 @@ error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-report-with-custom-diagnostic.rs:7:13 + --> $DIR/borrowck-report-with-custom-diagnostic.rs:9:13 | LL | let y = &mut x; | ------ mutable borrow occurs here @@ -11,7 +11,7 @@ LL | y.use_mut(); | - mutable borrow later used here error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-report-with-custom-diagnostic.rs:20:21 + --> $DIR/borrowck-report-with-custom-diagnostic.rs:22:21 | LL | let y = &x; | -- immutable borrow occurs here @@ -23,7 +23,7 @@ LL | y.use_ref(); | - immutable borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-report-with-custom-diagnostic.rs:35:17 + --> $DIR/borrowck-report-with-custom-diagnostic.rs:37:17 | LL | let y = &mut x; | ------ first mutable borrow occurs here diff --git a/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.rs b/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.rs index b09c96ada8a..5106ba6c86c 100644 --- a/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.rs +++ b/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.rs @@ -17,7 +17,7 @@ impl Foo { fn main() { unsafe { let sfoo: *mut Foo = &mut SFOO; - //~^ WARN mutable reference to mutable static is discouraged [static_mut_refs] + //~^ WARN mutable reference to mutable static [static_mut_refs] let x = (*sfoo).x(); (*sfoo).x[1] += 1; *x += 1; diff --git a/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.stderr b/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.stderr index a392177ffe2..4e19fd81735 100644 --- a/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.stderr +++ b/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.stderr @@ -1,4 +1,4 @@ -warning: creating a mutable reference to mutable static is discouraged +warning: creating a mutable reference to mutable static --> $DIR/borrowck-unsafe-static-mutable-borrows.rs:19:30 | LL | let sfoo: *mut Foo = &mut SFOO; diff --git a/tests/ui/borrowck/issue-81899.rs b/tests/ui/borrowck/issue-81899.rs index 380c03751f5..11755620d86 100644 --- a/tests/ui/borrowck/issue-81899.rs +++ b/tests/ui/borrowck/issue-81899.rs @@ -1,14 +1,16 @@ // Regression test for #81899. // The `panic!()` below is important to trigger the fixed ICE. +//@ dont-require-annotations: NOTE + const _CONST: &[u8] = &f(&[], |_| {}); //~ ERROR evaluation of constant value failed -//~^ constant +//~^ NOTE constant const fn f<F>(_: &[u8], _: F) -> &[u8] where F: FnMut(&u8), { - panic!() //~ inside `f + panic!() //~ NOTE inside `f } fn main() {} diff --git a/tests/ui/borrowck/issue-81899.stderr b/tests/ui/borrowck/issue-81899.stderr index b5cd5e4abf3..97d463cb6a7 100644 --- a/tests/ui/borrowck/issue-81899.stderr +++ b/tests/ui/borrowck/issue-81899.stderr @@ -1,17 +1,17 @@ error[E0080]: evaluation of constant value failed - --> $DIR/issue-81899.rs:4:24 + --> $DIR/issue-81899.rs:6:24 | LL | const _CONST: &[u8] = &f(&[], |_| {}); | ^^^^^^^^^^^^^^ evaluation panicked: explicit panic | -note: inside `f::<{closure@$DIR/issue-81899.rs:4:31: 4:34}>` - --> $DIR/issue-81899.rs:11:5 +note: inside `f::<{closure@$DIR/issue-81899.rs:6:31: 6:34}>` + --> $DIR/issue-81899.rs:13:5 | LL | panic!() | ^^^^^^^^ the failure occurred here note: erroneous constant encountered - --> $DIR/issue-81899.rs:4:23 + --> $DIR/issue-81899.rs:6:23 | LL | const _CONST: &[u8] = &f(&[], |_| {}); | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/borrowck/issue-88434-minimal-example.rs b/tests/ui/borrowck/issue-88434-minimal-example.rs index ebaa9a92273..7482b3fd612 100644 --- a/tests/ui/borrowck/issue-88434-minimal-example.rs +++ b/tests/ui/borrowck/issue-88434-minimal-example.rs @@ -1,13 +1,15 @@ // Regression test related to issue 88434 +//@ dont-require-annotations: NOTE + const _CONST: &() = &f(&|_| {}); //~ ERROR evaluation of constant value failed -//~^ constant +//~^ NOTE constant const fn f<F>(_: &F) where F: FnMut(&u8), { - panic!() //~ inside `f + panic!() //~ NOTE inside `f } fn main() { } diff --git a/tests/ui/borrowck/issue-88434-minimal-example.stderr b/tests/ui/borrowck/issue-88434-minimal-example.stderr index d9f3b4dcb90..4c525b9ea2c 100644 --- a/tests/ui/borrowck/issue-88434-minimal-example.stderr +++ b/tests/ui/borrowck/issue-88434-minimal-example.stderr @@ -1,17 +1,17 @@ error[E0080]: evaluation of constant value failed - --> $DIR/issue-88434-minimal-example.rs:3:22 + --> $DIR/issue-88434-minimal-example.rs:5:22 | LL | const _CONST: &() = &f(&|_| {}); | ^^^^^^^^^^ evaluation panicked: explicit panic | -note: inside `f::<{closure@$DIR/issue-88434-minimal-example.rs:3:25: 3:28}>` - --> $DIR/issue-88434-minimal-example.rs:10:5 +note: inside `f::<{closure@$DIR/issue-88434-minimal-example.rs:5:25: 5:28}>` + --> $DIR/issue-88434-minimal-example.rs:12:5 | LL | panic!() | ^^^^^^^^ the failure occurred here note: erroneous constant encountered - --> $DIR/issue-88434-minimal-example.rs:3:21 + --> $DIR/issue-88434-minimal-example.rs:5:21 | LL | const _CONST: &() = &f(&|_| {}); | ^^^^^^^^^^^ diff --git a/tests/ui/borrowck/issue-88434-removal-index-should-be-less.rs b/tests/ui/borrowck/issue-88434-removal-index-should-be-less.rs index 8d042630424..09b1f59c449 100644 --- a/tests/ui/borrowck/issue-88434-removal-index-should-be-less.rs +++ b/tests/ui/borrowck/issue-88434-removal-index-should-be-less.rs @@ -1,13 +1,15 @@ // Regression test for issue 88434 +//@ dont-require-annotations: NOTE + const _CONST: &[u8] = &f(&[], |_| {}); //~ ERROR evaluation of constant value failed -//~^ constant +//~^ NOTE constant const fn f<F>(_: &[u8], _: F) -> &[u8] where F: FnMut(&u8), { - panic!() //~ inside `f + panic!() //~ NOTE inside `f } fn main() { } diff --git a/tests/ui/borrowck/issue-88434-removal-index-should-be-less.stderr b/tests/ui/borrowck/issue-88434-removal-index-should-be-less.stderr index c82b5cf786d..a22621c9c1b 100644 --- a/tests/ui/borrowck/issue-88434-removal-index-should-be-less.stderr +++ b/tests/ui/borrowck/issue-88434-removal-index-should-be-less.stderr @@ -1,17 +1,17 @@ error[E0080]: evaluation of constant value failed - --> $DIR/issue-88434-removal-index-should-be-less.rs:3:24 + --> $DIR/issue-88434-removal-index-should-be-less.rs:5:24 | LL | const _CONST: &[u8] = &f(&[], |_| {}); | ^^^^^^^^^^^^^^ evaluation panicked: explicit panic | -note: inside `f::<{closure@$DIR/issue-88434-removal-index-should-be-less.rs:3:31: 3:34}>` - --> $DIR/issue-88434-removal-index-should-be-less.rs:10:5 +note: inside `f::<{closure@$DIR/issue-88434-removal-index-should-be-less.rs:5:31: 5:34}>` + --> $DIR/issue-88434-removal-index-should-be-less.rs:12:5 | LL | panic!() | ^^^^^^^^ the failure occurred here note: erroneous constant encountered - --> $DIR/issue-88434-removal-index-should-be-less.rs:3:23 + --> $DIR/issue-88434-removal-index-should-be-less.rs:5:23 | LL | const _CONST: &[u8] = &f(&[], |_| {}); | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/cast/ptr-to-trait-obj-different-regions-misc.rs b/tests/ui/cast/ptr-to-trait-obj-different-regions-misc.rs index f8910c944c6..ce94ba657b8 100644 --- a/tests/ui/cast/ptr-to-trait-obj-different-regions-misc.rs +++ b/tests/ui/cast/ptr-to-trait-obj-different-regions-misc.rs @@ -1,4 +1,5 @@ //@ check-fail +//@ dont-require-annotations: NOTE trait Trait<'a> {} @@ -18,7 +19,7 @@ fn change_lt_ba<'a, 'b: 'a>(x: *mut dyn Trait<'a>) -> *mut dyn Trait<'b> { fn change_lt_hr<'a>(x: *mut dyn Trait<'a>) -> *mut dyn for<'b> Trait<'b> { x as _ //~ error: lifetime may not live long enough //~^ error: mismatched types - //~| one type is more general than the other + //~| NOTE one type is more general than the other } trait Assocked { diff --git a/tests/ui/cast/ptr-to-trait-obj-different-regions-misc.stderr b/tests/ui/cast/ptr-to-trait-obj-different-regions-misc.stderr index faaa6325f34..88a89dc4ac1 100644 --- a/tests/ui/cast/ptr-to-trait-obj-different-regions-misc.stderr +++ b/tests/ui/cast/ptr-to-trait-obj-different-regions-misc.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:6:5 + --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:7:5 | LL | fn change_lt<'a, 'b>(x: *mut dyn Trait<'a>) -> *mut dyn Trait<'b> { | -- -- lifetime `'b` defined here @@ -14,7 +14,7 @@ LL | x as _ = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance error: lifetime may not live long enough - --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:6:5 + --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:7:5 | LL | fn change_lt<'a, 'b>(x: *mut dyn Trait<'a>) -> *mut dyn Trait<'b> { | -- -- lifetime `'b` defined here @@ -31,7 +31,7 @@ LL | x as _ help: `'b` and `'a` must be the same: replace one with the other error: lifetime may not live long enough - --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:11:5 + --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:12:5 | LL | fn change_lt_ab<'a: 'b, 'b>(x: *mut dyn Trait<'a>) -> *mut dyn Trait<'b> { | -- -- lifetime `'b` defined here @@ -46,7 +46,7 @@ LL | x as _ = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance error: lifetime may not live long enough - --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:15:5 + --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:16:5 | LL | fn change_lt_ba<'a, 'b: 'a>(x: *mut dyn Trait<'a>) -> *mut dyn Trait<'b> { | -- -- lifetime `'b` defined here @@ -61,7 +61,7 @@ LL | x as _ = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance error: lifetime may not live long enough - --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:19:5 + --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:20:5 | LL | fn change_lt_hr<'a>(x: *mut dyn Trait<'a>) -> *mut dyn for<'b> Trait<'b> { | -- lifetime `'a` defined here @@ -74,7 +74,7 @@ LL | fn change_lt_hr<'a>(x: *mut dyn Trait<'a>) -> *mut dyn for<'b> Trait<'b> + | ++++ error[E0308]: mismatched types - --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:19:5 + --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:20:5 | LL | x as _ | ^^^^^^ one type is more general than the other @@ -83,7 +83,7 @@ LL | x as _ found trait object `dyn Trait<'_>` error: lifetime may not live long enough - --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:31:5 + --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:32:5 | LL | fn change_assoc_0<'a, 'b>( | -- -- lifetime `'b` defined here @@ -99,7 +99,7 @@ LL | x as _ = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance error: lifetime may not live long enough - --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:31:5 + --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:32:5 | LL | fn change_assoc_0<'a, 'b>( | -- -- lifetime `'b` defined here @@ -119,7 +119,7 @@ help: `'b` and `'a` must be the same: replace one with the other = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: lifetime may not live long enough - --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:38:5 + --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:39:5 | LL | fn change_assoc_1<'a, 'b>( | -- -- lifetime `'b` defined here @@ -135,7 +135,7 @@ LL | x as _ = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance error: lifetime may not live long enough - --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:38:5 + --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:39:5 | LL | fn change_assoc_1<'a, 'b>( | -- -- lifetime `'b` defined here @@ -155,7 +155,7 @@ help: `'b` and `'a` must be the same: replace one with the other = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0521]: borrowed data escapes outside of function - --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:45:5 + --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:46:5 | LL | fn extend_to_static<'a>(ptr: *const dyn Trait<'a>) { | -- --- diff --git a/tests/ui/catch-unwind-bang.rs b/tests/ui/catch-unwind-bang.rs deleted file mode 100644 index c874c649f33..00000000000 --- a/tests/ui/catch-unwind-bang.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass -//@ needs-unwind - -fn worker() -> ! { - panic!() -} - -fn main() { - std::panic::catch_unwind(worker).unwrap_err(); -} diff --git a/tests/ui/cfg/disallowed-cli-cfgs.reliable_f128_.stderr b/tests/ui/cfg/disallowed-cli-cfgs.reliable_f128_.stderr new file mode 100644 index 00000000000..1b6e0506001 --- /dev/null +++ b/tests/ui/cfg/disallowed-cli-cfgs.reliable_f128_.stderr @@ -0,0 +1,8 @@ +error: unexpected `--cfg target_has_reliable_f128` flag + | + = note: config `target_has_reliable_f128` is only supposed to be controlled by `--target` + = note: manually setting a built-in cfg can and does create incoherent behaviors + = note: `#[deny(explicit_builtin_cfgs_in_flags)]` on by default + +error: aborting due to 1 previous error + diff --git a/tests/ui/cfg/disallowed-cli-cfgs.reliable_f128_math_.stderr b/tests/ui/cfg/disallowed-cli-cfgs.reliable_f128_math_.stderr new file mode 100644 index 00000000000..86e7342b8fc --- /dev/null +++ b/tests/ui/cfg/disallowed-cli-cfgs.reliable_f128_math_.stderr @@ -0,0 +1,8 @@ +error: unexpected `--cfg target_has_reliable_f128_math` flag + | + = note: config `target_has_reliable_f128_math` is only supposed to be controlled by `--target` + = note: manually setting a built-in cfg can and does create incoherent behaviors + = note: `#[deny(explicit_builtin_cfgs_in_flags)]` on by default + +error: aborting due to 1 previous error + diff --git a/tests/ui/cfg/disallowed-cli-cfgs.reliable_f16_.stderr b/tests/ui/cfg/disallowed-cli-cfgs.reliable_f16_.stderr new file mode 100644 index 00000000000..cf5000ecf27 --- /dev/null +++ b/tests/ui/cfg/disallowed-cli-cfgs.reliable_f16_.stderr @@ -0,0 +1,8 @@ +error: unexpected `--cfg target_has_reliable_f16` flag + | + = note: config `target_has_reliable_f16` is only supposed to be controlled by `--target` + = note: manually setting a built-in cfg can and does create incoherent behaviors + = note: `#[deny(explicit_builtin_cfgs_in_flags)]` on by default + +error: aborting due to 1 previous error + diff --git a/tests/ui/cfg/disallowed-cli-cfgs.reliable_f16_math_.stderr b/tests/ui/cfg/disallowed-cli-cfgs.reliable_f16_math_.stderr new file mode 100644 index 00000000000..079e5627e4c --- /dev/null +++ b/tests/ui/cfg/disallowed-cli-cfgs.reliable_f16_math_.stderr @@ -0,0 +1,8 @@ +error: unexpected `--cfg target_has_reliable_f16_math` flag + | + = note: config `target_has_reliable_f16_math` is only supposed to be controlled by `--target` + = note: manually setting a built-in cfg can and does create incoherent behaviors + = note: `#[deny(explicit_builtin_cfgs_in_flags)]` on by default + +error: aborting due to 1 previous error + diff --git a/tests/ui/cfg/disallowed-cli-cfgs.rs b/tests/ui/cfg/disallowed-cli-cfgs.rs index e9661abf3ab..f7f9d2b5cd7 100644 --- a/tests/ui/cfg/disallowed-cli-cfgs.rs +++ b/tests/ui/cfg/disallowed-cli-cfgs.rs @@ -8,6 +8,7 @@ //@ revisions: target_thread_local_ relocation_model_ //@ revisions: fmt_debug_ //@ revisions: emscripten_wasm_eh_ +//@ revisions: reliable_f16_ reliable_f16_math_ reliable_f128_ reliable_f128_math_ //@ [overflow_checks_]compile-flags: --cfg overflow_checks //@ [debug_assertions_]compile-flags: --cfg debug_assertions @@ -35,6 +36,10 @@ //@ [relocation_model_]compile-flags: --cfg relocation_model="a" //@ [fmt_debug_]compile-flags: --cfg fmt_debug="shallow" //@ [emscripten_wasm_eh_]compile-flags: --cfg emscripten_wasm_eh +//@ [reliable_f16_]compile-flags: --cfg target_has_reliable_f16 +//@ [reliable_f16_math_]compile-flags: --cfg target_has_reliable_f16_math +//@ [reliable_f128_]compile-flags: --cfg target_has_reliable_f128 +//@ [reliable_f128_math_]compile-flags: --cfg target_has_reliable_f128_math fn main() {} diff --git a/tests/ui/check-cfg/and-more-diagnostic.rs b/tests/ui/check-cfg/and-more-diagnostic.rs index 977f55e8a6d..5422829c5b3 100644 --- a/tests/ui/check-cfg/and-more-diagnostic.rs +++ b/tests/ui/check-cfg/and-more-diagnostic.rs @@ -5,7 +5,7 @@ //@ no-auto-check-cfg //@ compile-flags: --check-cfg=cfg() //@ normalize-stderr: "and \d+ more" -> "and X more" -//@ normalize-stderr: "`[a-zA-Z0-9_-]+`" -> "`xxx`" +//@ normalize-stderr: "`[a-zA-Z0-9_\.-]+`" -> "`xxx`" fn main() { cfg!(target_feature = "zebra"); diff --git a/tests/ui/check-cfg/target_feature.stderr b/tests/ui/check-cfg/target_feature.stderr index 4f7b8345e86..3d7323298ba 100644 --- a/tests/ui/check-cfg/target_feature.stderr +++ b/tests/ui/check-cfg/target_feature.stderr @@ -29,6 +29,8 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `amx-transpose` `atomics` `avx` +`avx10.1` +`avx10.2` `avx2` `avx512bf16` `avx512bitalg` @@ -324,12 +326,20 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `zcmop` `zdinx` `zfa` +`zfbfmin` `zfh` `zfhmin` `zfinx` `zhinx` `zhinxmin` +`zic64b` +`zicbom` +`zicbop` `zicboz` +`ziccamoa` +`ziccif` +`zicclsm` +`ziccrse` `zicntr` `zicond` `zicsr` @@ -356,6 +366,8 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `zve64d` `zve64f` `zve64x` +`zvfbfmin` +`zvfbfwma` `zvfh` `zvfhmin` `zvkb` diff --git a/tests/ui/cfguard-run.rs b/tests/ui/codegen/cfguard-run.rs index 52ad3e3cc04..52ad3e3cc04 100644 --- a/tests/ui/cfguard-run.rs +++ b/tests/ui/codegen/cfguard-run.rs diff --git a/tests/ui/codegen/equal-pointers-unequal/as-cast/basic.rs b/tests/ui/codegen/equal-pointers-unequal/as-cast/basic.rs deleted file mode 100644 index e2a00ce173d..00000000000 --- a/tests/ui/codegen/equal-pointers-unequal/as-cast/basic.rs +++ /dev/null @@ -1,21 +0,0 @@ -//@ known-bug: #107975 -//@ compile-flags: -Copt-level=2 -//@ run-pass - -fn main() { - let a: usize = { - let v = 0u8; - &v as *const _ as usize - }; - let b: usize = { - let v = 0u8; - &v as *const _ as usize - }; - - // `a` and `b` are not equal. - assert_ne!(a, b); - // But they are the same number. - assert_eq!(format!("{a}"), format!("{b}")); - // And they are equal. - assert_eq!(a, b); -} diff --git a/tests/ui/codegen/equal-pointers-unequal/as-cast/function.rs b/tests/ui/codegen/equal-pointers-unequal/as-cast/function.rs deleted file mode 100644 index 15434de50f7..00000000000 --- a/tests/ui/codegen/equal-pointers-unequal/as-cast/function.rs +++ /dev/null @@ -1,22 +0,0 @@ -//@ known-bug: #107975 -//@ compile-flags: -Copt-level=2 -//@ run-pass - -// Based on https://github.com/rust-lang/rust/issues/107975#issuecomment-1434203908 - -fn f() -> usize { - let v = 0; - &v as *const _ as usize -} - -fn main() { - let a = f(); - let b = f(); - - // `a` and `b` are not equal. - assert_ne!(a, b); - // But they are the same number. - assert_eq!(format!("{a}"), format!("{b}")); - // And they are equal. - assert_eq!(a, b); -} diff --git a/tests/ui/codegen/equal-pointers-unequal/as-cast/print.rs b/tests/ui/codegen/equal-pointers-unequal/as-cast/print.rs deleted file mode 100644 index f33a9e511b6..00000000000 --- a/tests/ui/codegen/equal-pointers-unequal/as-cast/print.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ known-bug: #107975 -//@ compile-flags: -Copt-level=2 -//@ run-pass - -// https://github.com/rust-lang/rust/issues/107975#issuecomment-1430704499 - -fn main() { - let a = { - let v = 0; - &v as *const _ as usize - }; - let b = { - let v = 0; - &v as *const _ as usize - }; - - assert_ne!(a, b); - println!("{a}"); // or b - assert_eq!(a, b); -} diff --git a/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/basic.rs b/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/basic.rs deleted file mode 100644 index b2b4934aa5f..00000000000 --- a/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/basic.rs +++ /dev/null @@ -1,23 +0,0 @@ -//@ known-bug: #107975 -//@ compile-flags: -Copt-level=2 -//@ run-pass - -use std::ptr; - -fn main() { - let a: usize = { - let v = 0u8; - ptr::from_ref(&v).expose_provenance() - }; - let b: usize = { - let v = 0u8; - ptr::from_ref(&v).expose_provenance() - }; - - // `a` and `b` are not equal. - assert_ne!(a, b); - // But they are the same number. - assert_eq!(format!("{a}"), format!("{b}")); - // And they are equal. - assert_eq!(a, b); -} diff --git a/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/function.rs b/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/function.rs deleted file mode 100644 index bf130c9f759..00000000000 --- a/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/function.rs +++ /dev/null @@ -1,24 +0,0 @@ -//@ known-bug: #107975 -//@ compile-flags: -Copt-level=2 -//@ run-pass - -// Based on https://github.com/rust-lang/rust/issues/107975#issuecomment-1434203908 - -use std::ptr; - -fn f() -> usize { - let v = 0; - ptr::from_ref(&v).expose_provenance() -} - -fn main() { - let a = f(); - let b = f(); - - // `a` and `b` are not equal. - assert_ne!(a, b); - // But they are the same number. - assert_eq!(format!("{a}"), format!("{b}")); - // And they are equal. - assert_eq!(a, b); -} diff --git a/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/print.rs b/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/print.rs deleted file mode 100644 index 0baf8886395..00000000000 --- a/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/print.rs +++ /dev/null @@ -1,22 +0,0 @@ -//@ known-bug: #107975 -//@ compile-flags: -Copt-level=2 -//@ run-pass - -// https://github.com/rust-lang/rust/issues/107975#issuecomment-1430704499 - -use std::ptr; - -fn main() { - let a: usize = { - let v = 0; - ptr::from_ref(&v).expose_provenance() - }; - let b: usize = { - let v = 0; - ptr::from_ref(&v).expose_provenance() - }; - - assert_ne!(a, b); - println!("{a}"); // or b - assert_eq!(a, b); -} diff --git a/tests/ui/codegen/equal-pointers-unequal/strict-provenance/basic.rs b/tests/ui/codegen/equal-pointers-unequal/strict-provenance/basic.rs deleted file mode 100644 index 4602ec654d1..00000000000 --- a/tests/ui/codegen/equal-pointers-unequal/strict-provenance/basic.rs +++ /dev/null @@ -1,23 +0,0 @@ -//@ known-bug: #107975 -//@ compile-flags: -Copt-level=2 -//@ run-pass - -use std::ptr; - -fn main() { - let a: usize = { - let v = 0u8; - ptr::from_ref(&v).addr() - }; - let b: usize = { - let v = 0u8; - ptr::from_ref(&v).addr() - }; - - // `a` and `b` are not equal. - assert_ne!(a, b); - // But they are the same number. - assert_eq!(format!("{a}"), format!("{b}")); - // And they are equal. - assert_eq!(a, b); -} diff --git a/tests/ui/codegen/equal-pointers-unequal/strict-provenance/function.rs b/tests/ui/codegen/equal-pointers-unequal/strict-provenance/function.rs deleted file mode 100644 index 789a78c15b4..00000000000 --- a/tests/ui/codegen/equal-pointers-unequal/strict-provenance/function.rs +++ /dev/null @@ -1,24 +0,0 @@ -//@ known-bug: #107975 -//@ compile-flags: -Copt-level=2 -//@ run-pass - -// Based on https://github.com/rust-lang/rust/issues/107975#issuecomment-1434203908 - -use std::ptr; - -fn f() -> usize { - let v = 0; - ptr::from_ref(&v).addr() -} - -fn main() { - let a = f(); - let b = f(); - - // `a` and `b` are not equal. - assert_ne!(a, b); - // But they are the same number. - assert_eq!(format!("{a}"), format!("{b}")); - // And they are equal. - assert_eq!(a, b); -} diff --git a/tests/ui/codegen/equal-pointers-unequal/strict-provenance/print.rs b/tests/ui/codegen/equal-pointers-unequal/strict-provenance/print.rs deleted file mode 100644 index b7165ce1e5c..00000000000 --- a/tests/ui/codegen/equal-pointers-unequal/strict-provenance/print.rs +++ /dev/null @@ -1,22 +0,0 @@ -//@ known-bug: #107975 -//@ compile-flags: -Copt-level=2 -//@ run-pass - -// https://github.com/rust-lang/rust/issues/107975#issuecomment-1430704499 - -use std::ptr; - -fn main() { - let a: usize = { - let v = 0; - ptr::from_ref(&v).addr() - }; - let b: usize = { - let v = 0; - ptr::from_ref(&v).addr() - }; - - assert_ne!(a, b); - println!("{a}"); // or b - assert_eq!(a, b); -} diff --git a/tests/ui/codegen/no-mangle-on-internal-lang-items.rs b/tests/ui/codegen/no-mangle-on-internal-lang-items.rs new file mode 100644 index 00000000000..37766936410 --- /dev/null +++ b/tests/ui/codegen/no-mangle-on-internal-lang-items.rs @@ -0,0 +1,14 @@ +// Issue a error when the user uses #[no_mangle] on internal language items +//@ edition:2024 + +#![feature(rustc_attrs)] + +#[rustc_std_internal_symbol] +#[unsafe(no_mangle)] //~ERROR `#[no_mangle]` cannot be used on internal language items +fn internal_lang_function () { + +} + +fn main() { + +} diff --git a/tests/ui/codegen/no-mangle-on-internal-lang-items.stderr b/tests/ui/codegen/no-mangle-on-internal-lang-items.stderr new file mode 100644 index 00000000000..12461a6abb9 --- /dev/null +++ b/tests/ui/codegen/no-mangle-on-internal-lang-items.stderr @@ -0,0 +1,12 @@ +error: `#[no_mangle]` cannot be used on internal language items + --> $DIR/no-mangle-on-internal-lang-items.rs:7:1 + | +LL | #[unsafe(no_mangle)] + | ^^^^^^^^^^^^^^^^^^^^ +LL | fn internal_lang_function () { + | ---------------------------- should be the internal language item + | + = note: Rustc requires this item to have a specific mangled name. + +error: aborting due to 1 previous error + diff --git a/tests/ui/codegen/no-mangle-on-panic-handler.rs b/tests/ui/codegen/no-mangle-on-panic-handler.rs new file mode 100644 index 00000000000..1dc0cce0a2e --- /dev/null +++ b/tests/ui/codegen/no-mangle-on-panic-handler.rs @@ -0,0 +1,14 @@ +// Issue an error when the user uses #[no_mangle] on the panic handler +//@ edition:2024 + +#![crate_type="lib"] +#![no_std] +#![no_main] + +use core::panic::PanicInfo; + +#[unsafe(no_mangle)] //~ ERROR `#[no_mangle]` cannot be used on internal language items +#[panic_handler] +pub unsafe fn panic_fmt(pi: &PanicInfo) -> ! { + loop {} +} diff --git a/tests/ui/codegen/no-mangle-on-panic-handler.stderr b/tests/ui/codegen/no-mangle-on-panic-handler.stderr new file mode 100644 index 00000000000..dc88b66d1b5 --- /dev/null +++ b/tests/ui/codegen/no-mangle-on-panic-handler.stderr @@ -0,0 +1,16 @@ +error: `#[no_mangle]` cannot be used on internal language items + --> $DIR/no-mangle-on-panic-handler.rs:10:1 + | +LL | #[unsafe(no_mangle)] + | ^^^^^^^^^^^^^^^^^^^^ +LL | #[panic_handler] +LL | pub unsafe fn panic_fmt(pi: &PanicInfo) -> ! { + | -------------------------------------------- should be the internal language item + | + = note: Rustc requires this item to have a specific mangled name. + = note: If you are trying to prevent mangling to ease debugging, many + = note: debuggers support a command such as `rbreak rust_begin_unwind` to + = note: match `.*rust_begin_unwind.*` instead of `break rust_begin_unwind` on a specific name + +error: aborting due to 1 previous error + diff --git a/tests/ui/coercion/coerce-mut.rs b/tests/ui/coercion/coerce-mut.rs index 43f0b55856d..d3ed0a52303 100644 --- a/tests/ui/coercion/coerce-mut.rs +++ b/tests/ui/coercion/coerce-mut.rs @@ -1,10 +1,12 @@ +//@ dont-require-annotations: NOTE + fn f(x: &mut i32) {} fn main() { let x = 0; f(&x); //~^ ERROR mismatched types - //~| expected mutable reference `&mut i32` - //~| found reference `&{integer}` - //~| types differ in mutability + //~| NOTE expected mutable reference `&mut i32` + //~| NOTE found reference `&{integer}` + //~| NOTE types differ in mutability } diff --git a/tests/ui/coercion/coerce-mut.stderr b/tests/ui/coercion/coerce-mut.stderr index 9bbfcc29e61..0e2a2d04467 100644 --- a/tests/ui/coercion/coerce-mut.stderr +++ b/tests/ui/coercion/coerce-mut.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/coerce-mut.rs:5:7 + --> $DIR/coerce-mut.rs:7:7 | LL | f(&x); | - ^^ types differ in mutability @@ -9,7 +9,7 @@ LL | f(&x); = note: expected mutable reference `&mut i32` found reference `&{integer}` note: function defined here - --> $DIR/coerce-mut.rs:1:4 + --> $DIR/coerce-mut.rs:3:4 | LL | fn f(x: &mut i32) {} | ^ ----------- diff --git a/tests/ui/coercion/coercion-slice.rs b/tests/ui/coercion/coercion-slice.rs index b99235dd37f..a0795e8316f 100644 --- a/tests/ui/coercion/coercion-slice.rs +++ b/tests/ui/coercion/coercion-slice.rs @@ -3,5 +3,6 @@ fn main() { let _: &[i32] = [0]; //~^ ERROR mismatched types - //~| expected `&[i32]`, found `[{integer}; 1]` + //~| NOTE expected `&[i32]`, found `[{integer}; 1]` + //~| NOTE expected due to this } diff --git a/tests/ui/coercion/issue-73886.stderr b/tests/ui/coercion/issue-73886.stderr index a6f8ba65ab5..0d4c90017cf 100644 --- a/tests/ui/coercion/issue-73886.stderr +++ b/tests/ui/coercion/issue-73886.stderr @@ -8,9 +8,14 @@ error[E0605]: non-primitive cast: `u32` as `Option<_>` --> $DIR/issue-73886.rs:4:13 | LL | let _ = 7u32 as Option<_>; - | ^^^^^^^^^^^^^^^^^ help: consider using the `From` trait instead: `Option<_>::from(7u32)` + | ^^^^^^^^^^^^^^^^^ | = note: an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object +help: consider using the `From` trait instead + | +LL - let _ = 7u32 as Option<_>; +LL + let _ = Option::<_>::from(7u32); + | error: aborting due to 2 previous errors diff --git a/tests/ui/coercion/mut-mut-wont-coerce.rs b/tests/ui/coercion/mut-mut-wont-coerce.rs index 33016e1e48a..6b00bfd583d 100644 --- a/tests/ui/coercion/mut-mut-wont-coerce.rs +++ b/tests/ui/coercion/mut-mut-wont-coerce.rs @@ -2,6 +2,9 @@ // Making this compile was a feature request in rust-lang/rust#34117 but this is currently // "working as intended". Allowing "deep pointer coercion" seems footgun-prone, and would // require proceeding carefully. + +//@ dont-require-annotations: NOTE + use std::ops::{Deref, DerefMut}; struct Foo(i32); @@ -34,7 +37,7 @@ fn make_foo(_: *mut *mut Foo) { fn main() { let mut result: SmartPtr<Foo> = SmartPtr(std::ptr::null_mut()); make_foo(&mut &mut *result); //~ ERROR mismatched types - //~^ expected `*mut *mut Foo`, found `&mut &mut Foo` + //~^ NOTE expected `*mut *mut Foo`, found `&mut &mut Foo` make_foo(out(&mut result)); // works, but makes one wonder why above coercion cannot happen } diff --git a/tests/ui/coercion/mut-mut-wont-coerce.stderr b/tests/ui/coercion/mut-mut-wont-coerce.stderr index 5daf9cbd3d3..c37ea6af5a8 100644 --- a/tests/ui/coercion/mut-mut-wont-coerce.stderr +++ b/tests/ui/coercion/mut-mut-wont-coerce.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/mut-mut-wont-coerce.rs:36:14 + --> $DIR/mut-mut-wont-coerce.rs:39:14 | LL | make_foo(&mut &mut *result); | -------- ^^^^^^^^^^^^^^^^^ expected `*mut *mut Foo`, found `&mut &mut Foo` @@ -9,7 +9,7 @@ LL | make_foo(&mut &mut *result); = note: expected raw pointer `*mut *mut Foo` found mutable reference `&mut &mut Foo` note: function defined here - --> $DIR/mut-mut-wont-coerce.rs:30:4 + --> $DIR/mut-mut-wont-coerce.rs:33:4 | LL | fn make_foo(_: *mut *mut Foo) { | ^^^^^^^^ ---------------- diff --git a/tests/ui/coercion/non-primitive-cast-135412.fixed b/tests/ui/coercion/non-primitive-cast-135412.fixed new file mode 100644 index 00000000000..5cadc9368d5 --- /dev/null +++ b/tests/ui/coercion/non-primitive-cast-135412.fixed @@ -0,0 +1,10 @@ +//@ run-rustfix + +use std::sync::Arc; + +fn main() { + let _ = Option::<_>::from(7u32); + //~^ ERROR non-primitive cast: `u32` as `Option<_>` + let _ = Arc::<str>::from("String"); + //~^ ERROR non-primitive cast: `&'static str` as `Arc<str>` +} diff --git a/tests/ui/coercion/non-primitive-cast-135412.rs b/tests/ui/coercion/non-primitive-cast-135412.rs new file mode 100644 index 00000000000..67a3ef340d2 --- /dev/null +++ b/tests/ui/coercion/non-primitive-cast-135412.rs @@ -0,0 +1,10 @@ +//@ run-rustfix + +use std::sync::Arc; + +fn main() { + let _ = 7u32 as Option<_>; + //~^ ERROR non-primitive cast: `u32` as `Option<_>` + let _ = "String" as Arc<str>; + //~^ ERROR non-primitive cast: `&'static str` as `Arc<str>` +} diff --git a/tests/ui/coercion/non-primitive-cast-135412.stderr b/tests/ui/coercion/non-primitive-cast-135412.stderr new file mode 100644 index 00000000000..7e5861f83e9 --- /dev/null +++ b/tests/ui/coercion/non-primitive-cast-135412.stderr @@ -0,0 +1,29 @@ +error[E0605]: non-primitive cast: `u32` as `Option<_>` + --> $DIR/non-primitive-cast-135412.rs:6:13 + | +LL | let _ = 7u32 as Option<_>; + | ^^^^^^^^^^^^^^^^^ + | + = note: an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object +help: consider using the `From` trait instead + | +LL - let _ = 7u32 as Option<_>; +LL + let _ = Option::<_>::from(7u32); + | + +error[E0605]: non-primitive cast: `&'static str` as `Arc<str>` + --> $DIR/non-primitive-cast-135412.rs:8:13 + | +LL | let _ = "String" as Arc<str>; + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object +help: consider using the `From` trait instead + | +LL - let _ = "String" as Arc<str>; +LL + let _ = Arc::<str>::from("String"); + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0605`. diff --git a/tests/ui/compiletest-self-test/compile-flags-last.stderr b/tests/ui/compiletest-self-test/compile-flags-last.stderr index 72d92206e2b..5a48361cfc0 100644 --- a/tests/ui/compiletest-self-test/compile-flags-last.stderr +++ b/tests/ui/compiletest-self-test/compile-flags-last.stderr @@ -1,5 +1,5 @@ error: Argument to option 'cap-lints' missing Usage: - --cap-lints LEVEL Set the most restrictive lint level. More restrictive + --cap-lints <LEVEL> Set the most restrictive lint level. More restrictive lints are capped at this level diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.rs b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.rs index 761a6387a24..e743b78fd13 100644 --- a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.rs +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.rs @@ -9,11 +9,11 @@ struct CantParam(ImplementsConstParamTy); impl std::marker::UnsizedConstParamTy for CantParam {} //~^ error: the type `CantParam` does not `#[derive(PartialEq)]` -//~| the trait bound `CantParam: Eq` is not satisfied +//~| ERROR the trait bound `CantParam: Eq` is not satisfied #[derive(std::marker::UnsizedConstParamTy)] //~^ error: the type `CantParamDerive` does not `#[derive(PartialEq)]` -//~| the trait bound `CantParamDerive: Eq` is not satisfied +//~| ERROR the trait bound `CantParamDerive: Eq` is not satisfied struct CantParamDerive(ImplementsConstParamTy); fn check<T: std::marker::UnsizedConstParamTy>() {} diff --git a/tests/ui/const-generics/const_eval_unchecked_doesnt_fire_patterns.rs b/tests/ui/const-generics/const_eval_unchecked_doesnt_fire_patterns.rs new file mode 100644 index 00000000000..fae2d16f430 --- /dev/null +++ b/tests/ui/const-generics/const_eval_unchecked_doesnt_fire_patterns.rs @@ -0,0 +1,23 @@ +//@ check-pass + +// Previously the `CONST_EVALUATABLE_UNCHECKED` FCW would fire on const evaluation of +// associated consts. This is unnecessary as the FCW only needs to apply for repeat expr +// counts which are anon consts with generic parameters provided. #140447 + +pub struct Foo<const N: usize>; + +impl<const N: usize> Foo<N> { + const UNUSED_PARAM: usize = { + let _: [(); N]; + 3 + }; + + pub fn bar() { + match 1 { + Self::UNUSED_PARAM => (), + _ => (), + } + } +} + +fn main() {} diff --git a/tests/ui/const-generics/defaults/concrete-const-param-type.rs b/tests/ui/const-generics/defaults/concrete-const-param-type.rs new file mode 100644 index 00000000000..c411f81192b --- /dev/null +++ b/tests/ui/const-generics/defaults/concrete-const-param-type.rs @@ -0,0 +1,13 @@ +#![feature(generic_const_parameter_types, unsized_const_params, adt_const_params)] +//~^ WARN the feature `generic_const_parameter_types` is incomplete +//~| WARN the feature `unsized_const_params` is incomplete +// Make sure that we test the const param type of default const parameters +// if both the type of the default and the type of the parameter are concrete. + +use std::marker::ConstParamTy_; + +struct Foo<const N: u32, const M: u64 = N>; //~ ERROR the constant `N` is not of type `u64` +struct Bar<T: ConstParamTy_, const N: T, const M: u64 = N>(T); // ok +struct Baz<T: ConstParamTy_, const N: u32, const M: T = N>(T); // ok + +fn main() {} diff --git a/tests/ui/const-generics/defaults/concrete-const-param-type.stderr b/tests/ui/const-generics/defaults/concrete-const-param-type.stderr new file mode 100644 index 00000000000..ad077f87e5d --- /dev/null +++ b/tests/ui/const-generics/defaults/concrete-const-param-type.stderr @@ -0,0 +1,25 @@ +warning: the feature `generic_const_parameter_types` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/concrete-const-param-type.rs:1:12 + | +LL | #![feature(generic_const_parameter_types, unsized_const_params, adt_const_params)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #137626 <https://github.com/rust-lang/rust/issues/137626> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: the feature `unsized_const_params` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/concrete-const-param-type.rs:1:43 + | +LL | #![feature(generic_const_parameter_types, unsized_const_params, adt_const_params)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #95174 <https://github.com/rust-lang/rust/issues/95174> for more information + +error: the constant `N` is not of type `u64` + --> $DIR/concrete-const-param-type.rs:9:26 + | +LL | struct Foo<const N: u32, const M: u64 = N>; + | ^^^^^^^^^^^^^^^^ expected `u64`, found `u32` + +error: aborting due to 1 previous error; 2 warnings emitted + diff --git a/tests/ui/const-generics/defaults/mismatch.rs b/tests/ui/const-generics/defaults/mismatch.rs index 3e35c2060b1..bbedf247bd0 100644 --- a/tests/ui/const-generics/defaults/mismatch.rs +++ b/tests/ui/const-generics/defaults/mismatch.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + pub struct Example<const N: usize = 13>; pub struct Example2<T = u32, const N: usize = 13>(T); pub struct Example3<const N: usize = 13, T = u32>(T); @@ -6,17 +8,17 @@ pub struct Example4<const N: usize = 13, const M: usize = 4>; fn main() { let e: Example<13> = (); //~^ ERROR mismatched types - //~| expected struct `Example` + //~| NOTE expected struct `Example` let e: Example2<u32, 13> = (); //~^ ERROR mismatched types - //~| expected struct `Example2` + //~| NOTE expected struct `Example2` let e: Example3<13, u32> = (); //~^ ERROR mismatched types - //~| expected struct `Example3` + //~| NOTE expected struct `Example3` let e: Example3<7> = (); //~^ ERROR mismatched types - //~| expected struct `Example3<7>` + //~| NOTE expected struct `Example3<7>` let e: Example4<7> = (); //~^ ERROR mismatched types - //~| expected struct `Example4<7>` + //~| NOTE expected struct `Example4<7>` } diff --git a/tests/ui/const-generics/defaults/mismatch.stderr b/tests/ui/const-generics/defaults/mismatch.stderr index 9c4f0bc950b..8cedd1a28c4 100644 --- a/tests/ui/const-generics/defaults/mismatch.stderr +++ b/tests/ui/const-generics/defaults/mismatch.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/mismatch.rs:7:26 + --> $DIR/mismatch.rs:9:26 | LL | let e: Example<13> = (); | ----------- ^^ expected `Example`, found `()` @@ -10,7 +10,7 @@ LL | let e: Example<13> = (); found unit type `()` error[E0308]: mismatched types - --> $DIR/mismatch.rs:10:32 + --> $DIR/mismatch.rs:12:32 | LL | let e: Example2<u32, 13> = (); | ----------------- ^^ expected `Example2`, found `()` @@ -21,7 +21,7 @@ LL | let e: Example2<u32, 13> = (); found unit type `()` error[E0308]: mismatched types - --> $DIR/mismatch.rs:13:32 + --> $DIR/mismatch.rs:15:32 | LL | let e: Example3<13, u32> = (); | ----------------- ^^ expected `Example3`, found `()` @@ -32,7 +32,7 @@ LL | let e: Example3<13, u32> = (); found unit type `()` error[E0308]: mismatched types - --> $DIR/mismatch.rs:16:26 + --> $DIR/mismatch.rs:18:26 | LL | let e: Example3<7> = (); | ----------- ^^ expected `Example3<7>`, found `()` @@ -43,7 +43,7 @@ LL | let e: Example3<7> = (); found unit type `()` error[E0308]: mismatched types - --> $DIR/mismatch.rs:19:26 + --> $DIR/mismatch.rs:21:26 | LL | let e: Example4<7> = (); | ----------- ^^ expected `Example4<7>`, found `()` diff --git a/tests/ui/const-generics/issues/issue-100313.rs b/tests/ui/const-generics/issues/issue-100313.rs index 7ce2a3b908c..7d43d7bee34 100644 --- a/tests/ui/const-generics/issues/issue-100313.rs +++ b/tests/ui/const-generics/issues/issue-100313.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + #![allow(incomplete_features)] #![feature(adt_const_params, unsized_const_params)] @@ -6,7 +8,7 @@ struct T<const B: &'static bool>; impl<const B: &'static bool> T<B> { const fn set_false(&self) { unsafe { - *(B as *const bool as *mut bool) = false; //~ inside `T + *(B as *const bool as *mut bool) = false; //~ NOTE inside `T } } } diff --git a/tests/ui/const-generics/issues/issue-100313.stderr b/tests/ui/const-generics/issues/issue-100313.stderr index 03a658a83af..98c3ec5379b 100644 --- a/tests/ui/const-generics/issues/issue-100313.stderr +++ b/tests/ui/const-generics/issues/issue-100313.stderr @@ -1,11 +1,11 @@ error[E0080]: evaluation of constant value failed - --> $DIR/issue-100313.rs:16:5 + --> $DIR/issue-100313.rs:18:5 | LL | x.set_false(); | ^^^^^^^^^^^^^ writing to ALLOC0 which is read-only | note: inside `T::<&true>::set_false` - --> $DIR/issue-100313.rs:9:13 + --> $DIR/issue-100313.rs:11:13 | LL | *(B as *const bool as *mut bool) = false; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here diff --git a/tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr b/tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr index 11a824ba73b..d1f3b08dd36 100644 --- a/tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr +++ b/tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr @@ -1,11 +1,11 @@ error[E0080]: evaluation of constant value failed - --> $DIR/invalid-patterns.rs:38:32 + --> $DIR/invalid-patterns.rs:40:32 | LL | get_flag::<false, { unsafe { char_raw.character } }>(); | ^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/invalid-patterns.rs:41:14 + --> $DIR/invalid-patterns.rs:43:14 | LL | get_flag::<{ unsafe { bool_raw.boolean } }, 'z'>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x42, but expected a boolean @@ -16,7 +16,7 @@ LL | get_flag::<{ unsafe { bool_raw.boolean } }, 'z'>(); } error[E0080]: it is undefined behavior to use this value - --> $DIR/invalid-patterns.rs:43:14 + --> $DIR/invalid-patterns.rs:45:14 | LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x42, but expected a boolean @@ -27,31 +27,31 @@ LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } error[E0080]: evaluation of constant value failed - --> $DIR/invalid-patterns.rs:43:58 + --> $DIR/invalid-patterns.rs:45:58 | LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); | ^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0308]: mismatched types - --> $DIR/invalid-patterns.rs:29:21 + --> $DIR/invalid-patterns.rs:31:21 | LL | get_flag::<false, 0xFF>(); | ^^^^ expected `char`, found `u8` error[E0308]: mismatched types - --> $DIR/invalid-patterns.rs:31:14 + --> $DIR/invalid-patterns.rs:33:14 | LL | get_flag::<7, 'c'>(); | ^ expected `bool`, found integer error[E0308]: mismatched types - --> $DIR/invalid-patterns.rs:33:14 + --> $DIR/invalid-patterns.rs:35:14 | LL | get_flag::<42, 0x5ad>(); | ^^ expected `bool`, found integer error[E0308]: mismatched types - --> $DIR/invalid-patterns.rs:33:18 + --> $DIR/invalid-patterns.rs:35:18 | LL | get_flag::<42, 0x5ad>(); | ^^^^^ expected `char`, found `u8` diff --git a/tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr b/tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr index 11a824ba73b..d1f3b08dd36 100644 --- a/tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr +++ b/tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr @@ -1,11 +1,11 @@ error[E0080]: evaluation of constant value failed - --> $DIR/invalid-patterns.rs:38:32 + --> $DIR/invalid-patterns.rs:40:32 | LL | get_flag::<false, { unsafe { char_raw.character } }>(); | ^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/invalid-patterns.rs:41:14 + --> $DIR/invalid-patterns.rs:43:14 | LL | get_flag::<{ unsafe { bool_raw.boolean } }, 'z'>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x42, but expected a boolean @@ -16,7 +16,7 @@ LL | get_flag::<{ unsafe { bool_raw.boolean } }, 'z'>(); } error[E0080]: it is undefined behavior to use this value - --> $DIR/invalid-patterns.rs:43:14 + --> $DIR/invalid-patterns.rs:45:14 | LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x42, but expected a boolean @@ -27,31 +27,31 @@ LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } error[E0080]: evaluation of constant value failed - --> $DIR/invalid-patterns.rs:43:58 + --> $DIR/invalid-patterns.rs:45:58 | LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); | ^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0308]: mismatched types - --> $DIR/invalid-patterns.rs:29:21 + --> $DIR/invalid-patterns.rs:31:21 | LL | get_flag::<false, 0xFF>(); | ^^^^ expected `char`, found `u8` error[E0308]: mismatched types - --> $DIR/invalid-patterns.rs:31:14 + --> $DIR/invalid-patterns.rs:33:14 | LL | get_flag::<7, 'c'>(); | ^ expected `bool`, found integer error[E0308]: mismatched types - --> $DIR/invalid-patterns.rs:33:14 + --> $DIR/invalid-patterns.rs:35:14 | LL | get_flag::<42, 0x5ad>(); | ^^ expected `bool`, found integer error[E0308]: mismatched types - --> $DIR/invalid-patterns.rs:33:18 + --> $DIR/invalid-patterns.rs:35:18 | LL | get_flag::<42, 0x5ad>(); | ^^^^^ expected `char`, found `u8` diff --git a/tests/ui/const-generics/min_const_generics/invalid-patterns.rs b/tests/ui/const-generics/min_const_generics/invalid-patterns.rs index a9d2a8a5dd7..10b0d742a0a 100644 --- a/tests/ui/const-generics/min_const_generics/invalid-patterns.rs +++ b/tests/ui/const-generics/min_const_generics/invalid-patterns.rs @@ -1,4 +1,6 @@ //@ stderr-per-bitwidth +//@ dont-require-annotations: NOTE + use std::mem::transmute; fn get_flag<const FlagSet: bool, const ShortName: char>() -> Option<char> { @@ -37,11 +39,11 @@ fn main() { get_flag::<false, { unsafe { char_raw.character } }>(); //~^ ERROR evaluation of constant value failed - //~| uninitialized + //~| NOTE uninitialized get_flag::<{ unsafe { bool_raw.boolean } }, 'z'>(); //~^ ERROR it is undefined behavior get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); //~^ ERROR evaluation of constant value failed - //~| uninitialized + //~| NOTE uninitialized //~| ERROR it is undefined behavior } diff --git a/tests/ui/const-ptr/forbidden_slices.stderr b/tests/ui/const-ptr/forbidden_slices.stderr index 6f2da272ad3..c73d2ca938c 100644 --- a/tests/ui/const-ptr/forbidden_slices.stderr +++ b/tests/ui/const-ptr/forbidden_slices.stderr @@ -114,7 +114,7 @@ error[E0080]: could not evaluate static initializer --> $DIR/forbidden_slices.rs:54:25 | LL | from_ptr_range(ptr..ptr.add(2)) // errors inside libcore - | ^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to 8 bytes of memory, but got ALLOC10 which is only 4 bytes from the end of the allocation + | ^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC10 which is only 4 bytes from the end of the allocation | note: inside `std::ptr::const_ptr::<impl *const u32>::add` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -169,7 +169,7 @@ error[E0080]: could not evaluate static initializer --> $DIR/forbidden_slices.rs:79:25 | LL | from_ptr_range(ptr..ptr.add(1)) - | ^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to 8 bytes of memory, but got ALLOC11+0x1 which is only 7 bytes from the end of the allocation + | ^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC11+0x1 which is only 7 bytes from the end of the allocation | note: inside `std::ptr::const_ptr::<impl *const u64>::add` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL diff --git a/tests/ui/const-ptr/out_of_bounds_read.stderr b/tests/ui/const-ptr/out_of_bounds_read.stderr index b396fc4d71b..1d625a26b78 100644 --- a/tests/ui/const-ptr/out_of_bounds_read.stderr +++ b/tests/ui/const-ptr/out_of_bounds_read.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/out_of_bounds_read.rs:8:33 | LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes + | ^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes | note: inside `std::ptr::read::<u32>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL @@ -11,7 +11,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/out_of_bounds_read.rs:10:39 | LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() }; - | ^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes + | ^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes | note: inside `std::ptr::const_ptr::<impl *const u32>::read` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -22,7 +22,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/out_of_bounds_read.rs:12:37 | LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes | note: inside `std::ptr::mut_ptr::<impl *mut u32>::read` --> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL diff --git a/tests/ui/consts/const-array-oob.rs b/tests/ui/consts/const-array-oob.rs index cf3db077e36..4b457d1c23c 100644 --- a/tests/ui/consts/const-array-oob.rs +++ b/tests/ui/consts/const-array-oob.rs @@ -1,10 +1,11 @@ const FOO: [usize; 3] = [1, 2, 3]; const BAR: usize = FOO[5]; //~^ ERROR: evaluation of constant value failed +//~| NOTE index out of bounds: the length is 3 but the index is 5 const BLUB: [u32; FOO[4]] = [5, 6]; //~^ ERROR evaluation of constant value failed [E0080] -//~| index out of bounds: the length is 3 but the index is 4 +//~| NOTE index out of bounds: the length is 3 but the index is 4 fn main() { let _ = BAR; diff --git a/tests/ui/consts/const-array-oob.stderr b/tests/ui/consts/const-array-oob.stderr index be31f183b9a..89427c051e7 100644 --- a/tests/ui/consts/const-array-oob.stderr +++ b/tests/ui/consts/const-array-oob.stderr @@ -1,5 +1,5 @@ error[E0080]: evaluation of constant value failed - --> $DIR/const-array-oob.rs:5:19 + --> $DIR/const-array-oob.rs:6:19 | LL | const BLUB: [u32; FOO[4]] = [5, 6]; | ^^^^^^ index out of bounds: the length is 3 but the index is 4 diff --git a/tests/ui/consts/const-compare-bytes-ub.stderr b/tests/ui/consts/const-compare-bytes-ub.stderr index 9ef5c8ad43a..0e77310c6ba 100644 --- a/tests/ui/consts/const-compare-bytes-ub.stderr +++ b/tests/ui/consts/const-compare-bytes-ub.stderr @@ -2,31 +2,31 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-compare-bytes-ub.rs:9:9 | LL | compare_bytes(0 as *const u8, 2 as *const u8, 1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 1 byte of memory, but got a null pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 1 byte, but got null pointer error[E0080]: evaluation of constant value failed --> $DIR/const-compare-bytes-ub.rs:13:9 | LL | compare_bytes(1 as *const u8, 0 as *const u8, 1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 1 byte of memory, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) error[E0080]: evaluation of constant value failed --> $DIR/const-compare-bytes-ub.rs:17:9 | LL | compare_bytes(1 as *const u8, 2 as *const u8, 1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 1 byte of memory, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) error[E0080]: evaluation of constant value failed --> $DIR/const-compare-bytes-ub.rs:21:9 | LL | compare_bytes([1, 2, 3].as_ptr(), [1, 2, 3, 4].as_ptr(), 4) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0 which is only 3 bytes from the end of the allocation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got ALLOC0 which is only 3 bytes from the end of the allocation error[E0080]: evaluation of constant value failed --> $DIR/const-compare-bytes-ub.rs:25:9 | LL | compare_bytes([1, 2, 3, 4].as_ptr(), [1, 2, 3].as_ptr(), 4) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC1 which is only 3 bytes from the end of the allocation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got ALLOC1 which is only 3 bytes from the end of the allocation error[E0080]: evaluation of constant value failed --> $DIR/const-compare-bytes-ub.rs:29:9 diff --git a/tests/ui/consts/const-deref-ptr.stderr b/tests/ui/consts/const-deref-ptr.stderr index 070685e0b9d..37502864947 100644 --- a/tests/ui/consts/const-deref-ptr.stderr +++ b/tests/ui/consts/const-deref-ptr.stderr @@ -2,7 +2,7 @@ error[E0080]: could not evaluate static initializer --> $DIR/const-deref-ptr.rs:4:29 | LL | static C: u64 = unsafe {*(0xdeadbeef as *const u64)}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 8 bytes of memory, but got 0xdeadbeef[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 8 bytes, but got 0xdeadbeef[noalloc] which is a dangling pointer (it has no provenance) error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-err-late.rs b/tests/ui/consts/const-err-late.rs index 6dff2c101a0..f8bea388109 100644 --- a/tests/ui/consts/const-err-late.rs +++ b/tests/ui/consts/const-err-late.rs @@ -1,5 +1,6 @@ //@ build-fail //@ compile-flags: -C overflow-checks=on +//@ dont-require-annotations: NOTE #![allow(arithmetic_overflow, unconditional_panic)] @@ -16,5 +17,5 @@ impl<T> S<T> { } fn main() { - black_box((S::<i32>::FOO, S::<u32>::FOO)); //~ constant + black_box((S::<i32>::FOO, S::<u32>::FOO)); //~ NOTE constant } diff --git a/tests/ui/consts/const-err-late.stderr b/tests/ui/consts/const-err-late.stderr index 53badeafa35..0c021e8761e 100644 --- a/tests/ui/consts/const-err-late.stderr +++ b/tests/ui/consts/const-err-late.stderr @@ -1,29 +1,29 @@ error[E0080]: evaluation of `S::<i32>::FOO` failed - --> $DIR/const-err-late.rs:13:21 + --> $DIR/const-err-late.rs:14:21 | LL | const FOO: u8 = [5u8][1]; | ^^^^^^^^ index out of bounds: the length is 1 but the index is 1 note: erroneous constant encountered - --> $DIR/const-err-late.rs:19:16 + --> $DIR/const-err-late.rs:20:16 | LL | black_box((S::<i32>::FOO, S::<u32>::FOO)); | ^^^^^^^^^^^^^ error[E0080]: evaluation of `S::<u32>::FOO` failed - --> $DIR/const-err-late.rs:13:21 + --> $DIR/const-err-late.rs:14:21 | LL | const FOO: u8 = [5u8][1]; | ^^^^^^^^ index out of bounds: the length is 1 but the index is 1 note: erroneous constant encountered - --> $DIR/const-err-late.rs:19:31 + --> $DIR/const-err-late.rs:20:31 | LL | black_box((S::<i32>::FOO, S::<u32>::FOO)); | ^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/const-err-late.rs:19:16 + --> $DIR/const-err-late.rs:20:16 | LL | black_box((S::<i32>::FOO, S::<u32>::FOO)); | ^^^^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | black_box((S::<i32>::FOO, S::<u32>::FOO)); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` note: erroneous constant encountered - --> $DIR/const-err-late.rs:19:31 + --> $DIR/const-err-late.rs:20:31 | LL | black_box((S::<i32>::FOO, S::<u32>::FOO)); | ^^^^^^^^^^^^^ diff --git a/tests/ui/consts/const-err-multi.rs b/tests/ui/consts/const-err-multi.rs index b265bc4c4d8..f21cc97345c 100644 --- a/tests/ui/consts/const-err-multi.rs +++ b/tests/ui/consts/const-err-multi.rs @@ -1,11 +1,12 @@ pub const A: i8 = -i8::MIN; //~^ ERROR constant +//~| NOTE attempt to negate `i8::MIN`, which would overflow pub const B: i8 = A; -//~^ constant +//~^ NOTE constant pub const C: u8 = A as u8; -//~^ constant +//~^ NOTE constant pub const D: i8 = 50 - A; -//~^ constant +//~^ NOTE constant fn main() { let _ = (A, B, C, D); diff --git a/tests/ui/consts/const-err-multi.stderr b/tests/ui/consts/const-err-multi.stderr index 2fe0b9bb463..c60be59b87d 100644 --- a/tests/ui/consts/const-err-multi.stderr +++ b/tests/ui/consts/const-err-multi.stderr @@ -5,19 +5,19 @@ LL | pub const A: i8 = -i8::MIN; | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow note: erroneous constant encountered - --> $DIR/const-err-multi.rs:3:19 + --> $DIR/const-err-multi.rs:4:19 | LL | pub const B: i8 = A; | ^ note: erroneous constant encountered - --> $DIR/const-err-multi.rs:5:19 + --> $DIR/const-err-multi.rs:6:19 | LL | pub const C: u8 = A as u8; | ^ note: erroneous constant encountered - --> $DIR/const-err-multi.rs:7:24 + --> $DIR/const-err-multi.rs:8:24 | LL | pub const D: i8 = 50 - A; | ^ diff --git a/tests/ui/consts/const-eval/const-eval-overflow-4b.rs b/tests/ui/consts/const-eval/const-eval-overflow-4b.rs index ce9c980de0d..3ad23a515a7 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-4b.rs +++ b/tests/ui/consts/const-eval/const-eval-overflow-4b.rs @@ -3,12 +3,14 @@ // // This test is checking the count in an array type. +//@ dont-require-annotations: NOTE + #![allow(unused_imports)] const A_I8_T : [u32; (i8::MAX as i8 + 1u8) as usize] //~^ ERROR mismatched types - //~| expected `i8`, found `u8` + //~| NOTE expected `i8`, found `u8` //~| ERROR cannot add `u8` to `i8` = [0; (i8::MAX as usize) + 1]; diff --git a/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr b/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr index 399f21a9894..1a0832b8ba0 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr @@ -1,11 +1,11 @@ error[E0308]: mismatched types - --> $DIR/const-eval-overflow-4b.rs:9:30 + --> $DIR/const-eval-overflow-4b.rs:11:30 | LL | : [u32; (i8::MAX as i8 + 1u8) as usize] | ^^^ expected `i8`, found `u8` error[E0277]: cannot add `u8` to `i8` - --> $DIR/const-eval-overflow-4b.rs:9:28 + --> $DIR/const-eval-overflow-4b.rs:11:28 | LL | : [u32; (i8::MAX as i8 + 1u8) as usize] | ^ no implementation for `i8 + u8` @@ -18,13 +18,13 @@ LL | : [u32; (i8::MAX as i8 + 1u8) as usize] `i8` implements `Add` error[E0604]: only `u8` can be cast as `char`, not `i8` - --> $DIR/const-eval-overflow-4b.rs:22:13 + --> $DIR/const-eval-overflow-4b.rs:24:13 | LL | : [u32; 5i8 as char as usize] | ^^^^^^^^^^^ invalid cast | help: try casting from `u8` instead - --> $DIR/const-eval-overflow-4b.rs:22:13 + --> $DIR/const-eval-overflow-4b.rs:24:13 | LL | : [u32; 5i8 as char as usize] | ^^^^^^^^^^^ diff --git a/tests/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr b/tests/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr index f099bc7ef7c..3eccd596274 100644 --- a/tests/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr +++ b/tests/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr @@ -1,5 +1,5 @@ error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:26:49 + --> $DIR/const-pointer-values-in-various-types.rs:27:49 | LL | const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }.u }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -8,7 +8,7 @@ LL | const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 } = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:29:43 + --> $DIR/const-pointer-values-in-various-types.rs:30:43 | LL | const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -17,7 +17,7 @@ LL | const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_ = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:32:45 + --> $DIR/const-pointer-values-in-various-types.rs:33:45 | LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -26,7 +26,7 @@ LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uin = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:35:45 + --> $DIR/const-pointer-values-in-various-types.rs:36:45 | LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -35,7 +35,7 @@ LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uin = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:38:45 + --> $DIR/const-pointer-values-in-various-types.rs:39:45 | LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -44,13 +44,13 @@ LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uin = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:41:47 + --> $DIR/const-pointer-values-in-various-types.rs:42:47 | LL | const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:45:43 + --> $DIR/const-pointer-values-in-various-types.rs:46:43 | LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -59,7 +59,7 @@ LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:48:45 + --> $DIR/const-pointer-values-in-various-types.rs:49:45 | LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -68,7 +68,7 @@ LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:51:45 + --> $DIR/const-pointer-values-in-various-types.rs:52:45 | LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -77,7 +77,7 @@ LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:54:45 + --> $DIR/const-pointer-values-in-various-types.rs:55:45 | LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -86,13 +86,13 @@ LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:57:47 + --> $DIR/const-pointer-values-in-various-types.rs:58:47 | LL | const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:61:45 + --> $DIR/const-pointer-values-in-various-types.rs:62:45 | LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -101,7 +101,7 @@ LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.flo = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:64:45 + --> $DIR/const-pointer-values-in-various-types.rs:65:45 | LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -110,7 +110,7 @@ LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.flo = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:67:47 + --> $DIR/const-pointer-values-in-various-types.rs:68:47 | LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -119,7 +119,7 @@ LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.t = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:70:47 + --> $DIR/const-pointer-values-in-various-types.rs:71:47 | LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -128,7 +128,7 @@ LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.c = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:73:39 + --> $DIR/const-pointer-values-in-various-types.rs:74:39 | LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -137,7 +137,7 @@ LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:76:41 + --> $DIR/const-pointer-values-in-various-types.rs:77:41 | LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -146,7 +146,7 @@ LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 } = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:79:41 + --> $DIR/const-pointer-values-in-various-types.rs:80:41 | LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -155,7 +155,7 @@ LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 } = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:82:41 + --> $DIR/const-pointer-values-in-various-types.rs:83:41 | LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -164,7 +164,7 @@ LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 } = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:85:43 + --> $DIR/const-pointer-values-in-various-types.rs:86:43 | LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -173,7 +173,7 @@ LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_12 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:88:39 + --> $DIR/const-pointer-values-in-various-types.rs:89:39 | LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -182,7 +182,7 @@ LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:91:41 + --> $DIR/const-pointer-values-in-various-types.rs:92:41 | LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -191,7 +191,7 @@ LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:94:41 + --> $DIR/const-pointer-values-in-various-types.rs:95:41 | LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -200,7 +200,7 @@ LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:97:41 + --> $DIR/const-pointer-values-in-various-types.rs:98:41 | LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -209,7 +209,7 @@ LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:100:43 + --> $DIR/const-pointer-values-in-various-types.rs:101:43 | LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -218,7 +218,7 @@ LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:103:41 + --> $DIR/const-pointer-values-in-various-types.rs:104:41 | LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -227,7 +227,7 @@ LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:106:41 + --> $DIR/const-pointer-values-in-various-types.rs:107:41 | LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -236,7 +236,7 @@ LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:109:43 + --> $DIR/const-pointer-values-in-various-types.rs:110:43 | LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -245,7 +245,7 @@ LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_ = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:112:43 + --> $DIR/const-pointer-values-in-various-types.rs:113:43 | LL | const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer diff --git a/tests/ui/consts/const-eval/const-pointer-values-in-various-types.rs b/tests/ui/consts/const-eval/const-pointer-values-in-various-types.rs index d6b6d427807..ce7380cd155 100644 --- a/tests/ui/consts/const-eval/const-pointer-values-in-various-types.rs +++ b/tests/ui/consts/const-eval/const-pointer-values-in-various-types.rs @@ -1,5 +1,6 @@ //@ only-x86_64 //@ stderr-per-bitwidth +//@ dont-require-annotations: NOTE #[repr(C)] union Nonsense { @@ -40,7 +41,7 @@ fn main() { const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 }; //~^ ERROR evaluation of constant value failed - //~| uninitialized + //~| NOTE uninitialized const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 }; //~^ ERROR evaluation of constant value failed @@ -56,7 +57,7 @@ fn main() { const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 }; //~^ ERROR evaluation of constant value failed - //~| uninitialized + //~| NOTE uninitialized const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 }; //~^ ERROR evaluation of constant value failed diff --git a/tests/ui/consts/const-eval/const_raw_ptr_ops2.rs b/tests/ui/consts/const-eval/const_raw_ptr_ops2.rs index ca96cfd9d19..0e88aa80c79 100644 --- a/tests/ui/consts/const-eval/const_raw_ptr_ops2.rs +++ b/tests/ui/consts/const-eval/const_raw_ptr_ops2.rs @@ -5,6 +5,6 @@ const Z: i32 = unsafe { *(&1 as *const i32) }; // bad, will thus error in miri const Z2: i32 = unsafe { *(42 as *const i32) }; //~ ERROR evaluation of constant value failed -//~| NOTE is a dangling pointer +//~| NOTE dangling pointer const Z3: i32 = unsafe { *(44 as *const i32) }; //~ ERROR evaluation of constant value failed -//~| NOTE is a dangling pointer +//~| NOTE dangling pointer diff --git a/tests/ui/consts/const-eval/const_raw_ptr_ops2.stderr b/tests/ui/consts/const-eval/const_raw_ptr_ops2.stderr index b0c864652e5..a8a5560ccb9 100644 --- a/tests/ui/consts/const-eval/const_raw_ptr_ops2.stderr +++ b/tests/ui/consts/const-eval/const_raw_ptr_ops2.stderr @@ -2,13 +2,13 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_raw_ptr_ops2.rs:7:26 | LL | const Z2: i32 = unsafe { *(42 as *const i32) }; - | ^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got 0x2a[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got 0x2a[noalloc] which is a dangling pointer (it has no provenance) error[E0080]: evaluation of constant value failed --> $DIR/const_raw_ptr_ops2.rs:9:26 | LL | const Z3: i32 = unsafe { *(44 as *const i32) }; - | ^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got 0x2c[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got 0x2c[noalloc] which is a dangling pointer (it has no provenance) error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/format.rs b/tests/ui/consts/const-eval/format.rs index 1878fc03827..a8085a786e1 100644 --- a/tests/ui/consts/const-eval/format.rs +++ b/tests/ui/consts/const-eval/format.rs @@ -9,4 +9,9 @@ const fn print() { //~| ERROR cannot call non-const function `_print` in constant functions } +const fn format_args() { + format_args!("{}", 0); + //~^ ERROR cannot call non-const formatting macro in constant functions +} + fn main() {} diff --git a/tests/ui/consts/const-eval/format.stderr b/tests/ui/consts/const-eval/format.stderr index e8d7bbcea09..2f202705b7f 100644 --- a/tests/ui/consts/const-eval/format.stderr +++ b/tests/ui/consts/const-eval/format.stderr @@ -1,16 +1,16 @@ error[E0015]: cannot call non-const formatting macro in constant functions - --> $DIR/format.rs:2:13 + --> $DIR/format.rs:2:5 | LL | panic!("{:?}", 0); - | ^^^^ + | ^^^^^^^^^^^^^^^^^ | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const formatting macro in constant functions - --> $DIR/format.rs:7:15 + --> $DIR/format.rs:7:5 | LL | println!("{:?}", 0); - | ^^^^ + | ^^^^^^^^^^^^^^^^^^^ | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = 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) @@ -24,6 +24,14 @@ LL | println!("{:?}", 0); = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 3 previous errors +error[E0015]: cannot call non-const formatting macro in constant functions + --> $DIR/format.rs:13:5 + | +LL | format_args!("{}", 0); + | ^^^^^^^^^^^^^^^^^^^^^ + | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs index c1a544031c2..b47e2b3c1ed 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs @@ -1,11 +1,13 @@ +//@ dont-require-annotations: NOTE + #![feature(core_intrinsics)] #![feature(const_heap)] use std::intrinsics; -const FOO: i32 = foo(); //~ error: evaluation of constant value failed +const FOO: i32 = foo(); //~ ERROR evaluation of constant value failed const fn foo() -> i32 { unsafe { - let _ = intrinsics::const_allocate(4, 3) as *mut i32; //~ inside `foo` + let _ = intrinsics::const_allocate(4, 3) as *mut i32; //~ NOTE inside `foo` } 1 } diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr index e1cb7a83996..9f7546df3a2 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr @@ -1,11 +1,11 @@ error[E0080]: evaluation of constant value failed - --> $DIR/alloc_intrinsic_errors.rs:5:18 + --> $DIR/alloc_intrinsic_errors.rs:7:18 | LL | const FOO: i32 = foo(); | ^^^^^ invalid align passed to `const_allocate`: 3 is not a power of 2 | note: inside `foo` - --> $DIR/alloc_intrinsic_errors.rs:8:17 + --> $DIR/alloc_intrinsic_errors.rs:10:17 | LL | let _ = intrinsics::const_allocate(4, 3) as *mut i32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here diff --git a/tests/ui/consts/const-eval/issue-44578.rs b/tests/ui/consts/const-eval/issue-44578.rs index 945bf93f8fa..565e1d3825b 100644 --- a/tests/ui/consts/const-eval/issue-44578.rs +++ b/tests/ui/consts/const-eval/issue-44578.rs @@ -1,4 +1,5 @@ //@ build-fail +//@ dont-require-annotations: NOTE trait Foo { const AMT: usize; @@ -23,5 +24,5 @@ impl Foo for u16 { fn main() { println!("{}", <Bar<u16, u8> as Foo>::AMT); - //~^ constant + //~^ NOTE constant } diff --git a/tests/ui/consts/const-eval/issue-44578.stderr b/tests/ui/consts/const-eval/issue-44578.stderr index 7d5cf86d396..5093cec81c7 100644 --- a/tests/ui/consts/const-eval/issue-44578.stderr +++ b/tests/ui/consts/const-eval/issue-44578.stderr @@ -1,17 +1,17 @@ error[E0080]: evaluation of `<Bar<u16, u8> as Foo>::AMT` failed - --> $DIR/issue-44578.rs:13:24 + --> $DIR/issue-44578.rs:14:24 | LL | const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1 note: erroneous constant encountered - --> $DIR/issue-44578.rs:25:20 + --> $DIR/issue-44578.rs:26:20 | LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/issue-44578.rs:25:20 + --> $DIR/issue-44578.rs:26:20 | LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` note: erroneous constant encountered - --> $DIR/issue-44578.rs:25:20 + --> $DIR/issue-44578.rs:26:20 | LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -27,7 +27,7 @@ LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); = note: this note 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) note: erroneous constant encountered - --> $DIR/issue-44578.rs:25:20 + --> $DIR/issue-44578.rs:26:20 | LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr b/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr index 2de68d3fee9..1f4f217b175 100644 --- a/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr +++ b/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr @@ -1,23 +1,23 @@ error[E0080]: evaluation of `<A<()> as Foo<()>>::BAR` failed - --> $DIR/issue-50814-2.rs:16:24 + --> $DIR/issue-50814-2.rs:17:24 | LL | const BAR: usize = [5, 6, 7][T::BOO]; | ^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 42 note: erroneous constant encountered - --> $DIR/issue-50814-2.rs:20:6 + --> $DIR/issue-50814-2.rs:21:6 | LL | &<A<T> as Foo<T>>::BAR | ^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/issue-50814-2.rs:20:5 + --> $DIR/issue-50814-2.rs:21:5 | LL | &<A<T> as Foo<T>>::BAR | ^^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/issue-50814-2.rs:20:5 + --> $DIR/issue-50814-2.rs:21:5 | LL | &<A<T> as Foo<T>>::BAR | ^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | &<A<T> as Foo<T>>::BAR = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` note: erroneous constant encountered - --> $DIR/issue-50814-2.rs:20:5 + --> $DIR/issue-50814-2.rs:21:5 | LL | &<A<T> as Foo<T>>::BAR | ^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | &<A<T> as Foo<T>>::BAR = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` note: erroneous constant encountered - --> $DIR/issue-50814-2.rs:20:5 + --> $DIR/issue-50814-2.rs:21:5 | LL | &<A<T> as Foo<T>>::BAR | ^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | &<A<T> as Foo<T>>::BAR = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` note: erroneous constant encountered - --> $DIR/issue-50814-2.rs:20:6 + --> $DIR/issue-50814-2.rs:21:6 | LL | &<A<T> as Foo<T>>::BAR | ^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | &<A<T> as Foo<T>>::BAR = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` note: erroneous constant encountered - --> $DIR/issue-50814-2.rs:20:6 + --> $DIR/issue-50814-2.rs:21:6 | LL | &<A<T> as Foo<T>>::BAR | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/consts/const-eval/issue-50814-2.normal.stderr b/tests/ui/consts/const-eval/issue-50814-2.normal.stderr index 4a7dfb19304..f790862aef1 100644 --- a/tests/ui/consts/const-eval/issue-50814-2.normal.stderr +++ b/tests/ui/consts/const-eval/issue-50814-2.normal.stderr @@ -1,23 +1,23 @@ error[E0080]: evaluation of `<A<()> as Foo<()>>::BAR` failed - --> $DIR/issue-50814-2.rs:16:24 + --> $DIR/issue-50814-2.rs:17:24 | LL | const BAR: usize = [5, 6, 7][T::BOO]; | ^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 42 note: erroneous constant encountered - --> $DIR/issue-50814-2.rs:20:6 + --> $DIR/issue-50814-2.rs:21:6 | LL | &<A<T> as Foo<T>>::BAR | ^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/issue-50814-2.rs:20:5 + --> $DIR/issue-50814-2.rs:21:5 | LL | &<A<T> as Foo<T>>::BAR | ^^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/issue-50814-2.rs:20:6 + --> $DIR/issue-50814-2.rs:21:6 | LL | &<A<T> as Foo<T>>::BAR | ^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | &<A<T> as Foo<T>>::BAR = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` note: the above error was encountered while instantiating `fn foo::<()>` - --> $DIR/issue-50814-2.rs:32:22 + --> $DIR/issue-50814-2.rs:33:22 | LL | println!("{:x}", foo::<()>() as *const usize as usize); | ^^^^^^^^^^^ diff --git a/tests/ui/consts/const-eval/issue-50814-2.rs b/tests/ui/consts/const-eval/issue-50814-2.rs index c2e2de67a65..261dcd3aa4c 100644 --- a/tests/ui/consts/const-eval/issue-50814-2.rs +++ b/tests/ui/consts/const-eval/issue-50814-2.rs @@ -1,6 +1,7 @@ //@ build-fail //@ revisions: normal mir-opt //@ [mir-opt]compile-flags: -Zmir-opt-level=4 +//@ dont-require-annotations: NOTE trait C { const BOO: usize; @@ -17,7 +18,7 @@ impl<T: C> Foo<T> for A<T> { } fn foo<T: C>() -> &'static usize { - &<A<T> as Foo<T>>::BAR //~ constant + &<A<T> as Foo<T>>::BAR //~ NOTE constant } impl C for () { diff --git a/tests/ui/consts/const-eval/issue-50814.rs b/tests/ui/consts/const-eval/issue-50814.rs index 27b5b39ad73..5495fb43bba 100644 --- a/tests/ui/consts/const-eval/issue-50814.rs +++ b/tests/ui/consts/const-eval/issue-50814.rs @@ -1,4 +1,5 @@ //@ build-fail +//@ dont-require-annotations: NOTE trait Unsigned { const MAX: u8; @@ -19,7 +20,7 @@ impl<A: Unsigned, B: Unsigned> Unsigned for Sum<A, B> { fn foo<T>(_: T) -> &'static u8 { &Sum::<U8, U8>::MAX - //~^ constant + //~^ NOTE constant } fn main() { diff --git a/tests/ui/consts/const-eval/issue-50814.stderr b/tests/ui/consts/const-eval/issue-50814.stderr index fe0e25b820f..5b23c48e450 100644 --- a/tests/ui/consts/const-eval/issue-50814.stderr +++ b/tests/ui/consts/const-eval/issue-50814.stderr @@ -1,17 +1,17 @@ error[E0080]: evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed - --> $DIR/issue-50814.rs:15:21 + --> $DIR/issue-50814.rs:16:21 | LL | const MAX: u8 = A::MAX + B::MAX; | ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, which would overflow note: erroneous constant encountered - --> $DIR/issue-50814.rs:21:6 + --> $DIR/issue-50814.rs:22:6 | LL | &Sum::<U8, U8>::MAX | ^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed - --> $DIR/issue-50814.rs:15:21 + --> $DIR/issue-50814.rs:16:21 | LL | const MAX: u8 = A::MAX + B::MAX; | ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, which would overflow @@ -19,7 +19,7 @@ LL | const MAX: u8 = A::MAX + B::MAX; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` note: erroneous constant encountered - --> $DIR/issue-50814.rs:21:6 + --> $DIR/issue-50814.rs:22:6 | LL | &Sum::<U8, U8>::MAX | ^^^^^^^^^^^^^^^^^^ @@ -27,13 +27,13 @@ LL | &Sum::<U8, U8>::MAX = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` note: erroneous constant encountered - --> $DIR/issue-50814.rs:21:5 + --> $DIR/issue-50814.rs:22:5 | LL | &Sum::<U8, U8>::MAX | ^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/issue-50814.rs:21:6 + --> $DIR/issue-50814.rs:22:6 | LL | &Sum::<U8, U8>::MAX | ^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | &Sum::<U8, U8>::MAX = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` note: the above error was encountered while instantiating `fn foo::<i32>` - --> $DIR/issue-50814.rs:26:5 + --> $DIR/issue-50814.rs:27:5 | LL | foo(0); | ^^^^^^ diff --git a/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr b/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr index bd6dafb9366..1996cd2721e 100644 --- a/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr +++ b/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/nonnull_as_ref_ub.rs:4:29 | LL | const _: () = assert!(42 == *unsafe { NON_NULL.as_ref() }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 1 byte of memory, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/panic-assoc-never-type.rs b/tests/ui/consts/const-eval/panic-assoc-never-type.rs index bdaa51494b9..79b5dafaf15 100644 --- a/tests/ui/consts/const-eval/panic-assoc-never-type.rs +++ b/tests/ui/consts/const-eval/panic-assoc-never-type.rs @@ -1,4 +1,5 @@ //@ build-fail +//@ dont-require-annotations: NOTE // Regression test for #66975 #![feature(never_type)] @@ -11,5 +12,5 @@ impl PrintName { } fn main() { - let _ = PrintName::VOID; //~ erroneous constant encountered + let _ = PrintName::VOID; //~ NOTE erroneous constant encountered } diff --git a/tests/ui/consts/const-eval/panic-assoc-never-type.stderr b/tests/ui/consts/const-eval/panic-assoc-never-type.stderr index 71b33d8d0d5..03413f46b20 100644 --- a/tests/ui/consts/const-eval/panic-assoc-never-type.stderr +++ b/tests/ui/consts/const-eval/panic-assoc-never-type.stderr @@ -1,17 +1,17 @@ error[E0080]: evaluation of constant value failed - --> $DIR/panic-assoc-never-type.rs:9:21 + --> $DIR/panic-assoc-never-type.rs:10:21 | LL | const VOID: ! = panic!(); | ^^^^^^^^ evaluation panicked: explicit panic note: erroneous constant encountered - --> $DIR/panic-assoc-never-type.rs:14:13 + --> $DIR/panic-assoc-never-type.rs:15:13 | LL | let _ = PrintName::VOID; | ^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/panic-assoc-never-type.rs:14:13 + --> $DIR/panic-assoc-never-type.rs:15:13 | LL | let _ = PrintName::VOID; | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr index 27c85cc8ce4..120a08acc33 100644 --- a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:21:1 + --> $DIR/raw-bytes.rs:23:1 | LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x00000001, but expected a valid enum tag @@ -10,7 +10,7 @@ LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:29:1 + --> $DIR/raw-bytes.rs:31:1 | LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x00000000, but expected a valid enum tag @@ -21,7 +21,7 @@ LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:43:1 + --> $DIR/raw-bytes.rs:45:1 | LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant @@ -32,7 +32,7 @@ LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:45:1 + --> $DIR/raw-bytes.rs:47:1 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant @@ -43,7 +43,7 @@ LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:51:1 + --> $DIR/raw-bytes.rs:53:1 | LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0.1: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) @@ -54,7 +54,7 @@ LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::tran } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:56:1 + --> $DIR/raw-bytes.rs:58:1 | LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 @@ -65,7 +65,7 @@ LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:59:1 + --> $DIR/raw-bytes.rs:61:1 | LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 @@ -76,7 +76,7 @@ LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:61:1 + --> $DIR/raw-bytes.rs:63:1 | LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 @@ -87,7 +87,7 @@ LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:67:1 + --> $DIR/raw-bytes.rs:69:1 | LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 42, but expected something in the range 10..=30 @@ -98,7 +98,7 @@ LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:73:1 + --> $DIR/raw-bytes.rs:75:1 | LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 20, but expected something less or equal to 10, or greater or equal to 30 @@ -109,7 +109,7 @@ LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:76:1 + --> $DIR/raw-bytes.rs:78:1 | LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 @@ -120,7 +120,7 @@ LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe { } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:84:1 + --> $DIR/raw-bytes.rs:86:1 | LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) @@ -131,7 +131,7 @@ LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:88:1 + --> $DIR/raw-bytes.rs:90:1 | LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) @@ -142,7 +142,7 @@ LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:92:1 + --> $DIR/raw-bytes.rs:94:1 | LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference @@ -153,7 +153,7 @@ LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:95:1 + --> $DIR/raw-bytes.rs:97:1 | LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null box @@ -164,7 +164,7 @@ LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:98:1 + --> $DIR/raw-bytes.rs:100:1 | LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance) @@ -175,7 +175,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:101:1 + --> $DIR/raw-bytes.rs:103:1 | LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance) @@ -186,7 +186,7 @@ LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:104:1 + --> $DIR/raw-bytes.rs:106:1 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer @@ -197,7 +197,7 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:106:1 + --> $DIR/raw-bytes.rs:108:1 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer @@ -208,7 +208,7 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:108:1 + --> $DIR/raw-bytes.rs:110:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC3<imm>, but expected a function pointer @@ -219,7 +219,7 @@ LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:114:1 + --> $DIR/raw-bytes.rs:116:1 | LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type Bar @@ -230,7 +230,7 @@ LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:139:1 + --> $DIR/raw-bytes.rs:141:1 | LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) @@ -241,7 +241,7 @@ LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:141:1 + --> $DIR/raw-bytes.rs:143:1 | LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object @@ -252,7 +252,7 @@ LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, us } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:143:1 + --> $DIR/raw-bytes.rs:145:1 | LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object @@ -263,7 +263,7 @@ LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize: } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:146:1 + --> $DIR/raw-bytes.rs:148:1 | LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered uninitialized memory, but expected a string @@ -274,7 +274,7 @@ LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit: } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:148:1 + --> $DIR/raw-bytes.rs:150:1 | LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered uninitialized memory, but expected a string @@ -285,7 +285,7 @@ LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUni } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:150:1 + --> $DIR/raw-bytes.rs:152:1 | LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered a pointer, but expected a string @@ -298,7 +298,7 @@ LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _> = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:154:1 + --> $DIR/raw-bytes.rs:156:1 | LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) @@ -309,7 +309,7 @@ LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:156:1 + --> $DIR/raw-bytes.rs:158:1 | LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object @@ -320,7 +320,7 @@ LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, is } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:159:1 + --> $DIR/raw-bytes.rs:161:1 | LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation) @@ -331,7 +331,7 @@ LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999us } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:162:1 + --> $DIR/raw-bytes.rs:164:1 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x03, but expected a boolean @@ -342,13 +342,13 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:162:40 + --> $DIR/raw-bytes.rs:164:40 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:168:1 + --> $DIR/raw-bytes.rs:170:1 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered 0x03, but expected a boolean @@ -359,13 +359,13 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3 } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:168:42 + --> $DIR/raw-bytes.rs:170:42 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:172:1 + --> $DIR/raw-bytes.rs:174:1 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.1[0]: encountered 0x03, but expected a boolean @@ -376,13 +376,13 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:172:42 + --> $DIR/raw-bytes.rs:174:42 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:177:1 + --> $DIR/raw-bytes.rs:179:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC17<imm>, but expected a vtable pointer @@ -393,7 +393,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W(( } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:181:1 + --> $DIR/raw-bytes.rs:183:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC19<imm>, but expected a vtable pointer @@ -404,7 +404,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W(( } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:185:1 + --> $DIR/raw-bytes.rs:187:1 | LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer @@ -415,7 +415,7 @@ LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:188:1 + --> $DIR/raw-bytes.rs:190:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC22<imm>, but expected a vtable pointer @@ -426,7 +426,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::trans } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:192:1 + --> $DIR/raw-bytes.rs:194:1 | LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.<dyn-downcast>: encountered 0x03, but expected a boolean @@ -437,7 +437,7 @@ LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:196:1 + --> $DIR/raw-bytes.rs:198:1 | LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer @@ -448,7 +448,7 @@ LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:199:1 + --> $DIR/raw-bytes.rs:201:1 | LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC27<imm>, but expected a vtable pointer @@ -459,7 +459,7 @@ LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transm } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:204:1 + --> $DIR/raw-bytes.rs:206:1 | LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type [!; 1] @@ -470,7 +470,7 @@ LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:205:1 + --> $DIR/raw-bytes.rs:207:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; | ^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a value of the never type `!` @@ -481,7 +481,7 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:206:1 + --> $DIR/raw-bytes.rs:208:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; | ^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a value of the never type `!` @@ -492,7 +492,7 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:210:1 + --> $DIR/raw-bytes.rs:212:1 | LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer @@ -503,7 +503,7 @@ LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) } } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:213:1 + --> $DIR/raw-bytes.rs:215:1 | LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) }; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer @@ -516,7 +516,7 @@ LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem: = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:216:1 + --> $DIR/raw-bytes.rs:218:1 | LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean @@ -527,7 +527,7 @@ LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:220:1 + --> $DIR/raw-bytes.rs:222:1 | LL | pub static S7: &[u16] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[1]: encountered uninitialized memory, but expected an integer @@ -538,7 +538,7 @@ LL | pub static S7: &[u16] = unsafe { } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:227:1 + --> $DIR/raw-bytes.rs:229:1 | LL | pub static R4: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer @@ -549,7 +549,7 @@ LL | pub static R4: &[u8] = unsafe { } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:232:1 + --> $DIR/raw-bytes.rs:234:1 | LL | pub static R5: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer @@ -562,7 +562,7 @@ LL | pub static R5: &[u8] = unsafe { = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:237:1 + --> $DIR/raw-bytes.rs:239:1 | LL | pub static R6: &[bool] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean diff --git a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr index 2b0ce99a881..d54ad7c8546 100644 --- a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:21:1 + --> $DIR/raw-bytes.rs:23:1 | LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x0000000000000001, but expected a valid enum tag @@ -10,7 +10,7 @@ LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:29:1 + --> $DIR/raw-bytes.rs:31:1 | LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x0000000000000000, but expected a valid enum tag @@ -21,7 +21,7 @@ LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:43:1 + --> $DIR/raw-bytes.rs:45:1 | LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant @@ -32,7 +32,7 @@ LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:45:1 + --> $DIR/raw-bytes.rs:47:1 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant @@ -43,7 +43,7 @@ LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:51:1 + --> $DIR/raw-bytes.rs:53:1 | LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0.1: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) @@ -54,7 +54,7 @@ LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::tran } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:56:1 + --> $DIR/raw-bytes.rs:58:1 | LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 @@ -65,7 +65,7 @@ LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:59:1 + --> $DIR/raw-bytes.rs:61:1 | LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 @@ -76,7 +76,7 @@ LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:61:1 + --> $DIR/raw-bytes.rs:63:1 | LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 @@ -87,7 +87,7 @@ LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:67:1 + --> $DIR/raw-bytes.rs:69:1 | LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 42, but expected something in the range 10..=30 @@ -98,7 +98,7 @@ LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:73:1 + --> $DIR/raw-bytes.rs:75:1 | LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 20, but expected something less or equal to 10, or greater or equal to 30 @@ -109,7 +109,7 @@ LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:76:1 + --> $DIR/raw-bytes.rs:78:1 | LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 @@ -120,7 +120,7 @@ LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe { } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:84:1 + --> $DIR/raw-bytes.rs:86:1 | LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) @@ -131,7 +131,7 @@ LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:88:1 + --> $DIR/raw-bytes.rs:90:1 | LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) @@ -142,7 +142,7 @@ LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:92:1 + --> $DIR/raw-bytes.rs:94:1 | LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference @@ -153,7 +153,7 @@ LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:95:1 + --> $DIR/raw-bytes.rs:97:1 | LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null box @@ -164,7 +164,7 @@ LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:98:1 + --> $DIR/raw-bytes.rs:100:1 | LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance) @@ -175,7 +175,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:101:1 + --> $DIR/raw-bytes.rs:103:1 | LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance) @@ -186,7 +186,7 @@ LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:104:1 + --> $DIR/raw-bytes.rs:106:1 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer @@ -197,7 +197,7 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:106:1 + --> $DIR/raw-bytes.rs:108:1 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer @@ -208,7 +208,7 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:108:1 + --> $DIR/raw-bytes.rs:110:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC3<imm>, but expected a function pointer @@ -219,7 +219,7 @@ LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:114:1 + --> $DIR/raw-bytes.rs:116:1 | LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type Bar @@ -230,7 +230,7 @@ LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:139:1 + --> $DIR/raw-bytes.rs:141:1 | LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) @@ -241,7 +241,7 @@ LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:141:1 + --> $DIR/raw-bytes.rs:143:1 | LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object @@ -252,7 +252,7 @@ LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, us } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:143:1 + --> $DIR/raw-bytes.rs:145:1 | LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object @@ -263,7 +263,7 @@ LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize: } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:146:1 + --> $DIR/raw-bytes.rs:148:1 | LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered uninitialized memory, but expected a string @@ -274,7 +274,7 @@ LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit: } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:148:1 + --> $DIR/raw-bytes.rs:150:1 | LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered uninitialized memory, but expected a string @@ -285,7 +285,7 @@ LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUni } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:150:1 + --> $DIR/raw-bytes.rs:152:1 | LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered a pointer, but expected a string @@ -298,7 +298,7 @@ LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _> = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:154:1 + --> $DIR/raw-bytes.rs:156:1 | LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) @@ -309,7 +309,7 @@ LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:156:1 + --> $DIR/raw-bytes.rs:158:1 | LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object @@ -320,7 +320,7 @@ LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, is } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:159:1 + --> $DIR/raw-bytes.rs:161:1 | LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation) @@ -331,7 +331,7 @@ LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999us } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:162:1 + --> $DIR/raw-bytes.rs:164:1 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x03, but expected a boolean @@ -342,13 +342,13 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:162:40 + --> $DIR/raw-bytes.rs:164:40 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:168:1 + --> $DIR/raw-bytes.rs:170:1 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered 0x03, but expected a boolean @@ -359,13 +359,13 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3 } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:168:42 + --> $DIR/raw-bytes.rs:170:42 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:172:1 + --> $DIR/raw-bytes.rs:174:1 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.1[0]: encountered 0x03, but expected a boolean @@ -376,13 +376,13 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:172:42 + --> $DIR/raw-bytes.rs:174:42 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:177:1 + --> $DIR/raw-bytes.rs:179:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC17<imm>, but expected a vtable pointer @@ -393,7 +393,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W(( } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:181:1 + --> $DIR/raw-bytes.rs:183:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC19<imm>, but expected a vtable pointer @@ -404,7 +404,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W(( } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:185:1 + --> $DIR/raw-bytes.rs:187:1 | LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer @@ -415,7 +415,7 @@ LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:188:1 + --> $DIR/raw-bytes.rs:190:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC22<imm>, but expected a vtable pointer @@ -426,7 +426,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::trans } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:192:1 + --> $DIR/raw-bytes.rs:194:1 | LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.<dyn-downcast>: encountered 0x03, but expected a boolean @@ -437,7 +437,7 @@ LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:196:1 + --> $DIR/raw-bytes.rs:198:1 | LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer @@ -448,7 +448,7 @@ LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:199:1 + --> $DIR/raw-bytes.rs:201:1 | LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC27<imm>, but expected a vtable pointer @@ -459,7 +459,7 @@ LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transm } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:204:1 + --> $DIR/raw-bytes.rs:206:1 | LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type [!; 1] @@ -470,7 +470,7 @@ LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:205:1 + --> $DIR/raw-bytes.rs:207:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; | ^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a value of the never type `!` @@ -481,7 +481,7 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:206:1 + --> $DIR/raw-bytes.rs:208:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; | ^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a value of the never type `!` @@ -492,7 +492,7 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:210:1 + --> $DIR/raw-bytes.rs:212:1 | LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer @@ -503,7 +503,7 @@ LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) } } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:213:1 + --> $DIR/raw-bytes.rs:215:1 | LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) }; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer @@ -516,7 +516,7 @@ LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem: = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:216:1 + --> $DIR/raw-bytes.rs:218:1 | LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean @@ -527,7 +527,7 @@ LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:220:1 + --> $DIR/raw-bytes.rs:222:1 | LL | pub static S7: &[u16] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[1]: encountered uninitialized memory, but expected an integer @@ -538,7 +538,7 @@ LL | pub static S7: &[u16] = unsafe { } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:227:1 + --> $DIR/raw-bytes.rs:229:1 | LL | pub static R4: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer @@ -549,7 +549,7 @@ LL | pub static R4: &[u8] = unsafe { } error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:232:1 + --> $DIR/raw-bytes.rs:234:1 | LL | pub static R5: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer @@ -562,7 +562,7 @@ LL | pub static R5: &[u8] = unsafe { = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:237:1 + --> $DIR/raw-bytes.rs:239:1 | LL | pub static R6: &[bool] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean diff --git a/tests/ui/consts/const-eval/raw-bytes.rs b/tests/ui/consts/const-eval/raw-bytes.rs index 9187de56362..1a585d55a5f 100644 --- a/tests/ui/consts/const-eval/raw-bytes.rs +++ b/tests/ui/consts/const-eval/raw-bytes.rs @@ -2,7 +2,9 @@ //@ ignore-endian-big // ignore-tidy-linelength //@ normalize-stderr: "╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼" -> "╾ALLOC_ID$1╼" -#![allow(invalid_value)] +//@ dont-require-annotations: NOTE + +#![allow(invalid_value, unnecessary_transmutes)] #![feature(never_type, rustc_attrs, ptr_metadata, slice_from_ptr_range, const_slice_from_ptr_range)] use std::mem; @@ -83,11 +85,11 @@ const NULL_FAT_PTR: NonNull<dyn Send> = unsafe { const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; //~^ ERROR it is undefined behavior to use this value -//~| constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) +//~| NOTE constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) }; //~^ ERROR it is undefined behavior to use this value -//~| constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) +//~| NOTE constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) const NULL: &u16 = unsafe { mem::transmute(0usize) }; //~^ ERROR it is undefined behavior to use this value @@ -161,44 +163,44 @@ const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) // bad data *inside* the slice const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; //~^ ERROR it is undefined behavior to use this value -//~| constant +//~| NOTE constant // bad: sized field is not okay const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); //~^ ERROR it is undefined behavior to use this value -//~| constant +//~| NOTE constant // bad: unsized part is not okay const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); //~^ ERROR it is undefined behavior to use this value -//~| constant +//~| NOTE constant // bad trait object const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; //~^ ERROR it is undefined behavior to use this value -//~| expected a vtable +//~| NOTE expected a vtable // bad trait object const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; //~^ ERROR it is undefined behavior to use this value -//~| expected a vtable +//~| NOTE expected a vtable // bad trait object const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; //~^ ERROR it is undefined behavior to use this value -//~| expected a vtable +//~| NOTE expected a vtable const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; //~^ ERROR it is undefined behavior to use this value -//~| expected a vtable +//~| NOTE expected a vtable // bad data *inside* the trait object const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; //~^ ERROR it is undefined behavior to use this value -//~| expected a boolean +//~| NOTE expected a boolean const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; //~^ ERROR it is undefined behavior to use this value -//~| null pointer +//~| NOTE null pointer const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; //~^ ERROR it is undefined behavior to use this value -//~| vtable +//~| NOTE vtable // Uninhabited types const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR undefined behavior diff --git a/tests/ui/consts/const-eval/raw-pointer-ub.rs b/tests/ui/consts/const-eval/raw-pointer-ub.rs index 478e93a910e..13a95f9b78f 100644 --- a/tests/ui/consts/const-eval/raw-pointer-ub.rs +++ b/tests/ui/consts/const-eval/raw-pointer-ub.rs @@ -39,7 +39,7 @@ const OOB: () = unsafe { let mem = [0u32; 1]; let ptr = mem.as_ptr().cast::<u64>(); let _val = *ptr; //~ERROR: evaluation of constant value failed - //~^NOTE: expected a pointer to 8 bytes of memory + //~^NOTE: is only 4 bytes from the end of the allocation }; fn main() {} diff --git a/tests/ui/consts/const-eval/raw-pointer-ub.stderr b/tests/ui/consts/const-eval/raw-pointer-ub.stderr index 4fff293b2ee..ed5793c84c5 100644 --- a/tests/ui/consts/const-eval/raw-pointer-ub.stderr +++ b/tests/ui/consts/const-eval/raw-pointer-ub.stderr @@ -31,7 +31,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/raw-pointer-ub.rs:41:16 | LL | let _val = *ptr; - | ^^^^ memory access failed: expected a pointer to 8 bytes of memory, but got ALLOC0 which is only 4 bytes from the end of the allocation + | ^^^^ memory access failed: attempting to access 8 bytes, but got ALLOC0 which is only 4 bytes from the end of the allocation error: aborting due to 5 previous errors diff --git a/tests/ui/consts/const-eval/transmute-const-promotion.rs b/tests/ui/consts/const-eval/transmute-const-promotion.rs index 1f0240d4b5a..840334f43c0 100644 --- a/tests/ui/consts/const-eval/transmute-const-promotion.rs +++ b/tests/ui/consts/const-eval/transmute-const-promotion.rs @@ -1,3 +1,4 @@ +#![allow(unnecessary_transmutes)] use std::mem; fn main() { diff --git a/tests/ui/consts/const-eval/transmute-const-promotion.stderr b/tests/ui/consts/const-eval/transmute-const-promotion.stderr index 3603db03bb2..eb2fed091c3 100644 --- a/tests/ui/consts/const-eval/transmute-const-promotion.stderr +++ b/tests/ui/consts/const-eval/transmute-const-promotion.stderr @@ -1,5 +1,5 @@ error[E0716]: temporary value dropped while borrowed - --> $DIR/transmute-const-promotion.rs:4:37 + --> $DIR/transmute-const-promotion.rs:5:37 | LL | let x: &'static u32 = unsafe { &mem::transmute(3.0f32) }; | ------------ ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use diff --git a/tests/ui/consts/const-eval/transmute-const.rs b/tests/ui/consts/const-eval/transmute-const.rs index 1cfad00ca76..fb6cb77675f 100644 --- a/tests/ui/consts/const-eval/transmute-const.rs +++ b/tests/ui/consts/const-eval/transmute-const.rs @@ -1,3 +1,4 @@ +#![allow(unnecessary_transmutes)] use std::mem; static FOO: bool = unsafe { mem::transmute(3u8) }; diff --git a/tests/ui/consts/const-eval/transmute-const.stderr b/tests/ui/consts/const-eval/transmute-const.stderr index d72289487d7..35a5cabaa67 100644 --- a/tests/ui/consts/const-eval/transmute-const.stderr +++ b/tests/ui/consts/const-eval/transmute-const.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/transmute-const.rs:3:1 + --> $DIR/transmute-const.rs:4:1 | LL | static FOO: bool = unsafe { mem::transmute(3u8) }; | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x03, but expected a boolean diff --git a/tests/ui/consts/const-eval/ub-enum.rs b/tests/ui/consts/const-eval/ub-enum.rs index 5be444e667a..ac543430da9 100644 --- a/tests/ui/consts/const-eval/ub-enum.rs +++ b/tests/ui/consts/const-eval/ub-enum.rs @@ -2,8 +2,10 @@ //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" //@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP" //@ normalize-stderr: "0x0+" -> "0x0" +//@ dont-require-annotations: NOTE + #![feature(never_type)] -#![allow(invalid_value)] +#![allow(invalid_value, unnecessary_transmutes)] use std::mem; @@ -58,7 +60,7 @@ union MaybeUninit<T: Copy> { } const BAD_ENUM2_UNDEF : Enum2 = unsafe { MaybeUninit { uninit: () }.init }; //~^ ERROR evaluation of constant value failed -//~| uninitialized +//~| NOTE uninitialized // Pointer value in an enum with a niche that is not just 0. const BAD_ENUM2_OPTION_PTR: Option<Enum2> = unsafe { mem::transmute(&0) }; diff --git a/tests/ui/consts/const-eval/ub-enum.stderr b/tests/ui/consts/const-eval/ub-enum.stderr index cfb7eaf537a..faec412b004 100644 --- a/tests/ui/consts/const-eval/ub-enum.stderr +++ b/tests/ui/consts/const-eval/ub-enum.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:27:1 + --> $DIR/ub-enum.rs:29:1 | LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x01, but expected a valid enum tag @@ -10,7 +10,7 @@ LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:30:1 + --> $DIR/ub-enum.rs:32:1 | LL | const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -19,7 +19,7 @@ LL | const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) }; = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:33:1 + --> $DIR/ub-enum.rs:35:1 | LL | const BAD_ENUM_WRAPPED: Wrap<Enum> = unsafe { mem::transmute(&1) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -28,7 +28,7 @@ LL | const BAD_ENUM_WRAPPED: Wrap<Enum> = unsafe { mem::transmute(&1) }; = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:45:1 + --> $DIR/ub-enum.rs:47:1 | LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x0, but expected a valid enum tag @@ -39,7 +39,7 @@ LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:47:1 + --> $DIR/ub-enum.rs:49:1 | LL | const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -48,7 +48,7 @@ LL | const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) }; = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:50:1 + --> $DIR/ub-enum.rs:52:1 | LL | const BAD_ENUM2_WRAPPED: Wrap<Enum2> = unsafe { mem::transmute(&0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -57,13 +57,13 @@ LL | const BAD_ENUM2_WRAPPED: Wrap<Enum2> = unsafe { mem::transmute(&0) }; = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:59:42 + --> $DIR/ub-enum.rs:61:42 | LL | const BAD_ENUM2_UNDEF : Enum2 = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:64:1 + --> $DIR/ub-enum.rs:66:1 | LL | const BAD_ENUM2_OPTION_PTR: Option<Enum2> = unsafe { mem::transmute(&0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -72,7 +72,7 @@ LL | const BAD_ENUM2_OPTION_PTR: Option<Enum2> = unsafe { mem::transmute(&0) }; = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:81:1 + --> $DIR/ub-enum.rs:83:1 | LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant @@ -83,7 +83,7 @@ LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:83:1 + --> $DIR/ub-enum.rs:85:1 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant @@ -94,7 +94,7 @@ LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:91:1 + --> $DIR/ub-enum.rs:93:1 | LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0.1: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) @@ -105,19 +105,19 @@ LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::tran } error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:96:77 + --> $DIR/ub-enum.rs:98:77 | LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) }; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:98:77 + --> $DIR/ub-enum.rs:100:77 | LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) }; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:103:14 + --> $DIR/ub-enum.rs:105:14 | LL | unsafe { std::mem::discriminant(&*(&() as *const () as *const Never)); }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ read discriminant of an uninhabited enum variant diff --git a/tests/ui/consts/const-eval/ub-incorrect-vtable.rs b/tests/ui/consts/const-eval/ub-incorrect-vtable.rs index 8058f7693a7..30c0ae3bb5a 100644 --- a/tests/ui/consts/const-eval/ub-incorrect-vtable.rs +++ b/tests/ui/consts/const-eval/ub-incorrect-vtable.rs @@ -11,19 +11,19 @@ // errors are emitted instead of ICEs. //@ stderr-per-bitwidth - +//@ dont-require-annotations: NOTE trait Trait {} const INVALID_VTABLE_ALIGNMENT: &dyn Trait = unsafe { std::mem::transmute((&92u8, &[0usize, 1usize, 1000usize])) }; //~^^ ERROR it is undefined behavior to use this value -//~| vtable +//~| NOTE vtable const INVALID_VTABLE_SIZE: &dyn Trait = unsafe { std::mem::transmute((&92u8, &[1usize, usize::MAX, 1usize])) }; //~^^ ERROR it is undefined behavior to use this value -//~| vtable +//~| NOTE vtable #[repr(transparent)] struct W<T>(T); @@ -33,18 +33,18 @@ fn drop_me(_: *mut usize) {} const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> = unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), 1usize, 1000usize))) }; //~^^ ERROR it is undefined behavior to use this value -//~| expected a vtable pointer +//~| NOTE expected a vtable pointer const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> = unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), usize::MAX, 1usize))) }; //~^^ ERROR it is undefined behavior to use this value -//~| expected a vtable pointer +//~| NOTE expected a vtable pointer // Even if the vtable has a fn ptr and a reasonable size+align, it still does not work. const INVALID_VTABLE_UB: W<&dyn Trait> = unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), 1usize, 1usize))) }; //~^^ ERROR it is undefined behavior to use this value -//~| expected a vtable pointer +//~| NOTE expected a vtable pointer // Trying to access the data in a vtable does not work, either. @@ -90,7 +90,7 @@ union Transmute<T: Copy, U: Copy> { const FOO: &dyn Bar = &Foo { foo: 128, bar: false }; const G: Wide = unsafe { Transmute { t: FOO }.u }; //~^ ERROR it is undefined behavior to use this value -//~| encountered a dangling reference +//~| NOTE encountered a dangling reference // (it is dangling because vtables do not contain memory that can be dereferenced) fn main() {} diff --git a/tests/ui/consts/const-eval/ub-int-array.rs b/tests/ui/consts/const-eval/ub-int-array.rs index cde0749dc5f..169ac7f1519 100644 --- a/tests/ui/consts/const-eval/ub-int-array.rs +++ b/tests/ui/consts/const-eval/ub-int-array.rs @@ -1,6 +1,8 @@ //! Test the "array of int" fast path in validity checking, and in particular whether it //! points at the right array element. +//@ dont-require-annotations: NOTE + use std::mem; #[repr(C)] @@ -17,7 +19,7 @@ impl<T: Copy> MaybeUninit<T> { const UNINIT_INT_0: [u32; 3] = unsafe { //~^ ERROR it is undefined behavior to use this value - //~| invalid value at [0] + //~| NOTE invalid value at [0] mem::transmute([ MaybeUninit { uninit: () }, // Constants chosen to achieve endianness-independent hex dump. @@ -27,7 +29,7 @@ const UNINIT_INT_0: [u32; 3] = unsafe { }; const UNINIT_INT_1: [u32; 3] = unsafe { //~^ ERROR it is undefined behavior to use this value - //~| invalid value at [1] + //~| NOTE invalid value at [1] mem::transmute([ MaybeUninit::new(0u8), MaybeUninit::new(0u8), @@ -45,7 +47,7 @@ const UNINIT_INT_1: [u32; 3] = unsafe { }; const UNINIT_INT_2: [u32; 3] = unsafe { //~^ ERROR it is undefined behavior to use this value - //~| invalid value at [2] + //~| NOTE invalid value at [2] mem::transmute([ MaybeUninit::new(0u8), MaybeUninit::new(0u8), diff --git a/tests/ui/consts/const-eval/ub-int-array.stderr b/tests/ui/consts/const-eval/ub-int-array.stderr index c8efd7e1bd3..d6ef9bcfeba 100644 --- a/tests/ui/consts/const-eval/ub-int-array.stderr +++ b/tests/ui/consts/const-eval/ub-int-array.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:18:1 + --> $DIR/ub-int-array.rs:20:1 | LL | const UNINIT_INT_0: [u32; 3] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered uninitialized memory, but expected an integer @@ -10,7 +10,7 @@ LL | const UNINIT_INT_0: [u32; 3] = unsafe { } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:28:1 + --> $DIR/ub-int-array.rs:30:1 | LL | const UNINIT_INT_1: [u32; 3] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [1]: encountered uninitialized memory, but expected an integer @@ -21,7 +21,7 @@ LL | const UNINIT_INT_1: [u32; 3] = unsafe { } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:46:1 + --> $DIR/ub-int-array.rs:48:1 | LL | const UNINIT_INT_2: [u32; 3] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [2]: encountered uninitialized memory, but expected an integer diff --git a/tests/ui/consts/const-eval/ub-nonnull.rs b/tests/ui/consts/const-eval/ub-nonnull.rs index b8e312759b4..8ae913db1e4 100644 --- a/tests/ui/consts/const-eval/ub-nonnull.rs +++ b/tests/ui/consts/const-eval/ub-nonnull.rs @@ -1,6 +1,8 @@ // Strip out raw byte dumps to make comparison platform-independent: //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" //@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP" +//@ dont-require-annotations: NOTE + #![allow(invalid_value)] // make sure we cannot allow away the errors tested here #![feature(rustc_attrs, ptr_metadata)] @@ -33,7 +35,7 @@ union MaybeUninit<T: Copy> { } const UNINIT: NonZero<u8> = unsafe { MaybeUninit { uninit: () }.init }; //~^ ERROR evaluation of constant value failed -//~| uninitialized +//~| NOTE uninitialized // Also test other uses of rustc_layout_scalar_valid_range_start diff --git a/tests/ui/consts/const-eval/ub-nonnull.stderr b/tests/ui/consts/const-eval/ub-nonnull.stderr index 0e4926eb49e..75dd0443ca4 100644 --- a/tests/ui/consts/const-eval/ub-nonnull.stderr +++ b/tests/ui/consts/const-eval/ub-nonnull.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:14:1 + --> $DIR/ub-nonnull.rs:16:1 | LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 @@ -10,13 +10,13 @@ LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-nonnull.rs:20:29 + --> $DIR/ub-nonnull.rs:22:29 | LL | let out_of_bounds_ptr = &ptr[255]; - | ^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to 255 bytes of memory, but got ALLOC1 which is only 1 byte from the end of the allocation + | ^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by 255 bytes, but got ALLOC1 which is only 1 byte from the end of the allocation error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:24:1 + --> $DIR/ub-nonnull.rs:26:1 | LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 @@ -27,7 +27,7 @@ LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:26:1 + --> $DIR/ub-nonnull.rs:28:1 | LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 @@ -38,13 +38,13 @@ LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-nonnull.rs:34:38 + --> $DIR/ub-nonnull.rs:36:38 | LL | const UNINIT: NonZero<u8> = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:43:1 + --> $DIR/ub-nonnull.rs:45:1 | LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 42, but expected something in the range 10..=30 @@ -55,7 +55,7 @@ LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:49:1 + --> $DIR/ub-nonnull.rs:51:1 | LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 20, but expected something less or equal to 10, or greater or equal to 30 @@ -66,7 +66,7 @@ LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:52:1 + --> $DIR/ub-nonnull.rs:54:1 | LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.rs b/tests/ui/consts/const-eval/ub-ref-ptr.rs index 50e510a3d54..988e6c62e34 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.rs +++ b/tests/ui/consts/const-eval/ub-ref-ptr.rs @@ -2,6 +2,8 @@ // Strip out raw byte dumps to make comparison platform-independent: //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" //@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP" +//@ dont-require-annotations: NOTE + #![allow(invalid_value)] use std::mem; @@ -14,11 +16,11 @@ union MaybeUninit<T: Copy> { const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; //~^ ERROR it is undefined behavior to use this value -//~| constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) +//~| NOTE constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) }; //~^ ERROR it is undefined behavior to use this value -//~| constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) +//~| NOTE constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) const NULL: &u16 = unsafe { mem::transmute(0usize) }; //~^ ERROR it is undefined behavior to use this value @@ -47,13 +49,13 @@ const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init }; //~^ ERROR evaluation of constant value failed -//~| uninitialized +//~| NOTE uninitialized const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; //~^ ERROR it is undefined behavior to use this value const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init }; //~^ ERROR evaluation of constant value failed -//~| uninitialized +//~| NOTE uninitialized const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; //~^ ERROR it is undefined behavior to use this value const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.stderr b/tests/ui/consts/const-eval/ub-ref-ptr.stderr index 72a523282e6..de5e721c3f7 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.stderr +++ b/tests/ui/consts/const-eval/ub-ref-ptr.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:15:1 + --> $DIR/ub-ref-ptr.rs:17:1 | LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) @@ -10,7 +10,7 @@ LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:19:1 + --> $DIR/ub-ref-ptr.rs:21:1 | LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) @@ -21,7 +21,7 @@ LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:23:1 + --> $DIR/ub-ref-ptr.rs:25:1 | LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference @@ -32,7 +32,7 @@ LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:26:1 + --> $DIR/ub-ref-ptr.rs:28:1 | LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null box @@ -43,7 +43,7 @@ LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:33:1 + --> $DIR/ub-ref-ptr.rs:35:1 | LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -52,7 +52,7 @@ LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:36:39 + --> $DIR/ub-ref-ptr.rs:38:39 | LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -61,13 +61,13 @@ LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported note: erroneous constant encountered - --> $DIR/ub-ref-ptr.rs:36:38 + --> $DIR/ub-ref-ptr.rs:38:38 | LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:39:86 + --> $DIR/ub-ref-ptr.rs:41:86 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer @@ -76,13 +76,13 @@ LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[us = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported note: erroneous constant encountered - --> $DIR/ub-ref-ptr.rs:39:85 + --> $DIR/ub-ref-ptr.rs:41:85 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; | ^^^^^^^^^^^^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:42:1 + --> $DIR/ub-ref-ptr.rs:44:1 | LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance) @@ -93,7 +93,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:45:1 + --> $DIR/ub-ref-ptr.rs:47:1 | LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance) @@ -104,13 +104,13 @@ LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:48:41 + --> $DIR/ub-ref-ptr.rs:50:41 | LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:52:1 + --> $DIR/ub-ref-ptr.rs:54:1 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer @@ -121,13 +121,13 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:54:38 + --> $DIR/ub-ref-ptr.rs:56:38 | LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:57:1 + --> $DIR/ub-ref-ptr.rs:59:1 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer @@ -138,7 +138,7 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:59:1 + --> $DIR/ub-ref-ptr.rs:61:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC2<imm>, but expected a function pointer @@ -149,7 +149,7 @@ LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:66:5 + --> $DIR/ub-ref-ptr.rs:68:5 | LL | ptr.read(); | ^^^^^^^^^^ accessing memory based on pointer with alignment 1, but alignment 4 is required diff --git a/tests/ui/consts/const-eval/ub-uninhabit.rs b/tests/ui/consts/const-eval/ub-uninhabit.rs index d0515a4e6f0..3a5e291d5df 100644 --- a/tests/ui/consts/const-eval/ub-uninhabit.rs +++ b/tests/ui/consts/const-eval/ub-uninhabit.rs @@ -1,6 +1,8 @@ // Strip out raw byte dumps to make comparison platform-independent: //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" //@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP" +//@ dont-require-annotations: NOTE + #![feature(core_intrinsics)] #![feature(never_type)] @@ -18,15 +20,15 @@ union MaybeUninit<T: Copy> { const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init }; //~^ ERROR evaluation of constant value failed -//~| constructing invalid value +//~| NOTE constructing invalid value const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; //~^ ERROR it is undefined behavior to use this value -//~| constructing invalid value +//~| NOTE constructing invalid value const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init }; //~^ ERROR evaluation of constant value failed -//~| constructing invalid value +//~| NOTE constructing invalid value const READ_NEVER: () = unsafe { @@ -34,7 +36,7 @@ const READ_NEVER: () = unsafe { let ptr = mem.as_ptr().cast::<!>(); let _val = intrinsics::read_via_copy(ptr); //~^ ERROR evaluation of constant value failed - //~| constructing invalid value + //~| NOTE constructing invalid value }; diff --git a/tests/ui/consts/const-eval/ub-uninhabit.stderr b/tests/ui/consts/const-eval/ub-uninhabit.stderr index d26f4e03666..9d3f93279e5 100644 --- a/tests/ui/consts/const-eval/ub-uninhabit.stderr +++ b/tests/ui/consts/const-eval/ub-uninhabit.stderr @@ -1,11 +1,11 @@ error[E0080]: evaluation of constant value failed - --> $DIR/ub-uninhabit.rs:19:35 + --> $DIR/ub-uninhabit.rs:21:35 | LL | const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type `Bar` error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-uninhabit.rs:23:1 + --> $DIR/ub-uninhabit.rs:25:1 | LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type Bar @@ -16,13 +16,13 @@ LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-uninhabit.rs:27:42 + --> $DIR/ub-uninhabit.rs:29:42 | LL | const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered a value of uninhabited type `Bar` error[E0080]: evaluation of constant value failed - --> $DIR/ub-uninhabit.rs:35:16 + --> $DIR/ub-uninhabit.rs:37:16 | LL | let _val = intrinsics::read_via_copy(ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of the never type `!` diff --git a/tests/ui/consts/const-eval/ub-wide-ptr.rs b/tests/ui/consts/const-eval/ub-wide-ptr.rs index a071a44272b..4b9bbb8066d 100644 --- a/tests/ui/consts/const-eval/ub-wide-ptr.rs +++ b/tests/ui/consts/const-eval/ub-wide-ptr.rs @@ -1,5 +1,5 @@ // ignore-tidy-linelength -#![allow(unused)] +#![allow(unused, unnecessary_transmutes)] #![feature(ptr_metadata)] use std::{ptr, mem}; @@ -9,7 +9,7 @@ use std::{ptr, mem}; //@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP" //@ normalize-stderr: "offset \d+" -> "offset N" //@ normalize-stderr: "size \d+" -> "size N" - +//@ dont-require-annotations: NOTE /// A newtype wrapper to prevent MIR generation from inserting reborrows that would affect the error /// message. @@ -62,7 +62,7 @@ const SLICE_VALID: &[u8] = unsafe { mem::transmute((&42u8, 1usize)) }; // bad slice: length uninit const SLICE_LENGTH_UNINIT: &[u8] = unsafe { //~^ ERROR evaluation of constant value failed -//~| uninitialized +//~| NOTE uninitialized let uninit_len = MaybeUninit::<usize> { uninit: () }; mem::transmute((42, uninit_len)) }; @@ -85,18 +85,18 @@ const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) }; // bad data *inside* the slice const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; //~^ ERROR it is undefined behavior to use this value -//~| constant +//~| NOTE constant // good MySliceBool const MYSLICE_GOOD: &MySliceBool = &MySlice(true, [false]); // bad: sized field is not okay const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); //~^ ERROR it is undefined behavior to use this value -//~| constant +//~| NOTE constant // bad: unsized part is not okay const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); //~^ ERROR it is undefined behavior to use this value -//~| constant +//~| NOTE constant // # raw slice const RAW_SLICE_VALID: *const [u8] = unsafe { mem::transmute((&42u8, 1usize)) }; // ok @@ -104,7 +104,7 @@ const RAW_SLICE_TOO_LONG: *const [u8] = unsafe { mem::transmute((&42u8, 999usize const RAW_SLICE_MUCH_TOO_LONG: *const [u8] = unsafe { mem::transmute((&42u8, usize::MAX)) }; // ok because raw const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe { //~^ ERROR evaluation of constant value failed -//~| uninitialized +//~| NOTE uninitialized let uninit_len = MaybeUninit::<usize> { uninit: () }; mem::transmute((42, uninit_len)) }; @@ -113,40 +113,40 @@ const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe { // bad trait object const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; //~^ ERROR it is undefined behavior to use this value -//~| vtable +//~| NOTE vtable // bad trait object const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; //~^ ERROR it is undefined behavior to use this value -//~| vtable +//~| NOTE vtable // bad trait object const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; //~^ ERROR it is undefined behavior to use this value -//~| vtable +//~| NOTE vtable const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) }; //~^ ERROR it is undefined behavior to use this value -//~| vtable +//~| NOTE vtable const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) }; //~^ ERROR it is undefined behavior to use this value -//~| vtable +//~| NOTE vtable const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) }; //~^ ERROR it is undefined behavior to use this value -//~| vtable +//~| NOTE vtable const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; //~^ ERROR it is undefined behavior to use this value -//~| vtable +//~| NOTE vtable // bad data *inside* the trait object const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; //~^ ERROR it is undefined behavior to use this value -//~| expected a boolean +//~| NOTE expected a boolean // # raw trait object const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; //~^ ERROR it is undefined behavior to use this value -//~| null pointer +//~| NOTE null pointer const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; //~^ ERROR it is undefined behavior to use this value -//~| vtable +//~| NOTE vtable const RAW_TRAIT_OBJ_CONTENT_INVALID: *const dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) } as *const dyn Trait; // ok because raw // Officially blessed way to get the vtable const DYN_METADATA: ptr::DynMetadata<dyn Send> = ptr::metadata::<dyn Send>(ptr::null::<i32>()); @@ -155,12 +155,12 @@ const DYN_METADATA: ptr::DynMetadata<dyn Send> = ptr::metadata::<dyn Send>(ptr:: static mut RAW_TRAIT_OBJ_VTABLE_NULL_THROUGH_REF: *const dyn Trait = unsafe { mem::transmute::<_, &dyn Trait>((&92u8, 0usize)) //~^^ ERROR it is undefined behavior to use this value - //~| null pointer + //~| NOTE null pointer }; static mut RAW_TRAIT_OBJ_VTABLE_INVALID_THROUGH_REF: *const dyn Trait = unsafe { mem::transmute::<_, &dyn Trait>((&92u8, &3u64)) //~^^ ERROR it is undefined behavior to use this value - //~| vtable + //~| NOTE vtable }; fn main() {} 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 c9799989ea8..55e9abe72e0 100644 --- a/tests/ui/consts/const-eval/union-const-eval-field.rs +++ b/tests/ui/consts/const-eval/union-const-eval-field.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + type Field1 = i32; type Field2 = f32; type Field3 = i64; @@ -25,7 +27,7 @@ const fn read_field2() -> Field2 { const fn read_field3() -> Field3 { const FIELD3: Field3 = unsafe { UNION.field3 }; //~^ ERROR evaluation of constant value failed - //~| uninitialized + //~| NOTE uninitialized FIELD3 } 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 b1de225ec58..4fd6b80381c 100644 --- a/tests/ui/consts/const-eval/union-const-eval-field.stderr +++ b/tests/ui/consts/const-eval/union-const-eval-field.stderr @@ -1,17 +1,17 @@ error[E0080]: evaluation of constant value failed - --> $DIR/union-const-eval-field.rs:26:37 + --> $DIR/union-const-eval-field.rs:28:37 | LL | const FIELD3: Field3 = unsafe { UNION.field3 }; | ^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory note: erroneous constant encountered - --> $DIR/union-const-eval-field.rs:29:5 + --> $DIR/union-const-eval-field.rs:31:5 | LL | FIELD3 | ^^^^^^ note: erroneous constant encountered - --> $DIR/union-const-eval-field.rs:29:5 + --> $DIR/union-const-eval-field.rs:31:5 | LL | FIELD3 | ^^^^^^ diff --git a/tests/ui/consts/const-eval/union-ub.32bit.stderr b/tests/ui/consts/const-eval/union-ub.32bit.stderr index e5c8f88be98..38ded4d65cf 100644 --- a/tests/ui/consts/const-eval/union-ub.32bit.stderr +++ b/tests/ui/consts/const-eval/union-ub.32bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/union-ub.rs:32:1 + --> $DIR/union-ub.rs:33:1 | LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool}; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x2a, but expected a boolean @@ -10,7 +10,7 @@ LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool}; } error[E0080]: evaluation of constant value failed - --> $DIR/union-ub.rs:34:36 + --> $DIR/union-ub.rs:35:36 | LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory diff --git a/tests/ui/consts/const-eval/union-ub.64bit.stderr b/tests/ui/consts/const-eval/union-ub.64bit.stderr index e5c8f88be98..38ded4d65cf 100644 --- a/tests/ui/consts/const-eval/union-ub.64bit.stderr +++ b/tests/ui/consts/const-eval/union-ub.64bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/union-ub.rs:32:1 + --> $DIR/union-ub.rs:33:1 | LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool}; | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x2a, but expected a boolean @@ -10,7 +10,7 @@ LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool}; } error[E0080]: evaluation of constant value failed - --> $DIR/union-ub.rs:34:36 + --> $DIR/union-ub.rs:35:36 | LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory diff --git a/tests/ui/consts/const-eval/union-ub.rs b/tests/ui/consts/const-eval/union-ub.rs index 5eb4ad4b47f..7d8fd7446a0 100644 --- a/tests/ui/consts/const-eval/union-ub.rs +++ b/tests/ui/consts/const-eval/union-ub.rs @@ -1,4 +1,5 @@ //@ stderr-per-bitwidth +//@ dont-require-annotations: NOTE #[repr(C)] union DummyUnion { @@ -33,7 +34,7 @@ const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool}; //~^ ERROR it is undefined behavior to use this value const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool}; //~^ ERROR evaluation of constant value failed -//~| uninitialized +//~| NOTE uninitialized // The value is not valid for any union variant, but that's fine // unions are just a convenient way to transmute bits around diff --git a/tests/ui/consts/const-eval/unwind-abort.rs b/tests/ui/consts/const-eval/unwind-abort.rs index fee53f8528d..b239dba0239 100644 --- a/tests/ui/consts/const-eval/unwind-abort.rs +++ b/tests/ui/consts/const-eval/unwind-abort.rs @@ -1,5 +1,7 @@ +//@ dont-require-annotations: NOTE + const extern "C" fn foo() { - panic!() //~ inside `foo` + panic!() //~ NOTE inside `foo` } const _: () = foo(); //~ ERROR evaluation of constant value failed diff --git a/tests/ui/consts/const-eval/unwind-abort.stderr b/tests/ui/consts/const-eval/unwind-abort.stderr index 7d096c5d587..5ed7467e84b 100644 --- a/tests/ui/consts/const-eval/unwind-abort.stderr +++ b/tests/ui/consts/const-eval/unwind-abort.stderr @@ -1,11 +1,11 @@ error[E0080]: evaluation of constant value failed - --> $DIR/unwind-abort.rs:5:15 + --> $DIR/unwind-abort.rs:7:15 | LL | const _: () = foo(); | ^^^^^ evaluation panicked: explicit panic | note: inside `foo` - --> $DIR/unwind-abort.rs:2:5 + --> $DIR/unwind-abort.rs:4:5 | LL | panic!() | ^^^^^^^^ the failure occurred here diff --git a/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs b/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs index c4df93b6239..5f1d27b0de0 100644 --- a/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs +++ b/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs @@ -1,5 +1,7 @@ +//@ dont-require-annotations: NOTE + const fn foo() -> ! { - unsafe { std::mem::transmute(()) } //~ inside `foo` + unsafe { std::mem::transmute(()) } //~ NOTE inside `foo` } // Type defined in a submodule, so that it is not "visibly" diff --git a/tests/ui/consts/const-eval/validate_uninhabited_zsts.stderr b/tests/ui/consts/const-eval/validate_uninhabited_zsts.stderr index 29311fdb25a..0407ae5c323 100644 --- a/tests/ui/consts/const-eval/validate_uninhabited_zsts.stderr +++ b/tests/ui/consts/const-eval/validate_uninhabited_zsts.stderr @@ -1,17 +1,17 @@ error[E0080]: evaluation of constant value failed - --> $DIR/validate_uninhabited_zsts.rs:15:33 + --> $DIR/validate_uninhabited_zsts.rs:17:33 | LL | const FOO: [empty::Empty; 3] = [foo(); 3]; | ^^^^^ constructing invalid value: encountered a value of the never type `!` | note: inside `foo` - --> $DIR/validate_uninhabited_zsts.rs:2:14 + --> $DIR/validate_uninhabited_zsts.rs:4:14 | LL | unsafe { std::mem::transmute(()) } | ^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here error[E0080]: evaluation of constant value failed - --> $DIR/validate_uninhabited_zsts.rs:18:42 + --> $DIR/validate_uninhabited_zsts.rs:20:42 | LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered a value of uninhabited type `Void` diff --git a/tests/ui/consts/const-len-underflow-separate-spans.next.stderr b/tests/ui/consts/const-len-underflow-separate-spans.next.stderr index bd2a81f5148..aacd74635e9 100644 --- a/tests/ui/consts/const-len-underflow-separate-spans.next.stderr +++ b/tests/ui/consts/const-len-underflow-separate-spans.next.stderr @@ -5,7 +5,7 @@ LL | const LEN: usize = ONE - TWO; | ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, which would overflow note: erroneous constant encountered - --> $DIR/const-len-underflow-separate-spans.rs:14:17 + --> $DIR/const-len-underflow-separate-spans.rs:15:17 | LL | let a: [i8; LEN] = unimplemented!(); | ^^^ diff --git a/tests/ui/consts/const-len-underflow-separate-spans.old.stderr b/tests/ui/consts/const-len-underflow-separate-spans.old.stderr index bd2a81f5148..aacd74635e9 100644 --- a/tests/ui/consts/const-len-underflow-separate-spans.old.stderr +++ b/tests/ui/consts/const-len-underflow-separate-spans.old.stderr @@ -5,7 +5,7 @@ LL | const LEN: usize = ONE - TWO; | ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, which would overflow note: erroneous constant encountered - --> $DIR/const-len-underflow-separate-spans.rs:14:17 + --> $DIR/const-len-underflow-separate-spans.rs:15:17 | LL | let a: [i8; LEN] = unimplemented!(); | ^^^ diff --git a/tests/ui/consts/const-len-underflow-separate-spans.rs b/tests/ui/consts/const-len-underflow-separate-spans.rs index 42314eed7aa..14eb88b1427 100644 --- a/tests/ui/consts/const-len-underflow-separate-spans.rs +++ b/tests/ui/consts/const-len-underflow-separate-spans.rs @@ -9,8 +9,9 @@ const ONE: usize = 1; const TWO: usize = 2; const LEN: usize = ONE - TWO; //~^ ERROR constant +//~| NOTE attempt to compute `1_usize - 2_usize`, which would overflow fn main() { let a: [i8; LEN] = unimplemented!(); -//~^ constant +//~^ NOTE constant } diff --git a/tests/ui/consts/const-mut-refs/mut_ref_in_final.rs b/tests/ui/consts/const-mut-refs/mut_ref_in_final.rs index 283c1224e01..bc534be6832 100644 --- a/tests/ui/consts/const-mut-refs/mut_ref_in_final.rs +++ b/tests/ui/consts/const-mut-refs/mut_ref_in_final.rs @@ -1,6 +1,7 @@ //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" //@ normalize-stderr: "( 0x[0-9a-f][0-9a-f] │)? ([0-9a-f][0-9a-f] |__ |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> " HEX_DUMP" //@ normalize-stderr: "HEX_DUMP\s*\n\s*HEX_DUMP" -> "HEX_DUMP" +//@ dont-require-annotations: NOTE use std::cell::UnsafeCell; use std::mem; @@ -25,7 +26,7 @@ const B4: Option<&mut i32> = helper(&mut 42); //~ ERROR temporary value dropped // Not ok, since it points to read-only memory. const IMMUT_MUT_REF: &mut u16 = unsafe { mem::transmute(&13) }; //~^ ERROR undefined behavior to use this value -//~| pointing to read-only memory +//~| NOTE pointing to read-only memory // Ok, because no references to mutable data exist here, since the `{}` moves // its value and then takes a reference to that. diff --git a/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr b/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr index 4f50ae32312..1f49f08c401 100644 --- a/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr +++ b/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr @@ -1,11 +1,11 @@ error[E0764]: mutable references are not allowed in the final value of constants - --> $DIR/mut_ref_in_final.rs:14:21 + --> $DIR/mut_ref_in_final.rs:15:21 | LL | const B: *mut i32 = &mut 4; | ^^^^^^ error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:20:40 + --> $DIR/mut_ref_in_final.rs:21:40 | LL | const B3: Option<&mut i32> = Some(&mut 42); | ----------^^- @@ -15,7 +15,7 @@ LL | const B3: Option<&mut i32> = Some(&mut 42); | using this value as a constant requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:23:42 + --> $DIR/mut_ref_in_final.rs:24:42 | LL | const B4: Option<&mut i32> = helper(&mut 42); | ------------^^- @@ -25,7 +25,7 @@ LL | const B4: Option<&mut i32> = helper(&mut 42); | using this value as a constant requires that borrow lasts for `'static` error[E0080]: it is undefined behavior to use this value - --> $DIR/mut_ref_in_final.rs:26:1 + --> $DIR/mut_ref_in_final.rs:27:1 | LL | const IMMUT_MUT_REF: &mut u16 = unsafe { mem::transmute(&13) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory @@ -36,7 +36,7 @@ LL | const IMMUT_MUT_REF: &mut u16 = unsafe { mem::transmute(&13) }; } error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:50:65 + --> $DIR/mut_ref_in_final.rs:51:65 | LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | -------------------------------^^-- @@ -46,7 +46,7 @@ LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | using this value as a constant requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:53:67 + --> $DIR/mut_ref_in_final.rs:54:67 | LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | -------------------------------^^-- @@ -56,7 +56,7 @@ LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | using this value as a static requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:56:71 + --> $DIR/mut_ref_in_final.rs:57:71 | LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | -------------------------------^^-- @@ -66,25 +66,25 @@ LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | using this value as a static requires that borrow lasts for `'static` error[E0764]: mutable references are not allowed in the final value of statics - --> $DIR/mut_ref_in_final.rs:69:53 + --> $DIR/mut_ref_in_final.rs:70:53 | LL | static RAW_MUT_CAST_S: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ }; | ^^^^^^^ error[E0764]: mutable references are not allowed in the final value of statics - --> $DIR/mut_ref_in_final.rs:71:54 + --> $DIR/mut_ref_in_final.rs:72:54 | LL | static RAW_MUT_COERCE_S: SyncPtr<i32> = SyncPtr { x: &mut 0 }; | ^^^^^^ error[E0764]: mutable references are not allowed in the final value of constants - --> $DIR/mut_ref_in_final.rs:73:52 + --> $DIR/mut_ref_in_final.rs:74:52 | LL | const RAW_MUT_CAST_C: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ }; | ^^^^^^^ error[E0764]: mutable references are not allowed in the final value of constants - --> $DIR/mut_ref_in_final.rs:75:53 + --> $DIR/mut_ref_in_final.rs:76:53 | LL | const RAW_MUT_COERCE_C: SyncPtr<i32> = SyncPtr { x: &mut 0 }; | ^^^^^^ diff --git a/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs b/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs index ac903fca20a..a58c4437e15 100644 --- a/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs +++ b/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs @@ -1,6 +1,7 @@ //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" //@ normalize-stderr: "( 0x[0-9a-f][0-9a-f] │)? ([0-9a-f][0-9a-f] |__ |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> " HEX_DUMP" //@ normalize-stderr: "HEX_DUMP\s*\n\s*HEX_DUMP" -> "HEX_DUMP" +//@ dont-require-annotations: NOTE use std::sync::Mutex; @@ -16,16 +17,16 @@ const fn helper() -> Option<&'static mut i32> { unsafe { Some(&mut *std::ptr::addr_of_mut!(BUFFER)) } } const MUT: Option<&mut i32> = helper(); //~ ERROR it is undefined behavior to use this value -//~^ encountered reference to mutable +//~^ NOTE encountered reference to mutable const fn helper_int2ptr() -> Option<&'static mut i32> { unsafe { // Undefined behaviour (integer as pointer), who doesn't love tests like this. Some(&mut *(42 as *mut i32)) } } const INT2PTR: Option<&mut i32> = helper_int2ptr(); //~ ERROR it is undefined behavior to use this value -//~^ encountered a dangling reference +//~^ NOTE encountered a dangling reference static INT2PTR_STATIC: Option<&mut i32> = helper_int2ptr(); //~ ERROR it is undefined behavior to use this value -//~^ encountered a dangling reference +//~^ NOTE encountered a dangling reference const fn helper_dangling() -> Option<&'static mut i32> { unsafe { // Undefined behaviour (dangling pointer), who doesn't love tests like this. diff --git a/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr b/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr index aebac56f8c5..4ea6fa62475 100644 --- a/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr +++ b/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/mut_ref_in_final_dynamic_check.rs:18:1 + --> $DIR/mut_ref_in_final_dynamic_check.rs:19:1 | LL | const MUT: Option<&mut i32> = helper(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0: encountered reference to mutable memory in `const` @@ -10,7 +10,7 @@ LL | const MUT: Option<&mut i32> = helper(); } error[E0080]: it is undefined behavior to use this value - --> $DIR/mut_ref_in_final_dynamic_check.rs:25:1 + --> $DIR/mut_ref_in_final_dynamic_check.rs:26:1 | LL | const INT2PTR: Option<&mut i32> = helper_int2ptr(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0: encountered a dangling reference (0x2a[noalloc] has no provenance) @@ -21,7 +21,7 @@ LL | const INT2PTR: Option<&mut i32> = helper_int2ptr(); } error[E0080]: it is undefined behavior to use this value - --> $DIR/mut_ref_in_final_dynamic_check.rs:27:1 + --> $DIR/mut_ref_in_final_dynamic_check.rs:28:1 | LL | static INT2PTR_STATIC: Option<&mut i32> = helper_int2ptr(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0: encountered a dangling reference (0x2a[noalloc] has no provenance) @@ -32,7 +32,7 @@ LL | static INT2PTR_STATIC: Option<&mut i32> = helper_int2ptr(); } error[E0080]: it is undefined behavior to use this value - --> $DIR/mut_ref_in_final_dynamic_check.rs:34:1 + --> $DIR/mut_ref_in_final_dynamic_check.rs:35:1 | LL | const DANGLING: Option<&mut i32> = helper_dangling(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0: encountered a dangling reference (use-after-free) @@ -43,7 +43,7 @@ LL | const DANGLING: Option<&mut i32> = helper_dangling(); } error[E0080]: it is undefined behavior to use this value - --> $DIR/mut_ref_in_final_dynamic_check.rs:35:1 + --> $DIR/mut_ref_in_final_dynamic_check.rs:36:1 | LL | static DANGLING_STATIC: Option<&mut i32> = helper_dangling(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0: encountered a dangling reference (use-after-free) diff --git a/tests/ui/consts/const-pattern-irrefutable.rs b/tests/ui/consts/const-pattern-irrefutable.rs index 759d2e8b2ed..e131fd27d53 100644 --- a/tests/ui/consts/const-pattern-irrefutable.rs +++ b/tests/ui/consts/const-pattern-irrefutable.rs @@ -1,15 +1,17 @@ +//@ dont-require-annotations: NOTE + mod foo { pub const b: u8 = 2; - //~^ missing patterns are not covered because `b` is interpreted as a constant pattern, not a new variable + //~^ NOTE missing patterns are not covered because `b` is interpreted as a constant pattern, not a new variable pub const d: (u8, u8) = (2, 1); - //~^ missing patterns are not covered because `d` is interpreted as a constant pattern, not a new variable + //~^ NOTE missing patterns are not covered because `d` is interpreted as a constant pattern, not a new variable } use foo::b as c; use foo::d; const a: u8 = 2; -//~^ missing patterns are not covered because `a` is interpreted as a constant pattern, not a new variable +//~^ NOTE missing patterns are not covered because `a` is interpreted as a constant pattern, not a new variable #[derive(PartialEq)] struct S { @@ -23,19 +25,19 @@ const e: S = S { fn main() { let a = 4; //~^ ERROR refutable pattern in local binding - //~| patterns `0_u8..=1_u8` and `3_u8..=u8::MAX` not covered + //~| NOTE patterns `0_u8..=1_u8` and `3_u8..=u8::MAX` not covered //~| HELP introduce a variable instead let c = 4; //~^ ERROR refutable pattern in local binding - //~| patterns `0_u8..=1_u8` and `3_u8..=u8::MAX` not covered + //~| NOTE patterns `0_u8..=1_u8` and `3_u8..=u8::MAX` not covered //~| HELP introduce a variable instead let d = (4, 4); //~^ ERROR refutable pattern in local binding - //~| patterns `(0_u8..=1_u8, _)` and `(3_u8..=u8::MAX, _)` not covered + //~| NOTE patterns `(0_u8..=1_u8, _)` and `(3_u8..=u8::MAX, _)` not covered //~| HELP introduce a variable instead let e = S { //~^ ERROR refutable pattern in local binding - //~| pattern `S { foo: 1_u8..=u8::MAX }` not covered + //~| NOTE pattern `S { foo: 1_u8..=u8::MAX }` not covered //~| HELP introduce a variable instead foo: 1, }; diff --git a/tests/ui/consts/const-pattern-irrefutable.stderr b/tests/ui/consts/const-pattern-irrefutable.stderr index 06bd01bff79..f52ebc31333 100644 --- a/tests/ui/consts/const-pattern-irrefutable.stderr +++ b/tests/ui/consts/const-pattern-irrefutable.stderr @@ -1,5 +1,5 @@ error[E0005]: refutable pattern in local binding - --> $DIR/const-pattern-irrefutable.rs:24:9 + --> $DIR/const-pattern-irrefutable.rs:26:9 | LL | const a: u8 = 2; | ----------- missing patterns are not covered because `a` is interpreted as a constant pattern, not a new variable @@ -16,7 +16,7 @@ LL | let a_var = 4; | ++++ error[E0005]: refutable pattern in local binding - --> $DIR/const-pattern-irrefutable.rs:28:9 + --> $DIR/const-pattern-irrefutable.rs:30:9 | LL | pub const b: u8 = 2; | --------------- missing patterns are not covered because `b` is interpreted as a constant pattern, not a new variable @@ -34,7 +34,7 @@ LL + let b_var = 4; | error[E0005]: refutable pattern in local binding - --> $DIR/const-pattern-irrefutable.rs:32:9 + --> $DIR/const-pattern-irrefutable.rs:34:9 | LL | pub const d: (u8, u8) = (2, 1); | --------------------- missing patterns are not covered because `d` is interpreted as a constant pattern, not a new variable @@ -51,7 +51,7 @@ LL | let d_var = (4, 4); | ++++ error[E0005]: refutable pattern in local binding - --> $DIR/const-pattern-irrefutable.rs:36:9 + --> $DIR/const-pattern-irrefutable.rs:38:9 | LL | const e: S = S { | ---------- missing patterns are not covered because `e` is interpreted as a constant pattern, not a new variable @@ -62,7 +62,7 @@ LL | let e = S { = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html note: `S` defined here - --> $DIR/const-pattern-irrefutable.rs:15:8 + --> $DIR/const-pattern-irrefutable.rs:17:8 | LL | struct S { | ^ diff --git a/tests/ui/consts/const-tup-index-span.rs b/tests/ui/consts/const-tup-index-span.rs index e77d392e694..4cb7143b435 100644 --- a/tests/ui/consts/const-tup-index-span.rs +++ b/tests/ui/consts/const-tup-index-span.rs @@ -2,7 +2,8 @@ const TUP: (usize,) = 5usize << 64; //~^ ERROR mismatched types -//~| expected `(usize,)`, found `usize` +//~| NOTE expected `(usize,)`, found `usize` +//~| NOTE expected tuple `(usize,)` const ARR: [i32; TUP.0] = []; fn main() { diff --git a/tests/ui/consts/const_let_assign2.rs b/tests/ui/consts/const_let_assign2.rs index e8ebba7b208..5349ae31bb4 100644 --- a/tests/ui/consts/const_let_assign2.rs +++ b/tests/ui/consts/const_let_assign2.rs @@ -16,7 +16,7 @@ static mut BB: AA = AA::new(); fn main() { let ptr = unsafe { &mut BB }; - //~^ WARN mutable reference to mutable static is discouraged [static_mut_refs] + //~^ WARN mutable reference to mutable static [static_mut_refs] for a in ptr.data.iter() { println!("{}", a); } diff --git a/tests/ui/consts/const_let_assign2.stderr b/tests/ui/consts/const_let_assign2.stderr index 0d76f142d17..1bb560437b6 100644 --- a/tests/ui/consts/const_let_assign2.stderr +++ b/tests/ui/consts/const_let_assign2.stderr @@ -1,4 +1,4 @@ -warning: creating a mutable reference to mutable static is discouraged +warning: creating a mutable reference to mutable static --> $DIR/const_let_assign2.rs:18:24 | LL | let ptr = unsafe { &mut BB }; diff --git a/tests/ui/consts/const_refs_to_static_fail.rs b/tests/ui/consts/const_refs_to_static_fail.rs index 596ed50af38..e1f2262ba29 100644 --- a/tests/ui/consts/const_refs_to_static_fail.rs +++ b/tests/ui/consts/const_refs_to_static_fail.rs @@ -1,5 +1,6 @@ //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" //@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP" +//@ dont-require-annotations: NOTE #![feature(sync_unsafe_cell)] @@ -9,14 +10,14 @@ static S: SyncUnsafeCell<i32> = SyncUnsafeCell::new(0); static mut S_MUT: i32 = 0; const C1: &SyncUnsafeCell<i32> = &S; //~ERROR undefined behavior -//~| encountered reference to mutable memory +//~| NOTE encountered reference to mutable memory const C1_READ: () = unsafe { assert!(*C1.get() == 0); }; const C2: *const i32 = unsafe { std::ptr::addr_of!(S_MUT) }; const C2_READ: () = unsafe { assert!(*C2 == 0); //~ERROR evaluation of constant value failed - //~^ constant accesses mutable global memory + //~^ NOTE constant accesses mutable global memory }; fn main() { diff --git a/tests/ui/consts/const_refs_to_static_fail.stderr b/tests/ui/consts/const_refs_to_static_fail.stderr index 297561dbcf1..245806da5c6 100644 --- a/tests/ui/consts/const_refs_to_static_fail.stderr +++ b/tests/ui/consts/const_refs_to_static_fail.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refs_to_static_fail.rs:11:1 + --> $DIR/const_refs_to_static_fail.rs:12:1 | LL | const C1: &SyncUnsafeCell<i32> = &S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` @@ -10,13 +10,13 @@ LL | const C1: &SyncUnsafeCell<i32> = &S; } note: erroneous constant encountered - --> $DIR/const_refs_to_static_fail.rs:14:14 + --> $DIR/const_refs_to_static_fail.rs:15:14 | LL | assert!(*C1.get() == 0); | ^^ error[E0080]: evaluation of constant value failed - --> $DIR/const_refs_to_static_fail.rs:18:13 + --> $DIR/const_refs_to_static_fail.rs:19:13 | LL | assert!(*C2 == 0); | ^^^ constant accesses mutable global memory diff --git a/tests/ui/consts/const_refs_to_static_fail_invalid.rs b/tests/ui/consts/const_refs_to_static_fail_invalid.rs index 3383a208345..f6ccfbfc52f 100644 --- a/tests/ui/consts/const_refs_to_static_fail_invalid.rs +++ b/tests/ui/consts/const_refs_to_static_fail_invalid.rs @@ -1,5 +1,7 @@ //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" //@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP" +//@ dont-require-annotations: NOTE + #![allow(static_mut_refs)] fn invalid() { @@ -7,7 +9,7 @@ fn invalid() { const C: &bool = unsafe { std::mem::transmute(&S) }; //~^ERROR: undefined behavior - //~| expected a boolean + //~| NOTE expected a boolean // This must be rejected here (or earlier), since it's not a valid `&bool`. match &true { @@ -23,7 +25,7 @@ fn extern_() { const C: &i8 = unsafe { &S }; //~^ERROR: undefined behavior - //~| `extern` static + //~| NOTE `extern` static // This must be rejected here (or earlier), since the pattern cannot be read. match &0 { @@ -37,7 +39,7 @@ fn mutable() { const C: &i32 = unsafe { &S_MUT }; //~^ERROR: undefined behavior - //~| encountered reference to mutable memory + //~| NOTE encountered reference to mutable memory // This *must not build*, the constant we are matching against // could change its value! diff --git a/tests/ui/consts/const_refs_to_static_fail_invalid.stderr b/tests/ui/consts/const_refs_to_static_fail_invalid.stderr index c9d5cb60bf7..e0086e07af7 100644 --- a/tests/ui/consts/const_refs_to_static_fail_invalid.stderr +++ b/tests/ui/consts/const_refs_to_static_fail_invalid.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refs_to_static_fail_invalid.rs:8:5 + --> $DIR/const_refs_to_static_fail_invalid.rs:10:5 | LL | const C: &bool = unsafe { std::mem::transmute(&S) }; | ^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered 0x0a, but expected a boolean @@ -10,7 +10,7 @@ LL | const C: &bool = unsafe { std::mem::transmute(&S) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refs_to_static_fail_invalid.rs:24:5 + --> $DIR/const_refs_to_static_fail_invalid.rs:26:5 | LL | const C: &i8 = unsafe { &S }; | ^^^^^^^^^^^^ constructing invalid value: encountered reference to `extern` static in `const` @@ -21,7 +21,7 @@ LL | const C: &i8 = unsafe { &S }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refs_to_static_fail_invalid.rs:38:5 + --> $DIR/const_refs_to_static_fail_invalid.rs:40:5 | LL | const C: &i32 = unsafe { &S_MUT }; | ^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` diff --git a/tests/ui/consts/copy-intrinsic.rs b/tests/ui/consts/copy-intrinsic.rs index 5ae46787800..da483d671f9 100644 --- a/tests/ui/consts/copy-intrinsic.rs +++ b/tests/ui/consts/copy-intrinsic.rs @@ -32,7 +32,7 @@ const COPY_OOB_1: () = unsafe { copy_nonoverlapping(0x100 as *const i32, dangle, 0); // Non-zero-sized copy is not. copy_nonoverlapping(0x100 as *const i32, dangle, 1); //~ ERROR evaluation of constant value failed [E0080] - //~| NOTE got 0x100[noalloc] which is a dangling pointer + //~| NOTE which is a dangling pointer }; const COPY_OOB_2: () = unsafe { let x = 0i32; @@ -41,7 +41,7 @@ const COPY_OOB_2: () = unsafe { copy_nonoverlapping(dangle, 0x100 as *mut i32, 0); // Non-zero-sized copy is not. copy_nonoverlapping(dangle, 0x100 as *mut i32, 1); //~ ERROR evaluation of constant value failed [E0080] - //~| NOTE +0x28 which is at or beyond the end of the allocation + //~| NOTE is at or beyond the end of the allocation of size 4 bytes }; const COPY_SIZE_OVERFLOW: () = unsafe { diff --git a/tests/ui/consts/copy-intrinsic.stderr b/tests/ui/consts/copy-intrinsic.stderr index 41af3a2cd2d..13321b5703a 100644 --- a/tests/ui/consts/copy-intrinsic.stderr +++ b/tests/ui/consts/copy-intrinsic.stderr @@ -2,13 +2,13 @@ error[E0080]: evaluation of constant value failed --> $DIR/copy-intrinsic.rs:34:5 | LL | copy_nonoverlapping(0x100 as *const i32, dangle, 1); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got 0x100[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got 0x100[noalloc] which is a dangling pointer (it has no provenance) error[E0080]: evaluation of constant value failed --> $DIR/copy-intrinsic.rs:43:5 | LL | copy_nonoverlapping(dangle, 0x100 as *mut i32, 1); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0+0x28 which is at or beyond the end of the allocation of size 4 bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got ALLOC0+0x28 which is at or beyond the end of the allocation of size 4 bytes error[E0080]: evaluation of constant value failed --> $DIR/copy-intrinsic.rs:50:5 diff --git a/tests/ui/consts/extra-const-ub/detect-extra-ub.rs b/tests/ui/consts/extra-const-ub/detect-extra-ub.rs index 481f2ff88df..c3bd8301d5c 100644 --- a/tests/ui/consts/extra-const-ub/detect-extra-ub.rs +++ b/tests/ui/consts/extra-const-ub/detect-extra-ub.rs @@ -2,6 +2,7 @@ //@ [no_flag] check-pass //@ [with_flag] compile-flags: -Zextra-const-ub-checks #![feature(never_type)] +#![allow(unnecessary_transmutes)] use std::mem::transmute; use std::ptr::addr_of; diff --git a/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr b/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr index 0100aafb6b7..ea3b0e70b82 100644 --- a/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr +++ b/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr @@ -1,11 +1,11 @@ error[E0080]: evaluation of constant value failed - --> $DIR/detect-extra-ub.rs:29:20 + --> $DIR/detect-extra-ub.rs:30:20 | LL | let _x: bool = transmute(3u8); | ^^^^^^^^^^^^^^ constructing invalid value: encountered 0x03, but expected a boolean error[E0080]: evaluation of constant value failed - --> $DIR/detect-extra-ub.rs:35:21 + --> $DIR/detect-extra-ub.rs:36:21 | LL | let _x: usize = transmute(&3u8); | ^^^^^^^^^^^^^^^ constructing invalid value: encountered a pointer, but expected an integer @@ -14,7 +14,7 @@ LL | let _x: usize = transmute(&3u8); = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/detect-extra-ub.rs:41:28 + --> $DIR/detect-extra-ub.rs:42:28 | LL | let _x: PtrSizedEnum = transmute(&3u8); | ^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered a pointer, but expected an integer @@ -23,7 +23,7 @@ LL | let _x: PtrSizedEnum = transmute(&3u8); = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/detect-extra-ub.rs:48:30 + --> $DIR/detect-extra-ub.rs:49:30 | LL | let _x: (usize, usize) = transmute(x); | ^^^^^^^^^^^^ constructing invalid value at .0: encountered a pointer, but expected an integer @@ -32,19 +32,19 @@ LL | let _x: (usize, usize) = transmute(x); = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/detect-extra-ub.rs:54:20 + --> $DIR/detect-extra-ub.rs:55:20 | LL | let _x: &u32 = transmute(&[0u8; 4]); | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 4 byte alignment but found 1) error[E0080]: evaluation of constant value failed - --> $DIR/detect-extra-ub.rs:62:13 + --> $DIR/detect-extra-ub.rs:63:13 | LL | let v = *addr_of!(data).cast::<UninhDiscriminant>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant error[E0080]: evaluation of constant value failed - --> $DIR/detect-extra-ub.rs:82:16 + --> $DIR/detect-extra-ub.rs:83:16 | LL | let _val = *(&mem as *const Align as *const [*const u8; 2]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered a partial pointer or a mix of pointers @@ -53,7 +53,7 @@ LL | let _val = *(&mem as *const Align as *const [*const u8; 2]); = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: evaluation of constant value failed - --> $DIR/detect-extra-ub.rs:97:16 + --> $DIR/detect-extra-ub.rs:98:16 | LL | let _val = &*slice; | ^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object diff --git a/tests/ui/consts/issue-17718-const-bad-values.rs b/tests/ui/consts/issue-17718-const-bad-values.rs index c4de7b61f07..286972365d5 100644 --- a/tests/ui/consts/issue-17718-const-bad-values.rs +++ b/tests/ui/consts/issue-17718-const-bad-values.rs @@ -1,5 +1,6 @@ //@ normalize-stderr: "\(size: \d+, align: \d+\)" -> "(size: $$PTR, align: $$PTR)" //@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*A(LLOC)?[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP" +//@ dont-require-annotations: NOTE #![allow(static_mut_refs)] @@ -9,6 +10,6 @@ const C1: &'static mut [usize] = &mut []; static mut S: i32 = 3; const C2: &'static mut i32 = unsafe { &mut S }; //~^ ERROR: it is undefined behavior to use this value -//~| reference to mutable memory +//~| NOTE reference to mutable memory fn main() {} diff --git a/tests/ui/consts/issue-17718-const-bad-values.stderr b/tests/ui/consts/issue-17718-const-bad-values.stderr index 364fa7be5aa..102491e90ba 100644 --- a/tests/ui/consts/issue-17718-const-bad-values.stderr +++ b/tests/ui/consts/issue-17718-const-bad-values.stderr @@ -1,11 +1,11 @@ error[E0764]: mutable references are not allowed in the final value of constants - --> $DIR/issue-17718-const-bad-values.rs:6:34 + --> $DIR/issue-17718-const-bad-values.rs:7:34 | LL | const C1: &'static mut [usize] = &mut []; | ^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/issue-17718-const-bad-values.rs:10:1 + --> $DIR/issue-17718-const-bad-values.rs:11:1 | LL | const C2: &'static mut i32 = unsafe { &mut S }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` diff --git a/tests/ui/consts/issue-39974.rs b/tests/ui/consts/issue-39974.rs index 9cb180014b8..adc65d9be0d 100644 --- a/tests/ui/consts/issue-39974.rs +++ b/tests/ui/consts/issue-39974.rs @@ -1,10 +1,11 @@ const LENGTH: f64 = 2; //~^ ERROR mismatched types +//~| NOTE expected `f64`, found integer struct Thing { f: [[f64; 2]; LENGTH], //~^ ERROR mismatched types - //~| expected `usize`, found `f64` + //~| NOTE expected `usize`, found `f64` } fn main() { diff --git a/tests/ui/consts/issue-39974.stderr b/tests/ui/consts/issue-39974.stderr index d03f709b0ea..1c15debb119 100644 --- a/tests/ui/consts/issue-39974.stderr +++ b/tests/ui/consts/issue-39974.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-39974.rs:5:19 + --> $DIR/issue-39974.rs:6:19 | LL | f: [[f64; 2]; LENGTH], | ^^^^^^ expected `usize`, found `f64` diff --git a/tests/ui/consts/issue-69532.rs b/tests/ui/consts/issue-69532.rs index 285cfe7213b..43ab1d6cca7 100644 --- a/tests/ui/consts/issue-69532.rs +++ b/tests/ui/consts/issue-69532.rs @@ -1,8 +1,8 @@ //@ run-pass const fn make_nans() -> (f64, f64, f32, f32) { - let nan1: f64 = unsafe { std::mem::transmute(0x7FF0_0001_0000_0001u64) }; - let nan2: f64 = unsafe { std::mem::transmute(0x7FF0_0000_0000_0001u64) }; + let nan1 = f64::from_bits(0x7FF0_0001_0000_0001); + let nan2 = f64::from_bits(0x7FF0_0000_0000_0001); let nan1_32 = nan1 as f32; let nan2_32 = nan2 as f32; diff --git a/tests/ui/consts/miri_unleashed/assoc_const_2.rs b/tests/ui/consts/miri_unleashed/assoc_const_2.rs index 5490c096391..1d8ed2065a4 100644 --- a/tests/ui/consts/miri_unleashed/assoc_const_2.rs +++ b/tests/ui/consts/miri_unleashed/assoc_const_2.rs @@ -1,4 +1,5 @@ //@ build-fail +//@ dont-require-annotations: NOTE // a test demonstrating that const qualification cannot prevent monomorphization time errors @@ -24,5 +25,5 @@ impl Bar<String> for String {} fn main() { let x = <() as Bar<()>>::F; // this test only causes errors due to the line below, so post-monomorphization - let y = <String as Bar<String>>::F; //~ constant + let y = <String as Bar<String>>::F; //~ NOTE constant } diff --git a/tests/ui/consts/miri_unleashed/assoc_const_2.stderr b/tests/ui/consts/miri_unleashed/assoc_const_2.stderr index e923d95b755..5503f8e56f0 100644 --- a/tests/ui/consts/miri_unleashed/assoc_const_2.stderr +++ b/tests/ui/consts/miri_unleashed/assoc_const_2.stderr @@ -1,17 +1,17 @@ error[E0080]: evaluation of `<std::string::String as Bar<std::string::String>>::F` failed - --> $DIR/assoc_const_2.rs:10:20 + --> $DIR/assoc_const_2.rs:11:20 | LL | const F: u32 = 100 / U::X; | ^^^^^^^^^^ attempt to divide `100_u32` by zero note: erroneous constant encountered - --> $DIR/assoc_const_2.rs:27:13 + --> $DIR/assoc_const_2.rs:28:13 | LL | let y = <String as Bar<String>>::F; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/assoc_const_2.rs:27:13 + --> $DIR/assoc_const_2.rs:28:13 | LL | let y = <String as Bar<String>>::F; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static.rs b/tests/ui/consts/miri_unleashed/const_refers_to_static.rs index fdccc17ab49..c66aaec8c56 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static.rs +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static.rs @@ -1,6 +1,7 @@ //@ compile-flags: -Zunleash-the-miri-inside-of-you //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" //@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP" +//@ dont-require-annotations: NOTE use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; @@ -20,7 +21,7 @@ const READ_MUT: u32 = unsafe { MUTABLE }; //~ERROR evaluation of constant value // Evaluating this does not read anything mutable, but validation does, so this should error. const REF_INTERIOR_MUT: &usize = { //~ ERROR undefined behavior - //~| encountered reference to mutable memory + //~| NOTE encountered reference to mutable memory static FOO: AtomicUsize = AtomicUsize::new(0); unsafe { &*(&FOO as *const _ as *const usize) } }; diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr index f8e0606fbd7..f647107094d 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr @@ -1,23 +1,23 @@ error[E0080]: evaluation of constant value failed - --> $DIR/const_refers_to_static.rs:10:5 + --> $DIR/const_refers_to_static.rs:11:5 | LL | FOO.fetch_add(1, Ordering::Relaxed) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calling non-const function `AtomicUsize::fetch_add` error[E0080]: evaluation of constant value failed - --> $DIR/const_refers_to_static.rs:15:14 + --> $DIR/const_refers_to_static.rs:16:14 | LL | unsafe { *(&FOO as *const _ as *const usize) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses mutable global memory error[E0080]: evaluation of constant value failed - --> $DIR/const_refers_to_static.rs:19:32 + --> $DIR/const_refers_to_static.rs:20:32 | LL | const READ_MUT: u32 = unsafe { MUTABLE }; | ^^^^^^^ constant accesses mutable global memory error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static.rs:22:1 + --> $DIR/const_refers_to_static.rs:23:1 | LL | const REF_INTERIOR_MUT: &usize = { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` @@ -30,7 +30,7 @@ LL | const REF_INTERIOR_MUT: &usize = { warning: skipping const checks | help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static.rs:10:5 + --> $DIR/const_refers_to_static.rs:11:5 | LL | FOO.fetch_add(1, Ordering::Relaxed) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs index b33ebfb06be..86d23d44bff 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs @@ -2,6 +2,8 @@ //@ aux-build:static_cross_crate.rs //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" //@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP" +//@ dont-require-annotations: NOTE + #![feature(half_open_range_patterns_in_slices)] #![allow(static_mut_refs)] @@ -10,25 +12,25 @@ extern crate static_cross_crate; // Sneaky: reference to a mutable static. // Allowing this would be a disaster for pattern matching, we could violate exhaustiveness checking! const SLICE_MUT: &[u8; 1] = { //~ ERROR undefined behavior - //~| encountered reference to mutable memory + //~| NOTE encountered reference to mutable memory unsafe { &static_cross_crate::ZERO } }; const U8_MUT: &u8 = { //~ ERROR undefined behavior - //~| encountered reference to mutable memory + //~| NOTE encountered reference to mutable memory unsafe { &static_cross_crate::ZERO[0] } }; // Also test indirection that reads from other static. const U8_MUT2: &u8 = { //~ ERROR undefined behavior - //~| encountered reference to mutable memory + //~| NOTE encountered reference to mutable memory unsafe { &(*static_cross_crate::ZERO_REF)[0] } }; const U8_MUT3: &u8 = { unsafe { match static_cross_crate::OPT_ZERO { //~^ ERROR evaluation of constant value failed - //~| constant accesses mutable global memory + //~| NOTE constant accesses mutable global memory Some(ref u) => u, None => panic!(), } diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr index 8f8271cce38..4e5052ed470 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static_cross_crate.rs:12:1 + --> $DIR/const_refers_to_static_cross_crate.rs:14:1 | LL | const SLICE_MUT: &[u8; 1] = { | ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` @@ -10,7 +10,7 @@ LL | const SLICE_MUT: &[u8; 1] = { } error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static_cross_crate.rs:17:1 + --> $DIR/const_refers_to_static_cross_crate.rs:19:1 | LL | const U8_MUT: &u8 = { | ^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` @@ -21,7 +21,7 @@ LL | const U8_MUT: &u8 = { } error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static_cross_crate.rs:23:1 + --> $DIR/const_refers_to_static_cross_crate.rs:25:1 | LL | const U8_MUT2: &u8 = { | ^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` @@ -32,7 +32,7 @@ LL | const U8_MUT2: &u8 = { } error[E0080]: evaluation of constant value failed - --> $DIR/const_refers_to_static_cross_crate.rs:29:15 + --> $DIR/const_refers_to_static_cross_crate.rs:31:15 | LL | match static_cross_crate::OPT_ZERO { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses mutable global memory diff --git a/tests/ui/consts/miri_unleashed/mutable_references.rs b/tests/ui/consts/miri_unleashed/mutable_references.rs index e7fc5699236..02a35487e8a 100644 --- a/tests/ui/consts/miri_unleashed/mutable_references.rs +++ b/tests/ui/consts/miri_unleashed/mutable_references.rs @@ -1,6 +1,7 @@ //@ compile-flags: -Zunleash-the-miri-inside-of-you //@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" //@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP" +//@ dont-require-annotations: NOTE #![allow(static_mut_refs)] use std::cell::UnsafeCell; @@ -11,10 +12,10 @@ use std::sync::atomic::*; // This requires walking nested statics. static FOO: &&mut u32 = &&mut 42; //~^ ERROR it is undefined behavior to use this value -//~| pointing to read-only memory +//~| NOTE pointing to read-only memory static OH_YES: &mut i32 = &mut 42; //~^ ERROR it is undefined behavior to use this value -//~| pointing to read-only memory +//~| NOTE pointing to read-only memory static BAR: &mut () = &mut (); //~^ ERROR encountered mutable pointer in final value of static @@ -25,11 +26,11 @@ static BOO: &mut Foo<()> = &mut Foo(()); const BLUNT: &mut i32 = &mut 42; //~^ ERROR: it is undefined behavior to use this value -//~| pointing to read-only memory +//~| NOTE pointing to read-only memory const SUBTLE: &mut i32 = unsafe { //~^ ERROR: it is undefined behavior to use this value - //~| constructing invalid value: encountered reference to mutable memory in `const` + //~| NOTE constructing invalid value: encountered reference to mutable memory in `const` static mut STATIC: i32 = 0; &mut STATIC }; @@ -42,13 +43,13 @@ struct Meh { unsafe impl Sync for Meh {} static MEH: Meh = Meh { x: &UnsafeCell::new(42) }; //~^ ERROR it is undefined behavior to use this value -//~| `UnsafeCell` in read-only memory +//~| NOTE `UnsafeCell` in read-only memory // Same with a const: // the following will never be ok! no interior mut behind consts, because // all allocs interned here will be marked immutable. const MUH: Meh = Meh { //~^ ERROR it is undefined behavior to use this value - //~| `UnsafeCell` in read-only memory + //~| NOTE `UnsafeCell` in read-only memory x: &UnsafeCell::new(42), }; @@ -60,30 +61,30 @@ unsafe impl Sync for Synced {} // Make sure we also catch this behind a type-erased `dyn Trait` reference. const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; //~^ ERROR: it is undefined behavior to use this value -//~| `UnsafeCell` in read-only memory +//~| NOTE `UnsafeCell` in read-only memory // # Check for mutable references to read-only memory static READONLY: i32 = 0; static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) }; //~^ ERROR: it is undefined behavior to use this value -//~| pointing to read-only memory +//~| NOTE pointing to read-only memory // # Check for consts pointing to mutable memory static mut MUTABLE: i32 = 42; -const POINTS_TO_MUTABLE: &i32 = unsafe { &MUTABLE }; //~ERROR: undefined behavior -//~| encountered reference to mutable memory +const POINTS_TO_MUTABLE: &i32 = unsafe { &MUTABLE }; //~ ERROR undefined behavior +//~| NOTE encountered reference to mutable memory static mut MUTABLE_REF: &mut i32 = &mut 42; const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF }; -//~^ ERROR: evaluation of constant value failed -//~| accesses mutable global memory +//~^ ERROR evaluation of constant value failed +//~| NOTE accesses mutable global memory const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _; -//~^ ERROR: mutable pointer in final value +//~^ ERROR mutable pointer in final value const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _; -//~^ ERROR: mutable pointer in final value +//~^ ERROR mutable pointer in final value // This does *not* error since it uses a shared reference, and we have to ignore // those. See <https://github.com/rust-lang/rust/pull/128543>. diff --git a/tests/ui/consts/miri_unleashed/mutable_references.stderr b/tests/ui/consts/miri_unleashed/mutable_references.stderr index ce5cedac8bc..3049be80adc 100644 --- a/tests/ui/consts/miri_unleashed/mutable_references.stderr +++ b/tests/ui/consts/miri_unleashed/mutable_references.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references.rs:12:1 + --> $DIR/mutable_references.rs:13:1 | LL | static FOO: &&mut u32 = &&mut 42; | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered mutable reference or box pointing to read-only memory @@ -10,7 +10,7 @@ LL | static FOO: &&mut u32 = &&mut 42; } error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references.rs:15:1 + --> $DIR/mutable_references.rs:16:1 | LL | static OH_YES: &mut i32 = &mut 42; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory @@ -21,19 +21,19 @@ LL | static OH_YES: &mut i32 = &mut 42; } error: encountered mutable pointer in final value of static - --> $DIR/mutable_references.rs:18:1 + --> $DIR/mutable_references.rs:19:1 | LL | static BAR: &mut () = &mut (); | ^^^^^^^^^^^^^^^^^^^ error: encountered mutable pointer in final value of static - --> $DIR/mutable_references.rs:23:1 + --> $DIR/mutable_references.rs:24:1 | LL | static BOO: &mut Foo<()> = &mut Foo(()); | ^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references.rs:26:1 + --> $DIR/mutable_references.rs:27:1 | LL | const BLUNT: &mut i32 = &mut 42; | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory @@ -44,7 +44,7 @@ LL | const BLUNT: &mut i32 = &mut 42; } error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references.rs:30:1 + --> $DIR/mutable_references.rs:31:1 | LL | const SUBTLE: &mut i32 = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` @@ -55,7 +55,7 @@ LL | const SUBTLE: &mut i32 = unsafe { } error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references.rs:43:1 + --> $DIR/mutable_references.rs:44:1 | LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) }; | ^^^^^^^^^^^^^^^ constructing invalid value at .x.<deref>: encountered `UnsafeCell` in read-only memory @@ -66,7 +66,7 @@ LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references.rs:49:1 + --> $DIR/mutable_references.rs:50:1 | LL | const MUH: Meh = Meh { | ^^^^^^^^^^^^^^ constructing invalid value at .x.<deref>: encountered `UnsafeCell` in read-only memory @@ -77,7 +77,7 @@ LL | const MUH: Meh = Meh { } error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references.rs:61:1 + --> $DIR/mutable_references.rs:62:1 | LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.<dyn-downcast>.x: encountered `UnsafeCell` in read-only memory @@ -88,7 +88,7 @@ LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references.rs:68:1 + --> $DIR/mutable_references.rs:69:1 | LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory @@ -99,7 +99,7 @@ LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const } error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references.rs:75:1 + --> $DIR/mutable_references.rs:76:1 | LL | const POINTS_TO_MUTABLE: &i32 = unsafe { &MUTABLE }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` @@ -110,37 +110,37 @@ LL | const POINTS_TO_MUTABLE: &i32 = unsafe { &MUTABLE }; } error[E0080]: evaluation of constant value failed - --> $DIR/mutable_references.rs:78:43 + --> $DIR/mutable_references.rs:79:43 | LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF }; | ^^^^^^^^^^^^^ constant accesses mutable global memory error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references.rs:82:1 + --> $DIR/mutable_references.rs:83:1 | LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references.rs:85:1 + --> $DIR/mutable_references.rs:86:1 | LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references.rs:105:1 + --> $DIR/mutable_references.rs:106:1 | LL | const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x: &mut 42 as *mut _ as *const _ }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references.rs:108:1 + --> $DIR/mutable_references.rs:109:1 | LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0594]: cannot assign to `*OH_YES`, as `OH_YES` is an immutable static item - --> $DIR/mutable_references.rs:115:5 + --> $DIR/mutable_references.rs:116:5 | LL | *OH_YES = 99; | ^^^^^^^^^^^^ cannot assign @@ -148,72 +148,72 @@ LL | *OH_YES = 99; warning: skipping const checks | help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:12:26 + --> $DIR/mutable_references.rs:13:26 | LL | static FOO: &&mut u32 = &&mut 42; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:15:27 + --> $DIR/mutable_references.rs:16:27 | LL | static OH_YES: &mut i32 = &mut 42; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:18:23 + --> $DIR/mutable_references.rs:19:23 | LL | static BAR: &mut () = &mut (); | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:23:28 + --> $DIR/mutable_references.rs:24:28 | LL | static BOO: &mut Foo<()> = &mut Foo(()); | ^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:26:25 + --> $DIR/mutable_references.rs:27:25 | LL | const BLUNT: &mut i32 = &mut 42; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:43:28 + --> $DIR/mutable_references.rs:44:28 | LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) }; | ^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:52:8 + --> $DIR/mutable_references.rs:53:8 | LL | x: &UnsafeCell::new(42), | ^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:61:27 + --> $DIR/mutable_references.rs:62:27 | LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:82:45 + --> $DIR/mutable_references.rs:83:45 | LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:85:46 + --> $DIR/mutable_references.rs:86:46 | LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:90:47 + --> $DIR/mutable_references.rs:91:47 | LL | const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _; | ^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:102:51 + --> $DIR/mutable_references.rs:103:51 | LL | const RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) }; | ^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:105:49 + --> $DIR/mutable_references.rs:106:49 | LL | const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x: &mut 42 as *mut _ as *const _ }; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:108:51 + --> $DIR/mutable_references.rs:109:51 | LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 }; | ^^^^^^ diff --git a/tests/ui/consts/offset_from_ub.rs b/tests/ui/consts/offset_from_ub.rs index 53d9c7a39da..47511c0343d 100644 --- a/tests/ui/consts/offset_from_ub.rs +++ b/tests/ui/consts/offset_from_ub.rs @@ -1,4 +1,6 @@ //@ normalize-stderr: "\d+ bytes" -> "$$BYTES bytes" +//@ dont-require-annotations: NOTE + #![feature(core_intrinsics)] use std::intrinsics::{ptr_offset_from, ptr_offset_from_unsigned}; @@ -16,7 +18,7 @@ pub const DIFFERENT_ALLOC: usize = { let uninit2 = std::mem::MaybeUninit::<Struct>::uninit(); let field_ptr: *const Struct = &uninit2 as *const _ as *const Struct; let offset = unsafe { ptr_offset_from(field_ptr, base_ptr) }; //~ERROR evaluation of constant value failed - //~| not both derived from the same allocation + //~| NOTE not both derived from the same allocation offset as usize }; @@ -29,14 +31,14 @@ pub const NOT_MULTIPLE_OF_SIZE: isize = { let base_ptr = data.as_ptr(); let field_ptr = &data[1] as *const u8 as *const u16; unsafe { ptr_offset_from(field_ptr, base_ptr as *const u16) } //~ERROR evaluation of constant value failed - //~| 1_isize cannot be divided by 2_isize without remainder + //~| NOTE 1_isize cannot be divided by 2_isize without remainder }; pub const DIFFERENT_INT: isize = { // offset_from with two different integers: like DIFFERENT_ALLOC let ptr1 = 8 as *const u8; let ptr2 = 16 as *const u8; unsafe { ptr_offset_from(ptr2, ptr1) } //~ERROR evaluation of constant value failed - //~| not both derived from the same allocation + //~| NOTE not both derived from the same allocation }; const OUT_OF_BOUNDS_1: isize = { @@ -45,7 +47,7 @@ const OUT_OF_BOUNDS_1: isize = { let end_ptr = (start_ptr).wrapping_add(length); // First ptr is out of bounds unsafe { ptr_offset_from(end_ptr, start_ptr) } //~ERROR evaluation of constant value failed - //~| the memory range between them is not in-bounds of an allocation + //~| NOTE the memory range between them is not in-bounds of an allocation }; const OUT_OF_BOUNDS_2: isize = { @@ -54,7 +56,7 @@ const OUT_OF_BOUNDS_2: isize = { let end_ptr = (start_ptr).wrapping_add(length); // Second ptr is out of bounds unsafe { ptr_offset_from(start_ptr, end_ptr) } //~ERROR evaluation of constant value failed - //~| the memory range between them is not in-bounds of an allocation + //~| NOTE the memory range between them is not in-bounds of an allocation }; pub const DIFFERENT_ALLOC_UNSIGNED: usize = { @@ -63,20 +65,20 @@ pub const DIFFERENT_ALLOC_UNSIGNED: usize = { let uninit2 = std::mem::MaybeUninit::<Struct>::uninit(); let field_ptr: *const Struct = &uninit2 as *const _ as *const Struct; unsafe { ptr_offset_from_unsigned(field_ptr, base_ptr) } //~ERROR evaluation of constant value failed - //~| not both derived from the same allocation + //~| NOTE not both derived from the same allocation }; pub const TOO_FAR_APART1: isize = { let ptr1 = &0u8 as *const u8; let ptr2 = ptr1.wrapping_add(isize::MAX as usize + 42); unsafe { ptr_offset_from(ptr2, ptr1) } //~ERROR evaluation of constant value failed - //~| too far ahead + //~| NOTE too far ahead }; pub const TOO_FAR_APART2: isize = { let ptr1 = &0u8 as *const u8; let ptr2 = ptr1.wrapping_add(isize::MAX as usize + 42); unsafe { ptr_offset_from(ptr1, ptr2) } //~ERROR evaluation of constant value failed - //~| too far before + //~| NOTE too far before }; pub const TOO_FAR_APART3: isize = { let ptr1 = &0u8 as *const u8; @@ -84,21 +86,21 @@ pub const TOO_FAR_APART3: isize = { // The result of this would be `isize::MIN`, which *does* fit in an `isize`, but its // absolute value does not. (Also anyway there cannot be an allocation of that size.) unsafe { ptr_offset_from(ptr1, ptr2) } //~ERROR evaluation of constant value failed - //~| too far before + //~| NOTE too far before }; const WRONG_ORDER_UNSIGNED: usize = { let a = ['a', 'b', 'c']; let p = a.as_ptr(); unsafe { ptr_offset_from_unsigned(p, p.add(2) ) } //~ERROR evaluation of constant value failed - //~| first pointer has smaller offset than second: 0 < 8 + //~| NOTE first pointer has smaller offset than second: 0 < 8 }; pub const TOO_FAR_APART_UNSIGNED: usize = { let ptr1 = &0u8 as *const u8; let ptr2 = ptr1.wrapping_add(isize::MAX as usize + 42); // This would fit into a `usize` but we still don't allow it. unsafe { ptr_offset_from_unsigned(ptr2, ptr1) } //~ERROR evaluation of constant value failed - //~| too far ahead + //~| NOTE too far ahead }; // These do NOT complain that pointers are too far apart; they pass that check (to then fail the diff --git a/tests/ui/consts/offset_from_ub.stderr b/tests/ui/consts/offset_from_ub.stderr index 08e42c9f30b..5bfb9a1170c 100644 --- a/tests/ui/consts/offset_from_ub.stderr +++ b/tests/ui/consts/offset_from_ub.stderr @@ -1,11 +1,11 @@ error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:18:27 + --> $DIR/offset_from_ub.rs:20:27 | LL | let offset = unsafe { ptr_offset_from(field_ptr, base_ptr) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on two different pointers that are not both derived from the same allocation error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:24:14 + --> $DIR/offset_from_ub.rs:26:14 | LL | unsafe { (42 as *const u8).offset_from(&5u8) as usize } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on two different pointers that are not both derived from the same allocation @@ -14,67 +14,67 @@ note: inside `std::ptr::const_ptr::<impl *const u8>::offset_from` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:31:14 + --> $DIR/offset_from_ub.rs:33:14 | LL | unsafe { ptr_offset_from(field_ptr, base_ptr as *const u16) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exact_div: 1_isize cannot be divided by 2_isize without remainder error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:38:14 + --> $DIR/offset_from_ub.rs:40:14 | LL | unsafe { ptr_offset_from(ptr2, ptr1) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on two different pointers that are not both derived from the same allocation error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:47:14 + --> $DIR/offset_from_ub.rs:49:14 | LL | unsafe { ptr_offset_from(end_ptr, start_ptr) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on two different pointers where the memory range between them is not in-bounds of an allocation error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:56:14 + --> $DIR/offset_from_ub.rs:58:14 | LL | unsafe { ptr_offset_from(start_ptr, end_ptr) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on two different pointers where the memory range between them is not in-bounds of an allocation error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:65:14 + --> $DIR/offset_from_ub.rs:67:14 | LL | unsafe { ptr_offset_from_unsigned(field_ptr, base_ptr) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:72:14 + --> $DIR/offset_from_ub.rs:74:14 | LL | unsafe { ptr_offset_from(ptr2, ptr1) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called when first pointer is too far ahead of second error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:78:14 + --> $DIR/offset_from_ub.rs:80:14 | LL | unsafe { ptr_offset_from(ptr1, ptr2) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called when first pointer is too far before second error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:86:14 + --> $DIR/offset_from_ub.rs:88:14 | LL | unsafe { ptr_offset_from(ptr1, ptr2) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called when first pointer is too far before second error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:93:14 + --> $DIR/offset_from_ub.rs:95:14 | LL | unsafe { ptr_offset_from_unsigned(p, p.add(2) ) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called when first pointer has smaller offset than second: 0 < 8 error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:100:14 + --> $DIR/offset_from_ub.rs:102:14 | LL | unsafe { ptr_offset_from_unsigned(ptr2, ptr1) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called when first pointer is too far ahead of second error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:109:14 + --> $DIR/offset_from_ub.rs:111:14 | LL | unsafe { ptr2.offset_from(ptr1) } | ^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on two different pointers that are not both derived from the same allocation @@ -83,7 +83,7 @@ note: inside `std::ptr::const_ptr::<impl *const u8>::offset_from` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:115:14 + --> $DIR/offset_from_ub.rs:117:14 | LL | unsafe { ptr1.offset_from(ptr2.wrapping_offset(1)) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called when first pointer is too far before second diff --git a/tests/ui/consts/offset_ub.stderr b/tests/ui/consts/offset_ub.stderr index a247ad25465..699b63dfd66 100644 --- a/tests/ui/consts/offset_ub.stderr +++ b/tests/ui/consts/offset_ub.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/offset_ub.rs:8:46 | LL | pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to the end of 1 byte of memory, but got ALLOC0 which is at the beginning of the allocation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got ALLOC0 which is at the beginning of the allocation | note: inside `std::ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -11,7 +11,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/offset_ub.rs:9:43 | LL | pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got ALLOC1 which is only 1 byte from the end of the allocation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got ALLOC1 which is only 1 byte from the end of the allocation | note: inside `std::ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -20,7 +20,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/offset_ub.rs:10:45 | LL | pub const AFTER_ARRAY: *const u8 = unsafe { [0u8; 100].as_ptr().offset(101) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got ALLOC2 which is only $BYTES bytes from the end of the allocation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got ALLOC2 which is only $BYTES bytes from the end of the allocation | note: inside `std::ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -47,7 +47,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/offset_ub.rs:14:56 | LL | pub const OVERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (usize::MAX as *const u8).offset(2) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got 0xf..f[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got 0xf..f[noalloc] which is a dangling pointer (it has no provenance) | note: inside `std::ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -56,7 +56,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/offset_ub.rs:15:57 | LL | pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).offset(-2) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to the end of $BYTES bytes of memory, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) | note: inside `std::ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -65,7 +65,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/offset_ub.rs:16:49 | LL | pub const NEGATIVE_OFFSET: *const u8 = unsafe { [0u8; 1].as_ptr().wrapping_offset(-2).offset(-2) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to the end of $BYTES bytes of memory, but got ALLOC3-0x2 which points to before the beginning of the allocation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got ALLOC3-0x2 which is only $BYTES bytes from the beginning of the allocation | note: inside `std::ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -74,7 +74,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/offset_ub.rs:18:50 | LL | pub const ZERO_SIZED_ALLOC: *const u8 = unsafe { [0u8; 0].as_ptr().offset(1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to 1 byte of memory, but got ALLOC4 which is at or beyond the end of the allocation of size $BYTES bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by 1 byte, but got ALLOC4 which is at or beyond the end of the allocation of size $BYTES bytes | note: inside `std::ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -83,7 +83,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/offset_ub.rs:19:42 | LL | pub const DANGLING: *const u8 = unsafe { ptr::NonNull::<u8>::dangling().as_ptr().offset(4) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) | note: inside `std::ptr::mut_ptr::<impl *mut u8>::offset` --> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL @@ -92,7 +92,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/offset_ub.rs:22:47 | LL | pub const UNDERFLOW_ABS: *const u8 = unsafe { (usize::MAX as *const u8).offset(isize::MIN) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to the end of $BYTES bytes of memory, but got 0xf..f[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got 0xf..f[noalloc] which is a dangling pointer (it has no provenance) | note: inside `std::ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL diff --git a/tests/ui/consts/required-consts/interpret-in-const-called-fn.noopt.stderr b/tests/ui/consts/required-consts/interpret-in-const-called-fn.noopt.stderr index 9184df472c4..f98e2c17202 100644 --- a/tests/ui/consts/required-consts/interpret-in-const-called-fn.noopt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-const-called-fn.noopt.stderr @@ -5,7 +5,7 @@ LL | const C: () = panic!(); | ^^^^^^^^ evaluation panicked: explicit panic note: erroneous constant encountered - --> $DIR/interpret-in-const-called-fn.rs:17:9 + --> $DIR/interpret-in-const-called-fn.rs:18:9 | LL | Fail::<T>::C; | ^^^^^^^^^^^^ diff --git a/tests/ui/consts/required-consts/interpret-in-const-called-fn.opt.stderr b/tests/ui/consts/required-consts/interpret-in-const-called-fn.opt.stderr index 9184df472c4..f98e2c17202 100644 --- a/tests/ui/consts/required-consts/interpret-in-const-called-fn.opt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-const-called-fn.opt.stderr @@ -5,7 +5,7 @@ LL | const C: () = panic!(); | ^^^^^^^^ evaluation panicked: explicit panic note: erroneous constant encountered - --> $DIR/interpret-in-const-called-fn.rs:17:9 + --> $DIR/interpret-in-const-called-fn.rs:18:9 | LL | Fail::<T>::C; | ^^^^^^^^^^^^ diff --git a/tests/ui/consts/required-consts/interpret-in-const-called-fn.rs b/tests/ui/consts/required-consts/interpret-in-const-called-fn.rs index f2e83f56f37..1ed6853f0a4 100644 --- a/tests/ui/consts/required-consts/interpret-in-const-called-fn.rs +++ b/tests/ui/consts/required-consts/interpret-in-const-called-fn.rs @@ -6,6 +6,7 @@ struct Fail<T>(T); impl<T> Fail<T> { const C: () = panic!(); //~ERROR evaluation of `Fail::<i32>::C` failed + //~| NOTE in this expansion of panic! } #[inline(never)] @@ -14,7 +15,7 @@ const fn no_codegen<T>() { // This bad constant is only used in dead code in a no-codegen function... and yet we still // must make sure that the build fails. // This relies on const-eval evaluating all `required_consts` of `const fn`. - Fail::<T>::C; //~ constant + Fail::<T>::C; //~ NOTE constant } } diff --git a/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr b/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr index 2bd0b92d4c2..f70e262ac4c 100644 --- a/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr @@ -1,11 +1,11 @@ error[E0080]: evaluation of constant value failed - --> $DIR/interpret-in-promoted.rs:13:28 + --> $DIR/interpret-in-promoted.rs:15:28 | LL | let _x: &'static () = &ub(); | ^^^^ entering unreachable code | note: inside `ub` - --> $DIR/interpret-in-promoted.rs:7:5 + --> $DIR/interpret-in-promoted.rs:9:5 | LL | std::hint::unreachable_unchecked(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ note: inside `unreachable_unchecked` --> $SRC_DIR/core/src/hint.rs:LL:COL note: erroneous constant encountered - --> $DIR/interpret-in-promoted.rs:13:27 + --> $DIR/interpret-in-promoted.rs:15:27 | LL | let _x: &'static () = &ub(); | ^^^^^ diff --git a/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr b/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr index 2bd0b92d4c2..f70e262ac4c 100644 --- a/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr @@ -1,11 +1,11 @@ error[E0080]: evaluation of constant value failed - --> $DIR/interpret-in-promoted.rs:13:28 + --> $DIR/interpret-in-promoted.rs:15:28 | LL | let _x: &'static () = &ub(); | ^^^^ entering unreachable code | note: inside `ub` - --> $DIR/interpret-in-promoted.rs:7:5 + --> $DIR/interpret-in-promoted.rs:9:5 | LL | std::hint::unreachable_unchecked(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ note: inside `unreachable_unchecked` --> $SRC_DIR/core/src/hint.rs:LL:COL note: erroneous constant encountered - --> $DIR/interpret-in-promoted.rs:13:27 + --> $DIR/interpret-in-promoted.rs:15:27 | LL | let _x: &'static () = &ub(); | ^^^^^ diff --git a/tests/ui/consts/required-consts/interpret-in-promoted.rs b/tests/ui/consts/required-consts/interpret-in-promoted.rs index 2c7b3375054..85d2ea3418c 100644 --- a/tests/ui/consts/required-consts/interpret-in-promoted.rs +++ b/tests/ui/consts/required-consts/interpret-in-promoted.rs @@ -1,10 +1,12 @@ //@revisions: noopt opt //@[noopt] compile-flags: -Copt-level=0 //@[opt] compile-flags: -O +//@ dont-require-annotations: NOTE + //! Make sure we evaluate const fn calls even if they get promoted and their result ignored. const unsafe fn ub() { - std::hint::unreachable_unchecked(); //~ inside `ub` + std::hint::unreachable_unchecked(); //~ NOTE inside `ub` } pub const FOO: () = unsafe { diff --git a/tests/ui/consts/required-consts/interpret-in-static.noopt.stderr b/tests/ui/consts/required-consts/interpret-in-static.noopt.stderr index aa778deb542..28daf265af4 100644 --- a/tests/ui/consts/required-consts/interpret-in-static.noopt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-static.noopt.stderr @@ -5,7 +5,7 @@ LL | const C: () = panic!(); | ^^^^^^^^ evaluation panicked: explicit panic note: erroneous constant encountered - --> $DIR/interpret-in-static.rs:16:9 + --> $DIR/interpret-in-static.rs:17:9 | LL | Fail::<i32>::C; | ^^^^^^^^^^^^^^ diff --git a/tests/ui/consts/required-consts/interpret-in-static.opt.stderr b/tests/ui/consts/required-consts/interpret-in-static.opt.stderr index aa778deb542..28daf265af4 100644 --- a/tests/ui/consts/required-consts/interpret-in-static.opt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-static.opt.stderr @@ -5,7 +5,7 @@ LL | const C: () = panic!(); | ^^^^^^^^ evaluation panicked: explicit panic note: erroneous constant encountered - --> $DIR/interpret-in-static.rs:16:9 + --> $DIR/interpret-in-static.rs:17:9 | LL | Fail::<i32>::C; | ^^^^^^^^^^^^^^ diff --git a/tests/ui/consts/required-consts/interpret-in-static.rs b/tests/ui/consts/required-consts/interpret-in-static.rs index 8bacd030440..7ddf15f9121 100644 --- a/tests/ui/consts/required-consts/interpret-in-static.rs +++ b/tests/ui/consts/required-consts/interpret-in-static.rs @@ -6,6 +6,7 @@ struct Fail<T>(T); impl<T> Fail<T> { const C: () = panic!(); //~ERROR evaluation of `Fail::<i32>::C` failed + //~| NOTE in this expansion of panic! } pub static FOO: () = { @@ -13,7 +14,7 @@ pub static FOO: () = { // This bad constant is only used in dead code in a static initializer... and yet we still // must make sure that the build fails. // This relies on const-eval evaluating all `required_consts` of the `static` MIR body. - Fail::<i32>::C; //~ constant + Fail::<i32>::C; //~ NOTE constant } }; diff --git a/tests/ui/consts/uninhabited-const-issue-61744.rs b/tests/ui/consts/uninhabited-const-issue-61744.rs index 743aaf58ef5..802d422888b 100644 --- a/tests/ui/consts/uninhabited-const-issue-61744.rs +++ b/tests/ui/consts/uninhabited-const-issue-61744.rs @@ -1,11 +1,12 @@ //@ build-fail +//@ dont-require-annotations: NOTE pub const unsafe fn fake_type<T>() -> T { - hint_unreachable() //~ inside + hint_unreachable() //~ NOTE inside } pub const unsafe fn hint_unreachable() -> ! { - fake_type() //~ inside + fake_type() //~ NOTE inside } trait Const { diff --git a/tests/ui/consts/uninhabited-const-issue-61744.stderr b/tests/ui/consts/uninhabited-const-issue-61744.stderr index dd175b92593..d0e90f9a423 100644 --- a/tests/ui/consts/uninhabited-const-issue-61744.stderr +++ b/tests/ui/consts/uninhabited-const-issue-61744.stderr @@ -1,641 +1,641 @@ error[E0080]: evaluation of `fake_type::<!>` failed - --> $DIR/uninhabited-const-issue-61744.rs:12:36 + --> $DIR/uninhabited-const-issue-61744.rs:13:36 | LL | const CONSTANT: i32 = unsafe { fake_type() }; | ^^^^^^^^^^^ reached the configured maximum number of stack frames | note: inside `fake_type::<i32>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:9:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::<!>` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:5:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ the failure occurred here diff --git a/tests/ui/copy-a-resource.rs b/tests/ui/copy-a-resource.rs deleted file mode 100644 index 55f2dd4ee6d..00000000000 --- a/tests/ui/copy-a-resource.rs +++ /dev/null @@ -1,21 +0,0 @@ -#[derive(Debug)] -struct Foo { - i: isize, -} - -impl Drop for Foo { - fn drop(&mut self) {} -} - -fn foo(i:isize) -> Foo { - Foo { - i: i - } -} - -fn main() { - let x = foo(10); - let _y = x.clone(); - //~^ ERROR no method named `clone` found - println!("{:?}", x); -} diff --git a/tests/ui/copy-a-resource.stderr b/tests/ui/copy-a-resource.stderr deleted file mode 100644 index ff1e28bf961..00000000000 --- a/tests/ui/copy-a-resource.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0599]: no method named `clone` found for struct `Foo` in the current scope - --> $DIR/copy-a-resource.rs:18:16 - | -LL | struct Foo { - | ---------- method `clone` not found for this struct -... -LL | let _y = x.clone(); - | ^^^^^ method not found in `Foo` - | - = help: items from traits can only be used if the trait is implemented and in scope - = note: the following trait defines an item `clone`, perhaps you need to implement it: - candidate #1: `Clone` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/coroutine/clone-rpit.next.stderr b/tests/ui/coroutine/clone-rpit.next.stderr deleted file mode 100644 index 213e9e908f5..00000000000 --- a/tests/ui/coroutine/clone-rpit.next.stderr +++ /dev/null @@ -1,47 +0,0 @@ -error[E0391]: cycle detected when type-checking `foo` - --> $DIR/clone-rpit.rs:13:1 - | -LL | pub fn foo<'a, 'b>() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: ...which requires coroutine witness types for `foo::{closure#0}`... - --> $DIR/clone-rpit.rs:15:5 - | -LL | move |_: ()| { - | ^^^^^^^^^^^^ -note: ...which requires promoting constants in MIR for `foo::{closure#0}`... - --> $DIR/clone-rpit.rs:15:5 - | -LL | move |_: ()| { - | ^^^^^^^^^^^^ -note: ...which requires checking if `foo::{closure#0}` contains FFI-unwind calls... - --> $DIR/clone-rpit.rs:15:5 - | -LL | move |_: ()| { - | ^^^^^^^^^^^^ -note: ...which requires building MIR for `foo::{closure#0}`... - --> $DIR/clone-rpit.rs:15:5 - | -LL | move |_: ()| { - | ^^^^^^^^^^^^ -note: ...which requires match-checking `foo::{closure#0}`... - --> $DIR/clone-rpit.rs:15:5 - | -LL | move |_: ()| { - | ^^^^^^^^^^^^ -note: ...which requires type-checking `foo::{closure#0}`... - --> $DIR/clone-rpit.rs:15:5 - | -LL | move |_: ()| { - | ^^^^^^^^^^^^ - = note: ...which again requires type-checking `foo`, completing the cycle -note: cycle used when match-checking `foo` - --> $DIR/clone-rpit.rs:13:1 - | -LL | pub fn foo<'a, 'b>() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/coroutine/clone-rpit.rs b/tests/ui/coroutine/clone-rpit.rs index 66569b4f427..3882564639b 100644 --- a/tests/ui/coroutine/clone-rpit.rs +++ b/tests/ui/coroutine/clone-rpit.rs @@ -1,8 +1,7 @@ //@ revisions: current next //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver -//@[current] check-pass -//@[next] known-bug: trait-system-refactor-initiative#82 +//@ check-pass #![feature(coroutines, coroutine_trait, coroutine_clone)] diff --git a/tests/ui/coroutine/dont-drop-stalled-generators.rs b/tests/ui/coroutine/dont-drop-stalled-generators.rs new file mode 100644 index 00000000000..8e0c45a9773 --- /dev/null +++ b/tests/ui/coroutine/dont-drop-stalled-generators.rs @@ -0,0 +1,25 @@ +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@ check-pass +//@ edition: 2024 + +// This test previously used the `is_copy_raw` query during +// HIR typeck, dropping the list of generators from the current +// body. This then caused a query cycle. + +struct W<T>(*const T); + +impl<T: Send> Clone for W<T> { + fn clone(&self) -> Self { W(self.0) } +} + +impl<T: Send> Copy for W<T> {} + +fn main() { + let coro = async {}; + let x = W(&raw const coro); + let c = || { + let x = x; + }; +} diff --git a/tests/ui/coroutine/drop-tracking-parent-expression.rs b/tests/ui/coroutine/drop-tracking-parent-expression.rs index 0f4d99c8936..702cbc88ae4 100644 --- a/tests/ui/coroutine/drop-tracking-parent-expression.rs +++ b/tests/ui/coroutine/drop-tracking-parent-expression.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + #![feature(coroutines, negative_impls, rustc_attrs, stmt_expr_attributes)] macro_rules! type_combinations { @@ -15,9 +17,9 @@ macro_rules! type_combinations { // dropped *after* the yield. { let g = #[coroutine] move || match drop($name::Client { ..$name::Client::default() }) { - //~^ `significant_drop::Client` which is not `Send` - //~| `insignificant_dtor::Client` which is not `Send` - //~| `derived_drop::Client` which is not `Send` + //~^ NOTE `significant_drop::Client` which is not `Send` + //~| NOTE `insignificant_dtor::Client` which is not `Send` + //~| NOTE `derived_drop::Client` which is not `Send` _ => yield, }; assert_send(g); diff --git a/tests/ui/coroutine/drop-tracking-parent-expression.stderr b/tests/ui/coroutine/drop-tracking-parent-expression.stderr index dc2f9768d23..2f5fe882f6e 100644 --- a/tests/ui/coroutine/drop-tracking-parent-expression.stderr +++ b/tests/ui/coroutine/drop-tracking-parent-expression.stderr @@ -1,5 +1,5 @@ error: coroutine cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:23:13 + --> $DIR/drop-tracking-parent-expression.rs:25:13 | LL | assert_send(g); | ^^^^^^^^^^^^^^ coroutine is not `Send` @@ -12,9 +12,9 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{coroutine@$DIR/drop-tracking-parent-expression.rs:17:34: 17:41}`, the trait `Send` is not implemented for `derived_drop::Client` + = help: within `{coroutine@$DIR/drop-tracking-parent-expression.rs:19:34: 19:41}`, the trait `Send` is not implemented for `derived_drop::Client` note: coroutine is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:21:22 + --> $DIR/drop-tracking-parent-expression.rs:23:22 | LL | let g = #[coroutine] move || match drop($name::Client { ..$name::Client::default() }) { | ------------------------ has type `derived_drop::Client` which is not `Send` @@ -30,14 +30,14 @@ LL | | }; LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:40:19 + --> $DIR/drop-tracking-parent-expression.rs:42:19 | LL | fn assert_send<T: Send>(_thing: T) {} | ^^^^ required by this bound in `assert_send` = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) error: coroutine cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:23:13 + --> $DIR/drop-tracking-parent-expression.rs:25:13 | LL | assert_send(g); | ^^^^^^^^^^^^^^ coroutine is not `Send` @@ -50,9 +50,9 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{coroutine@$DIR/drop-tracking-parent-expression.rs:17:34: 17:41}`, the trait `Send` is not implemented for `significant_drop::Client` + = help: within `{coroutine@$DIR/drop-tracking-parent-expression.rs:19:34: 19:41}`, the trait `Send` is not implemented for `significant_drop::Client` note: coroutine is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:21:22 + --> $DIR/drop-tracking-parent-expression.rs:23:22 | LL | let g = #[coroutine] move || match drop($name::Client { ..$name::Client::default() }) { | ------------------------ has type `significant_drop::Client` which is not `Send` @@ -68,14 +68,14 @@ LL | | }; LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:40:19 + --> $DIR/drop-tracking-parent-expression.rs:42:19 | LL | fn assert_send<T: Send>(_thing: T) {} | ^^^^ required by this bound in `assert_send` = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) error: coroutine cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:23:13 + --> $DIR/drop-tracking-parent-expression.rs:25:13 | LL | assert_send(g); | ^^^^^^^^^^^^^^ coroutine is not `Send` @@ -88,9 +88,9 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{coroutine@$DIR/drop-tracking-parent-expression.rs:17:34: 17:41}`, the trait `Send` is not implemented for `insignificant_dtor::Client` + = help: within `{coroutine@$DIR/drop-tracking-parent-expression.rs:19:34: 19:41}`, the trait `Send` is not implemented for `insignificant_dtor::Client` note: coroutine is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:21:22 + --> $DIR/drop-tracking-parent-expression.rs:23:22 | LL | let g = #[coroutine] move || match drop($name::Client { ..$name::Client::default() }) { | ------------------------ has type `insignificant_dtor::Client` which is not `Send` @@ -106,7 +106,7 @@ LL | | }; LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:40:19 + --> $DIR/drop-tracking-parent-expression.rs:42:19 | LL | fn assert_send<T: Send>(_thing: T) {} | ^^^^ required by this bound in `assert_send` diff --git a/tests/ui/coroutine/parent-expression.rs b/tests/ui/coroutine/parent-expression.rs index 0f4d99c8936..702cbc88ae4 100644 --- a/tests/ui/coroutine/parent-expression.rs +++ b/tests/ui/coroutine/parent-expression.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + #![feature(coroutines, negative_impls, rustc_attrs, stmt_expr_attributes)] macro_rules! type_combinations { @@ -15,9 +17,9 @@ macro_rules! type_combinations { // dropped *after* the yield. { let g = #[coroutine] move || match drop($name::Client { ..$name::Client::default() }) { - //~^ `significant_drop::Client` which is not `Send` - //~| `insignificant_dtor::Client` which is not `Send` - //~| `derived_drop::Client` which is not `Send` + //~^ NOTE `significant_drop::Client` which is not `Send` + //~| NOTE `insignificant_dtor::Client` which is not `Send` + //~| NOTE `derived_drop::Client` which is not `Send` _ => yield, }; assert_send(g); diff --git a/tests/ui/coroutine/parent-expression.stderr b/tests/ui/coroutine/parent-expression.stderr index a9125772b5a..f14bf05ed09 100644 --- a/tests/ui/coroutine/parent-expression.stderr +++ b/tests/ui/coroutine/parent-expression.stderr @@ -1,5 +1,5 @@ error: coroutine cannot be sent between threads safely - --> $DIR/parent-expression.rs:23:13 + --> $DIR/parent-expression.rs:25:13 | LL | assert_send(g); | ^^^^^^^^^^^^^^ coroutine is not `Send` @@ -12,9 +12,9 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{coroutine@$DIR/parent-expression.rs:17:34: 17:41}`, the trait `Send` is not implemented for `derived_drop::Client` + = help: within `{coroutine@$DIR/parent-expression.rs:19:34: 19:41}`, the trait `Send` is not implemented for `derived_drop::Client` note: coroutine is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:21:22 + --> $DIR/parent-expression.rs:23:22 | LL | let g = #[coroutine] move || match drop($name::Client { ..$name::Client::default() }) { | ------------------------ has type `derived_drop::Client` which is not `Send` @@ -30,14 +30,14 @@ LL | | }; LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:40:19 + --> $DIR/parent-expression.rs:42:19 | LL | fn assert_send<T: Send>(_thing: T) {} | ^^^^ required by this bound in `assert_send` = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) error: coroutine cannot be sent between threads safely - --> $DIR/parent-expression.rs:23:13 + --> $DIR/parent-expression.rs:25:13 | LL | assert_send(g); | ^^^^^^^^^^^^^^ coroutine is not `Send` @@ -50,9 +50,9 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{coroutine@$DIR/parent-expression.rs:17:34: 17:41}`, the trait `Send` is not implemented for `significant_drop::Client` + = help: within `{coroutine@$DIR/parent-expression.rs:19:34: 19:41}`, the trait `Send` is not implemented for `significant_drop::Client` note: coroutine is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:21:22 + --> $DIR/parent-expression.rs:23:22 | LL | let g = #[coroutine] move || match drop($name::Client { ..$name::Client::default() }) { | ------------------------ has type `significant_drop::Client` which is not `Send` @@ -68,14 +68,14 @@ LL | | }; LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:40:19 + --> $DIR/parent-expression.rs:42:19 | LL | fn assert_send<T: Send>(_thing: T) {} | ^^^^ required by this bound in `assert_send` = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) error: coroutine cannot be sent between threads safely - --> $DIR/parent-expression.rs:23:13 + --> $DIR/parent-expression.rs:25:13 | LL | assert_send(g); | ^^^^^^^^^^^^^^ coroutine is not `Send` @@ -88,9 +88,9 @@ LL | | }; LL | | ); | |_____- in this macro invocation | - = help: within `{coroutine@$DIR/parent-expression.rs:17:34: 17:41}`, the trait `Send` is not implemented for `insignificant_dtor::Client` + = help: within `{coroutine@$DIR/parent-expression.rs:19:34: 19:41}`, the trait `Send` is not implemented for `insignificant_dtor::Client` note: coroutine is not `Send` as this value is used across a yield - --> $DIR/parent-expression.rs:21:22 + --> $DIR/parent-expression.rs:23:22 | LL | let g = #[coroutine] move || match drop($name::Client { ..$name::Client::default() }) { | ------------------------ has type `insignificant_dtor::Client` which is not `Send` @@ -106,7 +106,7 @@ LL | | }; LL | | ); | |_____- in this macro invocation note: required by a bound in `assert_send` - --> $DIR/parent-expression.rs:40:19 + --> $DIR/parent-expression.rs:42:19 | LL | fn assert_send<T: Send>(_thing: T) {} | ^^^^ required by this bound in `assert_send` diff --git a/tests/ui/coverage-attr/bad-attr-ice.rs b/tests/ui/coverage-attr/bad-attr-ice.rs index 8d57bbbf49a..aeb44075bb6 100644 --- a/tests/ui/coverage-attr/bad-attr-ice.rs +++ b/tests/ui/coverage-attr/bad-attr-ice.rs @@ -10,7 +10,7 @@ #[coverage] //~^ ERROR malformed `coverage` attribute input -//[nofeat]~| the `#[coverage]` attribute is an experimental feature +//[nofeat]~| ERROR the `#[coverage]` attribute is an experimental feature fn main() {} // FIXME(#130766): When the `#[coverage(..)]` attribute is stabilized, diff --git a/tests/ui/cross/cross-borrow-trait.rs b/tests/ui/cross/cross-borrow-trait.rs index 180a75e3dfc..88ea78e44b3 100644 --- a/tests/ui/cross/cross-borrow-trait.rs +++ b/tests/ui/cross/cross-borrow-trait.rs @@ -1,6 +1,8 @@ // Test that cross-borrowing (implicitly converting from `Box<T>` to `&T`) is // forbidden when `T` is a trait. +//@ dont-require-annotations: NOTE + struct Foo; trait Trait { fn foo(&self) {} } impl Trait for Foo {} @@ -8,6 +10,6 @@ impl Trait for Foo {} pub fn main() { let x: Box<dyn Trait> = Box::new(Foo); let _y: &dyn Trait = x; //~ ERROR E0308 - //~| expected reference `&dyn Trait` - //~| found struct `Box<dyn Trait>` + //~| NOTE expected reference `&dyn Trait` + //~| NOTE found struct `Box<dyn Trait>` } diff --git a/tests/ui/cross/cross-borrow-trait.stderr b/tests/ui/cross/cross-borrow-trait.stderr index b670de39f6d..5fe80b5a3ee 100644 --- a/tests/ui/cross/cross-borrow-trait.stderr +++ b/tests/ui/cross/cross-borrow-trait.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/cross-borrow-trait.rs:10:26 + --> $DIR/cross-borrow-trait.rs:12:26 | LL | let _y: &dyn Trait = x; | ---------- ^ expected `&dyn Trait`, found `Box<dyn Trait>` diff --git a/tests/ui/destructure-trait-ref.rs b/tests/ui/destructure-trait-ref.rs index 50b64aeebf0..daa0ca30d68 100644 --- a/tests/ui/destructure-trait-ref.rs +++ b/tests/ui/destructure-trait-ref.rs @@ -1,6 +1,8 @@ // The regression test for #15031 to make sure destructuring trait // reference work properly. +//@ dont-require-annotations: NOTE + #![feature(box_patterns)] trait T { fn foo(&self) {} } @@ -31,14 +33,14 @@ fn main() { // n > m let &&x = &1isize as &dyn T; //~^ ERROR mismatched types - //~| expected trait object `dyn T` - //~| found reference `&_` + //~| NOTE expected trait object `dyn T` + //~| NOTE found reference `&_` let &&&x = &(&1isize as &dyn T); //~^ ERROR mismatched types - //~| expected trait object `dyn T` - //~| found reference `&_` + //~| NOTE expected trait object `dyn T` + //~| NOTE found reference `&_` let box box x = Box::new(1isize) as Box<dyn T>; //~^ ERROR mismatched types - //~| expected trait object `dyn T` - //~| found struct `Box<_>` + //~| NOTE expected trait object `dyn T` + //~| NOTE found struct `Box<_>` } diff --git a/tests/ui/destructure-trait-ref.stderr b/tests/ui/destructure-trait-ref.stderr index 38d20188827..0b5ea551a57 100644 --- a/tests/ui/destructure-trait-ref.stderr +++ b/tests/ui/destructure-trait-ref.stderr @@ -1,23 +1,23 @@ error[E0033]: type `&dyn T` cannot be dereferenced - --> $DIR/destructure-trait-ref.rs:26:9 + --> $DIR/destructure-trait-ref.rs:28:9 | LL | let &x = &1isize as &dyn T; | ^^ type `&dyn T` cannot be dereferenced error[E0033]: type `&dyn T` cannot be dereferenced - --> $DIR/destructure-trait-ref.rs:27:10 + --> $DIR/destructure-trait-ref.rs:29:10 | LL | let &&x = &(&1isize as &dyn T); | ^^ type `&dyn T` cannot be dereferenced error[E0033]: type `Box<dyn T>` cannot be dereferenced - --> $DIR/destructure-trait-ref.rs:28:9 + --> $DIR/destructure-trait-ref.rs:30:9 | LL | let box x = Box::new(1isize) as Box<dyn T>; | ^^^^^ type `Box<dyn T>` cannot be dereferenced error[E0308]: mismatched types - --> $DIR/destructure-trait-ref.rs:32:10 + --> $DIR/destructure-trait-ref.rs:34:10 | LL | let &&x = &1isize as &dyn T; | ^^ ----------------- this expression has type `&dyn T` @@ -33,7 +33,7 @@ LL + let &x = &1isize as &dyn T; | error[E0308]: mismatched types - --> $DIR/destructure-trait-ref.rs:36:11 + --> $DIR/destructure-trait-ref.rs:38:11 | LL | let &&&x = &(&1isize as &dyn T); | ^^ -------------------- this expression has type `&&dyn T` @@ -49,7 +49,7 @@ LL + let &&x = &(&1isize as &dyn T); | error[E0308]: mismatched types - --> $DIR/destructure-trait-ref.rs:40:13 + --> $DIR/destructure-trait-ref.rs:42:13 | LL | let box box x = Box::new(1isize) as Box<dyn T>; | ^^^^^ ------------------------------ this expression has type `Box<dyn T>` diff --git a/tests/ui/diagnostic-width/long-E0529.rs b/tests/ui/diagnostic-width/long-E0529.rs index 759a902da7e..4146d3be40f 100644 --- a/tests/ui/diagnostic-width/long-E0529.rs +++ b/tests/ui/diagnostic-width/long-E0529.rs @@ -1,4 +1,5 @@ //@ compile-flags: --diagnostic-width=60 -Zwrite-long-types-to-disk=yes +//@ dont-require-annotations: NOTE type A = (i32, i32, i32, i32); type B = (A, A, A, A); @@ -7,7 +8,7 @@ type D = (C, C, C, C); fn foo(x: D) { let [] = x; //~ ERROR expected an array or slice, found `(... - //~^ pattern cannot match with input type `(... + //~^ NOTE pattern cannot match with input type `(... } fn main() {} diff --git a/tests/ui/diagnostic-width/long-E0529.stderr b/tests/ui/diagnostic-width/long-E0529.stderr index bf3144cc9b6..e5b82b59271 100644 --- a/tests/ui/diagnostic-width/long-E0529.stderr +++ b/tests/ui/diagnostic-width/long-E0529.stderr @@ -1,5 +1,5 @@ error[E0529]: expected an array or slice, found `(..., ..., ..., ...)` - --> $DIR/long-E0529.rs:9:9 + --> $DIR/long-E0529.rs:10:9 | LL | let [] = x; | ^^ pattern cannot match with input type `(..., ..., ..., ...)` diff --git a/tests/ui/diagnostic-width/long-E0618.rs b/tests/ui/diagnostic-width/long-E0618.rs index b499bedc394..247061d17f8 100644 --- a/tests/ui/diagnostic-width/long-E0618.rs +++ b/tests/ui/diagnostic-width/long-E0618.rs @@ -1,11 +1,12 @@ //@ compile-flags: --diagnostic-width=60 -Zwrite-long-types-to-disk=yes +//@ dont-require-annotations: NOTE type A = (i32, i32, i32, i32); type B = (A, A, A, A); type C = (B, B, B, B); type D = (C, C, C, C); -fn foo(x: D) { //~ `x` has type `(... +fn foo(x: D) { //~ NOTE `x` has type `(... x(); //~ ERROR expected function, found `(... } diff --git a/tests/ui/diagnostic-width/long-E0618.stderr b/tests/ui/diagnostic-width/long-E0618.stderr index 05bf999c142..7d92b94faf8 100644 --- a/tests/ui/diagnostic-width/long-E0618.stderr +++ b/tests/ui/diagnostic-width/long-E0618.stderr @@ -1,5 +1,5 @@ error[E0618]: expected function, found `(..., ..., ..., ...)` - --> $DIR/long-E0618.rs:9:5 + --> $DIR/long-E0618.rs:10:5 | LL | fn foo(x: D) { | - `x` has type `(..., ..., ..., ...)` diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.next.stderr b/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.next.stderr index 6170250992c..8178f54b2aa 100644 --- a/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.next.stderr +++ b/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.next.stderr @@ -18,13 +18,16 @@ LL | where LL | T: AsExpression<Self::SqlType>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Foo::check` -error[E0271]: type mismatch resolving `Integer == Text` +error[E0277]: the trait bound `&str: AsExpression<Integer>` is not satisfied --> $DIR/as_expression.rs:56:5 | LL | SelectInt.check("bar"); - | ^^^^^^^^^^^^^^^^^^^^^^ types differ + | ^^^^^^^^^^^^^^^^^^^^^^ the trait `AsExpression<Integer>` is not implemented for `&str` + | + = help: the trait `AsExpression<Integer>` is not implemented for `&str` + but trait `AsExpression<Text>` is implemented for it + = help: for that trait implementation, expected `Text`, found `Integer` error: aborting due to 2 previous errors -Some errors have detailed explanations: E0271, E0277. -For more information about an error, try `rustc --explain E0271`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.rs b/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.rs index 673adb82870..86f39e43484 100644 --- a/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.rs +++ b/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.rs @@ -55,5 +55,5 @@ impl<T> Foo for T where T: Expression {} fn main() { SelectInt.check("bar"); //~^ ERROR the trait bound `&str: AsExpression<Integer>` is not satisfied - //[next]~| ERROR type mismatch + //[next]~| ERROR the trait bound `&str: AsExpression<Integer>` is not satisfied } diff --git a/tests/ui/diagnostic_namespace/on_unimplemented/custom-on-unimplemented-diagnostic.rs b/tests/ui/diagnostic_namespace/on_unimplemented/custom-on-unimplemented-diagnostic.rs index 3bb0939b5f9..44a84f40d44 100644 --- a/tests/ui/diagnostic_namespace/on_unimplemented/custom-on-unimplemented-diagnostic.rs +++ b/tests/ui/diagnostic_namespace/on_unimplemented/custom-on-unimplemented-diagnostic.rs @@ -1,5 +1,7 @@ //@ reference: attributes.diagnostic.on_unimplemented.intro //@ reference: attributes.diagnostic.on_unimplemented.keys +//@ dont-require-annotations: NOTE + #[diagnostic::on_unimplemented(message = "my message", label = "my label", note = "my note")] pub trait ProviderLt {} @@ -16,6 +18,6 @@ struct B; fn main() { B.request(); //~^ ERROR my message [E0599] - //~| my label - //~| my note + //~| NOTE my label + //~| NOTE my note } diff --git a/tests/ui/diagnostic_namespace/on_unimplemented/custom-on-unimplemented-diagnostic.stderr b/tests/ui/diagnostic_namespace/on_unimplemented/custom-on-unimplemented-diagnostic.stderr index 4c1838620b3..1ba2c2e222d 100644 --- a/tests/ui/diagnostic_namespace/on_unimplemented/custom-on-unimplemented-diagnostic.stderr +++ b/tests/ui/diagnostic_namespace/on_unimplemented/custom-on-unimplemented-diagnostic.stderr @@ -1,5 +1,5 @@ error[E0599]: my message - --> $DIR/custom-on-unimplemented-diagnostic.rs:17:7 + --> $DIR/custom-on-unimplemented-diagnostic.rs:19:7 | LL | struct B; | -------- method `request` not found for this struct because it doesn't satisfy `B: ProviderExt` or `B: ProviderLt` @@ -8,7 +8,7 @@ LL | B.request(); | ^^^^^^^ my label | note: trait bound `B: ProviderLt` was not satisfied - --> $DIR/custom-on-unimplemented-diagnostic.rs:12:18 + --> $DIR/custom-on-unimplemented-diagnostic.rs:14:18 | LL | impl<T: ?Sized + ProviderLt> ProviderExt for T {} | ^^^^^^^^^^ ----------- - @@ -16,13 +16,13 @@ LL | impl<T: ?Sized + ProviderLt> ProviderExt for T {} | unsatisfied trait bound introduced here = note: my note note: the trait `ProviderLt` must be implemented - --> $DIR/custom-on-unimplemented-diagnostic.rs:4:1 + --> $DIR/custom-on-unimplemented-diagnostic.rs:6:1 | LL | pub trait ProviderLt {} | ^^^^^^^^^^^^^^^^^^^^ = help: items from traits can only be used if the trait is implemented and in scope note: `ProviderExt` defines an item `request`, perhaps you need to implement it - --> $DIR/custom-on-unimplemented-diagnostic.rs:6:1 + --> $DIR/custom-on-unimplemented-diagnostic.rs:8:1 | LL | pub trait ProviderExt { | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/diagnostic_namespace/on_impl_trait.rs b/tests/ui/diagnostic_namespace/on_unimplemented/on_impl_trait.rs index 32a492c53a9..1ffa604b2bc 100644 --- a/tests/ui/diagnostic_namespace/on_impl_trait.rs +++ b/tests/ui/diagnostic_namespace/on_unimplemented/on_impl_trait.rs @@ -1,5 +1,6 @@ -// used to ICE, see <https://github.com/rust-lang/rust/issues/130627> -// Instead it should just ignore the diagnostic attribute +//! used to ICE, see <https://github.com/rust-lang/rust/issues/130627> +//! Instead it should just ignore the diagnostic attribute + #![feature(trait_alias)] trait Test {} diff --git a/tests/ui/diagnostic_namespace/on_impl_trait.stderr b/tests/ui/diagnostic_namespace/on_unimplemented/on_impl_trait.stderr index 59b9c31bc53..5eee6478922 100644 --- a/tests/ui/diagnostic_namespace/on_impl_trait.stderr +++ b/tests/ui/diagnostic_namespace/on_unimplemented/on_impl_trait.stderr @@ -1,5 +1,5 @@ warning: `#[diagnostic::on_unimplemented]` can only be applied to trait definitions - --> $DIR/on_impl_trait.rs:7:1 + --> $DIR/on_impl_trait.rs:8:1 | LL | #[diagnostic::on_unimplemented(message = "blah", label = "blah", note = "blah")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | #[diagnostic::on_unimplemented(message = "blah", label = "blah", note = "bl = note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default error[E0277]: the trait bound `{integer}: Alias` is not satisfied - --> $DIR/on_impl_trait.rs:15:9 + --> $DIR/on_impl_trait.rs:16:9 | LL | foo(&1); | --- ^^ the trait `Test` is not implemented for `{integer}` @@ -15,13 +15,13 @@ LL | foo(&1); | required by a bound introduced by this call | help: this trait has no implementations, consider adding one - --> $DIR/on_impl_trait.rs:5:1 + --> $DIR/on_impl_trait.rs:6:1 | LL | trait Test {} | ^^^^^^^^^^ = note: required for `{integer}` to implement `Alias` note: required by a bound in `foo` - --> $DIR/on_impl_trait.rs:12:11 + --> $DIR/on_impl_trait.rs:13:11 | LL | fn foo<T: Alias>(v: &T) {} | ^^^^^ required by this bound in `foo` diff --git a/tests/ui/dst/dst-bad-assign-3.rs b/tests/ui/dst/dst-bad-assign-3.rs index f96ecf7762c..e9e69134a62 100644 --- a/tests/ui/dst/dst-bad-assign-3.rs +++ b/tests/ui/dst/dst-bad-assign-3.rs @@ -1,5 +1,7 @@ // Forbid assignment into a dynamically sized type. +//@ dont-require-annotations: NOTE + struct Fat<T: ?Sized>(isize, &'static str, T); #[derive(PartialEq,Eq)] @@ -30,8 +32,8 @@ pub fn main() { let z: Box<dyn ToBar> = Box::new(Bar1 {f: 36}); f5.2 = Bar1 {f: 36}; //~^ ERROR mismatched types - //~| expected `dyn ToBar`, found `Bar1` - //~| expected trait object `dyn ToBar` - //~| found struct `Bar1` + //~| NOTE expected `dyn ToBar`, found `Bar1` + //~| NOTE expected trait object `dyn ToBar` + //~| NOTE found struct `Bar1` //~| ERROR the size for values of type } diff --git a/tests/ui/dst/dst-bad-assign-3.stderr b/tests/ui/dst/dst-bad-assign-3.stderr index 4aa1677e751..007f6b898be 100644 --- a/tests/ui/dst/dst-bad-assign-3.stderr +++ b/tests/ui/dst/dst-bad-assign-3.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/dst-bad-assign-3.rs:31:12 + --> $DIR/dst-bad-assign-3.rs:33:12 | LL | f5.2 = Bar1 {f: 36}; | ---- ^^^^^^^^^^^^ expected `dyn ToBar`, found `Bar1` @@ -11,7 +11,7 @@ LL | f5.2 = Bar1 {f: 36}; = help: `Bar1` implements `ToBar` so you could box the found value and coerce it to the trait object `Box<dyn ToBar>`, you will have to change the expected type as well error[E0277]: the size for values of type `dyn ToBar` cannot be known at compilation time - --> $DIR/dst-bad-assign-3.rs:31:5 + --> $DIR/dst-bad-assign-3.rs:33:5 | LL | f5.2 = Bar1 {f: 36}; | ^^^^ doesn't have a size known at compile-time diff --git a/tests/ui/dst/dst-bad-assign.rs b/tests/ui/dst/dst-bad-assign.rs index c55fb2c3e57..79a3f5c44d3 100644 --- a/tests/ui/dst/dst-bad-assign.rs +++ b/tests/ui/dst/dst-bad-assign.rs @@ -1,5 +1,7 @@ // Forbid assignment into a dynamically sized type. +//@ dont-require-annotations: NOTE + struct Fat<T: ?Sized> { f1: isize, f2: &'static str, @@ -34,8 +36,8 @@ pub fn main() { let z: Box<dyn ToBar> = Box::new(Bar1 {f: 36}); f5.ptr = Bar1 {f: 36}; //~^ ERROR mismatched types - //~| expected `dyn ToBar`, found `Bar1` - //~| expected trait object `dyn ToBar` - //~| found struct `Bar1` + //~| NOTE expected `dyn ToBar`, found `Bar1` + //~| NOTE expected trait object `dyn ToBar` + //~| NOTE found struct `Bar1` //~| ERROR the size for values of type } diff --git a/tests/ui/dst/dst-bad-assign.stderr b/tests/ui/dst/dst-bad-assign.stderr index f935d27e96e..fc73069bee0 100644 --- a/tests/ui/dst/dst-bad-assign.stderr +++ b/tests/ui/dst/dst-bad-assign.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/dst-bad-assign.rs:35:14 + --> $DIR/dst-bad-assign.rs:37:14 | LL | f5.ptr = Bar1 {f: 36}; | ------ ^^^^^^^^^^^^ expected `dyn ToBar`, found `Bar1` @@ -11,7 +11,7 @@ LL | f5.ptr = Bar1 {f: 36}; = help: `Bar1` implements `ToBar` so you could box the found value and coerce it to the trait object `Box<dyn ToBar>`, you will have to change the expected type as well error[E0277]: the size for values of type `dyn ToBar` cannot be known at compilation time - --> $DIR/dst-bad-assign.rs:35:5 + --> $DIR/dst-bad-assign.rs:37:5 | LL | f5.ptr = Bar1 {f: 36}; | ^^^^^^ doesn't have a size known at compile-time diff --git a/tests/ui/dst/dst-bad-coerce4.rs b/tests/ui/dst/dst-bad-coerce4.rs index 25410aa4fac..b5288d5d3e1 100644 --- a/tests/ui/dst/dst-bad-coerce4.rs +++ b/tests/ui/dst/dst-bad-coerce4.rs @@ -9,7 +9,8 @@ pub fn main() { let f1: &Fat<[isize]> = &Fat { ptr: [1, 2, 3] }; let f2: &Fat<[isize; 3]> = f1; //~^ ERROR mismatched types - //~| expected `&Fat<[isize; 3]>`, found `&Fat<[isize]>` - //~| expected reference `&Fat<[isize; 3]>` - //~| found reference `&Fat<[isize]>` + //~| NOTE expected `&Fat<[isize; 3]>`, found `&Fat<[isize]>` + //~| NOTE expected reference `&Fat<[isize; 3]>` + //~| NOTE found reference `&Fat<[isize]>` + //~| NOTE expected due to this } diff --git a/tests/ui/dynamically-sized-types/dst-raw.rs b/tests/ui/dynamically-sized-types/dst-raw.rs index 111848c5a7f..935f0f11ca6 100644 --- a/tests/ui/dynamically-sized-types/dst-raw.rs +++ b/tests/ui/dynamically-sized-types/dst-raw.rs @@ -1,6 +1,8 @@ //@ run-pass // Test DST raw pointers +#![allow(dangerous_implicit_autorefs)] + trait Trait { fn foo(&self) -> isize; } diff --git a/tests/ui/empty/empty-never-array.rs b/tests/ui/empty/empty-never-array.rs index fd93346101d..c84d9bd85a3 100644 --- a/tests/ui/empty/empty-never-array.rs +++ b/tests/ui/empty/empty-never-array.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + #![feature(never_type)] enum Helper<T, U> { @@ -9,7 +11,7 @@ enum Helper<T, U> { fn transmute<T, U>(t: T) -> U { let Helper::U(u) = Helper::T(t, []); //~^ ERROR refutable pattern in local binding - //~| `Helper::T(_, _)` not covered + //~| NOTE `Helper::T(_, _)` not covered u } diff --git a/tests/ui/empty/empty-never-array.stderr b/tests/ui/empty/empty-never-array.stderr index f9f39a6371e..ee04ff162a4 100644 --- a/tests/ui/empty/empty-never-array.stderr +++ b/tests/ui/empty/empty-never-array.stderr @@ -1,5 +1,5 @@ error[E0005]: refutable pattern in local binding - --> $DIR/empty-never-array.rs:10:9 + --> $DIR/empty-never-array.rs:12:9 | LL | let Helper::U(u) = Helper::T(t, []); | ^^^^^^^^^^^^ pattern `Helper::T(_, _)` not covered @@ -7,7 +7,7 @@ LL | let Helper::U(u) = Helper::T(t, []); = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html note: `Helper<T, U>` defined here - --> $DIR/empty-never-array.rs:3:6 + --> $DIR/empty-never-array.rs:5:6 | LL | enum Helper<T, U> { | ^^^^^^ diff --git a/tests/ui/enum-discriminant/discriminant-overflow.rs b/tests/ui/enum-discriminant/discriminant-overflow.rs index 774ced93c17..aa3f4c13c4e 100644 --- a/tests/ui/enum-discriminant/discriminant-overflow.rs +++ b/tests/ui/enum-discriminant/discriminant-overflow.rs @@ -1,8 +1,9 @@ // Issue 23030: Detect overflowing discriminant - // See also run-pass/discrim-explicit-23030.rs where the suggested // workaround is tested. +//@ dont-require-annotations: NOTE + fn f_i8() { #[repr(i8)] enum A { @@ -42,7 +43,7 @@ fn f_u16() { Ok = u16::MAX - 1, Ok2, OhNo, //~ ERROR enum discriminant overflowed [E0370] - //~| overflowed on value after 65535 + //~| NOTE overflowed on value after 65535 } let x = A::Ok; @@ -54,7 +55,7 @@ fn f_i32() { Ok = i32::MAX - 1, Ok2, OhNo, //~ ERROR enum discriminant overflowed [E0370] - //~| overflowed on value after 2147483647 + //~| NOTE overflowed on value after 2147483647 } let x = A::Ok; @@ -66,7 +67,7 @@ fn f_u32() { Ok = u32::MAX - 1, Ok2, OhNo, //~ ERROR enum discriminant overflowed [E0370] - //~| overflowed on value after 4294967295 + //~| NOTE overflowed on value after 4294967295 } let x = A::Ok; @@ -78,7 +79,7 @@ fn f_i64() { Ok = i64::MAX - 1, Ok2, OhNo, //~ ERROR enum discriminant overflowed [E0370] - //~| overflowed on value after 9223372036854775807 + //~| NOTE overflowed on value after 9223372036854775807 } let x = A::Ok; @@ -90,7 +91,7 @@ fn f_u64() { Ok = u64::MAX - 1, Ok2, OhNo, //~ ERROR enum discriminant overflowed [E0370] - //~| overflowed on value after 18446744073709551615 + //~| NOTE overflowed on value after 18446744073709551615 } let x = A::Ok; diff --git a/tests/ui/enum-discriminant/discriminant-overflow.stderr b/tests/ui/enum-discriminant/discriminant-overflow.stderr index 2ecc1839f57..2662ddb2b93 100644 --- a/tests/ui/enum-discriminant/discriminant-overflow.stderr +++ b/tests/ui/enum-discriminant/discriminant-overflow.stderr @@ -1,5 +1,5 @@ error[E0370]: enum discriminant overflowed - --> $DIR/discriminant-overflow.rs:11:9 + --> $DIR/discriminant-overflow.rs:12:9 | LL | OhNo, | ^^^^ overflowed on value after 127 @@ -7,7 +7,7 @@ LL | OhNo, = note: explicitly set `OhNo = -128` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discriminant-overflow.rs:22:9 + --> $DIR/discriminant-overflow.rs:23:9 | LL | OhNo, | ^^^^ overflowed on value after 255 @@ -15,7 +15,7 @@ LL | OhNo, = note: explicitly set `OhNo = 0` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discriminant-overflow.rs:33:9 + --> $DIR/discriminant-overflow.rs:34:9 | LL | OhNo, | ^^^^ overflowed on value after 32767 @@ -23,7 +23,7 @@ LL | OhNo, = note: explicitly set `OhNo = -32768` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discriminant-overflow.rs:44:9 + --> $DIR/discriminant-overflow.rs:45:9 | LL | OhNo, | ^^^^ overflowed on value after 65535 @@ -31,7 +31,7 @@ LL | OhNo, = note: explicitly set `OhNo = 0` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discriminant-overflow.rs:56:9 + --> $DIR/discriminant-overflow.rs:57:9 | LL | OhNo, | ^^^^ overflowed on value after 2147483647 @@ -39,7 +39,7 @@ LL | OhNo, = note: explicitly set `OhNo = -2147483648` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discriminant-overflow.rs:68:9 + --> $DIR/discriminant-overflow.rs:69:9 | LL | OhNo, | ^^^^ overflowed on value after 4294967295 @@ -47,7 +47,7 @@ LL | OhNo, = note: explicitly set `OhNo = 0` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discriminant-overflow.rs:80:9 + --> $DIR/discriminant-overflow.rs:81:9 | LL | OhNo, | ^^^^ overflowed on value after 9223372036854775807 @@ -55,7 +55,7 @@ LL | OhNo, = note: explicitly set `OhNo = -9223372036854775808` if that is desired outcome error[E0370]: enum discriminant overflowed - --> $DIR/discriminant-overflow.rs:92:9 + --> $DIR/discriminant-overflow.rs:93:9 | LL | OhNo, | ^^^^ overflowed on value after 18446744073709551615 diff --git a/tests/ui/error-codes/E0080.rs b/tests/ui/error-codes/E0080.rs index ea3264b61b3..55f45055f01 100644 --- a/tests/ui/error-codes/E0080.rs +++ b/tests/ui/error-codes/E0080.rs @@ -1,7 +1,8 @@ enum Enum { X = (1 << 500), //~ ERROR E0080 - //~| attempt to shift left by `500_i32`, which would overflow + //~| NOTE attempt to shift left by `500_i32`, which would overflow Y = (1 / 0) //~ ERROR E0080 + //~| NOTE attempt to divide `1_isize` by zero } fn main() { diff --git a/tests/ui/error-codes/E0106.rs b/tests/ui/error-codes/E0106.rs index cc3438727a8..c8030495628 100644 --- a/tests/ui/error-codes/E0106.rs +++ b/tests/ui/error-codes/E0106.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + struct Foo { x: &bool, //~^ ERROR E0106 @@ -16,10 +18,10 @@ struct Buzz<'a, 'b>(&'a str, &'b str); struct Quux { baz: Baz, //~^ ERROR E0106 - //~| expected named lifetime parameter + //~| NOTE expected named lifetime parameter buzz: Buzz, //~^ ERROR E0106 - //~| expected 2 lifetime parameters + //~| NOTE expected 2 lifetime parameters } fn main() { diff --git a/tests/ui/error-codes/E0106.stderr b/tests/ui/error-codes/E0106.stderr index d11a24f7768..97ae1df9873 100644 --- a/tests/ui/error-codes/E0106.stderr +++ b/tests/ui/error-codes/E0106.stderr @@ -1,5 +1,5 @@ error[E0106]: missing lifetime specifier - --> $DIR/E0106.rs:2:8 + --> $DIR/E0106.rs:4:8 | LL | x: &bool, | ^ expected named lifetime parameter @@ -11,7 +11,7 @@ LL ~ x: &'a bool, | error[E0106]: missing lifetime specifier - --> $DIR/E0106.rs:7:7 + --> $DIR/E0106.rs:9:7 | LL | B(&bool), | ^ expected named lifetime parameter @@ -24,7 +24,7 @@ LL ~ B(&'a bool), | error[E0106]: missing lifetime specifier - --> $DIR/E0106.rs:10:14 + --> $DIR/E0106.rs:12:14 | LL | type MyStr = &str; | ^ expected named lifetime parameter @@ -35,7 +35,7 @@ LL | type MyStr<'a> = &'a str; | ++++ ++ error[E0106]: missing lifetime specifier - --> $DIR/E0106.rs:17:10 + --> $DIR/E0106.rs:19:10 | LL | baz: Baz, | ^^^ expected named lifetime parameter @@ -47,7 +47,7 @@ LL ~ baz: Baz<'a>, | error[E0106]: missing lifetime specifiers - --> $DIR/E0106.rs:20:11 + --> $DIR/E0106.rs:22:11 | LL | buzz: Buzz, | ^^^^ expected 2 lifetime parameters diff --git a/tests/ui/error-codes/E0253.rs b/tests/ui/error-codes/E0253.rs deleted file mode 100644 index 8284f791c64..00000000000 --- a/tests/ui/error-codes/E0253.rs +++ /dev/null @@ -1,10 +0,0 @@ -mod foo { - pub trait MyTrait { - type SomeType; - } -} - -use foo::MyTrait::SomeType; - //~^ ERROR E0253 - -fn main() {} diff --git a/tests/ui/error-codes/E0253.stderr b/tests/ui/error-codes/E0253.stderr deleted file mode 100644 index 954dbc81693..00000000000 --- a/tests/ui/error-codes/E0253.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0253]: `SomeType` is not directly importable - --> $DIR/E0253.rs:7:5 - | -LL | use foo::MyTrait::SomeType; - | ^^^^^^^^^^^^^^^^^^^^^^ cannot be imported directly - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0253`. diff --git a/tests/ui/error-codes/E0428.rs b/tests/ui/error-codes/E0428.rs index eb9594fb8b6..08393b009d5 100644 --- a/tests/ui/error-codes/E0428.rs +++ b/tests/ui/error-codes/E0428.rs @@ -1,4 +1,6 @@ -struct Bar; //~ previous definition of the type `Bar` here +//@ dont-require-annotations: NOTE + +struct Bar; //~ NOTE previous definition of the type `Bar` here struct Bar; //~ ERROR E0428 fn main () { diff --git a/tests/ui/error-codes/E0428.stderr b/tests/ui/error-codes/E0428.stderr index b5bb84e2e68..78f57066e26 100644 --- a/tests/ui/error-codes/E0428.stderr +++ b/tests/ui/error-codes/E0428.stderr @@ -1,5 +1,5 @@ error[E0428]: the name `Bar` is defined multiple times - --> $DIR/E0428.rs:2:1 + --> $DIR/E0428.rs:4:1 | LL | struct Bar; | ----------- previous definition of the type `Bar` here diff --git a/tests/ui/error-festival.rs b/tests/ui/error-emitter/error-festival.rs index 356564e5407..ebb5882352c 100644 --- a/tests/ui/error-festival.rs +++ b/tests/ui/error-emitter/error-festival.rs @@ -1,3 +1,5 @@ +//! Check that if there are a lot of errors we truncate the list of errors appropriately + enum Question { Yes, No, diff --git a/tests/ui/error-festival.stderr b/tests/ui/error-emitter/error-festival.stderr index 9db95363791..be484bc8094 100644 --- a/tests/ui/error-festival.stderr +++ b/tests/ui/error-emitter/error-festival.stderr @@ -1,5 +1,5 @@ error[E0425]: cannot find value `y` in this scope - --> $DIR/error-festival.rs:14:5 + --> $DIR/error-festival.rs:16:5 | LL | y = 2; | ^ @@ -15,19 +15,19 @@ LL | let y = 2; | +++ error[E0603]: constant `FOO` is private - --> $DIR/error-festival.rs:22:10 + --> $DIR/error-festival.rs:24:10 | LL | foo::FOO; | ^^^ private constant | note: the constant `FOO` is defined here - --> $DIR/error-festival.rs:7:5 + --> $DIR/error-festival.rs:9:5 | LL | const FOO: u32 = 0; | ^^^^^^^^^^^^^^^^^^^ error[E0368]: binary assignment operation `+=` cannot be applied to type `&str` - --> $DIR/error-festival.rs:12:5 + --> $DIR/error-festival.rs:14:5 | LL | x += 2; | -^^^^^ @@ -35,19 +35,19 @@ LL | x += 2; | cannot use `+=` on type `&str` error[E0599]: no method named `z` found for reference `&str` in the current scope - --> $DIR/error-festival.rs:16:7 + --> $DIR/error-festival.rs:18:7 | LL | x.z(); | ^ method not found in `&str` error[E0600]: cannot apply unary operator `!` to type `Question` - --> $DIR/error-festival.rs:19:5 + --> $DIR/error-festival.rs:21:5 | LL | !Question::Yes; | ^^^^^^^^^^^^^^ cannot apply unary operator `!` | note: an implementation of `Not` might be missing for `Question` - --> $DIR/error-festival.rs:1:1 + --> $DIR/error-festival.rs:3:1 | LL | enum Question { | ^^^^^^^^^^^^^ must implement `Not` @@ -55,7 +55,7 @@ note: the trait `Not` must be implemented --> $SRC_DIR/core/src/ops/bit.rs:LL:COL error[E0604]: only `u8` can be cast as `char`, not `u32` - --> $DIR/error-festival.rs:25:5 + --> $DIR/error-festival.rs:27:5 | LL | 0u32 as char; | ^^^^^^^^^^^^ @@ -64,13 +64,13 @@ LL | 0u32 as char; | help: try `char::from_u32` instead: `char::from_u32(0u32)` error[E0605]: non-primitive cast: `u8` as `Vec<u8>` - --> $DIR/error-festival.rs:29:5 + --> $DIR/error-festival.rs:31:5 | LL | x as Vec<u8>; | ^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object error[E0054]: cannot cast `{integer}` as `bool` - --> $DIR/error-festival.rs:33:24 + --> $DIR/error-festival.rs:35:24 | LL | let x_is_nonzero = x as bool; | ^^^^^^^^^ @@ -82,7 +82,7 @@ LL + let x_is_nonzero = x != 0; | error[E0606]: casting `&u8` as `u32` is invalid - --> $DIR/error-festival.rs:37:18 + --> $DIR/error-festival.rs:39:18 | LL | let y: u32 = x as u32; | ^^^^^^^^ @@ -93,7 +93,7 @@ LL | let y: u32 = *x as u32; | + error[E0607]: cannot cast thin pointer `*const u8` to wide pointer `*const [u8]` - --> $DIR/error-festival.rs:41:5 + --> $DIR/error-festival.rs:43:5 | LL | v as *const [u8]; | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/explicit/explicit-self-lifetime-mismatch.rs b/tests/ui/explicit/explicit-self-lifetime-mismatch.rs index a9a6f50fb8e..aa5e352b6eb 100644 --- a/tests/ui/explicit/explicit-self-lifetime-mismatch.rs +++ b/tests/ui/explicit/explicit-self-lifetime-mismatch.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + struct Foo<'a,'b> { x: &'a isize, y: &'b isize, @@ -7,13 +9,13 @@ impl<'a,'b> Foo<'a,'b> { fn bar(self: Foo<'b,'a> //~^ ERROR mismatched `self` parameter type - //~| expected struct `Foo<'a, 'b>` - //~| found struct `Foo<'b, 'a>` - //~| lifetime mismatch + //~| NOTE expected struct `Foo<'a, 'b>` + //~| NOTE found struct `Foo<'b, 'a>` + //~| NOTE lifetime mismatch //~| ERROR mismatched `self` parameter type - //~| expected struct `Foo<'a, 'b>` - //~| found struct `Foo<'b, 'a>` - //~| lifetime mismatch + //~| NOTE expected struct `Foo<'a, 'b>` + //~| NOTE found struct `Foo<'b, 'a>` + //~| NOTE lifetime mismatch ) {} } diff --git a/tests/ui/explicit/explicit-self-lifetime-mismatch.stderr b/tests/ui/explicit/explicit-self-lifetime-mismatch.stderr index d5ffa8f1b2f..a20901e8c74 100644 --- a/tests/ui/explicit/explicit-self-lifetime-mismatch.stderr +++ b/tests/ui/explicit/explicit-self-lifetime-mismatch.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched `self` parameter type - --> $DIR/explicit-self-lifetime-mismatch.rs:8:12 + --> $DIR/explicit-self-lifetime-mismatch.rs:10:12 | LL | Foo<'b,'a> | ^^^^^^^^^^ lifetime mismatch @@ -7,18 +7,18 @@ LL | Foo<'b,'a> = note: expected struct `Foo<'a, 'b>` found struct `Foo<'b, 'a>` note: the lifetime `'b` as defined here... - --> $DIR/explicit-self-lifetime-mismatch.rs:6:9 + --> $DIR/explicit-self-lifetime-mismatch.rs:8:9 | LL | impl<'a,'b> Foo<'a,'b> { | ^^ note: ...does not necessarily outlive the lifetime `'a` as defined here - --> $DIR/explicit-self-lifetime-mismatch.rs:6:6 + --> $DIR/explicit-self-lifetime-mismatch.rs:8:6 | LL | impl<'a,'b> Foo<'a,'b> { | ^^ error[E0308]: mismatched `self` parameter type - --> $DIR/explicit-self-lifetime-mismatch.rs:8:12 + --> $DIR/explicit-self-lifetime-mismatch.rs:10:12 | LL | Foo<'b,'a> | ^^^^^^^^^^ lifetime mismatch @@ -26,12 +26,12 @@ LL | Foo<'b,'a> = note: expected struct `Foo<'a, 'b>` found struct `Foo<'b, 'a>` note: the lifetime `'a` as defined here... - --> $DIR/explicit-self-lifetime-mismatch.rs:6:6 + --> $DIR/explicit-self-lifetime-mismatch.rs:8:6 | LL | impl<'a,'b> Foo<'a,'b> { | ^^ note: ...does not necessarily outlive the lifetime `'b` as defined here - --> $DIR/explicit-self-lifetime-mismatch.rs:6:9 + --> $DIR/explicit-self-lifetime-mismatch.rs:8:9 | LL | impl<'a,'b> Foo<'a,'b> { | ^^ diff --git a/tests/ui/expr/if/if-branch-types.rs b/tests/ui/expr/if/if-branch-types.rs index c125ba30606..d6da3ee7193 100644 --- a/tests/ui/expr/if/if-branch-types.rs +++ b/tests/ui/expr/if/if-branch-types.rs @@ -1,5 +1,6 @@ fn main() { let x = if true { 10i32 } else { 10u32 }; //~^ ERROR `if` and `else` have incompatible types - //~| expected `i32`, found `u32` + //~| NOTE expected `i32`, found `u32` + //~| NOTE expected because of this } diff --git a/tests/ui/expr/if/if-without-else-result.rs b/tests/ui/expr/if/if-without-else-result.rs index 95604758a6b..29aa3d3f626 100644 --- a/tests/ui/expr/if/if-without-else-result.rs +++ b/tests/ui/expr/if/if-without-else-result.rs @@ -1,6 +1,8 @@ +//@ dont-require-annotations: NOTE + fn main() { let a = if true { true }; //~^ ERROR `if` may be missing an `else` clause [E0317] - //~| expected `bool`, found `()` + //~| NOTE expected `bool`, found `()` println!("{}", a); } diff --git a/tests/ui/expr/if/if-without-else-result.stderr b/tests/ui/expr/if/if-without-else-result.stderr index 4eaa0393496..d0a0981e2bd 100644 --- a/tests/ui/expr/if/if-without-else-result.stderr +++ b/tests/ui/expr/if/if-without-else-result.stderr @@ -1,5 +1,5 @@ error[E0317]: `if` may be missing an `else` clause - --> $DIR/if-without-else-result.rs:2:13 + --> $DIR/if-without-else-result.rs:4:13 | LL | let a = if true { true }; | ^^^^^^^^^^----^^ diff --git a/tests/ui/expr/if/issue-4201.rs b/tests/ui/expr/if/issue-4201.rs index 59c465b9e14..b456673b3c8 100644 --- a/tests/ui/expr/if/issue-4201.rs +++ b/tests/ui/expr/if/issue-4201.rs @@ -1,9 +1,11 @@ +//@ dont-require-annotations: NOTE + fn main() { let a = if true { 0 } else if false { //~^ ERROR `if` may be missing an `else` clause -//~| expected integer, found `()` +//~| NOTE expected integer, found `()` 1 }; } diff --git a/tests/ui/expr/if/issue-4201.stderr b/tests/ui/expr/if/issue-4201.stderr index c761d0b8553..4f5462c0372 100644 --- a/tests/ui/expr/if/issue-4201.stderr +++ b/tests/ui/expr/if/issue-4201.stderr @@ -1,5 +1,5 @@ error[E0317]: `if` may be missing an `else` clause - --> $DIR/issue-4201.rs:4:12 + --> $DIR/issue-4201.rs:6:12 | LL | } else if false { | ____________^ diff --git a/tests/ui/feature-gates/feature-gate-async-drop.rs b/tests/ui/feature-gates/feature-gate-async-drop.rs new file mode 100644 index 00000000000..20511b1d8ee --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-async-drop.rs @@ -0,0 +1,16 @@ +//@ edition: 2021 + +use std::future::AsyncDrop; //~ ERROR use of unstable library feature `async_drop` +use std::pin::Pin; + +struct Foo {} + +impl Drop for Foo { + fn drop(&mut self) {} +} + +impl AsyncDrop for Foo { //~ ERROR use of unstable library feature `async_drop` + async fn drop(self: Pin<&mut Self>) {} //~ ERROR use of unstable library feature `async_drop` +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-async-drop.stderr b/tests/ui/feature-gates/feature-gate-async-drop.stderr new file mode 100644 index 00000000000..e795c3a3422 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-async-drop.stderr @@ -0,0 +1,33 @@ +error[E0658]: use of unstable library feature `async_drop` + --> $DIR/feature-gate-async-drop.rs:3:5 + | +LL | use std::future::AsyncDrop; + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #126482 <https://github.com/rust-lang/rust/issues/126482> for more information + = help: add `#![feature(async_drop)]` 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[E0658]: use of unstable library feature `async_drop` + --> $DIR/feature-gate-async-drop.rs:13:5 + | +LL | async fn drop(self: Pin<&mut Self>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #126482 <https://github.com/rust-lang/rust/issues/126482> for more information + = help: add `#![feature(async_drop)]` 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[E0658]: use of unstable library feature `async_drop` + --> $DIR/feature-gate-async-drop.rs:12:6 + | +LL | impl AsyncDrop for Foo { + | ^^^^^^^^^ + | + = note: see issue #126482 <https://github.com/rust-lang/rust/issues/126482> for more information + = help: add `#![feature(async_drop)]` 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 3 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-avx10_target_feature.rs b/tests/ui/feature-gates/feature-gate-avx10_target_feature.rs new file mode 100644 index 00000000000..8557e67d1f4 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-avx10_target_feature.rs @@ -0,0 +1,6 @@ +//@ only-x86_64 +#[target_feature(enable = "avx10.1")] +//~^ ERROR: currently unstable +unsafe fn foo() {} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-avx10_target_feature.stderr b/tests/ui/feature-gates/feature-gate-avx10_target_feature.stderr new file mode 100644 index 00000000000..e45ea3524ca --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-avx10_target_feature.stderr @@ -0,0 +1,13 @@ +error[E0658]: the target feature `avx10.1` is currently unstable + --> $DIR/feature-gate-avx10_target_feature.rs:2:18 + | +LL | #[target_feature(enable = "avx10.1")] + | ^^^^^^^^^^^^^^^^^^ + | + = note: see issue #138843 <https://github.com/rust-lang/rust/issues/138843> for more information + = help: add `#![feature(avx10_target_feature)]` 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-cfg-target-has-reliable-f16-f128.rs b/tests/ui/feature-gates/feature-gate-cfg-target-has-reliable-f16-f128.rs new file mode 100644 index 00000000000..f1b0e3b01a4 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg-target-has-reliable-f16-f128.rs @@ -0,0 +1,12 @@ +//@ compile-flags: --check-cfg=cfg(target_has_reliable_f16,target_has_reliable_f16_math,target_has_reliable_f128,target_has_reliable_f128_math) + +fn main() { + cfg!(target_has_reliable_f16); + //~^ ERROR `cfg(target_has_reliable_f16)` is experimental and subject to change + cfg!(target_has_reliable_f16_math); + //~^ ERROR `cfg(target_has_reliable_f16_math)` is experimental and subject to change + cfg!(target_has_reliable_f128); + //~^ ERROR `cfg(target_has_reliable_f128)` is experimental and subject to change + cfg!(target_has_reliable_f128_math); + //~^ ERROR `cfg(target_has_reliable_f128_math)` is experimental and subject to change +} diff --git a/tests/ui/feature-gates/feature-gate-cfg-target-has-reliable-f16-f128.stderr b/tests/ui/feature-gates/feature-gate-cfg-target-has-reliable-f16-f128.stderr new file mode 100644 index 00000000000..9b90d18699e --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg-target-has-reliable-f16-f128.stderr @@ -0,0 +1,39 @@ +error[E0658]: `cfg(target_has_reliable_f16)` is experimental and subject to change + --> $DIR/feature-gate-cfg-target-has-reliable-f16-f128.rs:4:10 + | +LL | cfg!(target_has_reliable_f16); + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(cfg_target_has_reliable_f16_f128)]` 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[E0658]: `cfg(target_has_reliable_f16_math)` is experimental and subject to change + --> $DIR/feature-gate-cfg-target-has-reliable-f16-f128.rs:6:10 + | +LL | cfg!(target_has_reliable_f16_math); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(cfg_target_has_reliable_f16_f128)]` 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[E0658]: `cfg(target_has_reliable_f128)` is experimental and subject to change + --> $DIR/feature-gate-cfg-target-has-reliable-f16-f128.rs:8:10 + | +LL | cfg!(target_has_reliable_f128); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(cfg_target_has_reliable_f16_f128)]` 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[E0658]: `cfg(target_has_reliable_f128_math)` is experimental and subject to change + --> $DIR/feature-gate-cfg-target-has-reliable-f16-f128.rs:10:10 + | +LL | cfg!(target_has_reliable_f128_math); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(cfg_target_has_reliable_f16_f128)]` 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 4 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-cfg-target-thread-local.rs b/tests/ui/feature-gates/feature-gate-cfg-target-thread-local.rs index 131a10ea03b..a9d4f6fe04f 100644 --- a/tests/ui/feature-gates/feature-gate-cfg-target-thread-local.rs +++ b/tests/ui/feature-gates/feature-gate-cfg-target-thread-local.rs @@ -7,7 +7,7 @@ extern crate cfg_target_thread_local; extern "C" { #[cfg_attr(target_thread_local, thread_local)] - //~^ `cfg(target_thread_local)` is experimental and subject to change + //~^ ERROR `cfg(target_thread_local)` is experimental and subject to change static FOO: u32; } diff --git a/tests/ui/feature-gates/feature-gate-concat_idents.rs b/tests/ui/feature-gates/feature-gate-concat_idents.rs index 68caf3d71e9..4fc3b691597 100644 --- a/tests/ui/feature-gates/feature-gate-concat_idents.rs +++ b/tests/ui/feature-gates/feature-gate-concat_idents.rs @@ -1,3 +1,5 @@ +#![expect(deprecated)] // concat_idents is deprecated + const XY_1: i32 = 10; fn main() { diff --git a/tests/ui/feature-gates/feature-gate-concat_idents.stderr b/tests/ui/feature-gates/feature-gate-concat_idents.stderr index d0f4fe62d04..6399424eecd 100644 --- a/tests/ui/feature-gates/feature-gate-concat_idents.stderr +++ b/tests/ui/feature-gates/feature-gate-concat_idents.stderr @@ -1,5 +1,5 @@ error[E0658]: use of unstable library feature `concat_idents`: `concat_idents` is not stable enough for use and is subject to change - --> $DIR/feature-gate-concat_idents.rs:5:13 + --> $DIR/feature-gate-concat_idents.rs:7:13 | LL | let a = concat_idents!(X, Y_1); | ^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let a = concat_idents!(X, Y_1); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: use of unstable library feature `concat_idents`: `concat_idents` is not stable enough for use and is subject to change - --> $DIR/feature-gate-concat_idents.rs:6:13 + --> $DIR/feature-gate-concat_idents.rs:8:13 | LL | let b = concat_idents!(X, Y_2); | ^^^^^^^^^^^^^ diff --git a/tests/ui/feature-gates/feature-gate-concat_idents2.rs b/tests/ui/feature-gates/feature-gate-concat_idents2.rs index 9660ffeafa5..bc2b4f7cddf 100644 --- a/tests/ui/feature-gates/feature-gate-concat_idents2.rs +++ b/tests/ui/feature-gates/feature-gate-concat_idents2.rs @@ -1,3 +1,5 @@ +#![expect(deprecated)] // concat_idents is deprecated + fn main() { concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough //~| ERROR cannot find value `ab` in this scope diff --git a/tests/ui/feature-gates/feature-gate-concat_idents2.stderr b/tests/ui/feature-gates/feature-gate-concat_idents2.stderr index b42a1d999e4..a770c1a348b 100644 --- a/tests/ui/feature-gates/feature-gate-concat_idents2.stderr +++ b/tests/ui/feature-gates/feature-gate-concat_idents2.stderr @@ -1,5 +1,5 @@ error[E0658]: use of unstable library feature `concat_idents`: `concat_idents` is not stable enough for use and is subject to change - --> $DIR/feature-gate-concat_idents2.rs:2:5 + --> $DIR/feature-gate-concat_idents2.rs:4:5 | LL | concat_idents!(a, b); | ^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | concat_idents!(a, b); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0425]: cannot find value `ab` in this scope - --> $DIR/feature-gate-concat_idents2.rs:2:5 + --> $DIR/feature-gate-concat_idents2.rs:4:5 | LL | concat_idents!(a, b); | ^^^^^^^^^^^^^^^^^^^^ not found in this scope diff --git a/tests/ui/feature-gates/feature-gate-concat_idents3.rs b/tests/ui/feature-gates/feature-gate-concat_idents3.rs index 81710fd9fb0..d4a0d2e6bb0 100644 --- a/tests/ui/feature-gates/feature-gate-concat_idents3.rs +++ b/tests/ui/feature-gates/feature-gate-concat_idents3.rs @@ -1,3 +1,5 @@ +#![expect(deprecated)] // concat_idents is deprecated + const XY_1: i32 = 10; fn main() { diff --git a/tests/ui/feature-gates/feature-gate-concat_idents3.stderr b/tests/ui/feature-gates/feature-gate-concat_idents3.stderr index b186601d0ed..7d929322bc0 100644 --- a/tests/ui/feature-gates/feature-gate-concat_idents3.stderr +++ b/tests/ui/feature-gates/feature-gate-concat_idents3.stderr @@ -1,5 +1,5 @@ error[E0658]: use of unstable library feature `concat_idents`: `concat_idents` is not stable enough for use and is subject to change - --> $DIR/feature-gate-concat_idents3.rs:5:20 + --> $DIR/feature-gate-concat_idents3.rs:7:20 | LL | assert_eq!(10, concat_idents!(X, Y_1)); | ^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | assert_eq!(10, concat_idents!(X, Y_1)); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: use of unstable library feature `concat_idents`: `concat_idents` is not stable enough for use and is subject to change - --> $DIR/feature-gate-concat_idents3.rs:6:20 + --> $DIR/feature-gate-concat_idents3.rs:8:20 | LL | assert_eq!(20, concat_idents!(X, Y_2)); | ^^^^^^^^^^^^^ diff --git a/tests/ui/feature-gates/feature-gate-import-trait-associated-functions.rs b/tests/ui/feature-gates/feature-gate-import-trait-associated-functions.rs index aec13fb0202..c2c010eaba6 100644 --- a/tests/ui/feature-gates/feature-gate-import-trait-associated-functions.rs +++ b/tests/ui/feature-gates/feature-gate-import-trait-associated-functions.rs @@ -60,4 +60,7 @@ fn f() { let t: Option<S> = DEFAULT; } +trait Glob {} +use Glob::*; //~ ERROR `use` associated items of traits is unstable + fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-import-trait-associated-functions.stderr b/tests/ui/feature-gates/feature-gate-import-trait-associated-functions.stderr index d342f5bd551..fca3cef3e20 100644 --- a/tests/ui/feature-gates/feature-gate-import-trait-associated-functions.stderr +++ b/tests/ui/feature-gates/feature-gate-import-trait-associated-functions.stderr @@ -48,6 +48,16 @@ LL | use super::A::{self, DEFAULT, new}; = help: add `#![feature(import_trait_associated_functions)]` 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 5 previous errors +error[E0658]: `use` associated items of traits is unstable + --> $DIR/feature-gate-import-trait-associated-functions.rs:64:5 + | +LL | use Glob::*; + | ^^^^^^^ + | + = note: see issue #134691 <https://github.com/rust-lang/rust/issues/134691> for more information + = help: add `#![feature(import_trait_associated_functions)]` 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 6 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/float/target-has-reliable-nightly-float.rs b/tests/ui/float/target-has-reliable-nightly-float.rs new file mode 100644 index 00000000000..ad8600fc635 --- /dev/null +++ b/tests/ui/float/target-has-reliable-nightly-float.rs @@ -0,0 +1,31 @@ +//@ run-pass +//@ compile-flags: --check-cfg=cfg(target_has_reliable_f16,target_has_reliable_f16_math,target_has_reliable_f128,target_has_reliable_f128_math) +// Verify that the feature gates and config work and are registered as known config +// options. + +#![deny(unexpected_cfgs)] +#![feature(cfg_target_has_reliable_f16_f128)] + +#[cfg(target_has_reliable_f16)] +pub fn has_f16() {} + +#[cfg(target_has_reliable_f16_math)] +pub fn has_f16_math() {} + +#[cfg(target_has_reliable_f128 )] +pub fn has_f128() {} + +#[cfg(target_has_reliable_f128_math)] +pub fn has_f128_math() {} + +fn main() { + if cfg!(target_arch = "aarch64") && cfg!(target_os = "linux") { + // Aarch64+Linux is one target that has support for all features, so use it to spot + // check that the compiler does indeed enable these gates. + + assert!(cfg!(target_has_reliable_f16)); + assert!(cfg!(target_has_reliable_f16_math)); + assert!(cfg!(target_has_reliable_f128)); + assert!(cfg!(target_has_reliable_f128_math)); + } +} diff --git a/tests/ui/fn/fn-item-type.rs b/tests/ui/fn/fn-item-type.rs index c094a34b207..c4c090bfda7 100644 --- a/tests/ui/fn/fn-item-type.rs +++ b/tests/ui/fn/fn-item-type.rs @@ -1,6 +1,8 @@ // Test that the types of distinct fn items are not compatible by // default. See also `run-pass/fn-item-type-*.rs`. +//@ dont-require-annotations: NOTE + fn foo<T>(x: isize) -> isize { x * 2 } @@ -21,31 +23,31 @@ impl<T> Foo for T { fn main() { eq(foo::<u8>, bar::<u8>); //~^ ERROR mismatched types - //~| expected fn item `fn(_) -> _ {foo::<u8>}` - //~| found fn item `fn(_) -> _ {bar::<u8>}` - //~| expected fn item, found a different fn item - //~| different fn items have unique types, even if their signatures are the same + //~| NOTE expected fn item `fn(_) -> _ {foo::<u8>}` + //~| NOTE found fn item `fn(_) -> _ {bar::<u8>}` + //~| NOTE expected fn item, found a different fn item + //~| NOTE different fn items have unique types, even if their signatures are the same eq(foo::<u8>, foo::<i8>); //~^ ERROR mismatched types - //~| expected `u8`, found `i8` - //~| different fn items have unique types, even if their signatures are the same + //~| NOTE expected `u8`, found `i8` + //~| NOTE different fn items have unique types, even if their signatures are the same eq(bar::<String>, bar::<Vec<u8>>); //~^ ERROR mismatched types - //~| found fn item `fn(_) -> _ {bar::<Vec<u8>>}` - //~| expected `String`, found `Vec<u8>` + //~| NOTE found fn item `fn(_) -> _ {bar::<Vec<u8>>}` + //~| NOTE expected `String`, found `Vec<u8>` // Make sure we distinguish between trait methods correctly. eq(<u8 as Foo>::foo, <u16 as Foo>::foo); //~^ ERROR mismatched types - //~| expected `u8`, found `u16` - //~| different fn items have unique types, even if their signatures are the same + //~| NOTE expected `u8`, found `u16` + //~| NOTE different fn items have unique types, even if their signatures are the same eq(foo::<u8>, bar::<u8> as fn(isize) -> isize); //~^ ERROR mismatched types - //~| found fn pointer `fn(_) -> _` - //~| expected fn item, found fn pointer + //~| NOTE found fn pointer `fn(_) -> _` + //~| NOTE expected fn item, found fn pointer eq(foo::<u8> as fn(isize) -> isize, bar::<u8>); // ok! } diff --git a/tests/ui/fn/fn-item-type.stderr b/tests/ui/fn/fn-item-type.stderr index 5cc529543d2..ea202f96a8e 100644 --- a/tests/ui/fn/fn-item-type.stderr +++ b/tests/ui/fn/fn-item-type.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/fn-item-type.rs:22:19 + --> $DIR/fn-item-type.rs:24:19 | LL | eq(foo::<u8>, bar::<u8>); | -- --------- ^^^^^^^^^ expected fn item, found a different fn item @@ -11,7 +11,7 @@ LL | eq(foo::<u8>, bar::<u8>); found fn item `fn(_) -> _ {bar::<u8>}` = note: different fn items have unique types, even if their signatures are the same note: function defined here - --> $DIR/fn-item-type.rs:11:4 + --> $DIR/fn-item-type.rs:13:4 | LL | fn eq<T>(x: T, y: T) {} | ^^ - ---- ---- this parameter needs to match the fn item type of `x` @@ -21,7 +21,7 @@ LL | fn eq<T>(x: T, y: T) {} = help: consider casting both fn items to fn pointers using `as fn(isize) -> isize` error[E0308]: mismatched types - --> $DIR/fn-item-type.rs:29:19 + --> $DIR/fn-item-type.rs:31:19 | LL | eq(foo::<u8>, foo::<i8>); | -- --------- ^^^^^^^^^ expected `u8`, found `i8` @@ -33,7 +33,7 @@ LL | eq(foo::<u8>, foo::<i8>); found fn item `fn(_) -> _ {foo::<i8>}` = note: different fn items have unique types, even if their signatures are the same note: function defined here - --> $DIR/fn-item-type.rs:11:4 + --> $DIR/fn-item-type.rs:13:4 | LL | fn eq<T>(x: T, y: T) {} | ^^ - ---- ---- this parameter needs to match the fn item type of `x` @@ -43,7 +43,7 @@ LL | fn eq<T>(x: T, y: T) {} = help: consider casting both fn items to fn pointers using `as fn(isize) -> isize` error[E0308]: mismatched types - --> $DIR/fn-item-type.rs:34:23 + --> $DIR/fn-item-type.rs:36:23 | LL | eq(bar::<String>, bar::<Vec<u8>>); | -- ------------- ^^^^^^^^^^^^^^ expected `String`, found `Vec<u8>` @@ -55,7 +55,7 @@ LL | eq(bar::<String>, bar::<Vec<u8>>); found fn item `fn(_) -> _ {bar::<Vec<u8>>}` = note: different fn items have unique types, even if their signatures are the same note: function defined here - --> $DIR/fn-item-type.rs:11:4 + --> $DIR/fn-item-type.rs:13:4 | LL | fn eq<T>(x: T, y: T) {} | ^^ - ---- ---- this parameter needs to match the fn item type of `x` @@ -65,7 +65,7 @@ LL | fn eq<T>(x: T, y: T) {} = help: consider casting both fn items to fn pointers using `as fn(isize) -> isize` error[E0308]: mismatched types - --> $DIR/fn-item-type.rs:40:26 + --> $DIR/fn-item-type.rs:42:26 | LL | eq(<u8 as Foo>::foo, <u16 as Foo>::foo); | -- ---------------- ^^^^^^^^^^^^^^^^^ expected `u8`, found `u16` @@ -77,7 +77,7 @@ LL | eq(<u8 as Foo>::foo, <u16 as Foo>::foo); found fn item `fn() {<u16 as Foo>::foo}` = note: different fn items have unique types, even if their signatures are the same note: function defined here - --> $DIR/fn-item-type.rs:11:4 + --> $DIR/fn-item-type.rs:13:4 | LL | fn eq<T>(x: T, y: T) {} | ^^ - ---- ---- this parameter needs to match the fn item type of `x` @@ -87,7 +87,7 @@ LL | fn eq<T>(x: T, y: T) {} = help: consider casting both fn items to fn pointers using `as fn()` error[E0308]: mismatched types - --> $DIR/fn-item-type.rs:45:19 + --> $DIR/fn-item-type.rs:47:19 | LL | eq(foo::<u8>, bar::<u8> as fn(isize) -> isize); | -- --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected fn item, found fn pointer @@ -99,7 +99,7 @@ LL | eq(foo::<u8>, bar::<u8> as fn(isize) -> isize); found fn pointer `fn(_) -> _` = help: consider casting the fn item to a fn pointer: `foo::<u8> as fn(isize) -> isize` note: function defined here - --> $DIR/fn-item-type.rs:11:4 + --> $DIR/fn-item-type.rs:13:4 | LL | fn eq<T>(x: T, y: T) {} | ^^ - ---- ---- this parameter needs to match the fn item type of `x` diff --git a/tests/ui/fn/fn-pointer-mismatch.rs b/tests/ui/fn/fn-pointer-mismatch.rs index 1c50d8b0f8b..3854c8eab68 100644 --- a/tests/ui/fn/fn-pointer-mismatch.rs +++ b/tests/ui/fn/fn-pointer-mismatch.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + fn foo(x: u32) -> u32 { x * 2 } @@ -10,7 +12,7 @@ fn bar(x: u32) -> u32 { fn foobar(n: u32) -> u32 { let g = if n % 2 == 0 { &foo } else { &bar }; //~^ ERROR `if` and `else` have incompatible types - //~| different fn items have unique types, even if their signatures are the same + //~| NOTE different fn items have unique types, even if their signatures are the same g(n) } @@ -22,33 +24,33 @@ fn main() { let mut a = foo; a = bar; //~^ ERROR mismatched types - //~| expected fn item `fn(_) -> _ {foo}` - //~| found fn item `fn(_) -> _ {bar}` - //~| different fn items have unique types, even if their signatures are the same + //~| NOTE expected fn item `fn(_) -> _ {foo}` + //~| NOTE found fn item `fn(_) -> _ {bar}` + //~| NOTE different fn items have unique types, even if their signatures are the same // display note even when boxed let mut b = Box::new(foo); b = Box::new(bar); //~^ ERROR mismatched types - //~| different fn items have unique types, even if their signatures are the same + //~| NOTE different fn items have unique types, even if their signatures are the same // suggest removing reference let c: fn(u32) -> u32 = &foo; //~^ ERROR mismatched types - //~| expected fn pointer `fn(_) -> _` - //~| found reference `&fn(_) -> _ {foo}` + //~| NOTE expected fn pointer `fn(_) -> _` + //~| NOTE found reference `&fn(_) -> _ {foo}` // suggest using reference let d: &fn(u32) -> u32 = foo; //~^ ERROR mismatched types - //~| expected reference `&fn(_) -> _` - //~| found fn item `fn(_) -> _ {foo}` + //~| NOTE expected reference `&fn(_) -> _` + //~| NOTE found fn item `fn(_) -> _ {foo}` // suggest casting with reference let e: &fn(u32) -> u32 = &foo; //~^ ERROR mismatched types - //~| expected reference `&fn(_) -> _` - //~| found reference `&fn(_) -> _ {foo}` + //~| NOTE expected reference `&fn(_) -> _` + //~| NOTE found reference `&fn(_) -> _ {foo}` // OK let mut z: fn(u32) -> u32 = foo as fn(u32) -> u32; diff --git a/tests/ui/fn/fn-pointer-mismatch.stderr b/tests/ui/fn/fn-pointer-mismatch.stderr index 051eb945467..87a2e39913d 100644 --- a/tests/ui/fn/fn-pointer-mismatch.stderr +++ b/tests/ui/fn/fn-pointer-mismatch.stderr @@ -1,5 +1,5 @@ error[E0308]: `if` and `else` have incompatible types - --> $DIR/fn-pointer-mismatch.rs:11:43 + --> $DIR/fn-pointer-mismatch.rs:13:43 | LL | let g = if n % 2 == 0 { &foo } else { &bar }; | ---- ^^^^ expected `&fn(u32) -> u32 {foo}`, found `&fn(u32) -> u32 {bar}` @@ -12,7 +12,7 @@ LL | let g = if n % 2 == 0 { &foo } else { &bar }; = help: consider casting both fn items to fn pointers using `as fn(u32) -> u32` error[E0308]: mismatched types - --> $DIR/fn-pointer-mismatch.rs:23:9 + --> $DIR/fn-pointer-mismatch.rs:25:9 | LL | let mut a = foo; | --- expected due to this value @@ -25,7 +25,7 @@ LL | a = bar; = help: consider casting both fn items to fn pointers using `as fn(u32) -> u32` error[E0308]: mismatched types - --> $DIR/fn-pointer-mismatch.rs:31:18 + --> $DIR/fn-pointer-mismatch.rs:33:18 | LL | b = Box::new(bar); | -------- ^^^ expected fn item, found a different fn item @@ -40,7 +40,7 @@ note: associated function defined here = help: consider casting both fn items to fn pointers using `as fn(u32) -> u32` error[E0308]: mismatched types - --> $DIR/fn-pointer-mismatch.rs:36:29 + --> $DIR/fn-pointer-mismatch.rs:38:29 | LL | let c: fn(u32) -> u32 = &foo; | -------------- ^^^^ expected fn pointer, found `&fn(u32) -> u32 {foo}` @@ -56,7 +56,7 @@ LL + let c: fn(u32) -> u32 = foo; | error[E0308]: mismatched types - --> $DIR/fn-pointer-mismatch.rs:42:30 + --> $DIR/fn-pointer-mismatch.rs:44:30 | LL | let d: &fn(u32) -> u32 = foo; | --------------- ^^^ expected `&fn(u32) -> u32`, found fn item @@ -71,7 +71,7 @@ LL | let d: &fn(u32) -> u32 = &foo; | + error[E0308]: mismatched types - --> $DIR/fn-pointer-mismatch.rs:48:30 + --> $DIR/fn-pointer-mismatch.rs:50:30 | LL | let e: &fn(u32) -> u32 = &foo; | --------------- ^^^^ expected `&fn(u32) -> u32`, found `&fn(u32) -> u32 {foo}` diff --git a/tests/ui/fn/fn-trait-formatting.rs b/tests/ui/fn/fn-trait-formatting.rs index 61a8791ab1f..be74d1ca9be 100644 --- a/tests/ui/fn/fn-trait-formatting.rs +++ b/tests/ui/fn/fn-trait-formatting.rs @@ -1,20 +1,20 @@ -fn needs_fn<F>(x: F) where F: Fn(isize) -> isize {} - +//@ dont-require-annotations: NOTE +fn needs_fn<F>(x: F) where F: Fn(isize) -> isize {} fn main() { let _: () = Box::new(|_: isize| {}) as Box<dyn FnOnce(isize)>; //~^ ERROR mismatched types - //~| expected unit type `()` - //~| found struct `Box<dyn FnOnce(isize)>` + //~| NOTE expected unit type `()` + //~| NOTE found struct `Box<dyn FnOnce(isize)>` let _: () = Box::new(|_: isize, isize| {}) as Box<dyn Fn(isize, isize)>; //~^ ERROR mismatched types - //~| expected unit type `()` - //~| found struct `Box<dyn Fn(isize, isize)>` + //~| NOTE expected unit type `()` + //~| NOTE found struct `Box<dyn Fn(isize, isize)>` let _: () = Box::new(|| -> isize { unimplemented!() }) as Box<dyn FnMut() -> isize>; //~^ ERROR mismatched types - //~| expected unit type `()` - //~| found struct `Box<dyn FnMut() -> isize>` + //~| NOTE expected unit type `()` + //~| NOTE found struct `Box<dyn FnMut() -> isize>` needs_fn(1); //~^ ERROR expected a `Fn(isize)` closure, found `{integer}` diff --git a/tests/ui/fn/fn-trait-formatting.stderr b/tests/ui/fn/fn-trait-formatting.stderr index 9fdef49c5ef..bfd86106bf9 100644 --- a/tests/ui/fn/fn-trait-formatting.stderr +++ b/tests/ui/fn/fn-trait-formatting.stderr @@ -49,7 +49,7 @@ LL | needs_fn(1); | = help: the trait `Fn(isize)` is not implemented for `{integer}` note: required by a bound in `needs_fn` - --> $DIR/fn-trait-formatting.rs:1:31 + --> $DIR/fn-trait-formatting.rs:3:31 | LL | fn needs_fn<F>(x: F) where F: Fn(isize) -> isize {} | ^^^^^^^^^^^^^^^^^^ required by this bound in `needs_fn` diff --git a/tests/ui/foreign/issue-91370-foreign-fn-block-impl.rs b/tests/ui/foreign/issue-91370-foreign-fn-block-impl.rs index 23e08e01e6a..5317531cecd 100644 --- a/tests/ui/foreign/issue-91370-foreign-fn-block-impl.rs +++ b/tests/ui/foreign/issue-91370-foreign-fn-block-impl.rs @@ -1,10 +1,11 @@ // Regression test for issue #91370. extern "C" { - //~^ `extern` blocks define existing foreign functions + //~^ NOTE `extern` blocks define existing foreign functions fn f() { //~^ ERROR incorrect function inside `extern` block - //~| cannot have a body + //~| NOTE cannot have a body + //~| NOTE for more information, visit https://doc.rust-lang.org/std/keyword.extern.html impl Copy for u8 {} } } diff --git a/tests/ui/foreign/issue-91370-foreign-fn-block-impl.stderr b/tests/ui/foreign/issue-91370-foreign-fn-block-impl.stderr index 155fdf9d09a..ad6aff5d8c1 100644 --- a/tests/ui/foreign/issue-91370-foreign-fn-block-impl.stderr +++ b/tests/ui/foreign/issue-91370-foreign-fn-block-impl.stderr @@ -8,9 +8,7 @@ LL | fn f() { | ________^___- | | | | | cannot have a body -LL | | -LL | | -LL | | impl Copy for u8 {} +... | LL | | } | |_____- help: remove the invalid body: `;` | diff --git a/tests/ui/fully-qualified-type/fully-qualified-type-name2.rs b/tests/ui/fully-qualified-type/fully-qualified-type-name2.rs index f26d3be6630..983d694c440 100644 --- a/tests/ui/fully-qualified-type/fully-qualified-type-name2.rs +++ b/tests/ui/fully-qualified-type/fully-qualified-type-name2.rs @@ -1,5 +1,7 @@ // Test that we use fully-qualified type names in error messages. +//@ dont-require-annotations: NOTE + mod x { pub enum Foo { } } @@ -11,7 +13,7 @@ mod y { fn bar(x: x::Foo) -> y::Foo { return x; //~^ ERROR mismatched types - //~| expected `y::Foo`, found `x::Foo` + //~| NOTE expected `y::Foo`, found `x::Foo` } fn main() { diff --git a/tests/ui/fully-qualified-type/fully-qualified-type-name2.stderr b/tests/ui/fully-qualified-type/fully-qualified-type-name2.stderr index af716916548..90e54dfea2f 100644 --- a/tests/ui/fully-qualified-type/fully-qualified-type-name2.stderr +++ b/tests/ui/fully-qualified-type/fully-qualified-type-name2.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/fully-qualified-type-name2.rs:12:12 + --> $DIR/fully-qualified-type-name2.rs:14:12 | LL | fn bar(x: x::Foo) -> y::Foo { | ------ expected `y::Foo` because of return type @@ -8,12 +8,12 @@ LL | return x; | = note: `x::Foo` and `y::Foo` have similar names, but are actually distinct types note: `x::Foo` is defined in module `crate::x` of the current crate - --> $DIR/fully-qualified-type-name2.rs:4:5 + --> $DIR/fully-qualified-type-name2.rs:6:5 | LL | pub enum Foo { } | ^^^^^^^^^^^^ note: `y::Foo` is defined in module `crate::y` of the current crate - --> $DIR/fully-qualified-type-name2.rs:8:5 + --> $DIR/fully-qualified-type-name2.rs:10:5 | LL | pub enum Foo { } | ^^^^^^^^^^^^ diff --git a/tests/ui/fully-qualified-type/fully-qualified-type-name4.rs b/tests/ui/fully-qualified-type/fully-qualified-type-name4.rs index 41f07bab809..4fb4bb314df 100644 --- a/tests/ui/fully-qualified-type/fully-qualified-type-name4.rs +++ b/tests/ui/fully-qualified-type/fully-qualified-type-name4.rs @@ -2,12 +2,12 @@ use std::option::Option; -fn bar(x: usize) -> Option<usize> { +fn bar(x: usize) -> Option<usize> { //~ NOTE expected `Option<usize>` because of return type return x; //~^ ERROR mismatched types - //~| expected enum `Option<usize>` - //~| found type `usize` - //~| expected `Option<usize>`, found `usize` + //~| NOTE expected enum `Option<usize>` + //~| NOTE found type `usize` + //~| NOTE expected `Option<usize>`, found `usize` } fn main() { diff --git a/tests/ui/generic-const-items/user_type_annotations_pattern.rs b/tests/ui/generic-const-items/user_type_annotations_pattern.rs new file mode 100644 index 00000000000..aa3846df2bc --- /dev/null +++ b/tests/ui/generic-const-items/user_type_annotations_pattern.rs @@ -0,0 +1,14 @@ +#![feature(generic_const_items)] +#![expect(incomplete_features)] + +const FOO<'a: 'static>: usize = 10; + +fn bar<'a>() { + match 10_usize { + FOO::<'a> => todo!(), + //~^ ERROR: lifetime may not live long enough + _ => todo!(), + } +} + +fn main() {} diff --git a/tests/ui/generic-const-items/user_type_annotations_pattern.stderr b/tests/ui/generic-const-items/user_type_annotations_pattern.stderr new file mode 100644 index 00000000000..e15be275d29 --- /dev/null +++ b/tests/ui/generic-const-items/user_type_annotations_pattern.stderr @@ -0,0 +1,11 @@ +error: lifetime may not live long enough + --> $DIR/user_type_annotations_pattern.rs:8:9 + | +LL | fn bar<'a>() { + | -- lifetime `'a` defined here +LL | match 10_usize { +LL | FOO::<'a> => todo!(), + | ^^^^^^^^^ requires that `'a` must outlive `'static` + +error: aborting due to 1 previous error + diff --git a/tests/ui/generics/generic-type-params-name-repr.rs b/tests/ui/generics/generic-type-params-name-repr.rs index d60856b8904..bee8405a72c 100644 --- a/tests/ui/generics/generic-type-params-name-repr.rs +++ b/tests/ui/generics/generic-type-params-name-repr.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + use std::marker; struct A; @@ -12,40 +14,40 @@ fn main() { // Ensure that the printed type doesn't include the default type params... let _: Foo<isize> = (); //~^ ERROR mismatched types - //~| expected `Foo<isize>`, found `()` - //~| expected struct `Foo<isize>` - //~| found unit type `()` + //~| NOTE expected `Foo<isize>`, found `()` + //~| NOTE expected struct `Foo<isize>` + //~| NOTE found unit type `()` // ...even when they're present, but the same types as the defaults. let _: Foo<isize, B, C> = (); //~^ ERROR mismatched types - //~| expected `Foo<isize>`, found `()` - //~| expected struct `Foo<isize>` - //~| found unit type `()` + //~| NOTE expected `Foo<isize>`, found `()` + //~| NOTE expected struct `Foo<isize>` + //~| NOTE found unit type `()` // Including cases where the default is using previous type params. let _: HashMap<String, isize> = (); //~^ ERROR mismatched types - //~| expected `HashMap<String, isize>`, found `()` - //~| expected struct `HashMap<String, isize>` - //~| found unit type `()` + //~| NOTE expected `HashMap<String, isize>`, found `()` + //~| NOTE expected struct `HashMap<String, isize>` + //~| NOTE found unit type `()` let _: HashMap<String, isize, Hash<String>> = (); //~^ ERROR mismatched types - //~| expected `HashMap<String, isize>`, found `()` - //~| expected struct `HashMap<String, isize>` - //~| found unit type `()` + //~| NOTE expected `HashMap<String, isize>`, found `()` + //~| NOTE expected struct `HashMap<String, isize>` + //~| NOTE found unit type `()` // But not when there's a different type in between. let _: Foo<A, isize, C> = (); //~^ ERROR mismatched types - //~| expected `Foo<A, isize>`, found `()` - //~| expected struct `Foo<A, isize>` - //~| found unit type `()` + //~| NOTE expected `Foo<A, isize>`, found `()` + //~| NOTE expected struct `Foo<A, isize>` + //~| NOTE found unit type `()` // And don't print <> at all when there's just defaults. let _: Foo<A, B, C> = (); //~^ ERROR mismatched types - //~| expected `Foo`, found `()` - //~| expected struct `Foo` - //~| found unit type `()` + //~| NOTE expected `Foo`, found `()` + //~| NOTE expected struct `Foo` + //~| NOTE found unit type `()` } diff --git a/tests/ui/generics/generic-type-params-name-repr.stderr b/tests/ui/generics/generic-type-params-name-repr.stderr index 946f14cc1c6..ab03e8182ab 100644 --- a/tests/ui/generics/generic-type-params-name-repr.stderr +++ b/tests/ui/generics/generic-type-params-name-repr.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/generic-type-params-name-repr.rs:13:25 + --> $DIR/generic-type-params-name-repr.rs:15:25 | LL | let _: Foo<isize> = (); | ---------- ^^ expected `Foo<isize>`, found `()` @@ -10,7 +10,7 @@ LL | let _: Foo<isize> = (); found unit type `()` error[E0308]: mismatched types - --> $DIR/generic-type-params-name-repr.rs:20:31 + --> $DIR/generic-type-params-name-repr.rs:22:31 | LL | let _: Foo<isize, B, C> = (); | ---------------- ^^ expected `Foo<isize>`, found `()` @@ -21,7 +21,7 @@ LL | let _: Foo<isize, B, C> = (); found unit type `()` error[E0308]: mismatched types - --> $DIR/generic-type-params-name-repr.rs:27:37 + --> $DIR/generic-type-params-name-repr.rs:29:37 | LL | let _: HashMap<String, isize> = (); | ---------------------- ^^ expected `HashMap<String, isize>`, found `()` @@ -32,7 +32,7 @@ LL | let _: HashMap<String, isize> = (); found unit type `()` error[E0308]: mismatched types - --> $DIR/generic-type-params-name-repr.rs:32:51 + --> $DIR/generic-type-params-name-repr.rs:34:51 | LL | let _: HashMap<String, isize, Hash<String>> = (); | ------------------------------------ ^^ expected `HashMap<String, isize>`, found `()` @@ -43,7 +43,7 @@ LL | let _: HashMap<String, isize, Hash<String>> = (); found unit type `()` error[E0308]: mismatched types - --> $DIR/generic-type-params-name-repr.rs:39:31 + --> $DIR/generic-type-params-name-repr.rs:41:31 | LL | let _: Foo<A, isize, C> = (); | ---------------- ^^ expected `Foo<A, isize>`, found `()` @@ -54,7 +54,7 @@ LL | let _: Foo<A, isize, C> = (); found unit type `()` error[E0308]: mismatched types - --> $DIR/generic-type-params-name-repr.rs:46:27 + --> $DIR/generic-type-params-name-repr.rs:48:27 | LL | let _: Foo<A, B, C> = (); | ------------ ^^ expected `Foo`, found `()` diff --git a/tests/ui/generics/single-colon-path-not-const-generics.stderr b/tests/ui/generics/single-colon-path-not-const-generics.stderr index 9eb62de2756..163ea4bbda6 100644 --- a/tests/ui/generics/single-colon-path-not-const-generics.stderr +++ b/tests/ui/generics/single-colon-path-not-const-generics.stderr @@ -1,13 +1,15 @@ error: path separator must be a double colon --> $DIR/single-colon-path-not-const-generics.rs:8:18 | +LL | pub struct Foo { + | --- while parsing this struct LL | a: Vec<foo::bar:A>, | ^ | help: use a double colon instead | LL | a: Vec<foo::bar::A>, - | + + | + error: aborting due to 1 previous error diff --git a/tests/ui/generics/slightly-nice-generic-literal-messages.rs b/tests/ui/generics/slightly-nice-generic-literal-messages.rs index 268009f65a5..83c08e977b6 100644 --- a/tests/ui/generics/slightly-nice-generic-literal-messages.rs +++ b/tests/ui/generics/slightly-nice-generic-literal-messages.rs @@ -3,12 +3,12 @@ use std::marker; struct Foo<T,U>(T, marker::PhantomData<U>); fn main() { - match Foo(1.1, marker::PhantomData) { + match Foo(1.1, marker::PhantomData) { //~ NOTE this expression has type `Foo<{float}, _>` 1 => {} //~^ ERROR mismatched types - //~| expected struct `Foo<{float}, _>` - //~| found type `{integer}` - //~| expected `Foo<{float}, _>`, found integer + //~| NOTE expected struct `Foo<{float}, _>` + //~| NOTE found type `{integer}` + //~| NOTE expected `Foo<{float}, _>`, found integer } } diff --git a/tests/ui/impl-trait/equality.rs b/tests/ui/impl-trait/equality.rs index 828b5aac896..07fc4a5d41a 100644 --- a/tests/ui/impl-trait/equality.rs +++ b/tests/ui/impl-trait/equality.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + #![feature(specialization)] //~ WARN the feature `specialization` is incomplete trait Foo: Copy + ToString {} @@ -14,7 +16,7 @@ fn two(x: bool) -> impl Foo { } 0_u32 //~^ ERROR mismatched types - //~| expected `i32`, found `u32` + //~| NOTE expected `i32`, found `u32` } fn sum_to(n: u32) -> impl Foo { diff --git a/tests/ui/impl-trait/equality.stderr b/tests/ui/impl-trait/equality.stderr index 8106bab9878..424d56f67e0 100644 --- a/tests/ui/impl-trait/equality.stderr +++ b/tests/ui/impl-trait/equality.stderr @@ -1,5 +1,5 @@ warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/equality.rs:1:12 + --> $DIR/equality.rs:3:12 | LL | #![feature(specialization)] | ^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | #![feature(specialization)] = note: `#[warn(incomplete_features)]` on by default error[E0308]: mismatched types - --> $DIR/equality.rs:15:5 + --> $DIR/equality.rs:17:5 | LL | fn two(x: bool) -> impl Foo { | -------- expected `i32` because of return type @@ -24,7 +24,7 @@ LL + 0_i32 | error[E0277]: cannot add `impl Foo` to `u32` - --> $DIR/equality.rs:24:11 + --> $DIR/equality.rs:26:11 | LL | n + sum_to(n - 1) | ^ no implementation for `u32 + impl Foo` diff --git a/tests/ui/impl-trait/equality2.rs b/tests/ui/impl-trait/equality2.rs index 2e325867da8..808c600ecb7 100644 --- a/tests/ui/impl-trait/equality2.rs +++ b/tests/ui/impl-trait/equality2.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + #![feature(specialization)] //~ WARN the feature `specialization` is incomplete trait Foo: Copy + ToString {} @@ -24,21 +26,21 @@ impl Leak for i32 { fn main() { let _: u32 = hide(0_u32); //~^ ERROR mismatched types - //~| expected type `u32` - //~| found opaque type `impl Foo` - //~| expected `u32`, found opaque type + //~| NOTE expected type `u32` + //~| NOTE found opaque type `impl Foo` + //~| NOTE expected `u32`, found opaque type let _: i32 = Leak::leak(hide(0_i32)); //~^ ERROR mismatched types - //~| expected type `i32` - //~| found associated type `<impl Foo as Leak>::T` - //~| expected `i32`, found associated type + //~| NOTE expected type `i32` + //~| NOTE found associated type `<impl Foo as Leak>::T` + //~| NOTE expected `i32`, found associated type let mut x = (hide(0_u32), hide(0_i32)); x = (x.1, //~^ ERROR mismatched types - //~| expected `u32`, found `i32` + //~| NOTE expected `u32`, found `i32` x.0); //~^ ERROR mismatched types - //~| expected `i32`, found `u32` + //~| NOTE expected `i32`, found `u32` } diff --git a/tests/ui/impl-trait/equality2.stderr b/tests/ui/impl-trait/equality2.stderr index 52f25d2458c..2fa7eb288ff 100644 --- a/tests/ui/impl-trait/equality2.stderr +++ b/tests/ui/impl-trait/equality2.stderr @@ -1,5 +1,5 @@ warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/equality2.rs:1:12 + --> $DIR/equality2.rs:3:12 | LL | #![feature(specialization)] | ^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | #![feature(specialization)] = note: `#[warn(incomplete_features)]` on by default error[E0308]: mismatched types - --> $DIR/equality2.rs:25:18 + --> $DIR/equality2.rs:27:18 | LL | fn hide<T: Foo>(x: T) -> impl Foo { | -------- the found opaque type @@ -23,7 +23,7 @@ LL | let _: u32 = hide(0_u32); found opaque type `impl Foo` error[E0308]: mismatched types - --> $DIR/equality2.rs:31:18 + --> $DIR/equality2.rs:33:18 | LL | fn hide<T: Foo>(x: T) -> impl Foo { | -------- the found opaque type @@ -41,7 +41,7 @@ LL | fn hide<T: Foo>(x: T) -> impl Foo<T = i32> { | +++++++++ error[E0308]: mismatched types - --> $DIR/equality2.rs:38:10 + --> $DIR/equality2.rs:40:10 | LL | fn hide<T: Foo>(x: T) -> impl Foo { | -------- @@ -57,7 +57,7 @@ LL | x = (x.1, = note: distinct uses of `impl Trait` result in different opaque types error[E0308]: mismatched types - --> $DIR/equality2.rs:41:10 + --> $DIR/equality2.rs:43:10 | LL | fn hide<T: Foo>(x: T) -> impl Foo { | -------- diff --git a/tests/ui/impl-trait/in-trait/cycle-if-impl-doesnt-apply.rs b/tests/ui/impl-trait/in-trait/cycle-if-impl-doesnt-apply.rs new file mode 100644 index 00000000000..72e08ed3504 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/cycle-if-impl-doesnt-apply.rs @@ -0,0 +1,32 @@ +//@ check-pass +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@ edition: 2024 + +// Regression test for <https://github.com/rust-lang/trait-system-refactor-initiative/issues/185>. +// Avoid unnecessarily computing the RPITIT type of the first impl when checking the WF of the +// second impl, since the first impl relies on the hidden type of the second impl. + +trait Foo { + fn call(self) -> impl Send; +} + +trait Nested {} +impl<T> Foo for T +where + T: Nested, +{ + fn call(self) -> impl Sized { + NotSatisfied.call() + } +} + +struct NotSatisfied; +impl Foo for NotSatisfied { + fn call(self) -> impl Sized { + todo!() + } +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-4.rs b/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-4.rs new file mode 100644 index 00000000000..1ee3bfd1233 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-4.rs @@ -0,0 +1,23 @@ +trait ServerFn { + type Output; + fn run_body() -> impl Sized; +} +struct MyServerFn {} + +macro_rules! f { + () => { + impl ServerFn for MyServerFn { + type Output = (); + fn run_body() -> impl Sized {} + } + }; +} + +f! {} + +fn problem<T: ServerFn<Output = i64>>(_: T) {} + +fn main() { + problem(MyServerFn {}); + //~^ ERROR type mismatch resolving `<MyServerFn as ServerFn>::Output == i64` +} diff --git a/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-4.stderr b/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-4.stderr new file mode 100644 index 00000000000..b4c022d3521 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-4.stderr @@ -0,0 +1,26 @@ +error[E0271]: type mismatch resolving `<MyServerFn as ServerFn>::Output == i64` + --> $DIR/dont-probe-missing-item-name-4.rs:21:13 + | +LL | problem(MyServerFn {}); + | ------- ^^^^^^^^^^^^^ type mismatch resolving `<MyServerFn as ServerFn>::Output == i64` + | | + | required by a bound introduced by this call + | +note: expected this to be `i64` + --> $DIR/dont-probe-missing-item-name-4.rs:10:27 + | +LL | type Output = (); + | ^^ +... +LL | f! {} + | ----- in this macro invocation +note: required by a bound in `problem` + --> $DIR/dont-probe-missing-item-name-4.rs:18:24 + | +LL | fn problem<T: ServerFn<Output = i64>>(_: T) {} + | ^^^^^^^^^^^^ required by this bound in `problem` + = note: this error originates in the macro `f` (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 E0271`. diff --git a/tests/ui/impl-trait/no-method-suggested-traits.rs b/tests/ui/impl-trait/no-method-suggested-traits.rs index 6fc96f27a67..5a9361310c3 100644 --- a/tests/ui/impl-trait/no-method-suggested-traits.rs +++ b/tests/ui/impl-trait/no-method-suggested-traits.rs @@ -1,4 +1,6 @@ //@ aux-build:no_method_suggested_traits.rs +//@ dont-require-annotations: HELP + extern crate no_method_suggested_traits; struct Foo; @@ -22,9 +24,9 @@ fn main() { 1u32.method(); //~^ ERROR no method named - //~|items from traits can only be used if the trait is in scope + //~| HELP items from traits can only be used if the trait is in scope std::rc::Rc::new(&mut Box::new(&1u32)).method(); - //~^items from traits can only be used if the trait is in scope + //~^ HELP items from traits can only be used if the trait is in scope //~| ERROR no method named `method` found for struct 'a'.method(); diff --git a/tests/ui/impl-trait/no-method-suggested-traits.stderr b/tests/ui/impl-trait/no-method-suggested-traits.stderr index 0a974668188..64202513ae2 100644 --- a/tests/ui/impl-trait/no-method-suggested-traits.stderr +++ b/tests/ui/impl-trait/no-method-suggested-traits.stderr @@ -1,5 +1,5 @@ error[E0599]: no method named `method` found for type `u32` in the current scope - --> $DIR/no-method-suggested-traits.rs:23:10 + --> $DIR/no-method-suggested-traits.rs:25:10 | LL | 1u32.method(); | ^^^^^^ @@ -21,7 +21,7 @@ LL | 1u32.method2(); | + error[E0599]: no method named `method` found for struct `Rc<&mut Box<&u32>>` in the current scope - --> $DIR/no-method-suggested-traits.rs:26:44 + --> $DIR/no-method-suggested-traits.rs:28:44 | LL | std::rc::Rc::new(&mut Box::new(&1u32)).method(); | ^^^^^^ @@ -43,7 +43,7 @@ LL | std::rc::Rc::new(&mut Box::new(&1u32)).method2(); | + error[E0599]: no method named `method` found for type `char` in the current scope - --> $DIR/no-method-suggested-traits.rs:30:9 + --> $DIR/no-method-suggested-traits.rs:32:9 | LL | fn method(&self) {} | ------ the method is available for `char` here @@ -62,7 +62,7 @@ LL | 'a'.method2(); | + error[E0599]: no method named `method` found for struct `Rc<&mut Box<&char>>` in the current scope - --> $DIR/no-method-suggested-traits.rs:32:43 + --> $DIR/no-method-suggested-traits.rs:34:43 | LL | std::rc::Rc::new(&mut Box::new(&'a')).method(); | ^^^^^^ @@ -78,7 +78,7 @@ LL | std::rc::Rc::new(&mut Box::new(&'a')).method2(); | + error[E0599]: no method named `method` found for type `i32` in the current scope - --> $DIR/no-method-suggested-traits.rs:35:10 + --> $DIR/no-method-suggested-traits.rs:37:10 | LL | 1i32.method(); | ^^^^^^ @@ -99,7 +99,7 @@ LL | 1i32.method3(); | + error[E0599]: no method named `method` found for struct `Rc<&mut Box<&i32>>` in the current scope - --> $DIR/no-method-suggested-traits.rs:37:44 + --> $DIR/no-method-suggested-traits.rs:39:44 | LL | std::rc::Rc::new(&mut Box::new(&1i32)).method(); | ^^^^^^ @@ -115,7 +115,7 @@ LL | std::rc::Rc::new(&mut Box::new(&1i32)).method3(); | + error[E0599]: no method named `method` found for struct `Foo` in the current scope - --> $DIR/no-method-suggested-traits.rs:40:9 + --> $DIR/no-method-suggested-traits.rs:42:9 | LL | struct Foo; | ---------- method `method` not found for this struct @@ -131,7 +131,7 @@ LL | Foo.method(); candidate #4: `no_method_suggested_traits::qux::PrivPub` error[E0599]: no method named `method` found for struct `Rc<&mut Box<&Foo>>` in the current scope - --> $DIR/no-method-suggested-traits.rs:42:43 + --> $DIR/no-method-suggested-traits.rs:44:43 | LL | std::rc::Rc::new(&mut Box::new(&Foo)).method(); | ^^^^^^ method not found in `Rc<&mut Box<&Foo>>` @@ -144,85 +144,85 @@ LL | std::rc::Rc::new(&mut Box::new(&Foo)).method(); candidate #4: `no_method_suggested_traits::qux::PrivPub` error[E0599]: no method named `method2` found for type `u64` in the current scope - --> $DIR/no-method-suggested-traits.rs:45:10 + --> $DIR/no-method-suggested-traits.rs:47:10 | LL | 1u64.method2(); | ^^^^^^^ method not found in `u64` | = help: items from traits can only be used if the trait is implemented and in scope note: `foo::Bar` defines an item `method2`, perhaps you need to implement it - --> $DIR/no-method-suggested-traits.rs:8:5 + --> $DIR/no-method-suggested-traits.rs:10:5 | LL | pub trait Bar { | ^^^^^^^^^^^^^ error[E0599]: no method named `method2` found for struct `Rc<&mut Box<&u64>>` in the current scope - --> $DIR/no-method-suggested-traits.rs:47:44 + --> $DIR/no-method-suggested-traits.rs:49:44 | LL | std::rc::Rc::new(&mut Box::new(&1u64)).method2(); | ^^^^^^^ method not found in `Rc<&mut Box<&u64>>` | = help: items from traits can only be used if the trait is implemented and in scope note: `foo::Bar` defines an item `method2`, perhaps you need to implement it - --> $DIR/no-method-suggested-traits.rs:8:5 + --> $DIR/no-method-suggested-traits.rs:10:5 | LL | pub trait Bar { | ^^^^^^^^^^^^^ error[E0599]: no method named `method2` found for struct `no_method_suggested_traits::Foo` in the current scope - --> $DIR/no-method-suggested-traits.rs:50:37 + --> $DIR/no-method-suggested-traits.rs:52:37 | LL | no_method_suggested_traits::Foo.method2(); | ^^^^^^^ method not found in `Foo` | = help: items from traits can only be used if the trait is implemented and in scope note: `foo::Bar` defines an item `method2`, perhaps you need to implement it - --> $DIR/no-method-suggested-traits.rs:8:5 + --> $DIR/no-method-suggested-traits.rs:10:5 | LL | pub trait Bar { | ^^^^^^^^^^^^^ error[E0599]: no method named `method2` found for struct `Rc<&mut Box<&no_method_suggested_traits::Foo>>` in the current scope - --> $DIR/no-method-suggested-traits.rs:52:71 + --> $DIR/no-method-suggested-traits.rs:54:71 | LL | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Foo)).method2(); | ^^^^^^^ method not found in `Rc<&mut Box<&Foo>>` | = help: items from traits can only be used if the trait is implemented and in scope note: `foo::Bar` defines an item `method2`, perhaps you need to implement it - --> $DIR/no-method-suggested-traits.rs:8:5 + --> $DIR/no-method-suggested-traits.rs:10:5 | LL | pub trait Bar { | ^^^^^^^^^^^^^ error[E0599]: no method named `method2` found for enum `no_method_suggested_traits::Bar` in the current scope - --> $DIR/no-method-suggested-traits.rs:54:40 + --> $DIR/no-method-suggested-traits.rs:56:40 | LL | no_method_suggested_traits::Bar::X.method2(); | ^^^^^^^ method not found in `Bar` | = help: items from traits can only be used if the trait is implemented and in scope note: `foo::Bar` defines an item `method2`, perhaps you need to implement it - --> $DIR/no-method-suggested-traits.rs:8:5 + --> $DIR/no-method-suggested-traits.rs:10:5 | LL | pub trait Bar { | ^^^^^^^^^^^^^ error[E0599]: no method named `method2` found for struct `Rc<&mut Box<&no_method_suggested_traits::Bar>>` in the current scope - --> $DIR/no-method-suggested-traits.rs:56:74 + --> $DIR/no-method-suggested-traits.rs:58:74 | LL | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Bar::X)).method2(); | ^^^^^^^ method not found in `Rc<&mut Box<&Bar>>` | = help: items from traits can only be used if the trait is implemented and in scope note: `foo::Bar` defines an item `method2`, perhaps you need to implement it - --> $DIR/no-method-suggested-traits.rs:8:5 + --> $DIR/no-method-suggested-traits.rs:10:5 | LL | pub trait Bar { | ^^^^^^^^^^^^^ error[E0599]: no method named `method3` found for struct `Foo` in the current scope - --> $DIR/no-method-suggested-traits.rs:59:9 + --> $DIR/no-method-suggested-traits.rs:61:9 | LL | struct Foo; | ---------- method `method3` not found for this struct @@ -235,7 +235,7 @@ LL | Foo.method3(); candidate #1: `PubPub` error[E0599]: no method named `method3` found for struct `Rc<&mut Box<&Foo>>` in the current scope - --> $DIR/no-method-suggested-traits.rs:61:43 + --> $DIR/no-method-suggested-traits.rs:63:43 | LL | std::rc::Rc::new(&mut Box::new(&Foo)).method3(); | ^^^^^^^ method not found in `Rc<&mut Box<&Foo>>` @@ -245,7 +245,7 @@ LL | std::rc::Rc::new(&mut Box::new(&Foo)).method3(); candidate #1: `PubPub` error[E0599]: no method named `method3` found for enum `Bar` in the current scope - --> $DIR/no-method-suggested-traits.rs:63:12 + --> $DIR/no-method-suggested-traits.rs:65:12 | LL | enum Bar { X } | -------- method `method3` not found for this enum @@ -258,7 +258,7 @@ LL | Bar::X.method3(); candidate #1: `PubPub` error[E0599]: no method named `method3` found for struct `Rc<&mut Box<&Bar>>` in the current scope - --> $DIR/no-method-suggested-traits.rs:65:46 + --> $DIR/no-method-suggested-traits.rs:67:46 | LL | std::rc::Rc::new(&mut Box::new(&Bar::X)).method3(); | ^^^^^^^ method not found in `Rc<&mut Box<&Bar>>` @@ -268,37 +268,37 @@ LL | std::rc::Rc::new(&mut Box::new(&Bar::X)).method3(); candidate #1: `PubPub` error[E0599]: no method named `method3` found for type `usize` in the current scope - --> $DIR/no-method-suggested-traits.rs:69:13 + --> $DIR/no-method-suggested-traits.rs:71:13 | LL | 1_usize.method3(); | ^^^^^^^ method not found in `usize` error[E0599]: no method named `method3` found for struct `Rc<&mut Box<&usize>>` in the current scope - --> $DIR/no-method-suggested-traits.rs:70:47 + --> $DIR/no-method-suggested-traits.rs:72:47 | LL | std::rc::Rc::new(&mut Box::new(&1_usize)).method3(); | ^^^^^^^ method not found in `Rc<&mut Box<&usize>>` error[E0599]: no method named `method3` found for struct `no_method_suggested_traits::Foo` in the current scope - --> $DIR/no-method-suggested-traits.rs:71:37 + --> $DIR/no-method-suggested-traits.rs:73:37 | LL | no_method_suggested_traits::Foo.method3(); | ^^^^^^^ method not found in `Foo` error[E0599]: no method named `method3` found for struct `Rc<&mut Box<&no_method_suggested_traits::Foo>>` in the current scope - --> $DIR/no-method-suggested-traits.rs:72:71 + --> $DIR/no-method-suggested-traits.rs:74:71 | LL | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Foo)).method3(); | ^^^^^^^ method not found in `Rc<&mut Box<&Foo>>` error[E0599]: no method named `method3` found for enum `no_method_suggested_traits::Bar` in the current scope - --> $DIR/no-method-suggested-traits.rs:74:40 + --> $DIR/no-method-suggested-traits.rs:76:40 | LL | no_method_suggested_traits::Bar::X.method3(); | ^^^^^^^ method not found in `Bar` error[E0599]: no method named `method3` found for struct `Rc<&mut Box<&no_method_suggested_traits::Bar>>` in the current scope - --> $DIR/no-method-suggested-traits.rs:75:74 + --> $DIR/no-method-suggested-traits.rs:77:74 | LL | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Bar::X)).method3(); | ^^^^^^^ method not found in `Rc<&mut Box<&Bar>>` diff --git a/tests/ui/impl-trait/non-defining-uses/double-wrap-with-defining-use.rs b/tests/ui/impl-trait/non-defining-uses/double-wrap-with-defining-use.rs new file mode 100644 index 00000000000..339277fec37 --- /dev/null +++ b/tests/ui/impl-trait/non-defining-uses/double-wrap-with-defining-use.rs @@ -0,0 +1,12 @@ +// Regression test for ICE from issue #140545 +// The error message is confusing and wrong, but that's a different problem (#139350) +//@ edition:2018 + +trait Foo {} +fn a(x: impl Foo) -> impl Foo { + if true { x } else { a(a(x)) } + //~^ ERROR: expected generic type parameter, found `impl Foo` [E0792] + //~| ERROR: type parameter `impl Foo` is part of concrete type but not used in parameter list for the `impl Trait` type alias +} + +fn main(){} diff --git a/tests/ui/impl-trait/non-defining-uses/double-wrap-with-defining-use.stderr b/tests/ui/impl-trait/non-defining-uses/double-wrap-with-defining-use.stderr new file mode 100644 index 00000000000..1b02811e31b --- /dev/null +++ b/tests/ui/impl-trait/non-defining-uses/double-wrap-with-defining-use.stderr @@ -0,0 +1,17 @@ +error[E0792]: expected generic type parameter, found `impl Foo` + --> $DIR/double-wrap-with-defining-use.rs:7:26 + | +LL | fn a(x: impl Foo) -> impl Foo { + | -------- this generic parameter must be used with a generic type parameter +LL | if true { x } else { a(a(x)) } + | ^^^^^^^ + +error: type parameter `impl Foo` is part of concrete type but not used in parameter list for the `impl Trait` type alias + --> $DIR/double-wrap-with-defining-use.rs:7:26 + | +LL | if true { x } else { a(a(x)) } + | ^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/implied-bounds/sod_service_chain.rs b/tests/ui/implied-bounds/sod_service_chain.rs index 73dce2fce24..df1d430b37b 100644 --- a/tests/ui/implied-bounds/sod_service_chain.rs +++ b/tests/ui/implied-bounds/sod_service_chain.rs @@ -1,5 +1,7 @@ // Found in a crater run on #118553 +//@ dont-require-annotations: NOTE + pub trait Debug {} pub trait Service { @@ -30,16 +32,16 @@ impl<P: Service, S: Service<Input = P::Output>> ServiceChainBuilder<P, S> { //~^ ERROR the associated type //~| ERROR the associated type //~| ERROR the associated type - //~| the associated type - //~| the associated type - //~| the associated type + //~| NOTE the associated type + //~| NOTE the associated type + //~| NOTE the associated type //~| ERROR may not live long enough self, ) -> ServiceChainBuilder<ServiceChain<P, S>, NS> { //~^ ERROR the associated type //~| ERROR the associated type - //~| the associated type - //~| the associated type + //~| NOTE the associated type + //~| NOTE the associated type panic!(); } } diff --git a/tests/ui/implied-bounds/sod_service_chain.stderr b/tests/ui/implied-bounds/sod_service_chain.stderr index f5221fc1105..a3cc131d235 100644 --- a/tests/ui/implied-bounds/sod_service_chain.stderr +++ b/tests/ui/implied-bounds/sod_service_chain.stderr @@ -1,5 +1,5 @@ error[E0310]: the associated type `<P as Service>::Error` may not live long enough - --> $DIR/sod_service_chain.rs:29:5 + --> $DIR/sod_service_chain.rs:31:5 | LL | / pub fn next<NS: Service<Input = S::Output>>( ... | @@ -16,7 +16,7 @@ LL | ) -> ServiceChainBuilder<ServiceChain<P, S>, NS> where <P as Service>:: | ++++++++++++++++++++++++++++++++++++ error[E0310]: the associated type `<S as Service>::Error` may not live long enough - --> $DIR/sod_service_chain.rs:29:5 + --> $DIR/sod_service_chain.rs:31:5 | LL | / pub fn next<NS: Service<Input = S::Output>>( ... | @@ -33,7 +33,7 @@ LL | ) -> ServiceChainBuilder<ServiceChain<P, S>, NS> where <S as Service>:: | ++++++++++++++++++++++++++++++++++++ error[E0310]: the associated type `<P as Service>::Error` may not live long enough - --> $DIR/sod_service_chain.rs:38:10 + --> $DIR/sod_service_chain.rs:40:10 | LL | ) -> ServiceChainBuilder<ServiceChain<P, S>, NS> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -47,7 +47,7 @@ LL | ) -> ServiceChainBuilder<ServiceChain<P, S>, NS> where <P as Service>:: | ++++++++++++++++++++++++++++++++++++ error[E0310]: the associated type `<S as Service>::Error` may not live long enough - --> $DIR/sod_service_chain.rs:38:10 + --> $DIR/sod_service_chain.rs:40:10 | LL | ) -> ServiceChainBuilder<ServiceChain<P, S>, NS> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL | ) -> ServiceChainBuilder<ServiceChain<P, S>, NS> where <S as Service>:: | ++++++++++++++++++++++++++++++++++++ error[E0310]: the associated type `<P as Service>::Error` may not live long enough - --> $DIR/sod_service_chain.rs:29:5 + --> $DIR/sod_service_chain.rs:31:5 | LL | / pub fn next<NS: Service<Input = S::Output>>( ... | @@ -79,7 +79,7 @@ LL | ) -> ServiceChainBuilder<ServiceChain<P, S>, NS> where <P as Service>:: | ++++++++++++++++++++++++++++++++++++ error[E0310]: the associated type `<S as Service>::Error` may not live long enough - --> $DIR/sod_service_chain.rs:29:5 + --> $DIR/sod_service_chain.rs:31:5 | LL | / pub fn next<NS: Service<Input = S::Output>>( ... | diff --git a/tests/ui/imports/import.rs b/tests/ui/imports/import.rs index 3170dd2fae1..39a087c7a43 100644 --- a/tests/ui/imports/import.rs +++ b/tests/ui/imports/import.rs @@ -1,6 +1,8 @@ +//@ dont-require-annotations: NOTE + use zed::bar; use zed::baz; //~ ERROR unresolved import `zed::baz` [E0432] - //~| no `baz` in `zed` + //~| NOTE no `baz` in `zed` //~| HELP a similar name exists in the module //~| SUGGESTION bar @@ -8,7 +10,7 @@ use zed::baz; //~ ERROR unresolved import `zed::baz` [E0432] mod zed { pub fn bar() { println!("bar"); } use foo; //~ ERROR unresolved import `foo` [E0432] - //~^ no `foo` in the root + //~^ NOTE no `foo` in the root } fn main() { diff --git a/tests/ui/imports/import.stderr b/tests/ui/imports/import.stderr index 797712e2db9..4dae164991b 100644 --- a/tests/ui/imports/import.stderr +++ b/tests/ui/imports/import.stderr @@ -1,5 +1,5 @@ error[E0432]: unresolved import `zed::baz` - --> $DIR/import.rs:2:5 + --> $DIR/import.rs:4:5 | LL | use zed::baz; | ^^^^^--- @@ -8,19 +8,19 @@ LL | use zed::baz; | no `baz` in `zed` error[E0432]: unresolved import `foo` - --> $DIR/import.rs:10:9 + --> $DIR/import.rs:12:9 | LL | use foo; | ^^^ no `foo` in the root error[E0603]: unresolved item import `foo` is private - --> $DIR/import.rs:15:10 + --> $DIR/import.rs:17:10 | LL | zed::foo(); | ^^^ private unresolved item import | note: the unresolved item import `foo` is defined here - --> $DIR/import.rs:10:9 + --> $DIR/import.rs:12:9 | LL | use foo; | ^^^ diff --git a/tests/ui/imports/issue-19498.rs b/tests/ui/imports/issue-19498.rs index 5fe6742f55e..5b9ce85fd8b 100644 --- a/tests/ui/imports/issue-19498.rs +++ b/tests/ui/imports/issue-19498.rs @@ -1,13 +1,15 @@ +//@ dont-require-annotations: NOTE + use self::A; use self::B; mod A {} //~ ERROR the name `A` is defined multiple times -//~| `A` redefined here +//~| NOTE `A` redefined here pub mod B {} //~ ERROR the name `B` is defined multiple times -//~| `B` redefined here +//~| NOTE `B` redefined here mod C { use C::D; mod D {} //~ ERROR the name `D` is defined multiple times - //~| `D` redefined here + //~| NOTE `D` redefined here } fn main() {} diff --git a/tests/ui/imports/issue-19498.stderr b/tests/ui/imports/issue-19498.stderr index 69bdb67d389..eb0d68a24c9 100644 --- a/tests/ui/imports/issue-19498.stderr +++ b/tests/ui/imports/issue-19498.stderr @@ -1,5 +1,5 @@ error[E0255]: the name `A` is defined multiple times - --> $DIR/issue-19498.rs:3:1 + --> $DIR/issue-19498.rs:5:1 | LL | use self::A; | ------- previous import of the module `A` here @@ -14,7 +14,7 @@ LL | use self::A as OtherA; | +++++++++ error[E0255]: the name `B` is defined multiple times - --> $DIR/issue-19498.rs:5:1 + --> $DIR/issue-19498.rs:7:1 | LL | use self::B; | ------- previous import of the module `B` here @@ -29,7 +29,7 @@ LL | use self::B as OtherB; | +++++++++ error[E0255]: the name `D` is defined multiple times - --> $DIR/issue-19498.rs:9:5 + --> $DIR/issue-19498.rs:11:5 | LL | use C::D; | ---- previous import of the module `D` here diff --git a/tests/ui/imports/issue-24081.rs b/tests/ui/imports/issue-24081.rs index 10983ce11b5..561bbb067b8 100644 --- a/tests/ui/imports/issue-24081.rs +++ b/tests/ui/imports/issue-24081.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + use std::ops::Add; use std::ops::Sub; use std::ops::Mul; @@ -5,14 +7,14 @@ use std::ops::Div; use std::ops::Rem; type Add = bool; //~ ERROR the name `Add` is defined multiple times -//~| `Add` redefined here +//~| NOTE `Add` redefined here struct Sub { x: f32 } //~ ERROR the name `Sub` is defined multiple times -//~| `Sub` redefined here +//~| NOTE `Sub` redefined here enum Mul { A, B } //~ ERROR the name `Mul` is defined multiple times -//~| `Mul` redefined here +//~| NOTE `Mul` redefined here mod Div { } //~ ERROR the name `Div` is defined multiple times -//~| `Div` redefined here +//~| NOTE `Div` redefined here trait Rem { } //~ ERROR the name `Rem` is defined multiple times -//~| `Rem` redefined here +//~| NOTE `Rem` redefined here fn main() {} diff --git a/tests/ui/imports/issue-24081.stderr b/tests/ui/imports/issue-24081.stderr index 6ceba6c7013..c2346f524ce 100644 --- a/tests/ui/imports/issue-24081.stderr +++ b/tests/ui/imports/issue-24081.stderr @@ -1,5 +1,5 @@ error[E0255]: the name `Add` is defined multiple times - --> $DIR/issue-24081.rs:7:1 + --> $DIR/issue-24081.rs:9:1 | LL | use std::ops::Add; | ------------- previous import of the trait `Add` here @@ -14,7 +14,7 @@ LL | use std::ops::Add as OtherAdd; | +++++++++++ error[E0255]: the name `Sub` is defined multiple times - --> $DIR/issue-24081.rs:9:1 + --> $DIR/issue-24081.rs:11:1 | LL | use std::ops::Sub; | ------------- previous import of the trait `Sub` here @@ -29,7 +29,7 @@ LL | use std::ops::Sub as OtherSub; | +++++++++++ error[E0255]: the name `Mul` is defined multiple times - --> $DIR/issue-24081.rs:11:1 + --> $DIR/issue-24081.rs:13:1 | LL | use std::ops::Mul; | ------------- previous import of the trait `Mul` here @@ -44,7 +44,7 @@ LL | use std::ops::Mul as OtherMul; | +++++++++++ error[E0255]: the name `Div` is defined multiple times - --> $DIR/issue-24081.rs:13:1 + --> $DIR/issue-24081.rs:15:1 | LL | use std::ops::Div; | ------------- previous import of the trait `Div` here @@ -59,7 +59,7 @@ LL | use std::ops::Div as OtherDiv; | +++++++++++ error[E0255]: the name `Rem` is defined multiple times - --> $DIR/issue-24081.rs:15:1 + --> $DIR/issue-24081.rs:17:1 | LL | use std::ops::Rem; | ------------- previous import of the trait `Rem` here diff --git a/tests/ui/imports/issue-26886.rs b/tests/ui/imports/issue-26886.rs index 6e6d406c656..91be86ae774 100644 --- a/tests/ui/imports/issue-26886.rs +++ b/tests/ui/imports/issue-26886.rs @@ -1,8 +1,10 @@ +//@ dont-require-annotations: NOTE + use std::sync::{self, Arc}; use std::sync::Arc; //~ ERROR the name `Arc` is defined multiple times - //~| `Arc` must be defined only once in the type namespace of this module + //~| NOTE `Arc` must be defined only once in the type namespace of this module use std::sync; //~ ERROR the name `sync` is defined multiple times - //~| `sync` must be defined only once in the type namespace of this module + //~| NOTE `sync` must be defined only once in the type namespace of this module fn main() { } diff --git a/tests/ui/imports/issue-26886.stderr b/tests/ui/imports/issue-26886.stderr index e2b925ec5a7..a6143543446 100644 --- a/tests/ui/imports/issue-26886.stderr +++ b/tests/ui/imports/issue-26886.stderr @@ -1,5 +1,5 @@ error[E0252]: the name `Arc` is defined multiple times - --> $DIR/issue-26886.rs:2:5 + --> $DIR/issue-26886.rs:4:5 | LL | use std::sync::{self, Arc}; | --- previous import of the type `Arc` here @@ -9,7 +9,7 @@ LL | use std::sync::Arc; = note: `Arc` must be defined only once in the type namespace of this module error[E0252]: the name `sync` is defined multiple times - --> $DIR/issue-26886.rs:4:5 + --> $DIR/issue-26886.rs:6:5 | LL | use std::sync::{self, Arc}; | ---- previous import of the module `sync` here diff --git a/tests/ui/imports/issue-30560.rs b/tests/ui/imports/issue-30560.rs index d8d4ca608f1..fe5d17c1873 100644 --- a/tests/ui/imports/issue-30560.rs +++ b/tests/ui/imports/issue-30560.rs @@ -3,7 +3,4 @@ use Alias::*; //~ ERROR unresolved import `Alias` [E0432] use std::io::Result::*; //~ ERROR unresolved import `std::io::Result` [E0432] -trait T {} -use T::*; //~ ERROR items in traits are not importable - fn main() {} diff --git a/tests/ui/imports/issue-30560.stderr b/tests/ui/imports/issue-30560.stderr index 69cfd4c06a8..89492261cba 100644 --- a/tests/ui/imports/issue-30560.stderr +++ b/tests/ui/imports/issue-30560.stderr @@ -1,9 +1,3 @@ -error: items in traits are not importable - --> $DIR/issue-30560.rs:7:5 - | -LL | use T::*; - | ^^^^ - error[E0432]: unresolved import `Alias` --> $DIR/issue-30560.rs:2:5 | @@ -16,6 +10,6 @@ error[E0432]: unresolved import `std::io::Result` LL | use std::io::Result::*; | ^^^^^^ `Result` is a type alias, not a module -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/inference/tutorial-suffix-inference-test.rs b/tests/ui/inference/tutorial-suffix-inference-test.rs index 849adfd5368..ca593ff1b70 100644 --- a/tests/ui/inference/tutorial-suffix-inference-test.rs +++ b/tests/ui/inference/tutorial-suffix-inference-test.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + fn main() { let x = 3; let y: i32 = 3; @@ -8,10 +10,10 @@ fn main() { identity_u8(x); // after this, `x` is assumed to have type `u8` identity_u16(x); //~^ ERROR mismatched types - //~| expected `u16`, found `u8` + //~| NOTE expected `u16`, found `u8` identity_u16(y); //~^ ERROR mismatched types - //~| expected `u16`, found `i32` + //~| NOTE expected `u16`, found `i32` let a = 3; @@ -20,5 +22,5 @@ fn main() { identity_i(a); // ok identity_u16(a); //~^ ERROR mismatched types - //~| expected `u16`, found `isize` + //~| NOTE expected `u16`, found `isize` } diff --git a/tests/ui/inference/tutorial-suffix-inference-test.stderr b/tests/ui/inference/tutorial-suffix-inference-test.stderr index d83a1367dbf..39627aa9fc4 100644 --- a/tests/ui/inference/tutorial-suffix-inference-test.stderr +++ b/tests/ui/inference/tutorial-suffix-inference-test.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/tutorial-suffix-inference-test.rs:9:18 + --> $DIR/tutorial-suffix-inference-test.rs:11:18 | LL | identity_u16(x); | ------------ ^ expected `u16`, found `u8` @@ -7,7 +7,7 @@ LL | identity_u16(x); | arguments to this function are incorrect | note: function defined here - --> $DIR/tutorial-suffix-inference-test.rs:6:8 + --> $DIR/tutorial-suffix-inference-test.rs:8:8 | LL | fn identity_u16(n: u16) -> u16 { n } | ^^^^^^^^^^^^ ------ @@ -17,7 +17,7 @@ LL | identity_u16(x.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/tutorial-suffix-inference-test.rs:12:18 + --> $DIR/tutorial-suffix-inference-test.rs:14:18 | LL | identity_u16(y); | ------------ ^ expected `u16`, found `i32` @@ -25,7 +25,7 @@ LL | identity_u16(y); | arguments to this function are incorrect | note: function defined here - --> $DIR/tutorial-suffix-inference-test.rs:6:8 + --> $DIR/tutorial-suffix-inference-test.rs:8:8 | LL | fn identity_u16(n: u16) -> u16 { n } | ^^^^^^^^^^^^ ------ @@ -35,7 +35,7 @@ LL | identity_u16(y.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/tutorial-suffix-inference-test.rs:21:18 + --> $DIR/tutorial-suffix-inference-test.rs:23:18 | LL | identity_u16(a); | ------------ ^ expected `u16`, found `isize` @@ -43,7 +43,7 @@ LL | identity_u16(a); | arguments to this function are incorrect | note: function defined here - --> $DIR/tutorial-suffix-inference-test.rs:6:8 + --> $DIR/tutorial-suffix-inference-test.rs:8:8 | LL | fn identity_u16(n: u16) -> u16 { n } | ^^^^^^^^^^^^ ------ diff --git a/tests/ui/invalid-compile-flags/emit-output-types-without-args.stderr b/tests/ui/invalid-compile-flags/emit-output-types-without-args.stderr index 669913b5765..9e4486a272f 100644 --- a/tests/ui/invalid-compile-flags/emit-output-types-without-args.stderr +++ b/tests/ui/invalid-compile-flags/emit-output-types-without-args.stderr @@ -1,6 +1,7 @@ error: Argument to option 'emit' missing Usage: - --emit TYPE[=FILE] Comma separated list of types of output for the + --emit <TYPE>[=<FILE>] + Comma separated list of types of output for the compiler to emit. Each TYPE has the default FILE name: * asm - CRATE_NAME.s diff --git a/tests/ui/invalid-compile-flags/print-without-arg.stderr b/tests/ui/invalid-compile-flags/print-without-arg.stderr index fd2a36e761b..3048a59d0d0 100644 --- a/tests/ui/invalid-compile-flags/print-without-arg.stderr +++ b/tests/ui/invalid-compile-flags/print-without-arg.stderr @@ -1,6 +1,7 @@ error: Argument to option 'print' missing Usage: - --print INFO[=FILE] Compiler information to print on stdout (or to a file) + --print <INFO>[=<FILE>] + Compiler information to print on stdout (or to a file) INFO may be one of - (all-target-specs-json|calling-conventions|cfg|check-cfg|code-models|crate-name|crate-root-lint-levels|deployment-target|file-names|host-tuple|link-args|native-static-libs|relocation-models|split-debuginfo|stack-protector-strategies|supported-crate-types|sysroot|target-cpus|target-features|target-libdir|target-list|target-spec-json|tls-models). + <all-target-specs-json|calling-conventions|cfg|check-cfg|code-models|crate-name|crate-root-lint-levels|deployment-target|file-names|host-tuple|link-args|native-static-libs|relocation-models|split-debuginfo|stack-protector-strategies|supported-crate-types|sysroot|target-cpus|target-features|target-libdir|target-list|target-spec-json|tls-models>. diff --git a/tests/ui/issues/issue-13359.rs b/tests/ui/issues/issue-13359.rs index 9129790c501..5d31d7f861c 100644 --- a/tests/ui/issues/issue-13359.rs +++ b/tests/ui/issues/issue-13359.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + fn foo(_s: i16) { } fn bar(_s: u32) { } @@ -5,9 +7,9 @@ fn bar(_s: u32) { } fn main() { foo(1*(1 as isize)); //~^ ERROR mismatched types - //~| expected `i16`, found `isize` + //~| NOTE expected `i16`, found `isize` bar(1*(1 as usize)); //~^ ERROR mismatched types - //~| expected `u32`, found `usize` + //~| NOTE expected `u32`, found `usize` } diff --git a/tests/ui/issues/issue-13359.stderr b/tests/ui/issues/issue-13359.stderr index fef63680a86..91f5de8e8f3 100644 --- a/tests/ui/issues/issue-13359.stderr +++ b/tests/ui/issues/issue-13359.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-13359.rs:6:9 + --> $DIR/issue-13359.rs:8:9 | LL | foo(1*(1 as isize)); | --- ^^^^^^^^^^^^^^ expected `i16`, found `isize` @@ -7,7 +7,7 @@ LL | foo(1*(1 as isize)); | arguments to this function are incorrect | note: function defined here - --> $DIR/issue-13359.rs:1:4 + --> $DIR/issue-13359.rs:3:4 | LL | fn foo(_s: i16) { } | ^^^ ------- @@ -17,7 +17,7 @@ LL | foo((1*(1 as isize)).try_into().unwrap()); | + +++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/issue-13359.rs:10:9 + --> $DIR/issue-13359.rs:12:9 | LL | bar(1*(1 as usize)); | --- ^^^^^^^^^^^^^^ expected `u32`, found `usize` @@ -25,7 +25,7 @@ LL | bar(1*(1 as usize)); | arguments to this function are incorrect | note: function defined here - --> $DIR/issue-13359.rs:3:4 + --> $DIR/issue-13359.rs:5:4 | LL | fn bar(_s: u32) { } | ^^^ ------- diff --git a/tests/ui/issues/issue-13466.rs b/tests/ui/issues/issue-13466.rs index 52d4d75d29d..78ce4c1d2f6 100644 --- a/tests/ui/issues/issue-13466.rs +++ b/tests/ui/issues/issue-13466.rs @@ -1,5 +1,7 @@ // Regression test for #13466 +//@ dont-require-annotations: NOTE + pub fn main() { // The expected arm type `Option<T>` has one type parameter, while // the actual arm `Result<T, E>` has two. typeck should not be @@ -7,14 +9,14 @@ pub fn main() { let _x: usize = match Some(1) { Ok(u) => u, //~^ ERROR mismatched types - //~| expected enum `Option<{integer}>` - //~| found enum `Result<_, _>` - //~| expected `Option<{integer}>`, found `Result<_, _>` + //~| NOTE expected enum `Option<{integer}>` + //~| NOTE found enum `Result<_, _>` + //~| NOTE expected `Option<{integer}>`, found `Result<_, _>` Err(e) => panic!(e) //~^ ERROR mismatched types - //~| expected enum `Option<{integer}>` - //~| found enum `Result<_, _>` - //~| expected `Option<{integer}>`, found `Result<_, _>` + //~| NOTE expected enum `Option<{integer}>` + //~| NOTE found enum `Result<_, _>` + //~| NOTE expected `Option<{integer}>`, found `Result<_, _>` }; } diff --git a/tests/ui/issues/issue-13466.stderr b/tests/ui/issues/issue-13466.stderr index fd928e45863..68a555a1626 100644 --- a/tests/ui/issues/issue-13466.stderr +++ b/tests/ui/issues/issue-13466.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-13466.rs:8:9 + --> $DIR/issue-13466.rs:10:9 | LL | let _x: usize = match Some(1) { | ------- this expression has type `Option<{integer}>` @@ -10,7 +10,7 @@ LL | Ok(u) => u, found enum `Result<_, _>` error[E0308]: mismatched types - --> $DIR/issue-13466.rs:14:9 + --> $DIR/issue-13466.rs:16:9 | LL | let _x: usize = match Some(1) { | ------- this expression has type `Option<{integer}>` diff --git a/tests/ui/issues/issue-14541.rs b/tests/ui/issues/issue-14541.rs index 2ff1c1f8876..358d29419f9 100644 --- a/tests/ui/issues/issue-14541.rs +++ b/tests/ui/issues/issue-14541.rs @@ -4,7 +4,8 @@ struct Vec3 { y: f32, z: f32 } fn make(v: Vec2) { let Vec3 { y: _, z: _ } = v; //~^ ERROR mismatched types - //~| expected `Vec2`, found `Vec3` + //~| NOTE expected `Vec2`, found `Vec3` + //~| NOTE this expression has type `Vec2` } fn main() { } diff --git a/tests/ui/issues/issue-15094.rs b/tests/ui/issues/issue-15094.rs index cb27e2bcfb6..408ab82eb8c 100644 --- a/tests/ui/issues/issue-15094.rs +++ b/tests/ui/issues/issue-15094.rs @@ -10,8 +10,9 @@ impl<T: fmt::Debug> ops::FnOnce<(),> for Debuger<T> { type Output = (); fn call_once(self, _args: ()) { //~^ ERROR `call_once` has an incompatible type for trait - //~| expected signature `extern "rust-call" fn - //~| found signature `fn + //~| NOTE expected signature `extern "rust-call" fn + //~| NOTE found signature `fn + //~| NOTE expected "rust-call" fn, found "Rust" fn println!("{:?}", self.x); } } diff --git a/tests/ui/issues/issue-15381.rs b/tests/ui/issues/issue-15381.rs index 23b266bef1d..bd5f62ddc67 100644 --- a/tests/ui/issues/issue-15381.rs +++ b/tests/ui/issues/issue-15381.rs @@ -3,7 +3,8 @@ fn main() { for &[x,y,z] in values.chunks(3).filter(|&xs| xs.len() == 3) { //~^ ERROR refutable pattern in `for` loop binding - //~| patterns `&[]`, `&[_]`, `&[_, _]` and 1 more not covered + //~| NOTE patterns `&[]`, `&[_]`, `&[_, _]` and 1 more not covered + //~| NOTE the matched value is of type `&[u8]` println!("y={}", y); } } diff --git a/tests/ui/issues/issue-15783.rs b/tests/ui/issues/issue-15783.rs index ceb37a20e3f..ef948a1a88c 100644 --- a/tests/ui/issues/issue-15783.rs +++ b/tests/ui/issues/issue-15783.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + pub fn foo(params: Option<&[&str]>) -> usize { params.unwrap().first().unwrap().len() } @@ -7,8 +9,8 @@ fn main() { let x = Some(&[name]); let msg = foo(x); //~^ ERROR mismatched types - //~| expected enum `Option<&[&str]>` - //~| found enum `Option<&[&str; 1]>` - //~| expected `Option<&[&str]>`, found `Option<&[&str; 1]>` + //~| NOTE expected enum `Option<&[&str]>` + //~| NOTE found enum `Option<&[&str; 1]>` + //~| NOTE expected `Option<&[&str]>`, found `Option<&[&str; 1]>` assert_eq!(msg, 3); } diff --git a/tests/ui/issues/issue-15783.stderr b/tests/ui/issues/issue-15783.stderr index 7ed2e199130..c9c9a723a86 100644 --- a/tests/ui/issues/issue-15783.stderr +++ b/tests/ui/issues/issue-15783.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-15783.rs:8:19 + --> $DIR/issue-15783.rs:10: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:1:8 + --> $DIR/issue-15783.rs:3:8 | LL | pub fn foo(params: Option<&[&str]>) -> usize { | ^^^ ----------------------- diff --git a/tests/ui/issues/issue-16401.rs b/tests/ui/issues/issue-16401.rs index 19ae7da107c..0985a6806d2 100644 --- a/tests/ui/issues/issue-16401.rs +++ b/tests/ui/issues/issue-16401.rs @@ -4,12 +4,12 @@ struct Slice<T> { } fn main() { - match () { + match () { //~ NOTE this expression has type `()` Slice { data: data, len: len } => (), //~^ ERROR mismatched types - //~| expected unit type `()` - //~| found struct `Slice<_>` - //~| expected `()`, found `Slice<_>` + //~| NOTE expected unit type `()` + //~| NOTE found struct `Slice<_>` + //~| NOTE expected `()`, found `Slice<_>` _ => unreachable!() } } diff --git a/tests/ui/issues/issue-17033.rs b/tests/ui/issues/issue-17033.rs index 72a8cd9823a..b8eec3b6b25 100644 --- a/tests/ui/issues/issue-17033.rs +++ b/tests/ui/issues/issue-17033.rs @@ -1,6 +1,7 @@ fn f<'r>(p: &'r mut fn(p: &mut ())) { (*p)(()) //~ ERROR mismatched types - //~| expected `&mut ()`, found `()` + //~| NOTE expected `&mut ()`, found `()` + //~| NOTE arguments to this function are incorrect } fn main() {} diff --git a/tests/ui/issues/issue-17740.rs b/tests/ui/issues/issue-17740.rs index 574d3662b4f..20a73756ea3 100644 --- a/tests/ui/issues/issue-17740.rs +++ b/tests/ui/issues/issue-17740.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + struct Foo<'a> { data: &'a[u8], } @@ -5,13 +7,13 @@ struct Foo<'a> { impl <'a> Foo<'a>{ fn bar(self: &mut Foo) { //~^ ERROR mismatched `self` parameter type - //~| expected struct `Foo<'a>` - //~| found struct `Foo<'_>` - //~| lifetime mismatch + //~| NOTE expected struct `Foo<'a>` + //~| NOTE found struct `Foo<'_>` + //~| NOTE lifetime mismatch //~| ERROR mismatched `self` parameter type - //~| expected struct `Foo<'a>` - //~| found struct `Foo<'_>` - //~| lifetime mismatch + //~| NOTE expected struct `Foo<'a>` + //~| NOTE found struct `Foo<'_>` + //~| NOTE lifetime mismatch } } diff --git a/tests/ui/issues/issue-17740.stderr b/tests/ui/issues/issue-17740.stderr index d1773804155..198d7d5b37c 100644 --- a/tests/ui/issues/issue-17740.stderr +++ b/tests/ui/issues/issue-17740.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched `self` parameter type - --> $DIR/issue-17740.rs:6:18 + --> $DIR/issue-17740.rs:8:18 | LL | fn bar(self: &mut Foo) { | ^^^^^^^^ lifetime mismatch @@ -7,18 +7,18 @@ LL | fn bar(self: &mut Foo) { = note: expected struct `Foo<'a>` found struct `Foo<'_>` note: the anonymous lifetime defined here... - --> $DIR/issue-17740.rs:6:23 + --> $DIR/issue-17740.rs:8:23 | LL | fn bar(self: &mut Foo) { | ^^^ note: ...does not necessarily outlive the lifetime `'a` as defined here - --> $DIR/issue-17740.rs:5:7 + --> $DIR/issue-17740.rs:7:7 | LL | impl <'a> Foo<'a>{ | ^^ error[E0308]: mismatched `self` parameter type - --> $DIR/issue-17740.rs:6:18 + --> $DIR/issue-17740.rs:8:18 | LL | fn bar(self: &mut Foo) { | ^^^^^^^^ lifetime mismatch @@ -26,12 +26,12 @@ LL | fn bar(self: &mut Foo) { = note: expected struct `Foo<'a>` found struct `Foo<'_>` note: the lifetime `'a` as defined here... - --> $DIR/issue-17740.rs:5:7 + --> $DIR/issue-17740.rs:7:7 | LL | impl <'a> Foo<'a>{ | ^^ note: ...does not necessarily outlive the anonymous lifetime defined here - --> $DIR/issue-17740.rs:6:23 + --> $DIR/issue-17740.rs:8:23 | LL | fn bar(self: &mut Foo) { | ^^^ diff --git a/tests/ui/issues/issue-19991.rs b/tests/ui/issues/issue-19991.rs index dd0efa972ba..cb558b58697 100644 --- a/tests/ui/issues/issue-19991.rs +++ b/tests/ui/issues/issue-19991.rs @@ -1,9 +1,11 @@ // Test if the sugared `if let` construct correctly prints "missing an else clause" when an else // clause does not exist, instead of the unsympathetic "`match` arms have incompatible types" +//@ dont-require-annotations: NOTE + fn main() { if let Some(homura) = Some("madoka") { //~ ERROR missing an `else` clause - //~| expected integer, found `()` + //~| NOTE expected integer, found `()` 765 }; } diff --git a/tests/ui/issues/issue-19991.stderr b/tests/ui/issues/issue-19991.stderr index ff039f3adba..1449bab5142 100644 --- a/tests/ui/issues/issue-19991.stderr +++ b/tests/ui/issues/issue-19991.stderr @@ -1,5 +1,5 @@ error[E0317]: `if` may be missing an `else` clause - --> $DIR/issue-19991.rs:5:5 + --> $DIR/issue-19991.rs:7:5 | LL | / if let Some(homura) = Some("madoka") { LL | | diff --git a/tests/ui/issues/issue-21332.rs b/tests/ui/issues/issue-21332.rs index 4473d00fd5d..ad764f84aa8 100644 --- a/tests/ui/issues/issue-21332.rs +++ b/tests/ui/issues/issue-21332.rs @@ -4,7 +4,8 @@ impl Iterator for S { type Item = i32; fn next(&mut self) -> Result<i32, i32> { Ok(7) } //~^ ERROR method `next` has an incompatible type for trait - //~| expected `Option<i32>`, found `Result<i32, i32>` + //~| NOTE expected `Option<i32>`, found `Result<i32, i32>` + //~| NOTE expected signature `fn(&mut S) -> Option<i32>` } fn main() {} diff --git a/tests/ui/issues/issue-24819.rs b/tests/ui/issues/issue-24819.rs index fb4cfb7b29e..97d288e5cb1 100644 --- a/tests/ui/issues/issue-24819.rs +++ b/tests/ui/issues/issue-24819.rs @@ -1,10 +1,12 @@ +//@ dont-require-annotations: NOTE + use std::collections::HashSet; fn main() { let mut v = Vec::new(); foo(&mut v); //~^ ERROR mismatched types - //~| expected `&mut HashSet<u32>`, found `&mut Vec<_>` + //~| NOTE expected `&mut HashSet<u32>`, found `&mut Vec<_>` } fn foo(h: &mut HashSet<u32>) { diff --git a/tests/ui/issues/issue-24819.stderr b/tests/ui/issues/issue-24819.stderr index 8ec34aa13fa..e144f37d6e4 100644 --- a/tests/ui/issues/issue-24819.stderr +++ b/tests/ui/issues/issue-24819.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-24819.rs:5:9 + --> $DIR/issue-24819.rs:7:9 | LL | foo(&mut v); | --- ^^^^^^ expected `&mut HashSet<u32>`, found `&mut Vec<_>` @@ -9,7 +9,7 @@ LL | foo(&mut v); = note: expected mutable reference `&mut HashSet<u32>` found mutable reference `&mut Vec<_>` note: function defined here - --> $DIR/issue-24819.rs:10:4 + --> $DIR/issue-24819.rs:12:4 | LL | fn foo(h: &mut HashSet<u32>) { | ^^^ -------------------- diff --git a/tests/ui/issues/issue-25746-bool-transmute.rs b/tests/ui/issues/issue-25746-bool-transmute.rs index f8cdc980daa..046dcf83f62 100644 --- a/tests/ui/issues/issue-25746-bool-transmute.rs +++ b/tests/ui/issues/issue-25746-bool-transmute.rs @@ -1,4 +1,5 @@ //@ run-pass +#![allow(unnecessary_transmutes)] use std::mem::transmute; fn main() { diff --git a/tests/ui/issues/issue-27942.rs b/tests/ui/issues/issue-27942.rs index 34b34de3879..1c2e6456937 100644 --- a/tests/ui/issues/issue-27942.rs +++ b/tests/ui/issues/issue-27942.rs @@ -1,12 +1,14 @@ +//@ dont-require-annotations: NOTE + pub trait Resources<'a> {} pub trait Buffer<'a, R: Resources<'a>> { fn select(&self) -> BufferViewHandle<R>; //~^ ERROR mismatched types - //~| lifetime mismatch + //~| NOTE lifetime mismatch //~| ERROR mismatched types - //~| lifetime mismatch + //~| NOTE lifetime mismatch } pub struct BufferViewHandle<'a, R: 'a+Resources<'a>>(&'a R); diff --git a/tests/ui/issues/issue-27942.stderr b/tests/ui/issues/issue-27942.stderr index 8ea46bae26d..671875aa7e2 100644 --- a/tests/ui/issues/issue-27942.stderr +++ b/tests/ui/issues/issue-27942.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-27942.rs:5:25 + --> $DIR/issue-27942.rs:7:25 | LL | fn select(&self) -> BufferViewHandle<R>; | ^^^^^^^^^^^^^^^^^^^ lifetime mismatch @@ -7,18 +7,18 @@ LL | fn select(&self) -> BufferViewHandle<R>; = note: expected trait `Resources<'_>` found trait `Resources<'a>` note: the lifetime `'a` as defined here... - --> $DIR/issue-27942.rs:3:18 + --> $DIR/issue-27942.rs:5:18 | LL | pub trait Buffer<'a, R: Resources<'a>> { | ^^ note: ...does not necessarily outlive the anonymous lifetime defined here - --> $DIR/issue-27942.rs:5:15 + --> $DIR/issue-27942.rs:7:15 | LL | fn select(&self) -> BufferViewHandle<R>; | ^^^^^ error[E0308]: mismatched types - --> $DIR/issue-27942.rs:5:25 + --> $DIR/issue-27942.rs:7:25 | LL | fn select(&self) -> BufferViewHandle<R>; | ^^^^^^^^^^^^^^^^^^^ lifetime mismatch @@ -26,12 +26,12 @@ LL | fn select(&self) -> BufferViewHandle<R>; = note: expected trait `Resources<'_>` found trait `Resources<'a>` note: the anonymous lifetime defined here... - --> $DIR/issue-27942.rs:5:15 + --> $DIR/issue-27942.rs:7:15 | LL | fn select(&self) -> BufferViewHandle<R>; | ^^^^^ note: ...does not necessarily outlive the lifetime `'a` as defined here - --> $DIR/issue-27942.rs:3:18 + --> $DIR/issue-27942.rs:5:18 | LL | pub trait Buffer<'a, R: Resources<'a>> { | ^^ diff --git a/tests/ui/issues/issue-2823.rs b/tests/ui/issues/issue-2823.rs deleted file mode 100644 index 7b443b41526..00000000000 --- a/tests/ui/issues/issue-2823.rs +++ /dev/null @@ -1,14 +0,0 @@ -struct C { - x: isize, -} - -impl Drop for C { - fn drop(&mut self) { - println!("dropping: {}", self.x); - } -} - -fn main() { - let c = C{ x: 2}; - let _d = c.clone(); //~ ERROR no method named `clone` found -} diff --git a/tests/ui/issues/issue-2823.stderr b/tests/ui/issues/issue-2823.stderr deleted file mode 100644 index 5cd3f080450..00000000000 --- a/tests/ui/issues/issue-2823.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0599]: no method named `clone` found for struct `C` in the current scope - --> $DIR/issue-2823.rs:13:16 - | -LL | struct C { - | -------- method `clone` not found for this struct -... -LL | let _d = c.clone(); - | ^^^^^ method not found in `C` - | - = help: items from traits can only be used if the trait is implemented and in scope - = note: the following trait defines an item `clone`, perhaps you need to implement it: - candidate #1: `Clone` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/issues/issue-2951.rs b/tests/ui/issues/issue-2951.rs index 1798e3e7519..e28516fa307 100644 --- a/tests/ui/issues/issue-2951.rs +++ b/tests/ui/issues/issue-2951.rs @@ -1,10 +1,12 @@ +//@ dont-require-annotations: NOTE + fn foo<T, U>(x: T, y: U) { let mut xx = x; xx = y; //~^ ERROR mismatched types - //~| expected type parameter `T`, found type parameter `U` - //~| expected type parameter `T` - //~| found type parameter `U` + //~| NOTE expected type parameter `T`, found type parameter `U` + //~| NOTE expected type parameter `T` + //~| NOTE found type parameter `U` } fn main() { diff --git a/tests/ui/issues/issue-2951.stderr b/tests/ui/issues/issue-2951.stderr index 134808b4d23..d4b45935bf9 100644 --- a/tests/ui/issues/issue-2951.stderr +++ b/tests/ui/issues/issue-2951.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-2951.rs:3:10 + --> $DIR/issue-2951.rs:5:10 | LL | fn foo<T, U>(x: T, y: U) { | - - found type parameter diff --git a/tests/ui/issues/issue-31011.rs b/tests/ui/issues/issue-31011.rs index 86fe16f48e2..078d8b2d50f 100644 --- a/tests/ui/issues/issue-31011.rs +++ b/tests/ui/issues/issue-31011.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + macro_rules! log { ( $ctx:expr, $( $args:expr),* ) => { if $ctx.trace { @@ -16,7 +18,7 @@ struct Foo { fn wrap<T>(context: &T) -> () { log!(context, "entered wrapper"); - //~^ in this expansion of log! + //~^ NOTE in this expansion of log! } fn main() { diff --git a/tests/ui/issues/issue-31011.stderr b/tests/ui/issues/issue-31011.stderr index 9785d56f4fc..701141ee440 100644 --- a/tests/ui/issues/issue-31011.stderr +++ b/tests/ui/issues/issue-31011.stderr @@ -1,5 +1,5 @@ error[E0609]: no field `trace` on type `&T` - --> $DIR/issue-31011.rs:3:17 + --> $DIR/issue-31011.rs:5:17 | LL | if $ctx.trace { | ^^^^^ unknown field diff --git a/tests/ui/issues/issue-31910.rs b/tests/ui/issues/issue-31910.rs index 19cfc4627c7..fc82fda0ccd 100644 --- a/tests/ui/issues/issue-31910.rs +++ b/tests/ui/issues/issue-31910.rs @@ -1,8 +1,9 @@ enum Enum<T: Trait> { - //~^ ERROR: `T` is never used + //~^ ERROR `T` is never used + //~| NOTE unused type parameter X = Trait::Number, //~^ ERROR mismatched types - //~| expected `isize`, found `i32` + //~| NOTE expected `isize`, found `i32` } trait Trait { diff --git a/tests/ui/issues/issue-31910.stderr b/tests/ui/issues/issue-31910.stderr index ca2d2f619e6..56e4cee53d6 100644 --- a/tests/ui/issues/issue-31910.stderr +++ b/tests/ui/issues/issue-31910.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-31910.rs:3:9 + --> $DIR/issue-31910.rs:4:9 | LL | X = Trait::Number, | ^^^^^^^^^^^^^ expected `isize`, found `i32` diff --git a/tests/ui/issues/issue-32950.rs b/tests/ui/issues/issue-32950.rs index 27d68a11c1f..b51ac296776 100644 --- a/tests/ui/issues/issue-32950.rs +++ b/tests/ui/issues/issue-32950.rs @@ -1,4 +1,5 @@ #![feature(concat_idents)] +#![expect(deprecated)] // concat_idents is deprecated #[derive(Debug)] struct Baz<T>( diff --git a/tests/ui/issues/issue-32950.stderr b/tests/ui/issues/issue-32950.stderr index 3cdf35af1d8..38a82542f89 100644 --- a/tests/ui/issues/issue-32950.stderr +++ b/tests/ui/issues/issue-32950.stderr @@ -1,11 +1,11 @@ error: `derive` cannot be used on items with type macros - --> $DIR/issue-32950.rs:5:5 + --> $DIR/issue-32950.rs:6:5 | LL | concat_idents!(Foo, Bar) | ^^^^^^^^^^^^^^^^^^^^^^^^ error[E0412]: cannot find type `FooBar` in this scope - --> $DIR/issue-32950.rs:5:5 + --> $DIR/issue-32950.rs:6:5 | LL | concat_idents!(Foo, Bar) | ^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope diff --git a/tests/ui/issues/issue-3477.rs b/tests/ui/issues/issue-3477.rs index 3817d0e6a3e..eb94294d5a8 100644 --- a/tests/ui/issues/issue-3477.rs +++ b/tests/ui/issues/issue-3477.rs @@ -1,5 +1,6 @@ fn main() { let _p: char = 100; //~^ ERROR mismatched types - //~| expected `char`, found `u8` + //~| NOTE expected `char`, found `u8` + //~| NOTE expected due to this } diff --git a/tests/ui/issues/issue-3680.rs b/tests/ui/issues/issue-3680.rs index a0e52798122..7fdc6e179e4 100644 --- a/tests/ui/issues/issue-3680.rs +++ b/tests/ui/issues/issue-3680.rs @@ -1,9 +1,9 @@ fn main() { - match None { + match None { //~ NOTE this expression has type `Option<_>` Err(_) => () //~^ ERROR mismatched types - //~| expected enum `Option<_>` - //~| found enum `Result<_, _>` - //~| expected `Option<_>`, found `Result<_, _>` + //~| NOTE expected enum `Option<_>` + //~| NOTE found enum `Result<_, _>` + //~| NOTE expected `Option<_>`, found `Result<_, _>` } } diff --git a/tests/ui/issues/issue-37884.rs b/tests/ui/issues/issue-37884.rs index ee37481b23f..3480942d9d2 100644 --- a/tests/ui/issues/issue-37884.rs +++ b/tests/ui/issues/issue-37884.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + struct RepeatMut<'a, T>(T, &'a ()); impl<'a, T: 'a> Iterator for RepeatMut<'a, T> { @@ -5,7 +7,7 @@ impl<'a, T: 'a> Iterator for RepeatMut<'a, T> { type Item = &'a mut T; fn next(&'a mut self) -> Option<Self::Item> //~^ ERROR method not compatible with trait - //~| lifetime mismatch + //~| NOTE lifetime mismatch { Some(&mut self.0) } diff --git a/tests/ui/issues/issue-37884.stderr b/tests/ui/issues/issue-37884.stderr index 17037d2180d..a7a19e3c6df 100644 --- a/tests/ui/issues/issue-37884.stderr +++ b/tests/ui/issues/issue-37884.stderr @@ -1,5 +1,5 @@ error[E0308]: method not compatible with trait - --> $DIR/issue-37884.rs:6:5 + --> $DIR/issue-37884.rs:8:5 | LL | fn next(&'a mut self) -> Option<Self::Item> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch @@ -9,7 +9,7 @@ LL | fn next(&'a mut self) -> Option<Self::Item> note: the anonymous lifetime as defined here... --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL note: ...does not necessarily outlive the lifetime `'a` as defined here - --> $DIR/issue-37884.rs:3:6 + --> $DIR/issue-37884.rs:5:6 | LL | impl<'a, T: 'a> Iterator for RepeatMut<'a, T> { | ^^ diff --git a/tests/ui/issues/issue-39367.rs b/tests/ui/issues/issue-39367.rs index 937d6c4b9e0..68b4d28aae3 100644 --- a/tests/ui/issues/issue-39367.rs +++ b/tests/ui/issues/issue-39367.rs @@ -20,7 +20,7 @@ fn arena() -> &'static ArenaSet<Vec<u8>> { static mut ONCE: Once = Once::new(); ONCE.call_once(|| { - //~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs] + //~^ WARN creating a shared reference to mutable static [static_mut_refs] DATA = transmute ::<Box<ArenaSet<Vec<u8>>>, *const ArenaSet<Vec<u8>>> (Box::new(__static_ref_initialize())); diff --git a/tests/ui/issues/issue-39367.stderr b/tests/ui/issues/issue-39367.stderr index 333c9f9634a..df21c09983e 100644 --- a/tests/ui/issues/issue-39367.stderr +++ b/tests/ui/issues/issue-39367.stderr @@ -1,4 +1,4 @@ -warning: creating a shared reference to mutable static is discouraged +warning: creating a shared reference to mutable static --> $DIR/issue-39367.rs:22:13 | LL | / ONCE.call_once(|| { diff --git a/tests/ui/issues/issue-43355.rs b/tests/ui/issues/issue-43355.rs index bf819af7962..597472b4f48 100644 --- a/tests/ui/issues/issue-43355.rs +++ b/tests/ui/issues/issue-43355.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + pub trait Trait1<X> { type Output; } @@ -12,7 +14,7 @@ impl<X, T> Trait1<X> for T where T: Trait2<X> { impl<X> Trait1<Box<X>> for A { //~^ ERROR conflicting implementations of trait -//~| downstream crates may implement trait `Trait2<std::boxed::Box<_>>` for type `A` +//~| NOTE downstream crates may implement trait `Trait2<std::boxed::Box<_>>` for type `A` type Output = i32; } diff --git a/tests/ui/issues/issue-43355.stderr b/tests/ui/issues/issue-43355.stderr index 25179ef6a96..5a089cb3d8b 100644 --- a/tests/ui/issues/issue-43355.stderr +++ b/tests/ui/issues/issue-43355.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `Trait1<Box<_>>` for type `A` - --> $DIR/issue-43355.rs:13:1 + --> $DIR/issue-43355.rs:15:1 | LL | impl<X, T> Trait1<X> for T where T: Trait2<X> { | --------------------------------------------- first implementation here diff --git a/tests/ui/issues/issue-4517.rs b/tests/ui/issues/issue-4517.rs index 469304e2cf7..778f8f97bcc 100644 --- a/tests/ui/issues/issue-4517.rs +++ b/tests/ui/issues/issue-4517.rs @@ -1,8 +1,10 @@ +//@ dont-require-annotations: NOTE + fn bar(int_param: usize) {} fn main() { let foo: [u8; 4] = [1; 4]; bar(foo); //~^ ERROR mismatched types - //~| expected `usize`, found `[u8; 4]` + //~| NOTE expected `usize`, found `[u8; 4]` } diff --git a/tests/ui/issues/issue-4517.stderr b/tests/ui/issues/issue-4517.stderr index 5d544ee10a9..d078c7eb95a 100644 --- a/tests/ui/issues/issue-4517.stderr +++ b/tests/ui/issues/issue-4517.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-4517.rs:5:9 + --> $DIR/issue-4517.rs:7:9 | LL | bar(foo); | --- ^^^ expected `usize`, found `[u8; 4]` @@ -7,7 +7,7 @@ LL | bar(foo); | arguments to this function are incorrect | note: function defined here - --> $DIR/issue-4517.rs:1:4 + --> $DIR/issue-4517.rs:3:4 | LL | fn bar(int_param: usize) {} | ^^^ ---------------- diff --git a/tests/ui/issues/issue-4935.rs b/tests/ui/issues/issue-4935.rs index c95020a0c00..ef8a3eb32ab 100644 --- a/tests/ui/issues/issue-4935.rs +++ b/tests/ui/issues/issue-4935.rs @@ -1,6 +1,7 @@ // Regression test for issue #4935 fn foo(a: usize) {} -//~^ defined here +//~^ NOTE defined here fn main() { foo(5, 6) } //~^ ERROR function takes 1 argument but 2 arguments were supplied +//~| NOTE unexpected argument #2 of type `{integer}` diff --git a/tests/ui/issues/issue-4968.rs b/tests/ui/issues/issue-4968.rs index c8df46dc267..08539d6debd 100644 --- a/tests/ui/issues/issue-4968.rs +++ b/tests/ui/issues/issue-4968.rs @@ -1,10 +1,12 @@ // Regression test for issue #4968 +//@ dont-require-annotations: NOTE + const A: (isize,isize) = (4,2); fn main() { match 42 { A => () } //~^ ERROR mismatched types - //~| expected type `{integer}` - //~| found tuple `(isize, isize)` - //~| expected integer, found `(isize, isize)` + //~| NOTE expected type `{integer}` + //~| NOTE found tuple `(isize, isize)` + //~| NOTE expected integer, found `(isize, isize)` } diff --git a/tests/ui/issues/issue-4968.stderr b/tests/ui/issues/issue-4968.stderr index 549e5509474..2c1e1d7bfe5 100644 --- a/tests/ui/issues/issue-4968.stderr +++ b/tests/ui/issues/issue-4968.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-4968.rs:5:16 + --> $DIR/issue-4968.rs:7:16 | LL | const A: (isize,isize) = (4,2); | ---------------------- constant defined here diff --git a/tests/ui/issues/issue-50403.rs b/tests/ui/issues/issue-50403.rs index ab22aff26d9..f14958afc34 100644 --- a/tests/ui/issues/issue-50403.rs +++ b/tests/ui/issues/issue-50403.rs @@ -1,4 +1,5 @@ #![feature(concat_idents)] +#![expect(deprecated)] // concat_idents is deprecated fn main() { let x = concat_idents!(); //~ ERROR `concat_idents!()` takes 1 or more arguments diff --git a/tests/ui/issues/issue-50403.stderr b/tests/ui/issues/issue-50403.stderr index 193d815d519..e7dd05bb018 100644 --- a/tests/ui/issues/issue-50403.stderr +++ b/tests/ui/issues/issue-50403.stderr @@ -1,5 +1,5 @@ error: `concat_idents!()` takes 1 or more arguments - --> $DIR/issue-50403.rs:4:13 + --> $DIR/issue-50403.rs:5:13 | LL | let x = concat_idents!(); | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/issues/issue-5100.rs b/tests/ui/issues/issue-5100.rs index 53ebdec8164..e9ae551bb77 100644 --- a/tests/ui/issues/issue-5100.rs +++ b/tests/ui/issues/issue-5100.rs @@ -1,5 +1,6 @@ -#![feature(box_patterns)] +//@ dont-require-annotations: NOTE +#![feature(box_patterns)] enum A { B, C } @@ -7,41 +8,41 @@ fn main() { match (true, false) { A::B => (), //~^ ERROR mismatched types -//~| expected `(bool, bool)`, found `A` -//~| expected tuple `(bool, bool)` -//~| found enum `A` +//~| NOTE expected `(bool, bool)`, found `A` +//~| NOTE expected tuple `(bool, bool)` +//~| NOTE found enum `A` _ => () } match (true, false) { (true, false, false) => () //~^ ERROR mismatched types -//~| expected a tuple with 2 elements, found one with 3 elements -//~| expected tuple `(bool, bool)` -//~| found tuple `(_, _, _)` +//~| NOTE expected a tuple with 2 elements, found one with 3 elements +//~| NOTE expected tuple `(bool, bool)` +//~| NOTE found tuple `(_, _, _)` } match (true, false) { (true, false, false) => () //~^ ERROR mismatched types -//~| expected a tuple with 2 elements, found one with 3 elements -//~| expected tuple `(bool, bool)` -//~| found tuple `(_, _, _)` +//~| NOTE expected a tuple with 2 elements, found one with 3 elements +//~| NOTE expected tuple `(bool, bool)` +//~| NOTE found tuple `(_, _, _)` } match (true, false) { box (true, false) => () //~^ ERROR mismatched types -//~| expected tuple `(bool, bool)` -//~| found struct `Box<_>` +//~| NOTE expected tuple `(bool, bool)` +//~| NOTE found struct `Box<_>` } match (true, false) { &(true, false) => () //~^ ERROR mismatched types -//~| expected `(bool, bool)`, found `&_` -//~| expected tuple `(bool, bool)` -//~| found reference `&_` +//~| NOTE expected `(bool, bool)`, found `&_` +//~| NOTE expected tuple `(bool, bool)` +//~| NOTE found reference `&_` } @@ -53,5 +54,5 @@ fn main() { // Make sure none of the errors above were fatal let x: char = true; //~ ERROR mismatched types - //~| expected `char`, found `bool` + //~| NOTE expected `char`, found `bool` } diff --git a/tests/ui/issues/issue-5100.stderr b/tests/ui/issues/issue-5100.stderr index b1680aacd16..24d41a1a8af 100644 --- a/tests/ui/issues/issue-5100.stderr +++ b/tests/ui/issues/issue-5100.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-5100.rs:8:9 + --> $DIR/issue-5100.rs:9:9 | LL | enum A { B, C } | - unit variant defined here @@ -13,7 +13,7 @@ LL | A::B => (), found enum `A` error[E0308]: mismatched types - --> $DIR/issue-5100.rs:17:9 + --> $DIR/issue-5100.rs:18:9 | LL | match (true, false) { | ------------- this expression has type `(bool, bool)` @@ -24,7 +24,7 @@ LL | (true, false, false) => () found tuple `(_, _, _)` error[E0308]: mismatched types - --> $DIR/issue-5100.rs:25:9 + --> $DIR/issue-5100.rs:26:9 | LL | match (true, false) { | ------------- this expression has type `(bool, bool)` @@ -35,7 +35,7 @@ LL | (true, false, false) => () found tuple `(_, _, _)` error[E0308]: mismatched types - --> $DIR/issue-5100.rs:33:9 + --> $DIR/issue-5100.rs:34:9 | LL | match (true, false) { | ------------- this expression has type `(bool, bool)` @@ -46,7 +46,7 @@ LL | box (true, false) => () found struct `Box<_>` error[E0308]: mismatched types - --> $DIR/issue-5100.rs:40:9 + --> $DIR/issue-5100.rs:41:9 | LL | match (true, false) { | ------------- this expression has type `(bool, bool)` @@ -57,13 +57,13 @@ LL | &(true, false) => () found reference `&_` error[E0618]: expected function, found `(char, char)` - --> $DIR/issue-5100.rs:48:14 + --> $DIR/issue-5100.rs:49:14 | LL | let v = [('a', 'b') | ^^^^^^^^^^- help: consider separating array elements with a comma: `,` error[E0308]: mismatched types - --> $DIR/issue-5100.rs:55:19 + --> $DIR/issue-5100.rs:56:19 | LL | let x: char = true; | ---- ^^^^ expected `char`, found `bool` diff --git a/tests/ui/issues/issue-5358-1.rs b/tests/ui/issues/issue-5358-1.rs index 14ee962b722..281f219c039 100644 --- a/tests/ui/issues/issue-5358-1.rs +++ b/tests/ui/issues/issue-5358-1.rs @@ -2,12 +2,12 @@ enum Either<T, U> { Left(T), Right(U) } struct S(Either<usize, usize>); fn main() { - match S(Either::Left(5)) { + match S(Either::Left(5)) { //~ NOTE this expression has type `S` Either::Right(_) => {} //~^ ERROR mismatched types - //~| expected `S`, found `Either<_, _>` - //~| expected struct `S` - //~| found enum `Either<_, _>` + //~| NOTE expected `S`, found `Either<_, _>` + //~| NOTE expected struct `S` + //~| NOTE found enum `Either<_, _>` _ => {} } } diff --git a/tests/ui/issues/issue-7061.rs b/tests/ui/issues/issue-7061.rs index 8a6ee920a3a..c5d5a9d9498 100644 --- a/tests/ui/issues/issue-7061.rs +++ b/tests/ui/issues/issue-7061.rs @@ -1,10 +1,12 @@ +//@ dont-require-annotations: NOTE + struct BarStruct; impl<'a> BarStruct { fn foo(&'a mut self) -> Box<BarStruct> { self } //~^ ERROR mismatched types - //~| expected struct `Box<BarStruct>` - //~| found mutable reference `&'a mut BarStruct` + //~| NOTE expected struct `Box<BarStruct>` + //~| NOTE found mutable reference `&'a mut BarStruct` } fn main() {} diff --git a/tests/ui/issues/issue-7061.stderr b/tests/ui/issues/issue-7061.stderr index 4fca2ff39fe..b4c0ebfbdd5 100644 --- a/tests/ui/issues/issue-7061.stderr +++ b/tests/ui/issues/issue-7061.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-7061.rs:4:46 + --> $DIR/issue-7061.rs:6:46 | LL | fn foo(&'a mut self) -> Box<BarStruct> { self } | -------------- ^^^^ expected `Box<BarStruct>`, found `&mut BarStruct` diff --git a/tests/ui/issues/issue-7092.rs b/tests/ui/issues/issue-7092.rs index c3c96c7d3f6..fab18bd7cf7 100644 --- a/tests/ui/issues/issue-7092.rs +++ b/tests/ui/issues/issue-7092.rs @@ -2,12 +2,12 @@ enum Whatever { } fn foo(x: Whatever) { - match x { + match x { //~ NOTE this expression has type `Whatever` Some(field) => //~^ ERROR mismatched types -//~| expected `Whatever`, found `Option<_>` -//~| expected enum `Whatever` -//~| found enum `Option<_>` +//~| NOTE expected `Whatever`, found `Option<_>` +//~| NOTE expected enum `Whatever` +//~| NOTE found enum `Option<_>` field.access(), } } diff --git a/tests/ui/issues/issue-7867.rs b/tests/ui/issues/issue-7867.rs index e9fd10c6613..87e7c831e68 100644 --- a/tests/ui/issues/issue-7867.rs +++ b/tests/ui/issues/issue-7867.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + enum A { B, C } mod foo { pub fn bar() {} } @@ -6,9 +8,9 @@ fn main() { match (true, false) { A::B => (), //~^ ERROR mismatched types - //~| expected `(bool, bool)`, found `A` - //~| expected tuple `(bool, bool)` - //~| found enum `A` + //~| NOTE expected `(bool, bool)`, found `A` + //~| NOTE expected tuple `(bool, bool)` + //~| NOTE found enum `A` _ => () } } diff --git a/tests/ui/issues/issue-7867.stderr b/tests/ui/issues/issue-7867.stderr index 1a0cf5da8be..fcb69d775fa 100644 --- a/tests/ui/issues/issue-7867.stderr +++ b/tests/ui/issues/issue-7867.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-7867.rs:7:9 + --> $DIR/issue-7867.rs:9:9 | LL | enum A { B, C } | - unit variant defined here diff --git a/tests/ui/lazy-type-alias/extern-crate-has-eager-type-aliases.rs b/tests/ui/lazy-type-alias/extern-crate-has-eager-type-aliases.rs index efd77639198..33846987760 100644 --- a/tests/ui/lazy-type-alias/extern-crate-has-eager-type-aliases.rs +++ b/tests/ui/lazy-type-alias/extern-crate-has-eager-type-aliases.rs @@ -9,9 +9,9 @@ #![allow(incomplete_features)] // This used to crash when we were computing the variances of `Struct` since we would convert -// `eager::Alias<T>` to a weak projection due to the presence of `#![feature(lazy_type_alias)]` in +// `eager::Alias<T>` to a weak alias due to the presence of `#![feature(lazy_type_alias)]` in // this (!) crate and subsequently attempt to obtain the variances of the type alias associated with -// the weak projection which would panic because we don't compute this information for eager type +// the weak alias which would panic because we don't compute this information for eager type // aliases at all. struct Struct<T>(eager::Alias<T>); diff --git a/tests/ui/linking/cdylib-no-mangle.rs b/tests/ui/linking/cdylib-no-mangle.rs new file mode 100644 index 00000000000..f442c3f584d --- /dev/null +++ b/tests/ui/linking/cdylib-no-mangle.rs @@ -0,0 +1,20 @@ +//@ only-apple +//@ build-fail +//@ dont-check-compiler-stderr +//@ dont-check-compiler-stdout + +// Regression test for <https://github.com/rust-lang/rust/issues/139744>. +// Functions in the dynamic library marked with no_mangle should not be GC-ed. + +#![crate_type = "cdylib"] + +unsafe extern "C" { + unsafe static THIS_SYMBOL_SHOULD_BE_UNDEFINED: usize; +} + +#[unsafe(no_mangle)] +pub unsafe fn function_marked_with_no_mangle() { + println!("FUNCTION_MARKED_WITH_NO_MANGLE = {}", unsafe { THIS_SYMBOL_SHOULD_BE_UNDEFINED }); +} + +//~? ERROR linking diff --git a/tests/ui/linking/executable-no-mangle-strip.rs b/tests/ui/linking/executable-no-mangle-strip.rs new file mode 100644 index 00000000000..cc283dc53ee --- /dev/null +++ b/tests/ui/linking/executable-no-mangle-strip.rs @@ -0,0 +1,27 @@ +//@ run-pass +//@ ignore-windows-gnu: only statics marked with used can be GC-ed on windows-gnu + +// Regression test for <https://github.com/rust-lang/rust/issues/139744>. +// Functions in the binary marked with no_mangle should be GC-ed if they +// are not indirectly referenced by main. + +#![feature(used_with_arg)] + +#[cfg_attr(windows, link(name = "this_lib_does_not_exist", kind = "raw-dylib"))] +unsafe extern "C" { + unsafe static THIS_SYMBOL_SHOULD_BE_UNDEFINED: usize; +} + +#[unsafe(no_mangle)] +pub unsafe fn function_marked_with_no_mangle() { + println!("FUNCTION_MARKED_WITH_NO_MANGLE = {}", unsafe { THIS_SYMBOL_SHOULD_BE_UNDEFINED }); +} + +#[used(compiler)] +pub static FUNCTION_MARKED_WITH_USED: unsafe fn() = || { + println!("FUNCTION_MARKED_WITH_USED = {}", unsafe { THIS_SYMBOL_SHOULD_BE_UNDEFINED }); +}; + +fn main() { + println!("MAIN"); +} diff --git a/tests/ui/linking/weird-export-names.rs b/tests/ui/linking/weird-export-names.rs new file mode 100644 index 00000000000..8fb2dc6bf5e --- /dev/null +++ b/tests/ui/linking/weird-export-names.rs @@ -0,0 +1,10 @@ +//@ build-pass +//@ needs-crate-type: cdylib + +#![crate_type = "cdylib"] + +#[export_name = "foo.0123"] +pub extern "C" fn foo() {} + +#[export_name = "EXPORTS"] +pub extern "C" fn bar() {} diff --git a/tests/ui/lint/implicit_autorefs.fixed b/tests/ui/lint/implicit_autorefs.fixed new file mode 100644 index 00000000000..96a617b20c9 --- /dev/null +++ b/tests/ui/lint/implicit_autorefs.fixed @@ -0,0 +1,99 @@ +//@ check-pass +//@ run-rustfix + +#![allow(dead_code)] // For the rustfix-ed code. + +use std::mem::ManuallyDrop; +use std::ops::Deref; + +unsafe fn test_const(ptr: *const [u8]) { + let _ = (&(*ptr))[..16]; + //~^ WARN implicit autoref +} + +struct Test { + field: [u8], +} + +unsafe fn test_field(ptr: *const Test) -> *const [u8] { + let l = (&(*ptr).field).len(); + //~^ WARN implicit autoref + + &raw const (&(*ptr).field)[..l - 1] + //~^ WARN implicit autoref +} + +unsafe fn test_builtin_index(a: *mut [String]) { + _ = (&(*a)[0]).len(); + //~^ WARN implicit autoref + + _ = (&(&(*a))[..1][0]).len(); + //~^ WARN implicit autoref + //~^^ WARN implicit autoref +} + +unsafe fn test_overloaded_deref_const(ptr: *const ManuallyDrop<Test>) { + let _ = (&(*ptr)).field; + //~^ WARN implicit autoref + let _ = &raw const (&(*ptr)).field; + //~^ WARN implicit autoref +} + +unsafe fn test_overloaded_deref_mut(ptr: *mut ManuallyDrop<Test>) { + let _ = (&(*ptr)).field; + //~^ WARN implicit autoref +} + +unsafe fn test_double_overloaded_deref_const(ptr: *const ManuallyDrop<ManuallyDrop<Test>>) { + let _ = (&(*ptr)).field; + //~^ WARN implicit autoref +} + +unsafe fn test_manually_overloaded_deref() { + struct W<T>(T); + + impl<T> Deref for W<T> { + type Target = T; + fn deref(&self) -> &T { &self.0 } + } + + let w: W<i32> = W(5); + let w = &raw const w; + let _p: *const i32 = &raw const *(&**w); + //~^ WARN implicit autoref +} + +struct Test2 { + // Derefs to `[u8]`. + field: &'static [u8] +} + +fn test_more_manual_deref(ptr: *const Test2) -> usize { + unsafe { (&(*ptr).field).len() } + //~^ WARN implicit autoref +} + +unsafe fn test_no_attr(ptr: *mut ManuallyDrop<u8>) { + ptr.write(ManuallyDrop::new(1)); // Should not warn, as `ManuallyDrop::write` is not + // annotated with `#[rustc_no_implicit_auto_ref]` +} + +unsafe fn test_vec_get(ptr: *mut Vec<u8>) { + let _ = (&(*ptr)).get(0); + //~^ WARN implicit autoref + let _ = (&(*ptr)).get_unchecked(0); + //~^ WARN implicit autoref + let _ = (&mut (*ptr)).get_mut(0); + //~^ WARN implicit autoref + let _ = (&mut (*ptr)).get_unchecked_mut(0); + //~^ WARN implicit autoref +} + +unsafe fn test_string(ptr: *mut String) { + let _ = (&(*ptr)).len(); + //~^ WARN implicit autoref + let _ = (&(*ptr)).is_empty(); + //~^ WARN implicit autoref +} + +fn main() {} diff --git a/tests/ui/lint/implicit_autorefs.rs b/tests/ui/lint/implicit_autorefs.rs new file mode 100644 index 00000000000..61dd0ac50ce --- /dev/null +++ b/tests/ui/lint/implicit_autorefs.rs @@ -0,0 +1,99 @@ +//@ check-pass +//@ run-rustfix + +#![allow(dead_code)] // For the rustfix-ed code. + +use std::mem::ManuallyDrop; +use std::ops::Deref; + +unsafe fn test_const(ptr: *const [u8]) { + let _ = (*ptr)[..16]; + //~^ WARN implicit autoref +} + +struct Test { + field: [u8], +} + +unsafe fn test_field(ptr: *const Test) -> *const [u8] { + let l = (*ptr).field.len(); + //~^ WARN implicit autoref + + &raw const (*ptr).field[..l - 1] + //~^ WARN implicit autoref +} + +unsafe fn test_builtin_index(a: *mut [String]) { + _ = (*a)[0].len(); + //~^ WARN implicit autoref + + _ = (*a)[..1][0].len(); + //~^ WARN implicit autoref + //~^^ WARN implicit autoref +} + +unsafe fn test_overloaded_deref_const(ptr: *const ManuallyDrop<Test>) { + let _ = (*ptr).field; + //~^ WARN implicit autoref + let _ = &raw const (*ptr).field; + //~^ WARN implicit autoref +} + +unsafe fn test_overloaded_deref_mut(ptr: *mut ManuallyDrop<Test>) { + let _ = (*ptr).field; + //~^ WARN implicit autoref +} + +unsafe fn test_double_overloaded_deref_const(ptr: *const ManuallyDrop<ManuallyDrop<Test>>) { + let _ = (*ptr).field; + //~^ WARN implicit autoref +} + +unsafe fn test_manually_overloaded_deref() { + struct W<T>(T); + + impl<T> Deref for W<T> { + type Target = T; + fn deref(&self) -> &T { &self.0 } + } + + let w: W<i32> = W(5); + let w = &raw const w; + let _p: *const i32 = &raw const **w; + //~^ WARN implicit autoref +} + +struct Test2 { + // Derefs to `[u8]`. + field: &'static [u8] +} + +fn test_more_manual_deref(ptr: *const Test2) -> usize { + unsafe { (*ptr).field.len() } + //~^ WARN implicit autoref +} + +unsafe fn test_no_attr(ptr: *mut ManuallyDrop<u8>) { + ptr.write(ManuallyDrop::new(1)); // Should not warn, as `ManuallyDrop::write` is not + // annotated with `#[rustc_no_implicit_auto_ref]` +} + +unsafe fn test_vec_get(ptr: *mut Vec<u8>) { + let _ = (*ptr).get(0); + //~^ WARN implicit autoref + let _ = (*ptr).get_unchecked(0); + //~^ WARN implicit autoref + let _ = (*ptr).get_mut(0); + //~^ WARN implicit autoref + let _ = (*ptr).get_unchecked_mut(0); + //~^ WARN implicit autoref +} + +unsafe fn test_string(ptr: *mut String) { + let _ = (*ptr).len(); + //~^ WARN implicit autoref + let _ = (*ptr).is_empty(); + //~^ WARN implicit autoref +} + +fn main() {} diff --git a/tests/ui/lint/implicit_autorefs.stderr b/tests/ui/lint/implicit_autorefs.stderr new file mode 100644 index 00000000000..6dd1ac65ada --- /dev/null +++ b/tests/ui/lint/implicit_autorefs.stderr @@ -0,0 +1,219 @@ +warning: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:10:13 + | +LL | let _ = (*ptr)[..16]; + | ^^^^^^^^^^^^ + | + = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements + = note: `#[warn(dangerous_implicit_autorefs)]` on by default +help: try using a raw pointer method instead; or if this reference is intentional, make it explicit + | +LL | let _ = (&(*ptr))[..16]; + | ++ + + +warning: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:19:13 + | +LL | let l = (*ptr).field.len(); + | ^^^^^^^^^^^^^^^^^^ + | + = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements +help: try using a raw pointer method instead; or if this reference is intentional, make it explicit + | +LL | let l = (&(*ptr).field).len(); + | ++ + + +warning: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:22:16 + | +LL | &raw const (*ptr).field[..l - 1] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements +help: try using a raw pointer method instead; or if this reference is intentional, make it explicit + | +LL | &raw const (&(*ptr).field)[..l - 1] + | ++ + + +warning: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:27:9 + | +LL | _ = (*a)[0].len(); + | ^^^^^^^^^^^^^ + | + = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements +help: try using a raw pointer method instead; or if this reference is intentional, make it explicit + | +LL | _ = (&(*a)[0]).len(); + | ++ + + +warning: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:30:9 + | +LL | _ = (*a)[..1][0].len(); + | ^^^^^^^^^^^^^^^^^^ + | + = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements +help: try using a raw pointer method instead; or if this reference is intentional, make it explicit + | +LL | _ = (&(*a)[..1][0]).len(); + | ++ + + +warning: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:30:9 + | +LL | _ = (*a)[..1][0].len(); + | ^^^^^^^^^ + | + = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements +help: try using a raw pointer method instead; or if this reference is intentional, make it explicit + | +LL | _ = (&(*a))[..1][0].len(); + | ++ + + +warning: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:36:13 + | +LL | let _ = (*ptr).field; + | ^^^^^^^^^^^^ + | + = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements +help: try using a raw pointer method instead; or if this reference is intentional, make it explicit + | +LL | let _ = (&(*ptr)).field; + | ++ + + +warning: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:38:24 + | +LL | let _ = &raw const (*ptr).field; + | ^^^^^^^^^^^^ + | + = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements +help: try using a raw pointer method instead; or if this reference is intentional, make it explicit + | +LL | let _ = &raw const (&(*ptr)).field; + | ++ + + +warning: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:43:13 + | +LL | let _ = (*ptr).field; + | ^^^^^^^^^^^^ + | + = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements +help: try using a raw pointer method instead; or if this reference is intentional, make it explicit + | +LL | let _ = (&(*ptr)).field; + | ++ + + +warning: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:48:13 + | +LL | let _ = (*ptr).field; + | ^^^^^^^^^^^^ + | + = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements +help: try using a raw pointer method instead; or if this reference is intentional, make it explicit + | +LL | let _ = (&(*ptr)).field; + | ++ + + +warning: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:62:26 + | +LL | let _p: *const i32 = &raw const **w; + | ^^^^^^^^^^^^^^ + | + = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements +help: try using a raw pointer method instead; or if this reference is intentional, make it explicit + | +LL | let _p: *const i32 = &raw const *(&**w); + | +++ + + +warning: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:72:14 + | +LL | unsafe { (*ptr).field.len() } + | ^^^^^^^^^^^^^^^^^^ + | + = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements +help: try using a raw pointer method instead; or if this reference is intentional, make it explicit + | +LL | unsafe { (&(*ptr).field).len() } + | ++ + + +warning: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:82:13 + | +LL | let _ = (*ptr).get(0); + | ^^^^^^^^^^^^^ + | + = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements +help: try using a raw pointer method instead; or if this reference is intentional, make it explicit + | +LL | let _ = (&(*ptr)).get(0); + | ++ + + +warning: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:84:13 + | +LL | let _ = (*ptr).get_unchecked(0); + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements +help: try using a raw pointer method instead; or if this reference is intentional, make it explicit + | +LL | let _ = (&(*ptr)).get_unchecked(0); + | ++ + + +warning: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:86:13 + | +LL | let _ = (*ptr).get_mut(0); + | ^^^^^^^^^^^^^^^^^ + | + = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements +help: try using a raw pointer method instead; or if this reference is intentional, make it explicit + | +LL | let _ = (&mut (*ptr)).get_mut(0); + | +++++ + + +warning: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:88:13 + | +LL | let _ = (*ptr).get_unchecked_mut(0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements +help: try using a raw pointer method instead; or if this reference is intentional, make it explicit + | +LL | let _ = (&mut (*ptr)).get_unchecked_mut(0); + | +++++ + + +warning: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:93:13 + | +LL | let _ = (*ptr).len(); + | ^^^^^^^^^^^^ + | + = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements +help: try using a raw pointer method instead; or if this reference is intentional, make it explicit + | +LL | let _ = (&(*ptr)).len(); + | ++ + + +warning: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:95:13 + | +LL | let _ = (*ptr).is_empty(); + | ^^^^^^^^^^^^^^^^^ + | + = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements +help: try using a raw pointer method instead; or if this reference is intentional, make it explicit + | +LL | let _ = (&(*ptr)).is_empty(); + | ++ + + +warning: 18 warnings emitted + diff --git a/tests/ui/lint/invalid_null_args.rs b/tests/ui/lint/invalid_null_args.rs index 7948f0d86d0..f40f06a0d36 100644 --- a/tests/ui/lint/invalid_null_args.rs +++ b/tests/ui/lint/invalid_null_args.rs @@ -1,19 +1,19 @@ // check-fail // run-rustfix +#![allow(unnecessary_transmutes)] -use std::ptr; -use std::mem; +use std::{mem, ptr}; unsafe fn null_ptr() { ptr::write( - //~^ ERROR calling this function with a null pointer is undefined behavior + //~^ ERROR calling this function with a null pointer is undefined behavior ptr::null_mut() as *mut u32, mem::transmute::<[u8; 4], _>([0, 0, 0, 255]), ); let null_ptr = ptr::null_mut(); ptr::write( - //~^ ERROR calling this function with a null pointer is undefined behavior + //~^ ERROR calling this function with a null pointer is undefined behavior null_ptr as *mut u32, mem::transmute::<[u8; 4], _>([0, 0, 0, 255]), ); @@ -38,10 +38,10 @@ unsafe fn null_ptr() { ptr::copy_nonoverlapping::<usize>(ptr::null(), ptr::NonNull::dangling().as_ptr(), 0); //~^ ERROR calling this function with a null pointer is undefined behavior ptr::copy_nonoverlapping::<usize>( - //~^ ERROR calling this function with a null pointer is undefined behavior + //~^ ERROR calling this function with a null pointer is undefined behavior ptr::NonNull::dangling().as_ptr(), ptr::null_mut(), - 0 + 0, ); #[derive(Copy, Clone)] diff --git a/tests/ui/lint/invalid_null_args.stderr b/tests/ui/lint/invalid_null_args.stderr index f95bc2afa82..11c6270cfb7 100644 --- a/tests/ui/lint/invalid_null_args.stderr +++ b/tests/ui/lint/invalid_null_args.stderr @@ -117,7 +117,7 @@ LL | | LL | | ptr::NonNull::dangling().as_ptr(), LL | | ptr::null_mut(), | | --------------- null pointer originates from here -LL | | 0 +LL | | 0, LL | | ); | |_____^ | diff --git a/tests/ui/lint/lint-ctypes-enum.rs b/tests/ui/lint/lint-ctypes-enum.rs index 0d19d5b5347..b2ef27b833b 100644 --- a/tests/ui/lint/lint-ctypes-enum.rs +++ b/tests/ui/lint/lint-ctypes-enum.rs @@ -2,6 +2,8 @@ #![deny(improper_ctypes)] #![feature(ptr_internals)] #![feature(transparent_unions)] +#![feature(repr128)] +#![allow(incomplete_features)] use std::num; @@ -40,6 +42,20 @@ enum Isize { C, } +#[repr(u128)] +enum U128 { + A, + B, + C, +} + +#[repr(i128)] +enum I128 { + A, + B, + C, +} + #[repr(transparent)] struct TransparentStruct<T>(T, std::marker::PhantomData<Z>); @@ -71,6 +87,8 @@ extern "C" { fn repr_c(x: ReprC); fn repr_u8(x: U8); fn repr_isize(x: Isize); + fn repr_u128(x: U128); //~ ERROR `extern` block uses type `U128` + fn repr_i128(x: I128); //~ ERROR `extern` block uses type `I128` fn option_ref(x: Option<&'static u8>); fn option_fn(x: Option<extern "C" fn()>); fn option_nonnull(x: Option<std::ptr::NonNull<u8>>); diff --git a/tests/ui/lint/lint-ctypes-enum.stderr b/tests/ui/lint/lint-ctypes-enum.stderr index a491bd19605..d5fc844f756 100644 --- a/tests/ui/lint/lint-ctypes-enum.stderr +++ b/tests/ui/lint/lint-ctypes-enum.stderr @@ -1,5 +1,5 @@ error: `extern` block uses type `U`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:68:14 + --> $DIR/lint-ctypes-enum.rs:84:14 | LL | fn uf(x: U); | ^ not FFI-safe @@ -7,7 +7,7 @@ LL | fn uf(x: U); = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum = note: enum has no representation hint note: the type is defined here - --> $DIR/lint-ctypes-enum.rs:9:1 + --> $DIR/lint-ctypes-enum.rs:11:1 | LL | enum U { | ^^^^^^ @@ -18,7 +18,7 @@ LL | #![deny(improper_ctypes)] | ^^^^^^^^^^^^^^^ error: `extern` block uses type `B`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:69:14 + --> $DIR/lint-ctypes-enum.rs:85:14 | LL | fn bf(x: B); | ^ not FFI-safe @@ -26,13 +26,13 @@ LL | fn bf(x: B); = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum = note: enum has no representation hint note: the type is defined here - --> $DIR/lint-ctypes-enum.rs:12:1 + --> $DIR/lint-ctypes-enum.rs:14:1 | LL | enum B { | ^^^^^^ error: `extern` block uses type `T`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:70:14 + --> $DIR/lint-ctypes-enum.rs:86:14 | LL | fn tf(x: T); | ^ not FFI-safe @@ -40,13 +40,39 @@ LL | fn tf(x: T); = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum = note: enum has no representation hint note: the type is defined here - --> $DIR/lint-ctypes-enum.rs:16:1 + --> $DIR/lint-ctypes-enum.rs:18:1 | LL | enum T { | ^^^^^^ +error: `extern` block uses type `U128`, which is not FFI-safe + --> $DIR/lint-ctypes-enum.rs:90:21 + | +LL | fn repr_u128(x: U128); + | ^^^^ not FFI-safe + | + = note: 128-bit integers don't currently have a known stable ABI +note: the type is defined here + --> $DIR/lint-ctypes-enum.rs:46:1 + | +LL | enum U128 { + | ^^^^^^^^^ + +error: `extern` block uses type `I128`, which is not FFI-safe + --> $DIR/lint-ctypes-enum.rs:91:21 + | +LL | fn repr_i128(x: I128); + | ^^^^ not FFI-safe + | + = note: 128-bit integers don't currently have a known stable ABI +note: the type is defined here + --> $DIR/lint-ctypes-enum.rs:53:1 + | +LL | enum I128 { + | ^^^^^^^^^ + error: `extern` block uses type `u128`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:82:31 + --> $DIR/lint-ctypes-enum.rs:100:31 | LL | fn option_nonzero_u128(x: Option<num::NonZero<u128>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -54,7 +80,7 @@ LL | fn option_nonzero_u128(x: Option<num::NonZero<u128>>); = note: 128-bit integers don't currently have a known stable ABI error: `extern` block uses type `i128`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:89:31 + --> $DIR/lint-ctypes-enum.rs:107:31 | LL | fn option_nonzero_i128(x: Option<num::NonZero<i128>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -62,7 +88,7 @@ LL | fn option_nonzero_i128(x: Option<num::NonZero<i128>>); = note: 128-bit integers don't currently have a known stable ABI error: `extern` block uses type `Option<TransparentUnion<NonZero<u8>>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:94:36 + --> $DIR/lint-ctypes-enum.rs:112:36 | LL | fn option_transparent_union(x: Option<TransparentUnion<num::NonZero<u8>>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -71,7 +97,7 @@ LL | fn option_transparent_union(x: Option<TransparentUnion<num::NonZero<u8> = note: enum has no representation hint error: `extern` block uses type `Option<Rust<NonZero<u8>>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:96:28 + --> $DIR/lint-ctypes-enum.rs:114:28 | LL | fn option_repr_rust(x: Option<Rust<num::NonZero<u8>>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -80,7 +106,7 @@ LL | fn option_repr_rust(x: Option<Rust<num::NonZero<u8>>>); = note: enum has no representation hint error: `extern` block uses type `Option<u8>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:97:21 + --> $DIR/lint-ctypes-enum.rs:115:21 | LL | fn option_u8(x: Option<u8>); | ^^^^^^^^^^ not FFI-safe @@ -89,7 +115,7 @@ LL | fn option_u8(x: Option<u8>); = note: enum has no representation hint error: `extern` block uses type `u128`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:107:33 + --> $DIR/lint-ctypes-enum.rs:125:33 | LL | fn result_nonzero_u128_t(x: Result<num::NonZero<u128>, ()>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -97,7 +123,7 @@ LL | fn result_nonzero_u128_t(x: Result<num::NonZero<u128>, ()>); = note: 128-bit integers don't currently have a known stable ABI error: `extern` block uses type `i128`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:114:33 + --> $DIR/lint-ctypes-enum.rs:132:33 | LL | fn result_nonzero_i128_t(x: Result<num::NonZero<i128>, ()>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -105,7 +131,7 @@ LL | fn result_nonzero_i128_t(x: Result<num::NonZero<i128>, ()>); = note: 128-bit integers don't currently have a known stable ABI error: `extern` block uses type `Result<TransparentUnion<NonZero<u8>>, ()>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:119:38 + --> $DIR/lint-ctypes-enum.rs:137:38 | LL | fn result_transparent_union_t(x: Result<TransparentUnion<num::NonZero<u8>>, ()>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -114,7 +140,7 @@ LL | fn result_transparent_union_t(x: Result<TransparentUnion<num::NonZero<u = note: enum has no representation hint error: `extern` block uses type `Result<Rust<NonZero<u8>>, ()>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:121:30 + --> $DIR/lint-ctypes-enum.rs:139:30 | LL | fn result_repr_rust_t(x: Result<Rust<num::NonZero<u8>>, ()>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -123,7 +149,7 @@ LL | fn result_repr_rust_t(x: Result<Rust<num::NonZero<u8>>, ()>); = note: enum has no representation hint error: `extern` block uses type `Result<NonZero<u8>, U>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:125:51 + --> $DIR/lint-ctypes-enum.rs:143:51 | LL | fn result_1zst_exhaustive_single_variant_t(x: Result<num::NonZero<u8>, U>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -132,7 +158,7 @@ LL | fn result_1zst_exhaustive_single_variant_t(x: Result<num::NonZero<u8>, = note: enum has no representation hint error: `extern` block uses type `Result<NonZero<u8>, B>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:127:53 + --> $DIR/lint-ctypes-enum.rs:145:53 | LL | fn result_1zst_exhaustive_multiple_variant_t(x: Result<num::NonZero<u8>, B>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -141,7 +167,7 @@ LL | fn result_1zst_exhaustive_multiple_variant_t(x: Result<num::NonZero<u8> = note: enum has no representation hint error: `extern` block uses type `Result<NonZero<u8>, NonExhaustive>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:129:51 + --> $DIR/lint-ctypes-enum.rs:147:51 | LL | fn result_1zst_non_exhaustive_no_variant_t(x: Result<num::NonZero<u8>, NonExhaustive>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -150,7 +176,7 @@ LL | fn result_1zst_non_exhaustive_no_variant_t(x: Result<num::NonZero<u8>, = note: enum has no representation hint error: `extern` block uses type `Result<NonZero<u8>, Field>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:132:49 + --> $DIR/lint-ctypes-enum.rs:150:49 | LL | fn result_1zst_exhaustive_single_field_t(x: Result<num::NonZero<u8>, Field>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -159,7 +185,7 @@ LL | fn result_1zst_exhaustive_single_field_t(x: Result<num::NonZero<u8>, Fi = note: enum has no representation hint error: `extern` block uses type `Result<Result<(), NonZero<u8>>, ()>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:134:30 + --> $DIR/lint-ctypes-enum.rs:152:30 | LL | fn result_cascading_t(x: Result<Result<(), num::NonZero<u8>>, ()>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -168,7 +194,7 @@ LL | fn result_cascading_t(x: Result<Result<(), num::NonZero<u8>>, ()>); = note: enum has no representation hint error: `extern` block uses type `u128`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:145:33 + --> $DIR/lint-ctypes-enum.rs:163:33 | LL | fn result_nonzero_u128_e(x: Result<(), num::NonZero<u128>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -176,7 +202,7 @@ LL | fn result_nonzero_u128_e(x: Result<(), num::NonZero<u128>>); = note: 128-bit integers don't currently have a known stable ABI error: `extern` block uses type `i128`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:152:33 + --> $DIR/lint-ctypes-enum.rs:170:33 | LL | fn result_nonzero_i128_e(x: Result<(), num::NonZero<i128>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -184,7 +210,7 @@ LL | fn result_nonzero_i128_e(x: Result<(), num::NonZero<i128>>); = note: 128-bit integers don't currently have a known stable ABI error: `extern` block uses type `Result<(), TransparentUnion<NonZero<u8>>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:157:38 + --> $DIR/lint-ctypes-enum.rs:175:38 | LL | fn result_transparent_union_e(x: Result<(), TransparentUnion<num::NonZero<u8>>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -193,7 +219,7 @@ LL | fn result_transparent_union_e(x: Result<(), TransparentUnion<num::NonZe = note: enum has no representation hint error: `extern` block uses type `Result<(), Rust<NonZero<u8>>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:159:30 + --> $DIR/lint-ctypes-enum.rs:177:30 | LL | fn result_repr_rust_e(x: Result<(), Rust<num::NonZero<u8>>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -202,7 +228,7 @@ LL | fn result_repr_rust_e(x: Result<(), Rust<num::NonZero<u8>>>); = note: enum has no representation hint error: `extern` block uses type `Result<U, NonZero<u8>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:163:51 + --> $DIR/lint-ctypes-enum.rs:181:51 | LL | fn result_1zst_exhaustive_single_variant_e(x: Result<U, num::NonZero<u8>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -211,7 +237,7 @@ LL | fn result_1zst_exhaustive_single_variant_e(x: Result<U, num::NonZero<u8 = note: enum has no representation hint error: `extern` block uses type `Result<B, NonZero<u8>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:165:53 + --> $DIR/lint-ctypes-enum.rs:183:53 | LL | fn result_1zst_exhaustive_multiple_variant_e(x: Result<B, num::NonZero<u8>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -220,7 +246,7 @@ LL | fn result_1zst_exhaustive_multiple_variant_e(x: Result<B, num::NonZero< = note: enum has no representation hint error: `extern` block uses type `Result<NonExhaustive, NonZero<u8>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:167:51 + --> $DIR/lint-ctypes-enum.rs:185:51 | LL | fn result_1zst_non_exhaustive_no_variant_e(x: Result<NonExhaustive, num::NonZero<u8>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -229,7 +255,7 @@ LL | fn result_1zst_non_exhaustive_no_variant_e(x: Result<NonExhaustive, num = note: enum has no representation hint error: `extern` block uses type `Result<Field, NonZero<u8>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:170:49 + --> $DIR/lint-ctypes-enum.rs:188:49 | LL | fn result_1zst_exhaustive_single_field_e(x: Result<Field, num::NonZero<u8>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -238,7 +264,7 @@ LL | fn result_1zst_exhaustive_single_field_e(x: Result<Field, num::NonZero< = note: enum has no representation hint error: `extern` block uses type `Result<(), Result<(), NonZero<u8>>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:172:30 + --> $DIR/lint-ctypes-enum.rs:190:30 | LL | fn result_cascading_e(x: Result<(), Result<(), num::NonZero<u8>>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -247,7 +273,7 @@ LL | fn result_cascading_e(x: Result<(), Result<(), num::NonZero<u8>>>); = note: enum has no representation hint error: `extern` block uses type `Result<(), ()>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:174:27 + --> $DIR/lint-ctypes-enum.rs:192:27 | LL | fn result_unit_t_e(x: Result<(), ()>); | ^^^^^^^^^^^^^^ not FFI-safe @@ -255,5 +281,5 @@ LL | fn result_unit_t_e(x: Result<(), ()>); = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum = note: enum has no representation hint -error: aborting due to 27 previous errors +error: aborting due to 29 previous errors diff --git a/tests/ui/lint/non-snake-case/lint-uppercase-variables.rs b/tests/ui/lint/non-snake-case/lint-uppercase-variables.rs index 59dba536f24..aefbe63606a 100644 --- a/tests/ui/lint/non-snake-case/lint-uppercase-variables.rs +++ b/tests/ui/lint/non-snake-case/lint-uppercase-variables.rs @@ -35,6 +35,9 @@ fn main() { //~^^ ERROR `Foo` is named the same as one of the variants of the type `foo::Foo` //~^^^ WARN unused variable: `Foo` + let _: fn(CamelCase: i32); + //~^ ERROR variable `CamelCase` should have a snake case name + test(1); let _ = Something { X: 0 }; diff --git a/tests/ui/lint/non-snake-case/lint-uppercase-variables.stderr b/tests/ui/lint/non-snake-case/lint-uppercase-variables.stderr index 9220828014f..b0c56003957 100644 --- a/tests/ui/lint/non-snake-case/lint-uppercase-variables.stderr +++ b/tests/ui/lint/non-snake-case/lint-uppercase-variables.stderr @@ -85,6 +85,12 @@ error: variable `Foo` should have a snake case name LL | fn in_param(Foo: foo::Foo) {} | ^^^ help: convert the identifier to snake case (notice the capitalization): `foo` -error: aborting due to 9 previous errors; 3 warnings emitted +error: variable `CamelCase` should have a snake case name + --> $DIR/lint-uppercase-variables.rs:38:15 + | +LL | let _: fn(CamelCase: i32); + | ^^^^^^^^^ help: convert the identifier to snake case: `camel_case` + +error: aborting due to 10 previous errors; 3 warnings emitted For more information about this error, try `rustc --explain E0170`. diff --git a/tests/ui/lint/static-mut-refs.e2021.stderr b/tests/ui/lint/static-mut-refs.e2021.stderr index 00a2ca99f24..320e0cee8e8 100644 --- a/tests/ui/lint/static-mut-refs.e2021.stderr +++ b/tests/ui/lint/static-mut-refs.e2021.stderr @@ -1,4 +1,4 @@ -warning: creating a shared reference to mutable static is discouraged +warning: creating a shared reference to mutable static --> $DIR/static-mut-refs.rs:38:18 | LL | let _y = &X; @@ -12,7 +12,7 @@ help: use `&raw const` instead to create a raw pointer LL | let _y = &raw const X; | +++++++++ -warning: creating a mutable reference to mutable static is discouraged +warning: creating a mutable reference to mutable static --> $DIR/static-mut-refs.rs:42:18 | LL | let _y = &mut X; @@ -25,7 +25,7 @@ help: use `&raw mut` instead to create a raw pointer LL | let _y = &raw mut X; | +++ -warning: creating a shared reference to mutable static is discouraged +warning: creating a shared reference to mutable static --> $DIR/static-mut-refs.rs:50:22 | LL | let ref _a = X; @@ -34,7 +34,7 @@ LL | let ref _a = X; = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html> = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives -warning: creating a shared reference to mutable static is discouraged +warning: creating a shared reference to mutable static --> $DIR/static-mut-refs.rs:54:25 | LL | let (_b, _c) = (&X, &Y); @@ -47,7 +47,7 @@ help: use `&raw const` instead to create a raw pointer LL | let (_b, _c) = (&raw const X, &Y); | +++++++++ -warning: creating a shared reference to mutable static is discouraged +warning: creating a shared reference to mutable static --> $DIR/static-mut-refs.rs:54:29 | LL | let (_b, _c) = (&X, &Y); @@ -60,7 +60,7 @@ help: use `&raw const` instead to create a raw pointer LL | let (_b, _c) = (&X, &raw const Y); | +++++++++ -warning: creating a shared reference to mutable static is discouraged +warning: creating a shared reference to mutable static --> $DIR/static-mut-refs.rs:60:13 | LL | foo(&X); @@ -73,7 +73,7 @@ help: use `&raw const` instead to create a raw pointer LL | foo(&raw const X); | +++++++++ -warning: creating a shared reference to mutable static is discouraged +warning: creating a shared reference to mutable static --> $DIR/static-mut-refs.rs:66:17 | LL | let _ = Z.len(); @@ -82,7 +82,7 @@ LL | let _ = Z.len(); = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html> = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives -warning: creating a shared reference to mutable static is discouraged +warning: creating a shared reference to mutable static --> $DIR/static-mut-refs.rs:72:33 | LL | let _ = format!("{:?}", Z); @@ -91,7 +91,7 @@ LL | let _ = format!("{:?}", Z); = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html> = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives -warning: creating a shared reference to mutable static is discouraged +warning: creating a shared reference to mutable static --> $DIR/static-mut-refs.rs:76:18 | LL | let _v = &A.value; @@ -104,7 +104,7 @@ help: use `&raw const` instead to create a raw pointer LL | let _v = &raw const A.value; | +++++++++ -warning: creating a shared reference to mutable static is discouraged +warning: creating a shared reference to mutable static --> $DIR/static-mut-refs.rs:80:18 | LL | let _s = &A.s.value; @@ -117,7 +117,7 @@ help: use `&raw const` instead to create a raw pointer LL | let _s = &raw const A.s.value; | +++++++++ -warning: creating a shared reference to mutable static is discouraged +warning: creating a shared reference to mutable static --> $DIR/static-mut-refs.rs:84:22 | LL | let ref _v = A.value; @@ -126,7 +126,7 @@ LL | let ref _v = A.value; = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html> = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives -warning: creating a mutable reference to mutable static is discouraged +warning: creating a mutable reference to mutable static --> $DIR/static-mut-refs.rs:14:14 | LL | &mut ($x.0) diff --git a/tests/ui/lint/static-mut-refs.e2024.stderr b/tests/ui/lint/static-mut-refs.e2024.stderr index ff41f316250..bf7ffc62ce1 100644 --- a/tests/ui/lint/static-mut-refs.e2024.stderr +++ b/tests/ui/lint/static-mut-refs.e2024.stderr @@ -1,4 +1,4 @@ -error: creating a shared reference to mutable static is discouraged +error: creating a shared reference to mutable static --> $DIR/static-mut-refs.rs:38:18 | LL | let _y = &X; @@ -12,7 +12,7 @@ help: use `&raw const` instead to create a raw pointer LL | let _y = &raw const X; | +++++++++ -error: creating a mutable reference to mutable static is discouraged +error: creating a mutable reference to mutable static --> $DIR/static-mut-refs.rs:42:18 | LL | let _y = &mut X; @@ -25,7 +25,7 @@ help: use `&raw mut` instead to create a raw pointer LL | let _y = &raw mut X; | +++ -error: creating a shared reference to mutable static is discouraged +error: creating a shared reference to mutable static --> $DIR/static-mut-refs.rs:50:22 | LL | let ref _a = X; @@ -34,7 +34,7 @@ LL | let ref _a = X; = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html> = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives -error: creating a shared reference to mutable static is discouraged +error: creating a shared reference to mutable static --> $DIR/static-mut-refs.rs:54:25 | LL | let (_b, _c) = (&X, &Y); @@ -47,7 +47,7 @@ help: use `&raw const` instead to create a raw pointer LL | let (_b, _c) = (&raw const X, &Y); | +++++++++ -error: creating a shared reference to mutable static is discouraged +error: creating a shared reference to mutable static --> $DIR/static-mut-refs.rs:54:29 | LL | let (_b, _c) = (&X, &Y); @@ -60,7 +60,7 @@ help: use `&raw const` instead to create a raw pointer LL | let (_b, _c) = (&X, &raw const Y); | +++++++++ -error: creating a shared reference to mutable static is discouraged +error: creating a shared reference to mutable static --> $DIR/static-mut-refs.rs:60:13 | LL | foo(&X); @@ -73,7 +73,7 @@ help: use `&raw const` instead to create a raw pointer LL | foo(&raw const X); | +++++++++ -error: creating a shared reference to mutable static is discouraged +error: creating a shared reference to mutable static --> $DIR/static-mut-refs.rs:66:17 | LL | let _ = Z.len(); @@ -82,7 +82,7 @@ LL | let _ = Z.len(); = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html> = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives -error: creating a shared reference to mutable static is discouraged +error: creating a shared reference to mutable static --> $DIR/static-mut-refs.rs:72:33 | LL | let _ = format!("{:?}", Z); @@ -91,7 +91,7 @@ LL | let _ = format!("{:?}", Z); = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html> = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives -error: creating a shared reference to mutable static is discouraged +error: creating a shared reference to mutable static --> $DIR/static-mut-refs.rs:76:18 | LL | let _v = &A.value; @@ -104,7 +104,7 @@ help: use `&raw const` instead to create a raw pointer LL | let _v = &raw const A.value; | +++++++++ -error: creating a shared reference to mutable static is discouraged +error: creating a shared reference to mutable static --> $DIR/static-mut-refs.rs:80:18 | LL | let _s = &A.s.value; @@ -117,7 +117,7 @@ help: use `&raw const` instead to create a raw pointer LL | let _s = &raw const A.s.value; | +++++++++ -error: creating a shared reference to mutable static is discouraged +error: creating a shared reference to mutable static --> $DIR/static-mut-refs.rs:84:22 | LL | let ref _v = A.value; @@ -126,7 +126,7 @@ LL | let ref _v = A.value; = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html> = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives -error: creating a mutable reference to mutable static is discouraged +error: creating a mutable reference to mutable static --> $DIR/static-mut-refs.rs:14:14 | LL | &mut ($x.0) diff --git a/tests/ui/lint/static-mut-refs.rs b/tests/ui/lint/static-mut-refs.rs index 1040dfcae7a..d2511fb5b12 100644 --- a/tests/ui/lint/static-mut-refs.rs +++ b/tests/ui/lint/static-mut-refs.rs @@ -12,8 +12,8 @@ static mut FOO: (u32, u32) = (1, 2); macro_rules! bar { ($x:expr) => { &mut ($x.0) - //[e2021]~^ WARN creating a mutable reference to mutable static is discouraged [static_mut_refs] - //[e2024]~^^ ERROR creating a mutable reference to mutable static is discouraged [static_mut_refs] + //[e2021]~^ WARN creating a mutable reference to mutable static [static_mut_refs] + //[e2024]~^^ ERROR creating a mutable reference to mutable static [static_mut_refs] }; } @@ -36,54 +36,54 @@ fn main() { unsafe { let _y = &X; - //[e2021]~^ WARN shared reference to mutable static is discouraged [static_mut_refs] - //[e2024]~^^ ERROR shared reference to mutable static is discouraged [static_mut_refs] + //[e2021]~^ WARN shared reference to mutable static [static_mut_refs] + //[e2024]~^^ ERROR shared reference to mutable static [static_mut_refs] let _y = &mut X; - //[e2021]~^ WARN mutable reference to mutable static is discouraged [static_mut_refs] - //[e2024]~^^ ERROR mutable reference to mutable static is discouraged [static_mut_refs] + //[e2021]~^ WARN mutable reference to mutable static [static_mut_refs] + //[e2024]~^^ ERROR mutable reference to mutable static [static_mut_refs] let _z = &raw mut X; let _p = &raw const X; let ref _a = X; - //[e2021]~^ WARN shared reference to mutable static is discouraged [static_mut_refs] - //[e2024]~^^ ERROR shared reference to mutable static is discouraged [static_mut_refs] + //[e2021]~^ WARN shared reference to mutable static [static_mut_refs] + //[e2024]~^^ ERROR shared reference to mutable static [static_mut_refs] let (_b, _c) = (&X, &Y); - //[e2021]~^ WARN shared reference to mutable static is discouraged [static_mut_refs] - //[e2024]~^^ ERROR shared reference to mutable static is discouraged [static_mut_refs] - //[e2021]~^^^ WARN shared reference to mutable static is discouraged [static_mut_refs] - //[e2024]~^^^^ ERROR shared reference to mutable static is discouraged [static_mut_refs] + //[e2021]~^ WARN shared reference to mutable static [static_mut_refs] + //[e2024]~^^ ERROR shared reference to mutable static [static_mut_refs] + //[e2021]~^^^ WARN shared reference to mutable static [static_mut_refs] + //[e2024]~^^^^ ERROR shared reference to mutable static [static_mut_refs] foo(&X); - //[e2021]~^ WARN shared reference to mutable static is discouraged [static_mut_refs] - //[e2024]~^^ ERROR shared reference to mutable static is discouraged [static_mut_refs] + //[e2021]~^ WARN shared reference to mutable static [static_mut_refs] + //[e2024]~^^ ERROR shared reference to mutable static [static_mut_refs] static mut Z: &[i32; 3] = &[0, 1, 2]; let _ = Z.len(); - //[e2021]~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs] - //[e2024]~^^ ERROR creating a shared reference to mutable static is discouraged [static_mut_refs] + //[e2021]~^ WARN creating a shared reference to mutable static [static_mut_refs] + //[e2024]~^^ ERROR creating a shared reference to mutable static [static_mut_refs] let _ = Z[0]; let _ = format!("{:?}", Z); - //[e2021]~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs] - //[e2024]~^^ ERROR creating a shared reference to mutable static is discouraged [static_mut_refs] + //[e2021]~^ WARN creating a shared reference to mutable static [static_mut_refs] + //[e2024]~^^ ERROR creating a shared reference to mutable static [static_mut_refs] let _v = &A.value; - //[e2021]~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs] - //[e2024]~^^ ERROR creating a shared reference to mutable static is discouraged [static_mut_refs] + //[e2021]~^ WARN creating a shared reference to mutable static [static_mut_refs] + //[e2024]~^^ ERROR creating a shared reference to mutable static [static_mut_refs] let _s = &A.s.value; - //[e2021]~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs] - //[e2024]~^^ ERROR creating a shared reference to mutable static is discouraged [static_mut_refs] + //[e2021]~^ WARN creating a shared reference to mutable static [static_mut_refs] + //[e2024]~^^ ERROR creating a shared reference to mutable static [static_mut_refs] let ref _v = A.value; - //[e2021]~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs] - //[e2024]~^^ ERROR creating a shared reference to mutable static is discouraged [static_mut_refs] + //[e2021]~^ WARN creating a shared reference to mutable static [static_mut_refs] + //[e2024]~^^ ERROR creating a shared reference to mutable static [static_mut_refs] let _x = bar!(FOO); diff --git a/tests/ui/lint/unused-parens-for-macro-call-with-brace.fixed b/tests/ui/lint/unused-parens-for-macro-call-with-brace.fixed new file mode 100644 index 00000000000..4c9995fcb61 --- /dev/null +++ b/tests/ui/lint/unused-parens-for-macro-call-with-brace.fixed @@ -0,0 +1,28 @@ +//@ run-rustfix + +#![deny(unused_parens)] + +fn main() { + macro_rules! x { + () => { None::<i32> }; + } + + let Some(_) = (x!{}) else { return }; // no error + let Some(_) = (x!{}) else { return }; + //~^ ERROR: unnecessary parentheses around assigned value + + let Some(_) = (x!{}) else { return }; + //~^ ERROR: unnecessary parentheses around pattern + + let _ = x!{}; + let _ = x!{}; + //~^ ERROR: unnecessary parentheses around assigned value + + if let Some(_) = x!{} {}; + if let Some(_) = x!{} {}; + //~^ ERROR: unnecessary parentheses around `let` scrutinee expression + + while let Some(_) = x!{} {}; + while let Some(_) = x!{} {}; + //~^ ERROR: unnecessary parentheses around `let` scrutinee expression +} diff --git a/tests/ui/lint/unused-parens-for-macro-call-with-brace.rs b/tests/ui/lint/unused-parens-for-macro-call-with-brace.rs new file mode 100644 index 00000000000..59e215a48cc --- /dev/null +++ b/tests/ui/lint/unused-parens-for-macro-call-with-brace.rs @@ -0,0 +1,28 @@ +//@ run-rustfix + +#![deny(unused_parens)] + +fn main() { + macro_rules! x { + () => { None::<i32> }; + } + + let Some(_) = (x!{}) else { return }; // no error + let Some(_) = ((x!{})) else { return }; + //~^ ERROR: unnecessary parentheses around assigned value + + let Some((_)) = (x!{}) else { return }; + //~^ ERROR: unnecessary parentheses around pattern + + let _ = x!{}; + let _ = (x!{}); + //~^ ERROR: unnecessary parentheses around assigned value + + if let Some(_) = x!{} {}; + if let Some(_) = (x!{}) {}; + //~^ ERROR: unnecessary parentheses around `let` scrutinee expression + + while let Some(_) = x!{} {}; + while let Some(_) = (x!{}) {}; + //~^ ERROR: unnecessary parentheses around `let` scrutinee expression +} diff --git a/tests/ui/lint/unused-parens-for-macro-call-with-brace.stderr b/tests/ui/lint/unused-parens-for-macro-call-with-brace.stderr new file mode 100644 index 00000000000..8d3b4fe493e --- /dev/null +++ b/tests/ui/lint/unused-parens-for-macro-call-with-brace.stderr @@ -0,0 +1,67 @@ +error: unnecessary parentheses around assigned value + --> $DIR/unused-parens-for-macro-call-with-brace.rs:11:19 + | +LL | let Some(_) = ((x!{})) else { return }; + | ^ ^ + | +note: the lint level is defined here + --> $DIR/unused-parens-for-macro-call-with-brace.rs:3:9 + | +LL | #![deny(unused_parens)] + | ^^^^^^^^^^^^^ +help: remove these parentheses + | +LL - let Some(_) = ((x!{})) else { return }; +LL + let Some(_) = (x!{}) else { return }; + | + +error: unnecessary parentheses around pattern + --> $DIR/unused-parens-for-macro-call-with-brace.rs:14:14 + | +LL | let Some((_)) = (x!{}) else { return }; + | ^ ^ + | +help: remove these parentheses + | +LL - let Some((_)) = (x!{}) else { return }; +LL + let Some(_) = (x!{}) else { return }; + | + +error: unnecessary parentheses around assigned value + --> $DIR/unused-parens-for-macro-call-with-brace.rs:18:13 + | +LL | let _ = (x!{}); + | ^ ^ + | +help: remove these parentheses + | +LL - let _ = (x!{}); +LL + let _ = x!{}; + | + +error: unnecessary parentheses around `let` scrutinee expression + --> $DIR/unused-parens-for-macro-call-with-brace.rs:22:22 + | +LL | if let Some(_) = (x!{}) {}; + | ^ ^ + | +help: remove these parentheses + | +LL - if let Some(_) = (x!{}) {}; +LL + if let Some(_) = x!{} {}; + | + +error: unnecessary parentheses around `let` scrutinee expression + --> $DIR/unused-parens-for-macro-call-with-brace.rs:26:25 + | +LL | while let Some(_) = (x!{}) {}; + | ^ ^ + | +help: remove these parentheses + | +LL - while let Some(_) = (x!{}) {}; +LL + while let Some(_) = x!{} {}; + | + +error: aborting due to 5 previous errors + diff --git a/tests/ui/lint/wasm_c_abi_transition.rs b/tests/ui/lint/wasm_c_abi_transition.rs index 6a933a0de03..411772ae890 100644 --- a/tests/ui/lint/wasm_c_abi_transition.rs +++ b/tests/ui/lint/wasm_c_abi_transition.rs @@ -3,7 +3,7 @@ //@ add-core-stubs //@ build-fail -#![feature(no_core)] +#![feature(no_core, repr_simd)] #![no_core] #![crate_type = "lib"] #![deny(wasm_c_abi)] @@ -45,3 +45,13 @@ pub fn call_other_fun(x: MyType) { pub struct MyZstType; #[allow(improper_ctypes_definitions)] pub extern "C" fn zst_safe(_x: (), _y: MyZstType) {} + +// The old and new wasm ABI treats simd types like `v128` the same way, so no +// wasm_c_abi warning should be emitted. +#[repr(simd)] +#[allow(non_camel_case_types)] +pub struct v128([i32; 4]); +#[target_feature(enable = "simd128")] +pub extern "C" fn my_safe_simd(x: v128) -> v128 { x } +//~^ WARN `extern` fn uses type `v128`, which is not FFI-safe +//~| WARN `extern` fn uses type `v128`, which is not FFI-safe diff --git a/tests/ui/lint/wasm_c_abi_transition.stderr b/tests/ui/lint/wasm_c_abi_transition.stderr index 389710d5cb3..b4526bf8d68 100644 --- a/tests/ui/lint/wasm_c_abi_transition.stderr +++ b/tests/ui/lint/wasm_c_abi_transition.stderr @@ -1,3 +1,32 @@ +warning: `extern` fn uses type `v128`, which is not FFI-safe + --> $DIR/wasm_c_abi_transition.rs:55:35 + | +LL | pub extern "C" fn my_safe_simd(x: v128) -> v128 { x } + | ^^^^ not FFI-safe + | + = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct + = note: this struct has unspecified layout +note: the type is defined here + --> $DIR/wasm_c_abi_transition.rs:53:1 + | +LL | pub struct v128([i32; 4]); + | ^^^^^^^^^^^^^^^ + = note: `#[warn(improper_ctypes_definitions)]` on by default + +warning: `extern` fn uses type `v128`, which is not FFI-safe + --> $DIR/wasm_c_abi_transition.rs:55:44 + | +LL | pub extern "C" fn my_safe_simd(x: v128) -> v128 { x } + | ^^^^ not FFI-safe + | + = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct + = note: this struct has unspecified layout +note: the type is defined here + --> $DIR/wasm_c_abi_transition.rs:53:1 + | +LL | pub struct v128([i32; 4]); + | ^^^^^^^^^^^^^^^ + error: this function definition involves an argument of type `MyType` which is affected by the wasm ABI transition --> $DIR/wasm_c_abi_transition.rs:18:1 | @@ -33,7 +62,7 @@ LL | unsafe { other_fun(x) } = note: for more information, see issue #138762 <https://github.com/rust-lang/rust/issues/138762> = help: the "C" ABI Rust uses on wasm32-unknown-unknown will change to align with the standard "C" ABI for this target -error: aborting due to 3 previous errors +error: aborting due to 3 previous errors; 2 warnings emitted Future incompatibility report: Future breakage diagnostic: error: this function definition involves an argument of type `MyType` which is affected by the wasm ABI transition diff --git a/tests/ui/macros/issue-118786.rs b/tests/ui/macros/issue-118786.rs index a73b737fe07..78fd6ab6edd 100644 --- a/tests/ui/macros/issue-118786.rs +++ b/tests/ui/macros/issue-118786.rs @@ -1,4 +1,5 @@ //@ compile-flags: --crate-type lib -O -C debug-assertions=yes +//@ dont-require-annotations: NOTE // Regression test for issue 118786 @@ -7,7 +8,7 @@ macro_rules! make_macro { macro_rules! $macro_name { //~^ ERROR macro expansion ignores `{` and any tokens following //~| ERROR cannot find macro `macro_rules` in this scope - //~| put a macro name here + //~| NOTE put a macro name here () => {} } } diff --git a/tests/ui/macros/issue-118786.stderr b/tests/ui/macros/issue-118786.stderr index af4cc9ad863..ddec281b823 100644 --- a/tests/ui/macros/issue-118786.stderr +++ b/tests/ui/macros/issue-118786.stderr @@ -1,5 +1,5 @@ error: macros that expand to items must be delimited with braces or followed by a semicolon - --> $DIR/issue-118786.rs:16:13 + --> $DIR/issue-118786.rs:17:13 | LL | make_macro!((meow)); | ^^^^^^ @@ -15,7 +15,7 @@ LL | macro_rules! $macro_name; { | + error: macro expansion ignores `{` and any tokens following - --> $DIR/issue-118786.rs:7:34 + --> $DIR/issue-118786.rs:8:34 | LL | macro_rules! $macro_name { | ^ @@ -26,7 +26,7 @@ LL | make_macro!((meow)); = note: the usage of `make_macro!` is likely invalid in item context error: cannot find macro `macro_rules` in this scope - --> $DIR/issue-118786.rs:7:9 + --> $DIR/issue-118786.rs:8:9 | LL | macro_rules! $macro_name { | ^^^^^^^^^^^ @@ -35,7 +35,7 @@ LL | make_macro!((meow)); | ------------------- in this macro invocation | note: maybe you have forgotten to define a name for this `macro_rules!` - --> $DIR/issue-118786.rs:7:20 + --> $DIR/issue-118786.rs:8:20 | LL | macro_rules! $macro_name { | ^ put a macro name here diff --git a/tests/ui/macros/issue-29084.rs b/tests/ui/macros/issue-29084.rs index d1625268669..a0a2966f75b 100644 --- a/tests/ui/macros/issue-29084.rs +++ b/tests/ui/macros/issue-29084.rs @@ -1,13 +1,15 @@ +//@ dont-require-annotations: NOTE + macro_rules! foo { ($d:expr) => {{ fn bar(d: u8) { } bar(&mut $d); //~^ ERROR mismatched types - //~| expected `u8`, found `&mut u8` + //~| NOTE expected `u8`, found `&mut u8` }} } fn main() { foo!(0u8); - //~^ in this expansion of foo! + //~^ NOTE in this expansion of foo! } diff --git a/tests/ui/macros/issue-29084.stderr b/tests/ui/macros/issue-29084.stderr index 9c33e4e8427..6e7474c5b3f 100644 --- a/tests/ui/macros/issue-29084.stderr +++ b/tests/ui/macros/issue-29084.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-29084.rs:4:13 + --> $DIR/issue-29084.rs:6:13 | LL | bar(&mut $d); | --- ^^^^^^^ expected `u8`, found `&mut u8` @@ -10,7 +10,7 @@ LL | foo!(0u8); | --------- in this macro invocation | note: function defined here - --> $DIR/issue-29084.rs:3:12 + --> $DIR/issue-29084.rs:5:12 | LL | fn bar(d: u8) { } | ^^^ ----- diff --git a/tests/ui/macros/macros-nonfatal-errors.rs b/tests/ui/macros/macros-nonfatal-errors.rs index 79beffbe986..091d64ea5d9 100644 --- a/tests/ui/macros/macros-nonfatal-errors.rs +++ b/tests/ui/macros/macros-nonfatal-errors.rs @@ -5,6 +5,7 @@ #![feature(trace_macros, concat_idents)] #![feature(stmt_expr_attributes)] +#![expect(deprecated)] // concat_idents is deprecated use std::arch::asm; diff --git a/tests/ui/macros/macros-nonfatal-errors.stderr b/tests/ui/macros/macros-nonfatal-errors.stderr index 44194b506a4..2f990cb24e2 100644 --- a/tests/ui/macros/macros-nonfatal-errors.stderr +++ b/tests/ui/macros/macros-nonfatal-errors.stderr @@ -1,5 +1,5 @@ error: the `#[default]` attribute may only be used on unit enum variants - --> $DIR/macros-nonfatal-errors.rs:13:5 + --> $DIR/macros-nonfatal-errors.rs:14:5 | LL | #[default] | ^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | #[default] = help: consider a manual implementation of `Default` error: the `#[default]` attribute may only be used on unit enum variants - --> $DIR/macros-nonfatal-errors.rs:18:36 + --> $DIR/macros-nonfatal-errors.rs:19:36 | LL | struct DefaultInnerAttrTupleStruct(#[default] ()); | ^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | struct DefaultInnerAttrTupleStruct(#[default] ()); = help: consider a manual implementation of `Default` error: the `#[default]` attribute may only be used on unit enum variants - --> $DIR/macros-nonfatal-errors.rs:22:1 + --> $DIR/macros-nonfatal-errors.rs:23:1 | LL | #[default] | ^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | #[default] = help: consider a manual implementation of `Default` error: the `#[default]` attribute may only be used on unit enum variants - --> $DIR/macros-nonfatal-errors.rs:26:1 + --> $DIR/macros-nonfatal-errors.rs:27:1 | LL | #[default] | ^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | #[default] = help: consider a manual implementation of `Default` error: the `#[default]` attribute may only be used on unit enum variants - --> $DIR/macros-nonfatal-errors.rs:36:11 + --> $DIR/macros-nonfatal-errors.rs:37:11 | LL | Foo = #[default] 0, | ^^^^^^^^^^ @@ -39,7 +39,7 @@ LL | Foo = #[default] 0, = help: consider a manual implementation of `Default` error: the `#[default]` attribute may only be used on unit enum variants - --> $DIR/macros-nonfatal-errors.rs:37:14 + --> $DIR/macros-nonfatal-errors.rs:38:14 | LL | Bar([u8; #[default] 1]), | ^^^^^^^^^^ @@ -47,7 +47,7 @@ LL | Bar([u8; #[default] 1]), = help: consider a manual implementation of `Default` error[E0665]: `#[derive(Default)]` on enum with no `#[default]` - --> $DIR/macros-nonfatal-errors.rs:42:10 + --> $DIR/macros-nonfatal-errors.rs:43:10 | LL | #[derive(Default)] | ^^^^^^^ @@ -67,7 +67,7 @@ LL | #[default] Bar, | ++++++++++ error[E0665]: `#[derive(Default)]` on enum with no `#[default]` - --> $DIR/macros-nonfatal-errors.rs:48:10 + --> $DIR/macros-nonfatal-errors.rs:49:10 | LL | #[derive(Default)] | ^^^^^^^ @@ -78,7 +78,7 @@ LL | | } | |_- this enum needs a unit variant marked with `#[default]` error: multiple declared defaults - --> $DIR/macros-nonfatal-errors.rs:54:10 + --> $DIR/macros-nonfatal-errors.rs:55:10 | LL | #[derive(Default)] | ^^^^^^^ @@ -95,7 +95,7 @@ LL | Baz, = note: only one variant can be default error: `#[default]` attribute does not accept a value - --> $DIR/macros-nonfatal-errors.rs:66:5 + --> $DIR/macros-nonfatal-errors.rs:67:5 | LL | #[default = 1] | ^^^^^^^^^^^^^^ @@ -103,7 +103,7 @@ LL | #[default = 1] = help: try using `#[default]` error: multiple `#[default]` attributes - --> $DIR/macros-nonfatal-errors.rs:74:5 + --> $DIR/macros-nonfatal-errors.rs:75:5 | LL | #[default] | ---------- `#[default]` used here @@ -114,13 +114,13 @@ LL | Foo, | = note: only one `#[default]` attribute is needed help: try removing this - --> $DIR/macros-nonfatal-errors.rs:73:5 + --> $DIR/macros-nonfatal-errors.rs:74:5 | LL | #[default] | ^^^^^^^^^^ error: multiple `#[default]` attributes - --> $DIR/macros-nonfatal-errors.rs:84:5 + --> $DIR/macros-nonfatal-errors.rs:85:5 | LL | #[default] | ---------- `#[default]` used here @@ -132,7 +132,7 @@ LL | Foo, | = note: only one `#[default]` attribute is needed help: try removing these - --> $DIR/macros-nonfatal-errors.rs:81:5 + --> $DIR/macros-nonfatal-errors.rs:82:5 | LL | #[default] | ^^^^^^^^^^ @@ -142,7 +142,7 @@ LL | #[default] | ^^^^^^^^^^ error: the `#[default]` attribute may only be used on unit enum variants - --> $DIR/macros-nonfatal-errors.rs:91:5 + --> $DIR/macros-nonfatal-errors.rs:92:5 | LL | Foo {}, | ^^^ @@ -150,7 +150,7 @@ LL | Foo {}, = help: consider a manual implementation of `Default` error: default variant must be exhaustive - --> $DIR/macros-nonfatal-errors.rs:99:5 + --> $DIR/macros-nonfatal-errors.rs:100:5 | LL | #[non_exhaustive] | ----------------- declared `#[non_exhaustive]` here @@ -160,37 +160,37 @@ LL | Foo, = help: consider a manual implementation of `Default` error: asm template must be a string literal - --> $DIR/macros-nonfatal-errors.rs:104:10 + --> $DIR/macros-nonfatal-errors.rs:105:10 | LL | asm!(invalid); | ^^^^^^^ error: `concat_idents!()` requires ident args - --> $DIR/macros-nonfatal-errors.rs:107:5 + --> $DIR/macros-nonfatal-errors.rs:108:5 | LL | concat_idents!("not", "idents"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: argument must be a string literal - --> $DIR/macros-nonfatal-errors.rs:109:17 + --> $DIR/macros-nonfatal-errors.rs:110:17 | LL | option_env!(invalid); | ^^^^^^^ error: expected string literal - --> $DIR/macros-nonfatal-errors.rs:110:10 + --> $DIR/macros-nonfatal-errors.rs:111:10 | LL | env!(invalid); | ^^^^^^^ error: `env!()` takes 1 or 2 arguments - --> $DIR/macros-nonfatal-errors.rs:111:5 + --> $DIR/macros-nonfatal-errors.rs:112:5 | LL | env!(foo, abr, baz); | ^^^^^^^^^^^^^^^^^^^ error: environment variable `RUST_HOPEFULLY_THIS_DOESNT_EXIST` not defined at compile time - --> $DIR/macros-nonfatal-errors.rs:112:5 + --> $DIR/macros-nonfatal-errors.rs:113:5 | LL | env!("RUST_HOPEFULLY_THIS_DOESNT_EXIST"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -198,7 +198,7 @@ LL | env!("RUST_HOPEFULLY_THIS_DOESNT_EXIST"); = help: use `std::env::var("RUST_HOPEFULLY_THIS_DOESNT_EXIST")` to read the variable at run time error: format argument must be a string literal - --> $DIR/macros-nonfatal-errors.rs:114:13 + --> $DIR/macros-nonfatal-errors.rs:115:13 | LL | format!(invalid); | ^^^^^^^ @@ -209,43 +209,43 @@ LL | format!("{}", invalid); | +++++ error: argument must be a string literal - --> $DIR/macros-nonfatal-errors.rs:116:14 + --> $DIR/macros-nonfatal-errors.rs:117:14 | LL | include!(invalid); | ^^^^^^^ error: argument must be a string literal - --> $DIR/macros-nonfatal-errors.rs:118:18 + --> $DIR/macros-nonfatal-errors.rs:119:18 | LL | include_str!(invalid); | ^^^^^^^ error: couldn't read `$DIR/i'd be quite surprised if a file with this name existed`: $FILE_NOT_FOUND_MSG - --> $DIR/macros-nonfatal-errors.rs:119:5 + --> $DIR/macros-nonfatal-errors.rs:120:5 | LL | include_str!("i'd be quite surprised if a file with this name existed"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: argument must be a string literal - --> $DIR/macros-nonfatal-errors.rs:120:20 + --> $DIR/macros-nonfatal-errors.rs:121:20 | LL | include_bytes!(invalid); | ^^^^^^^ error: couldn't read `$DIR/i'd be quite surprised if a file with this name existed`: $FILE_NOT_FOUND_MSG - --> $DIR/macros-nonfatal-errors.rs:121:5 + --> $DIR/macros-nonfatal-errors.rs:122:5 | LL | include_bytes!("i'd be quite surprised if a file with this name existed"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: trace_macros! accepts only `true` or `false` - --> $DIR/macros-nonfatal-errors.rs:123:5 + --> $DIR/macros-nonfatal-errors.rs:124:5 | LL | trace_macros!(invalid); | ^^^^^^^^^^^^^^^^^^^^^^ error: default variant must be exhaustive - --> $DIR/macros-nonfatal-errors.rs:133:9 + --> $DIR/macros-nonfatal-errors.rs:134:9 | LL | #[non_exhaustive] | ----------------- declared `#[non_exhaustive]` here @@ -255,7 +255,7 @@ LL | Foo, = help: consider a manual implementation of `Default` error: cannot find macro `llvm_asm` in this scope - --> $DIR/macros-nonfatal-errors.rs:105:5 + --> $DIR/macros-nonfatal-errors.rs:106:5 | LL | llvm_asm!(invalid); | ^^^^^^^^ diff --git a/tests/ui/fail-simple.rs b/tests/ui/macros/no-matching-rule.rs index 55e547ee72b..55e547ee72b 100644 --- a/tests/ui/fail-simple.rs +++ b/tests/ui/macros/no-matching-rule.rs diff --git a/tests/ui/fail-simple.stderr b/tests/ui/macros/no-matching-rule.stderr index 50c350b3ef5..a6312a843f3 100644 --- a/tests/ui/fail-simple.stderr +++ b/tests/ui/macros/no-matching-rule.stderr @@ -1,5 +1,5 @@ error: no rules expected `@` - --> $DIR/fail-simple.rs:2:12 + --> $DIR/no-matching-rule.rs:2:12 | LL | panic!(@); | ^ no rules expected this token in macro call diff --git a/tests/ui/macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.stdout b/tests/ui/macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.stdout index 9300f610f8e..33193c78334 100644 --- a/tests/ui/macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.stdout +++ b/tests/ui/macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.stdout @@ -18,18 +18,18 @@ fn arbitrary_consuming_method_for_demonstration_purposes() { let mut __capture0 = ::core::asserting::Capture::new(); let __local_bind0 = &elem; if ::core::intrinsics::unlikely(!(*{ - (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); - __local_bind0 - } as usize)) { + (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); + __local_bind0 + } as usize)) { - { - ::std::rt::panic_fmt(format_args!("Assertion failed: elem as usize\nWith captures:\n elem = {0:?}\n", - __capture0)); - } + { + ::std::rt::panic_fmt(format_args!("Assertion failed: elem as usize\nWith captures:\n elem = {0:?}\n", + __capture0)); } + } }; } fn addr_of() { @@ -40,12 +40,12 @@ fn addr_of() { let mut __capture0 = ::core::asserting::Capture::new(); let __local_bind0 = &elem; if ::core::intrinsics::unlikely(!&*__local_bind0) { - (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); - { - ::std::rt::panic_fmt(format_args!("Assertion failed: &elem\nWith captures:\n elem = {0:?}\n", - __capture0)); - } + (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); + { + ::std::rt::panic_fmt(format_args!("Assertion failed: &elem\nWith captures:\n elem = {0:?}\n", + __capture0)); } + } }; } fn binary() { @@ -56,12 +56,12 @@ fn binary() { let mut __capture0 = ::core::asserting::Capture::new(); let __local_bind0 = &elem; if ::core::intrinsics::unlikely(!(*__local_bind0 == 1)) { - (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); - { - ::std::rt::panic_fmt(format_args!("Assertion failed: elem == 1\nWith captures:\n elem = {0:?}\n", - __capture0)); - } + (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); + { + ::std::rt::panic_fmt(format_args!("Assertion failed: elem == 1\nWith captures:\n elem = {0:?}\n", + __capture0)); } + } }; { #[allow(unused_imports)] @@ -69,12 +69,12 @@ fn binary() { let mut __capture0 = ::core::asserting::Capture::new(); let __local_bind0 = &elem; if ::core::intrinsics::unlikely(!(*__local_bind0 >= 1)) { - (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); - { - ::std::rt::panic_fmt(format_args!("Assertion failed: elem >= 1\nWith captures:\n elem = {0:?}\n", - __capture0)); - } + (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); + { + ::std::rt::panic_fmt(format_args!("Assertion failed: elem >= 1\nWith captures:\n elem = {0:?}\n", + __capture0)); } + } }; { #[allow(unused_imports)] @@ -82,12 +82,12 @@ fn binary() { let mut __capture0 = ::core::asserting::Capture::new(); let __local_bind0 = &elem; if ::core::intrinsics::unlikely(!(*__local_bind0 > 0)) { - (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); - { - ::std::rt::panic_fmt(format_args!("Assertion failed: elem > 0\nWith captures:\n elem = {0:?}\n", - __capture0)); - } + (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); + { + ::std::rt::panic_fmt(format_args!("Assertion failed: elem > 0\nWith captures:\n elem = {0:?}\n", + __capture0)); } + } }; { #[allow(unused_imports)] @@ -95,12 +95,12 @@ fn binary() { let mut __capture0 = ::core::asserting::Capture::new(); let __local_bind0 = &elem; if ::core::intrinsics::unlikely(!(*__local_bind0 < 3)) { - (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); - { - ::std::rt::panic_fmt(format_args!("Assertion failed: elem < 3\nWith captures:\n elem = {0:?}\n", - __capture0)); - } + (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); + { + ::std::rt::panic_fmt(format_args!("Assertion failed: elem < 3\nWith captures:\n elem = {0:?}\n", + __capture0)); } + } }; { #[allow(unused_imports)] @@ -108,12 +108,12 @@ fn binary() { let mut __capture0 = ::core::asserting::Capture::new(); let __local_bind0 = &elem; if ::core::intrinsics::unlikely(!(*__local_bind0 <= 3)) { - (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); - { - ::std::rt::panic_fmt(format_args!("Assertion failed: elem <= 3\nWith captures:\n elem = {0:?}\n", - __capture0)); - } + (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); + { + ::std::rt::panic_fmt(format_args!("Assertion failed: elem <= 3\nWith captures:\n elem = {0:?}\n", + __capture0)); } + } }; { #[allow(unused_imports)] @@ -121,12 +121,12 @@ fn binary() { let mut __capture0 = ::core::asserting::Capture::new(); let __local_bind0 = &elem; if ::core::intrinsics::unlikely(!(*__local_bind0 != 3)) { - (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); - { - ::std::rt::panic_fmt(format_args!("Assertion failed: elem != 3\nWith captures:\n elem = {0:?}\n", - __capture0)); - } + (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); + { + ::std::rt::panic_fmt(format_args!("Assertion failed: elem != 3\nWith captures:\n elem = {0:?}\n", + __capture0)); } + } }; } fn unary() { @@ -137,12 +137,12 @@ fn unary() { let mut __capture0 = ::core::asserting::Capture::new(); let __local_bind0 = &elem; if ::core::intrinsics::unlikely(!**__local_bind0) { - (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); - { - ::std::rt::panic_fmt(format_args!("Assertion failed: *elem\nWith captures:\n elem = {0:?}\n", - __capture0)); - } + (&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); + { + ::std::rt::panic_fmt(format_args!("Assertion failed: *elem\nWith captures:\n elem = {0:?}\n", + __capture0)); } + } }; } fn main() {} diff --git a/tests/ui/macros/stringify.rs b/tests/ui/macros/stringify.rs index 3490d3efc59..3f3d9252adb 100644 --- a/tests/ui/macros/stringify.rs +++ b/tests/ui/macros/stringify.rs @@ -288,6 +288,9 @@ fn test_expr() { // ExprKind::OffsetOf: untestable because this test works pre-expansion. // ExprKind::MacCall + c1!(expr, [ mac!() ], "mac!()"); + c1!(expr, [ mac![] ], "mac![]"); + c1!(expr, [ mac! {} ], "mac! {}"); c1!(expr, [ mac!(...) ], "mac!(...)"); c1!(expr, [ mac![...] ], "mac![...]"); c1!(expr, [ mac! { ... } ], "mac! { ... }"); @@ -353,7 +356,8 @@ fn test_item() { c1!(item, [ pub extern crate self as std; ], "pub extern crate self as std;"); // ItemKind::Use - c1!(item, [ pub use crate::{a, b::c}; ], "pub use crate::{ a, b::c };"); // FIXME + c1!(item, [ pub use crate::{a, b::c}; ], "pub use crate::{a, b::c};"); + c1!(item, [ pub use crate::{ e, ff }; ], "pub use crate::{ e, ff };"); c1!(item, [ pub use A::*; ], "pub use A::*;"); // ItemKind::Static @@ -482,9 +486,12 @@ fn test_item() { c1!(item, [ impl ~const Struct {} ], "impl ~const Struct {}"); // ItemKind::MacCall + c1!(item, [ mac!(); ], "mac!();"); + c1!(item, [ mac![]; ], "mac![];"); + c1!(item, [ mac! {} ], "mac! {}"); c1!(item, [ mac!(...); ], "mac!(...);"); c1!(item, [ mac![...]; ], "mac![...];"); - c1!(item, [ mac! { ... } ], "mac! { ... }"); + c1!(item, [ mac! {...} ], "mac! {...}"); // ItemKind::MacroDef c1!(item, @@ -598,8 +605,11 @@ fn test_pat() { c1!(pat, [ (pat) ], "(pat)"); // PatKind::MacCall + c1!(pat, [ mac!() ], "mac!()"); + c1!(pat, [ mac![] ], "mac![]"); + c1!(pat, [ mac! {} ], "mac! {}"); c1!(pat, [ mac!(...) ], "mac!(...)"); - c1!(pat, [ mac![...] ], "mac![...]"); + c1!(pat, [ mac! [ ... ] ], "mac! [...]"); c1!(pat, [ mac! { ... } ], "mac! { ... }"); // Attributes are not allowed on patterns. @@ -644,6 +654,9 @@ fn test_stmt() { c1!(stmt, [ ; ], ";"); // StmtKind::MacCall + c1!(stmt, [ mac! ( ) ], "mac! ()"); + c1!(stmt, [ mac![] ], "mac![]"); + c1!(stmt, [ mac!{} ], "mac!{}"); c1!(stmt, [ mac!(...) ], "mac!(...)"); c1!(stmt, [ mac![...] ], "mac![...]"); c1!(stmt, [ mac! { ... } ], "mac! { ... }"); @@ -739,6 +752,9 @@ fn test_ty() { // TyKind::ImplicitSelf: there is no syntax for this. // TyKind::MacCall + c1!(ty, [ mac!() ], "mac!()"); + c1!(ty, [ mac![] ], "mac![]"); + c1!(ty, [ mac! { } ], "mac! {}"); c1!(ty, [ mac!(...) ], "mac!(...)"); c1!(ty, [ mac![...] ], "mac![...]"); c1!(ty, [ mac! { ... } ], "mac! { ... }"); diff --git a/tests/ui/macros/trace_faulty_macros.stderr b/tests/ui/macros/trace_faulty_macros.stderr index 73fed66e619..e90d7a98db4 100644 --- a/tests/ui/macros/trace_faulty_macros.stderr +++ b/tests/ui/macros/trace_faulty_macros.stderr @@ -87,9 +87,9 @@ LL | let a = pat_macro!(); | ^^^^^^^^^^^^ | = note: expanding `pat_macro! { }` - = note: to `pat_macro! (A { a : a, b : 0, c : _, .. });` - = note: expanding `pat_macro! { A { a : a, b : 0, c : _, .. } }` - = note: to `A { a : a, b : 0, c : _, .. }` + = note: to `pat_macro! (A {a : a, b : 0, c : _, ..});` + = note: expanding `pat_macro! { A {a : a, b : 0, c : _, ..} }` + = note: to `A {a : a, b : 0, c : _, ..}` note: trace_macro --> $DIR/trace_faulty_macros.rs:53:5 diff --git a/tests/ui/match/issue-82392.stdout b/tests/ui/match/issue-82392.stdout index 8b7edabf004..a0d83d962e7 100644 --- a/tests/ui/match/issue-82392.stdout +++ b/tests/ui/match/issue-82392.stdout @@ -8,10 +8,10 @@ extern crate std; //@ edition:2015 fn main() ({ - (if (true as bool) - ({ } as - ()) else if (let Some(a) = - ((Some as - fn(i32) -> Option<i32> {Option::<i32>::Some})((3 as i32)) as - Option<i32>) as bool) ({ } as ()) as ()) - } as ()) + (if (true as bool) { + } else if (let Some(a) = + ((Some as + fn(i32) -> Option<i32> {Option::<i32>::Some})((3 as i32)) as + Option<i32>) as bool) { + } as ()) +} as ()) diff --git a/tests/ui/match/match-struct.rs b/tests/ui/match/match-struct.rs index 4da7b436ba8..2160571302f 100644 --- a/tests/ui/match/match-struct.rs +++ b/tests/ui/match/match-struct.rs @@ -2,10 +2,10 @@ struct S { a: isize } enum E { C(isize) } fn main() { - match (S { a: 1 }) { + match (S { a: 1 }) { //~ NOTE this expression has type `S` E::C(_) => (), //~^ ERROR mismatched types - //~| expected `S`, found `E` + //~| NOTE expected `S`, found `E` _ => () } } diff --git a/tests/ui/methods/clone-missing.rs b/tests/ui/methods/clone-missing.rs new file mode 100644 index 00000000000..c5ecd3f175e --- /dev/null +++ b/tests/ui/methods/clone-missing.rs @@ -0,0 +1,34 @@ +//! This test checks that calling `.clone()` on a type that does +//! not implement the `Clone` trait results in a compilation error. +//! The `NotClone` and AlsoNotClone structs do not derive or +//! implement `Clone`, so attempting to clone them should fail. + +struct NotClone { + i: isize, +} + +fn not_clone(i: isize) -> NotClone { + NotClone { i } +} + +struct AlsoNotClone { + i: isize, + j: NotClone, +} + +fn also_not_clone(i: isize) -> AlsoNotClone { + AlsoNotClone { + i, + j: NotClone { i: i }, + } +} + +fn main() { + let x = not_clone(10); + let _y = x.clone(); + //~^ ERROR no method named `clone` found + + let x = also_not_clone(10); + let _y = x.clone(); + //~^ ERROR no method named `clone` found +} diff --git a/tests/ui/methods/clone-missing.stderr b/tests/ui/methods/clone-missing.stderr new file mode 100644 index 00000000000..8676e73c8ca --- /dev/null +++ b/tests/ui/methods/clone-missing.stderr @@ -0,0 +1,29 @@ +error[E0599]: no method named `clone` found for struct `NotClone` in the current scope + --> $DIR/clone-missing.rs:28:16 + | +LL | struct NotClone { + | --------------- method `clone` not found for this struct +... +LL | let _y = x.clone(); + | ^^^^^ method not found in `NotClone` + | + = help: items from traits can only be used if the trait is implemented and in scope + = note: the following trait defines an item `clone`, perhaps you need to implement it: + candidate #1: `Clone` + +error[E0599]: no method named `clone` found for struct `AlsoNotClone` in the current scope + --> $DIR/clone-missing.rs:32:16 + | +LL | struct AlsoNotClone { + | ------------------- method `clone` not found for this struct +... +LL | let _y = x.clone(); + | ^^^^^ method not found in `AlsoNotClone` + | + = help: items from traits can only be used if the trait is implemented and in scope + = note: the following trait defines an item `clone`, perhaps you need to implement it: + candidate #1: `Clone` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/methods/method-deref-to-same-trait-object-with-separate-params.rs b/tests/ui/methods/method-deref-to-same-trait-object-with-separate-params.rs index 9e53ff07917..5ef1d0c6dc9 100644 --- a/tests/ui/methods/method-deref-to-same-trait-object-with-separate-params.rs +++ b/tests/ui/methods/method-deref-to-same-trait-object-with-separate-params.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + #![feature(arbitrary_self_types, coerce_unsized, dispatch_from_dyn, unsize)] #![feature(unsized_locals, unsized_fn_params)] //~^ WARN the feature `unsized_locals` is incomplete @@ -85,7 +87,7 @@ fn objectcandidate_impl() { // Observe the type of `z` is `u32` let _seetype: () = z; //~ ERROR mismatched types - //~| expected `()`, found `u32` + //~| NOTE expected `()`, found `u32` } fn traitcandidate_impl() { @@ -102,7 +104,7 @@ fn traitcandidate_impl() { // Observe the type of `z` is `u64` let _seetype: () = z; //~ ERROR mismatched types - //~| expected `()`, found `u64` + //~| NOTE expected `()`, found `u64` } fn traitcandidate_impl_with_nuisance() { @@ -137,7 +139,7 @@ fn neither_impl() { // Observe the type of `z` is `u8` let _seetype: () = z; //~ ERROR mismatched types - //~| expected `()`, found `u8` + //~| NOTE expected `()`, found `u8` } fn both_impls() { @@ -155,7 +157,7 @@ fn both_impls() { // Observe the type of `z` is `u32` let _seetype: () = z; //~ ERROR mismatched types - //~| expected `()`, found `u32` + //~| NOTE expected `()`, found `u32` } @@ -172,7 +174,7 @@ fn both_impls_with_nuisance() { // Observe the type of `z` is `u32` let _seetype: () = z; //~ ERROR mismatched types - //~| expected `()`, found `u32` + //~| NOTE expected `()`, found `u32` } fn main() { diff --git a/tests/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr b/tests/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr index d6da3f2cc39..213139a9b0b 100644 --- a/tests/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr +++ b/tests/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr @@ -1,5 +1,5 @@ warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:2:12 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:4:12 | LL | #![feature(unsized_locals, unsized_fn_params)] | ^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | #![feature(unsized_locals, unsized_fn_params)] = note: `#[warn(incomplete_features)]` on by default error[E0308]: mismatched types - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:87:24 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:89:24 | LL | let _seetype: () = z; | -- ^ expected `()`, found `u32` @@ -16,7 +16,7 @@ LL | let _seetype: () = z; | expected due to this error[E0308]: mismatched types - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:104:24 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:106:24 | LL | let _seetype: () = z; | -- ^ expected `()`, found `u64` @@ -24,23 +24,23 @@ LL | let _seetype: () = z; | expected due to this error[E0034]: multiple applicable items in scope - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:122:15 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:124:15 | LL | let z = x.foo(); | ^^^ multiple `foo` found | note: candidate #1 is defined in the trait `FinalFoo` - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:59:5 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:61:5 | LL | fn foo(&self) -> u8; | ^^^^^^^^^^^^^^^^^^^^ note: candidate #2 is defined in an impl of the trait `NuisanceFoo` for the type `T` - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:72:9 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:74:9 | LL | fn foo(self) {} | ^^^^^^^^^^^^ note: candidate #3 is defined in an impl of the trait `X` for the type `T` - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:45:9 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:47:9 | LL | fn foo(self: Smaht<Self, u64>) -> u64 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + let z = X::foo(x); | error[E0308]: mismatched types - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:139:24 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:141:24 | LL | let _seetype: () = z; | -- ^ expected `()`, found `u8` @@ -69,7 +69,7 @@ LL | let _seetype: () = z; | expected due to this error[E0308]: mismatched types - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:157:24 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:159:24 | LL | let _seetype: () = z; | -- ^ expected `()`, found `u32` @@ -77,7 +77,7 @@ LL | let _seetype: () = z; | expected due to this error[E0308]: mismatched types - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:174:24 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:176:24 | LL | let _seetype: () = z; | -- ^ expected `()`, found `u32` diff --git a/tests/ui/methods/method-self-arg-1.rs b/tests/ui/methods/method-self-arg-1.rs index 5912b4ec2c3..a0056b540a7 100644 --- a/tests/ui/methods/method-self-arg-1.rs +++ b/tests/ui/methods/method-self-arg-1.rs @@ -1,5 +1,7 @@ // Test method calls with self as an argument cannot subvert type checking. +//@ dont-require-annotations: NOTE + struct Foo; impl Foo { @@ -9,9 +11,9 @@ impl Foo { fn main() { let x = Foo; Foo::bar(x); //~ ERROR mismatched types - //~| expected `&Foo`, found `Foo` + //~| NOTE expected `&Foo`, found `Foo` Foo::bar(&42); //~ ERROR mismatched types - //~| expected `&Foo`, found `&{integer}` - //~| expected reference `&Foo` - //~| found reference `&{integer}` + //~| NOTE expected `&Foo`, found `&{integer}` + //~| NOTE expected reference `&Foo` + //~| NOTE found reference `&{integer}` } diff --git a/tests/ui/methods/method-self-arg-1.stderr b/tests/ui/methods/method-self-arg-1.stderr index dcc21acc5c0..1d5927da97f 100644 --- a/tests/ui/methods/method-self-arg-1.stderr +++ b/tests/ui/methods/method-self-arg-1.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/method-self-arg-1.rs:11:14 + --> $DIR/method-self-arg-1.rs:13:14 | LL | Foo::bar(x); | -------- ^ expected `&Foo`, found `Foo` @@ -7,7 +7,7 @@ LL | Foo::bar(x); | arguments to this function are incorrect | note: method defined here - --> $DIR/method-self-arg-1.rs:6:8 + --> $DIR/method-self-arg-1.rs:8:8 | LL | fn bar(&self) {} | ^^^ ----- @@ -17,7 +17,7 @@ LL | Foo::bar(&x); | + error[E0308]: mismatched types - --> $DIR/method-self-arg-1.rs:13:14 + --> $DIR/method-self-arg-1.rs:15:14 | LL | Foo::bar(&42); | -------- ^^^ expected `&Foo`, found `&{integer}` @@ -27,7 +27,7 @@ LL | Foo::bar(&42); = note: expected reference `&Foo` found reference `&{integer}` note: method defined here - --> $DIR/method-self-arg-1.rs:6:8 + --> $DIR/method-self-arg-1.rs:8:8 | LL | fn bar(&self) {} | ^^^ ----- diff --git a/tests/ui/mir/alignment/place_computation.rs b/tests/ui/mir/alignment/borrow_aligned_field_projection.rs index d3717db77c7..d3717db77c7 100644 --- a/tests/ui/mir/alignment/place_computation.rs +++ b/tests/ui/mir/alignment/borrow_aligned_field_projection.rs diff --git a/tests/ui/mir/alignment/borrow_misaligned_field_projection.rs b/tests/ui/mir/alignment/borrow_misaligned_field_projection.rs new file mode 100644 index 00000000000..a22965ce1d8 --- /dev/null +++ b/tests/ui/mir/alignment/borrow_misaligned_field_projection.rs @@ -0,0 +1,16 @@ +//@ run-fail +//@ ignore-i686-pc-windows-msvc: #112480 +//@ compile-flags: -C debug-assertions +//@ error-pattern: misaligned pointer dereference: address must be a multiple of 0x4 but is + +struct Misalignment { + a: u32, +} + +fn main() { + let mut items: [Misalignment; 2] = [Misalignment { a: 0 }, Misalignment { a: 1 }]; + unsafe { + let ptr: *const Misalignment = items.as_ptr().byte_add(1); + let _ptr: &u32 = unsafe { &(*ptr).a }; + } +} diff --git a/tests/ui/mir/alignment/misaligned_borrow.rs b/tests/ui/mir/alignment/misaligned_borrow.rs new file mode 100644 index 00000000000..de8912c7038 --- /dev/null +++ b/tests/ui/mir/alignment/misaligned_borrow.rs @@ -0,0 +1,12 @@ +//@ run-fail +//@ ignore-i686-pc-windows-msvc: #112480 +//@ compile-flags: -C debug-assertions +//@ error-pattern: misaligned pointer dereference: address must be a multiple of 0x4 but is + +fn main() { + let x = [0u32; 2]; + let ptr = x.as_ptr(); + unsafe { + let _ptr = &(*(ptr.byte_add(1))); + } +} diff --git a/tests/ui/mir/alignment/misaligned_mut_borrow.rs b/tests/ui/mir/alignment/misaligned_mut_borrow.rs new file mode 100644 index 00000000000..bba20edecfd --- /dev/null +++ b/tests/ui/mir/alignment/misaligned_mut_borrow.rs @@ -0,0 +1,12 @@ +//@ run-fail +//@ ignore-i686-pc-windows-msvc: #112480 +//@ compile-flags: -C debug-assertions +//@ error-pattern: misaligned pointer dereference: address must be a multiple of 0x4 but is + +fn main() { + let mut x = [0u32; 2]; + let ptr = x.as_mut_ptr(); + unsafe { + let _ptr = &mut (*(ptr.byte_add(1))); + } +} diff --git a/tests/ui/mismatched_types/issue-13033.rs b/tests/ui/mismatched_types/issue-13033.rs index fdb356e70c5..3b08857d780 100644 --- a/tests/ui/mismatched_types/issue-13033.rs +++ b/tests/ui/mismatched_types/issue-13033.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + trait Foo { fn bar(&mut self, other: &mut dyn Foo); } @@ -7,8 +9,8 @@ struct Baz; impl Foo for Baz { fn bar(&mut self, other: &dyn Foo) {} //~^ ERROR method `bar` has an incompatible type for trait - //~| expected signature `fn(&mut Baz, &mut dyn Foo)` - //~| found signature `fn(&mut Baz, &dyn Foo)` + //~| NOTE expected signature `fn(&mut Baz, &mut dyn Foo)` + //~| NOTE found signature `fn(&mut Baz, &dyn Foo)` } fn main() {} diff --git a/tests/ui/mismatched_types/issue-13033.stderr b/tests/ui/mismatched_types/issue-13033.stderr index 61786ef14c2..f12f81dcfa5 100644 --- a/tests/ui/mismatched_types/issue-13033.stderr +++ b/tests/ui/mismatched_types/issue-13033.stderr @@ -1,11 +1,11 @@ error[E0053]: method `bar` has an incompatible type for trait - --> $DIR/issue-13033.rs:8:30 + --> $DIR/issue-13033.rs:10:30 | LL | fn bar(&mut self, other: &dyn Foo) {} | ^^^^^^^^ types differ in mutability | note: type in trait - --> $DIR/issue-13033.rs:2:30 + --> $DIR/issue-13033.rs:4:30 | LL | fn bar(&mut self, other: &mut dyn Foo); | ^^^^^^^^^^^^ diff --git a/tests/ui/modules/mod-pub-access.rs b/tests/ui/modules/mod-pub-access.rs new file mode 100644 index 00000000000..c07e7a2ff30 --- /dev/null +++ b/tests/ui/modules/mod-pub-access.rs @@ -0,0 +1,11 @@ +//@ run-pass +// This is a name resolution smoke test that ensures paths with more than one +// segment (e.g., `foo::bar`) resolve correctly. +// It also serves as a basic visibility test — confirming that a `pub` item +// inside a private module can still be accessed from outside that module. + +mod foo { + pub fn bar(_offset: usize) {} +} + +fn main() { foo::bar(0); } diff --git a/tests/ui/moves/moves-based-on-type-match-bindings.rs b/tests/ui/moves/moves-based-on-type-match-bindings.rs index 4fb9b40e875..407f0976900 100644 --- a/tests/ui/moves/moves-based-on-type-match-bindings.rs +++ b/tests/ui/moves/moves-based-on-type-match-bindings.rs @@ -10,12 +10,12 @@ fn f10() { let x = Foo {f: "hi".to_string()}; let y = match x { - Foo {f} => {} + Foo {f} => {} //~ NOTE value partially moved here }; touch(&x); //~ ERROR borrow of partially moved value: `x` - //~^ value borrowed here after partial move - //~| partial move occurs because `x.f` has type `String` + //~^ NOTE value borrowed here after partial move + //~| NOTE partial move occurs because `x.f` has type `String` } fn main() {} diff --git a/tests/ui/mut/mut-pattern-mismatched.rs b/tests/ui/mut/mut-pattern-mismatched.rs index 700261fe40b..d99831bdaf5 100644 --- a/tests/ui/mut/mut-pattern-mismatched.rs +++ b/tests/ui/mut/mut-pattern-mismatched.rs @@ -1,20 +1,22 @@ +//@ dont-require-annotations: NOTE + fn main() { let foo = &mut 1; // (separate lines to ensure the spans are accurate) let &_ //~ ERROR mismatched types - //~| expected mutable reference `&mut {integer}` - //~| found reference `&_` - //~| types differ in mutability + //~| NOTE expected mutable reference `&mut {integer}` + //~| NOTE found reference `&_` + //~| NOTE types differ in mutability = foo; let &mut _ = foo; let bar = &1; let &_ = bar; let &mut _ //~ ERROR mismatched types - //~| expected reference `&{integer}` - //~| found mutable reference `&mut _` - //~| types differ in mutability + //~| NOTE expected reference `&{integer}` + //~| NOTE found mutable reference `&mut _` + //~| NOTE types differ in mutability = bar; } diff --git a/tests/ui/mut/mut-pattern-mismatched.stderr b/tests/ui/mut/mut-pattern-mismatched.stderr index cad1cef5155..25b1bfefaa2 100644 --- a/tests/ui/mut/mut-pattern-mismatched.stderr +++ b/tests/ui/mut/mut-pattern-mismatched.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/mut-pattern-mismatched.rs:6:10 + --> $DIR/mut-pattern-mismatched.rs:8:10 | LL | let &_ | ^^ types differ in mutability @@ -11,7 +11,7 @@ LL | = foo; found reference `&_` error[E0308]: mismatched types - --> $DIR/mut-pattern-mismatched.rs:15:9 + --> $DIR/mut-pattern-mismatched.rs:17:9 | LL | let &mut _ | ^^^^^^ types differ in mutability diff --git a/tests/ui/never_type/issue-10176.rs b/tests/ui/never_type/issue-10176.rs index 5ac4359c501..41e012d023f 100644 --- a/tests/ui/never_type/issue-10176.rs +++ b/tests/ui/never_type/issue-10176.rs @@ -1,9 +1,9 @@ -fn f() -> isize { +fn f() -> isize { //~ NOTE expected `isize` because of return type (return 1, return 2) //~^ ERROR mismatched types -//~| expected type `isize` -//~| found tuple `(!, !)` -//~| expected `isize`, found `(!, !)` +//~| NOTE expected type `isize` +//~| NOTE found tuple `(!, !)` +//~| NOTE expected `isize`, found `(!, !)` } fn main() {} diff --git a/tests/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.rs b/tests/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.rs index be882085c5c..73597408d10 100644 --- a/tests/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.rs +++ b/tests/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.rs @@ -15,7 +15,7 @@ struct S1 { impl S1 { fn new(_x: u64) -> S1 { S1 { a: unsafe { &mut X1 } } - //~^ WARN mutable reference to mutable static is discouraged [static_mut_refs] + //~^ WARN mutable reference to mutable static [static_mut_refs] } } diff --git a/tests/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.stderr b/tests/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.stderr index 9dbd6769693..8268f5df236 100644 --- a/tests/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.stderr +++ b/tests/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.stderr @@ -1,4 +1,4 @@ -warning: creating a mutable reference to mutable static is discouraged +warning: creating a mutable reference to mutable static --> $DIR/borrowck-thread-local-static-mut-borrow-outlives-fn.rs:17:26 | LL | S1 { a: unsafe { &mut X1 } } diff --git a/tests/ui/noexporttypeexe.rs b/tests/ui/noexporttypeexe.rs index 6b4402a81f0..35257b20ccd 100644 --- a/tests/ui/noexporttypeexe.rs +++ b/tests/ui/noexporttypeexe.rs @@ -9,7 +9,8 @@ fn main() { // not convertible to a path. let x: isize = noexporttypelib::foo(); //~^ ERROR mismatched types - //~| expected type `isize` - //~| found enum `Option<isize>` - //~| expected `isize`, found `Option<isize>` + //~| NOTE expected type `isize` + //~| NOTE found enum `Option<isize>` + //~| NOTE expected `isize`, found `Option<isize>` + //~| NOTE expected due to this } diff --git a/tests/ui/non-copyable-void.rs b/tests/ui/non-copyable-void.rs deleted file mode 100644 index 55bad82bc33..00000000000 --- a/tests/ui/non-copyable-void.rs +++ /dev/null @@ -1,10 +0,0 @@ -use std::ffi::c_void; - -fn main() { - let x : *const Vec<isize> = &vec![1,2,3]; - let y : *const c_void = x as *const c_void; - unsafe { - let _z = (*y).clone(); - //~^ ERROR no method named `clone` found - } -} diff --git a/tests/ui/non-copyable-void.stderr b/tests/ui/non-copyable-void.stderr deleted file mode 100644 index 373557fa01a..00000000000 --- a/tests/ui/non-copyable-void.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0599]: no method named `clone` found for enum `c_void` in the current scope - --> $DIR/non-copyable-void.rs:7:23 - | -LL | let _z = (*y).clone(); - | ^^^^^ method not found in `c_void` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/noncopyable-class.rs b/tests/ui/noncopyable-class.rs deleted file mode 100644 index 11b6eb736e9..00000000000 --- a/tests/ui/noncopyable-class.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Test that a class with a non-copyable field can't be -// copied - -#[derive(Debug)] -struct Bar { - x: isize, -} - -impl Drop for Bar { - fn drop(&mut self) {} -} - -fn bar(x:isize) -> Bar { - Bar { - x: x - } -} - -#[derive(Debug)] -struct Foo { - i: isize, - j: Bar, -} - -fn foo(i:isize) -> Foo { - Foo { - i: i, - j: bar(5) - } -} - -fn main() { - let x = foo(10); - let _y = x.clone(); //~ ERROR no method named `clone` found - println!("{:?}", x); -} diff --git a/tests/ui/noncopyable-class.stderr b/tests/ui/noncopyable-class.stderr deleted file mode 100644 index b8f7276c898..00000000000 --- a/tests/ui/noncopyable-class.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0599]: no method named `clone` found for struct `Foo` in the current scope - --> $DIR/noncopyable-class.rs:34:16 - | -LL | struct Foo { - | ---------- method `clone` not found for this struct -... -LL | let _y = x.clone(); - | ^^^^^ method not found in `Foo` - | - = help: items from traits can only be used if the trait is implemented and in scope - = note: the following trait defines an item `clone`, perhaps you need to implement it: - candidate #1: `Clone` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/numeric/integer-literal-suffix-inference.rs b/tests/ui/numeric/integer-literal-suffix-inference.rs index c320f2bb7b4..775e374e571 100644 --- a/tests/ui/numeric/integer-literal-suffix-inference.rs +++ b/tests/ui/numeric/integer-literal-suffix-inference.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + fn main() { // the smallest positive values that need these types @@ -37,184 +39,184 @@ fn main() { id_i8(a8); // ok id_i8(a16); //~^ ERROR mismatched types - //~| expected `i8`, found `i16` + //~| NOTE expected `i8`, found `i16` id_i8(a32); //~^ ERROR mismatched types - //~| expected `i8`, found `i32` + //~| NOTE expected `i8`, found `i32` id_i8(a64); //~^ ERROR mismatched types - //~| expected `i8`, found `i64` + //~| NOTE expected `i8`, found `i64` id_i8(asize); //~^ ERROR mismatched types - //~| expected `i8`, found `isize` + //~| NOTE expected `i8`, found `isize` id_i16(a8); //~^ ERROR mismatched types - //~| expected `i16`, found `i8` + //~| NOTE expected `i16`, found `i8` id_i16(a16); // ok id_i16(a32); //~^ ERROR mismatched types - //~| expected `i16`, found `i32` + //~| NOTE expected `i16`, found `i32` id_i16(a64); //~^ ERROR mismatched types - //~| expected `i16`, found `i64` + //~| NOTE expected `i16`, found `i64` id_i16(asize); //~^ ERROR mismatched types - //~| expected `i16`, found `isize` + //~| NOTE expected `i16`, found `isize` id_i32(a8); //~^ ERROR mismatched types - //~| expected `i32`, found `i8` + //~| NOTE expected `i32`, found `i8` id_i32(a16); //~^ ERROR mismatched types - //~| expected `i32`, found `i16` + //~| NOTE expected `i32`, found `i16` id_i32(a32); // ok id_i32(a64); //~^ ERROR mismatched types - //~| expected `i32`, found `i64` + //~| NOTE expected `i32`, found `i64` id_i32(asize); //~^ ERROR mismatched types - //~| expected `i32`, found `isize` + //~| NOTE expected `i32`, found `isize` id_i64(a8); //~^ ERROR mismatched types - //~| expected `i64`, found `i8` + //~| NOTE expected `i64`, found `i8` id_i64(a16); //~^ ERROR mismatched types - //~| expected `i64`, found `i16` + //~| NOTE expected `i64`, found `i16` id_i64(a32); //~^ ERROR mismatched types - //~| expected `i64`, found `i32` + //~| NOTE expected `i64`, found `i32` id_i64(a64); // ok id_i64(asize); //~^ ERROR mismatched types - //~| expected `i64`, found `isize` + //~| NOTE expected `i64`, found `isize` id_isize(a8); //~^ ERROR mismatched types - //~| expected `isize`, found `i8` + //~| NOTE expected `isize`, found `i8` id_isize(a16); //~^ ERROR mismatched types - //~| expected `isize`, found `i16` + //~| NOTE expected `isize`, found `i16` id_isize(a32); //~^ ERROR mismatched types - //~| expected `isize`, found `i32` + //~| NOTE expected `isize`, found `i32` id_isize(a64); //~^ ERROR mismatched types - //~| expected `isize`, found `i64` + //~| NOTE expected `isize`, found `i64` id_isize(asize); //ok id_i8(c8); // ok id_i8(c16); //~^ ERROR mismatched types - //~| expected `i8`, found `i16` + //~| NOTE expected `i8`, found `i16` id_i8(c32); //~^ ERROR mismatched types - //~| expected `i8`, found `i32` + //~| NOTE expected `i8`, found `i32` id_i8(c64); //~^ ERROR mismatched types - //~| expected `i8`, found `i64` + //~| NOTE expected `i8`, found `i64` id_i16(c8); //~^ ERROR mismatched types - //~| expected `i16`, found `i8` + //~| NOTE expected `i16`, found `i8` id_i16(c16); // ok id_i16(c32); //~^ ERROR mismatched types - //~| expected `i16`, found `i32` + //~| NOTE expected `i16`, found `i32` id_i16(c64); //~^ ERROR mismatched types - //~| expected `i16`, found `i64` + //~| NOTE expected `i16`, found `i64` id_i32(c8); //~^ ERROR mismatched types - //~| expected `i32`, found `i8` + //~| NOTE expected `i32`, found `i8` id_i32(c16); //~^ ERROR mismatched types - //~| expected `i32`, found `i16` + //~| NOTE expected `i32`, found `i16` id_i32(c32); // ok id_i32(c64); //~^ ERROR mismatched types - //~| expected `i32`, found `i64` + //~| NOTE expected `i32`, found `i64` id_i64(a8); //~^ ERROR mismatched types - //~| expected `i64`, found `i8` + //~| NOTE expected `i64`, found `i8` id_i64(a16); //~^ ERROR mismatched types - //~| expected `i64`, found `i16` + //~| NOTE expected `i64`, found `i16` id_i64(a32); //~^ ERROR mismatched types - //~| expected `i64`, found `i32` + //~| NOTE expected `i64`, found `i32` id_i64(a64); // ok id_u8(b8); // ok id_u8(b16); //~^ ERROR mismatched types - //~| expected `u8`, found `u16` + //~| NOTE expected `u8`, found `u16` id_u8(b32); //~^ ERROR mismatched types - //~| expected `u8`, found `u32` + //~| NOTE expected `u8`, found `u32` id_u8(b64); //~^ ERROR mismatched types - //~| expected `u8`, found `u64` + //~| NOTE expected `u8`, found `u64` id_u8(bsize); //~^ ERROR mismatched types - //~| expected `u8`, found `usize` + //~| NOTE expected `u8`, found `usize` id_u16(b8); //~^ ERROR mismatched types - //~| expected `u16`, found `u8` + //~| NOTE expected `u16`, found `u8` id_u16(b16); // ok id_u16(b32); //~^ ERROR mismatched types - //~| expected `u16`, found `u32` + //~| NOTE expected `u16`, found `u32` id_u16(b64); //~^ ERROR mismatched types - //~| expected `u16`, found `u64` + //~| NOTE expected `u16`, found `u64` id_u16(bsize); //~^ ERROR mismatched types - //~| expected `u16`, found `usize` + //~| NOTE expected `u16`, found `usize` id_u32(b8); //~^ ERROR mismatched types - //~| expected `u32`, found `u8` + //~| NOTE expected `u32`, found `u8` id_u32(b16); //~^ ERROR mismatched types - //~| expected `u32`, found `u16` + //~| NOTE expected `u32`, found `u16` id_u32(b32); // ok id_u32(b64); //~^ ERROR mismatched types - //~| expected `u32`, found `u64` + //~| NOTE expected `u32`, found `u64` id_u32(bsize); //~^ ERROR mismatched types - //~| expected `u32`, found `usize` + //~| NOTE expected `u32`, found `usize` id_u64(b8); //~^ ERROR mismatched types - //~| expected `u64`, found `u8` + //~| NOTE expected `u64`, found `u8` id_u64(b16); //~^ ERROR mismatched types - //~| expected `u64`, found `u16` + //~| NOTE expected `u64`, found `u16` id_u64(b32); //~^ ERROR mismatched types - //~| expected `u64`, found `u32` + //~| NOTE expected `u64`, found `u32` id_u64(b64); // ok id_u64(bsize); //~^ ERROR mismatched types - //~| expected `u64`, found `usize` + //~| NOTE expected `u64`, found `usize` id_usize(b8); //~^ ERROR mismatched types - //~| expected `usize`, found `u8` + //~| NOTE expected `usize`, found `u8` id_usize(b16); //~^ ERROR mismatched types - //~| expected `usize`, found `u16` + //~| NOTE expected `usize`, found `u16` id_usize(b32); //~^ ERROR mismatched types - //~| expected `usize`, found `u32` + //~| NOTE expected `usize`, found `u32` id_usize(b64); //~^ ERROR mismatched types - //~| expected `usize`, found `u64` + //~| NOTE expected `usize`, found `u64` id_usize(bsize); //ok } diff --git a/tests/ui/numeric/integer-literal-suffix-inference.stderr b/tests/ui/numeric/integer-literal-suffix-inference.stderr index 5045f584c89..30232e4d375 100644 --- a/tests/ui/numeric/integer-literal-suffix-inference.stderr +++ b/tests/ui/numeric/integer-literal-suffix-inference.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:38:11 + --> $DIR/integer-literal-suffix-inference.rs:40:11 | LL | id_i8(a16); | ----- ^^^ expected `i8`, found `i16` @@ -7,7 +7,7 @@ LL | id_i8(a16); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:15:8 + --> $DIR/integer-literal-suffix-inference.rs:17:8 | LL | fn id_i8(n: i8) -> i8 { n } | ^^^^^ ----- @@ -17,7 +17,7 @@ LL | id_i8(a16.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:41:11 + --> $DIR/integer-literal-suffix-inference.rs:43:11 | LL | id_i8(a32); | ----- ^^^ expected `i8`, found `i32` @@ -25,7 +25,7 @@ LL | id_i8(a32); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:15:8 + --> $DIR/integer-literal-suffix-inference.rs:17:8 | LL | fn id_i8(n: i8) -> i8 { n } | ^^^^^ ----- @@ -35,7 +35,7 @@ LL | id_i8(a32.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:44:11 + --> $DIR/integer-literal-suffix-inference.rs:46:11 | LL | id_i8(a64); | ----- ^^^ expected `i8`, found `i64` @@ -43,7 +43,7 @@ LL | id_i8(a64); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:15:8 + --> $DIR/integer-literal-suffix-inference.rs:17:8 | LL | fn id_i8(n: i8) -> i8 { n } | ^^^^^ ----- @@ -53,7 +53,7 @@ LL | id_i8(a64.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:47:11 + --> $DIR/integer-literal-suffix-inference.rs:49:11 | LL | id_i8(asize); | ----- ^^^^^ expected `i8`, found `isize` @@ -61,7 +61,7 @@ LL | id_i8(asize); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:15:8 + --> $DIR/integer-literal-suffix-inference.rs:17:8 | LL | fn id_i8(n: i8) -> i8 { n } | ^^^^^ ----- @@ -71,7 +71,7 @@ LL | id_i8(asize.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:51:12 + --> $DIR/integer-literal-suffix-inference.rs:53:12 | LL | id_i16(a8); | ------ ^^ expected `i16`, found `i8` @@ -79,7 +79,7 @@ LL | id_i16(a8); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:16:8 + --> $DIR/integer-literal-suffix-inference.rs:18:8 | LL | fn id_i16(n: i16) -> i16 { n } | ^^^^^^ ------ @@ -89,7 +89,7 @@ LL | id_i16(a8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:55:12 + --> $DIR/integer-literal-suffix-inference.rs:57:12 | LL | id_i16(a32); | ------ ^^^ expected `i16`, found `i32` @@ -97,7 +97,7 @@ LL | id_i16(a32); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:16:8 + --> $DIR/integer-literal-suffix-inference.rs:18:8 | LL | fn id_i16(n: i16) -> i16 { n } | ^^^^^^ ------ @@ -107,7 +107,7 @@ LL | id_i16(a32.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:58:12 + --> $DIR/integer-literal-suffix-inference.rs:60:12 | LL | id_i16(a64); | ------ ^^^ expected `i16`, found `i64` @@ -115,7 +115,7 @@ LL | id_i16(a64); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:16:8 + --> $DIR/integer-literal-suffix-inference.rs:18:8 | LL | fn id_i16(n: i16) -> i16 { n } | ^^^^^^ ------ @@ -125,7 +125,7 @@ LL | id_i16(a64.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:61:12 + --> $DIR/integer-literal-suffix-inference.rs:63:12 | LL | id_i16(asize); | ------ ^^^^^ expected `i16`, found `isize` @@ -133,7 +133,7 @@ LL | id_i16(asize); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:16:8 + --> $DIR/integer-literal-suffix-inference.rs:18:8 | LL | fn id_i16(n: i16) -> i16 { n } | ^^^^^^ ------ @@ -143,7 +143,7 @@ LL | id_i16(asize.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:65:12 + --> $DIR/integer-literal-suffix-inference.rs:67:12 | LL | id_i32(a8); | ------ ^^ expected `i32`, found `i8` @@ -151,7 +151,7 @@ LL | id_i32(a8); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:17:8 + --> $DIR/integer-literal-suffix-inference.rs:19:8 | LL | fn id_i32(n: i32) -> i32 { n } | ^^^^^^ ------ @@ -161,7 +161,7 @@ LL | id_i32(a8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:68:12 + --> $DIR/integer-literal-suffix-inference.rs:70:12 | LL | id_i32(a16); | ------ ^^^ expected `i32`, found `i16` @@ -169,7 +169,7 @@ LL | id_i32(a16); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:17:8 + --> $DIR/integer-literal-suffix-inference.rs:19:8 | LL | fn id_i32(n: i32) -> i32 { n } | ^^^^^^ ------ @@ -179,7 +179,7 @@ LL | id_i32(a16.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:72:12 + --> $DIR/integer-literal-suffix-inference.rs:74:12 | LL | id_i32(a64); | ------ ^^^ expected `i32`, found `i64` @@ -187,7 +187,7 @@ LL | id_i32(a64); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:17:8 + --> $DIR/integer-literal-suffix-inference.rs:19:8 | LL | fn id_i32(n: i32) -> i32 { n } | ^^^^^^ ------ @@ -197,7 +197,7 @@ LL | id_i32(a64.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:75:12 + --> $DIR/integer-literal-suffix-inference.rs:77:12 | LL | id_i32(asize); | ------ ^^^^^ expected `i32`, found `isize` @@ -205,7 +205,7 @@ LL | id_i32(asize); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:17:8 + --> $DIR/integer-literal-suffix-inference.rs:19:8 | LL | fn id_i32(n: i32) -> i32 { n } | ^^^^^^ ------ @@ -215,7 +215,7 @@ LL | id_i32(asize.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:79:12 + --> $DIR/integer-literal-suffix-inference.rs:81:12 | LL | id_i64(a8); | ------ ^^ expected `i64`, found `i8` @@ -223,7 +223,7 @@ LL | id_i64(a8); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:18:8 + --> $DIR/integer-literal-suffix-inference.rs:20:8 | LL | fn id_i64(n: i64) -> i64 { n } | ^^^^^^ ------ @@ -233,7 +233,7 @@ LL | id_i64(a8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:82:12 + --> $DIR/integer-literal-suffix-inference.rs:84:12 | LL | id_i64(a16); | ------ ^^^ expected `i64`, found `i16` @@ -241,7 +241,7 @@ LL | id_i64(a16); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:18:8 + --> $DIR/integer-literal-suffix-inference.rs:20:8 | LL | fn id_i64(n: i64) -> i64 { n } | ^^^^^^ ------ @@ -251,7 +251,7 @@ LL | id_i64(a16.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:85:12 + --> $DIR/integer-literal-suffix-inference.rs:87:12 | LL | id_i64(a32); | ------ ^^^ expected `i64`, found `i32` @@ -259,7 +259,7 @@ LL | id_i64(a32); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:18:8 + --> $DIR/integer-literal-suffix-inference.rs:20:8 | LL | fn id_i64(n: i64) -> i64 { n } | ^^^^^^ ------ @@ -269,7 +269,7 @@ LL | id_i64(a32.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:89:12 + --> $DIR/integer-literal-suffix-inference.rs:91:12 | LL | id_i64(asize); | ------ ^^^^^ expected `i64`, found `isize` @@ -277,7 +277,7 @@ LL | id_i64(asize); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:18:8 + --> $DIR/integer-literal-suffix-inference.rs:20:8 | LL | fn id_i64(n: i64) -> i64 { n } | ^^^^^^ ------ @@ -287,7 +287,7 @@ LL | id_i64(asize.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:93:14 + --> $DIR/integer-literal-suffix-inference.rs:95:14 | LL | id_isize(a8); | -------- ^^ expected `isize`, found `i8` @@ -295,7 +295,7 @@ LL | id_isize(a8); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:19:8 + --> $DIR/integer-literal-suffix-inference.rs:21:8 | LL | fn id_isize(n: isize) -> isize { n } | ^^^^^^^^ -------- @@ -305,7 +305,7 @@ LL | id_isize(a8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:96:14 + --> $DIR/integer-literal-suffix-inference.rs:98:14 | LL | id_isize(a16); | -------- ^^^ expected `isize`, found `i16` @@ -313,7 +313,7 @@ LL | id_isize(a16); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:19:8 + --> $DIR/integer-literal-suffix-inference.rs:21:8 | LL | fn id_isize(n: isize) -> isize { n } | ^^^^^^^^ -------- @@ -323,7 +323,7 @@ LL | id_isize(a16.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:99:14 + --> $DIR/integer-literal-suffix-inference.rs:101:14 | LL | id_isize(a32); | -------- ^^^ expected `isize`, found `i32` @@ -331,7 +331,7 @@ LL | id_isize(a32); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:19:8 + --> $DIR/integer-literal-suffix-inference.rs:21:8 | LL | fn id_isize(n: isize) -> isize { n } | ^^^^^^^^ -------- @@ -341,7 +341,7 @@ LL | id_isize(a32.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:102:14 + --> $DIR/integer-literal-suffix-inference.rs:104:14 | LL | id_isize(a64); | -------- ^^^ expected `isize`, found `i64` @@ -349,7 +349,7 @@ LL | id_isize(a64); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:19:8 + --> $DIR/integer-literal-suffix-inference.rs:21:8 | LL | fn id_isize(n: isize) -> isize { n } | ^^^^^^^^ -------- @@ -359,7 +359,7 @@ LL | id_isize(a64.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:108:11 + --> $DIR/integer-literal-suffix-inference.rs:110:11 | LL | id_i8(c16); | ----- ^^^ expected `i8`, found `i16` @@ -367,7 +367,7 @@ LL | id_i8(c16); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:15:8 + --> $DIR/integer-literal-suffix-inference.rs:17:8 | LL | fn id_i8(n: i8) -> i8 { n } | ^^^^^ ----- @@ -377,7 +377,7 @@ LL | id_i8(c16.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:111:11 + --> $DIR/integer-literal-suffix-inference.rs:113:11 | LL | id_i8(c32); | ----- ^^^ expected `i8`, found `i32` @@ -385,7 +385,7 @@ LL | id_i8(c32); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:15:8 + --> $DIR/integer-literal-suffix-inference.rs:17:8 | LL | fn id_i8(n: i8) -> i8 { n } | ^^^^^ ----- @@ -395,7 +395,7 @@ LL | id_i8(c32.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:114:11 + --> $DIR/integer-literal-suffix-inference.rs:116:11 | LL | id_i8(c64); | ----- ^^^ expected `i8`, found `i64` @@ -403,7 +403,7 @@ LL | id_i8(c64); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:15:8 + --> $DIR/integer-literal-suffix-inference.rs:17:8 | LL | fn id_i8(n: i8) -> i8 { n } | ^^^^^ ----- @@ -413,7 +413,7 @@ LL | id_i8(c64.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:118:12 + --> $DIR/integer-literal-suffix-inference.rs:120:12 | LL | id_i16(c8); | ------ ^^ expected `i16`, found `i8` @@ -421,7 +421,7 @@ LL | id_i16(c8); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:16:8 + --> $DIR/integer-literal-suffix-inference.rs:18:8 | LL | fn id_i16(n: i16) -> i16 { n } | ^^^^^^ ------ @@ -431,7 +431,7 @@ LL | id_i16(c8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:122:12 + --> $DIR/integer-literal-suffix-inference.rs:124:12 | LL | id_i16(c32); | ------ ^^^ expected `i16`, found `i32` @@ -439,7 +439,7 @@ LL | id_i16(c32); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:16:8 + --> $DIR/integer-literal-suffix-inference.rs:18:8 | LL | fn id_i16(n: i16) -> i16 { n } | ^^^^^^ ------ @@ -449,7 +449,7 @@ LL | id_i16(c32.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:125:12 + --> $DIR/integer-literal-suffix-inference.rs:127:12 | LL | id_i16(c64); | ------ ^^^ expected `i16`, found `i64` @@ -457,7 +457,7 @@ LL | id_i16(c64); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:16:8 + --> $DIR/integer-literal-suffix-inference.rs:18:8 | LL | fn id_i16(n: i16) -> i16 { n } | ^^^^^^ ------ @@ -467,7 +467,7 @@ LL | id_i16(c64.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:129:12 + --> $DIR/integer-literal-suffix-inference.rs:131:12 | LL | id_i32(c8); | ------ ^^ expected `i32`, found `i8` @@ -475,7 +475,7 @@ LL | id_i32(c8); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:17:8 + --> $DIR/integer-literal-suffix-inference.rs:19:8 | LL | fn id_i32(n: i32) -> i32 { n } | ^^^^^^ ------ @@ -485,7 +485,7 @@ LL | id_i32(c8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:132:12 + --> $DIR/integer-literal-suffix-inference.rs:134:12 | LL | id_i32(c16); | ------ ^^^ expected `i32`, found `i16` @@ -493,7 +493,7 @@ LL | id_i32(c16); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:17:8 + --> $DIR/integer-literal-suffix-inference.rs:19:8 | LL | fn id_i32(n: i32) -> i32 { n } | ^^^^^^ ------ @@ -503,7 +503,7 @@ LL | id_i32(c16.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:136:12 + --> $DIR/integer-literal-suffix-inference.rs:138:12 | LL | id_i32(c64); | ------ ^^^ expected `i32`, found `i64` @@ -511,7 +511,7 @@ LL | id_i32(c64); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:17:8 + --> $DIR/integer-literal-suffix-inference.rs:19:8 | LL | fn id_i32(n: i32) -> i32 { n } | ^^^^^^ ------ @@ -521,7 +521,7 @@ LL | id_i32(c64.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:140:12 + --> $DIR/integer-literal-suffix-inference.rs:142:12 | LL | id_i64(a8); | ------ ^^ expected `i64`, found `i8` @@ -529,7 +529,7 @@ LL | id_i64(a8); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:18:8 + --> $DIR/integer-literal-suffix-inference.rs:20:8 | LL | fn id_i64(n: i64) -> i64 { n } | ^^^^^^ ------ @@ -539,7 +539,7 @@ LL | id_i64(a8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:143:12 + --> $DIR/integer-literal-suffix-inference.rs:145:12 | LL | id_i64(a16); | ------ ^^^ expected `i64`, found `i16` @@ -547,7 +547,7 @@ LL | id_i64(a16); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:18:8 + --> $DIR/integer-literal-suffix-inference.rs:20:8 | LL | fn id_i64(n: i64) -> i64 { n } | ^^^^^^ ------ @@ -557,7 +557,7 @@ LL | id_i64(a16.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:146:12 + --> $DIR/integer-literal-suffix-inference.rs:148:12 | LL | id_i64(a32); | ------ ^^^ expected `i64`, found `i32` @@ -565,7 +565,7 @@ LL | id_i64(a32); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:18:8 + --> $DIR/integer-literal-suffix-inference.rs:20:8 | LL | fn id_i64(n: i64) -> i64 { n } | ^^^^^^ ------ @@ -575,7 +575,7 @@ LL | id_i64(a32.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:152:11 + --> $DIR/integer-literal-suffix-inference.rs:154:11 | LL | id_u8(b16); | ----- ^^^ expected `u8`, found `u16` @@ -583,7 +583,7 @@ LL | id_u8(b16); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:27:8 + --> $DIR/integer-literal-suffix-inference.rs:29:8 | LL | fn id_u8(n: u8) -> u8 { n } | ^^^^^ ----- @@ -593,7 +593,7 @@ LL | id_u8(b16.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:155:11 + --> $DIR/integer-literal-suffix-inference.rs:157:11 | LL | id_u8(b32); | ----- ^^^ expected `u8`, found `u32` @@ -601,7 +601,7 @@ LL | id_u8(b32); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:27:8 + --> $DIR/integer-literal-suffix-inference.rs:29:8 | LL | fn id_u8(n: u8) -> u8 { n } | ^^^^^ ----- @@ -611,7 +611,7 @@ LL | id_u8(b32.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:158:11 + --> $DIR/integer-literal-suffix-inference.rs:160:11 | LL | id_u8(b64); | ----- ^^^ expected `u8`, found `u64` @@ -619,7 +619,7 @@ LL | id_u8(b64); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:27:8 + --> $DIR/integer-literal-suffix-inference.rs:29:8 | LL | fn id_u8(n: u8) -> u8 { n } | ^^^^^ ----- @@ -629,7 +629,7 @@ LL | id_u8(b64.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:161:11 + --> $DIR/integer-literal-suffix-inference.rs:163:11 | LL | id_u8(bsize); | ----- ^^^^^ expected `u8`, found `usize` @@ -637,7 +637,7 @@ LL | id_u8(bsize); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:27:8 + --> $DIR/integer-literal-suffix-inference.rs:29:8 | LL | fn id_u8(n: u8) -> u8 { n } | ^^^^^ ----- @@ -647,7 +647,7 @@ LL | id_u8(bsize.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:165:12 + --> $DIR/integer-literal-suffix-inference.rs:167:12 | LL | id_u16(b8); | ------ ^^ expected `u16`, found `u8` @@ -655,7 +655,7 @@ LL | id_u16(b8); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:28:8 + --> $DIR/integer-literal-suffix-inference.rs:30:8 | LL | fn id_u16(n: u16) -> u16 { n } | ^^^^^^ ------ @@ -665,7 +665,7 @@ LL | id_u16(b8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:169:12 + --> $DIR/integer-literal-suffix-inference.rs:171:12 | LL | id_u16(b32); | ------ ^^^ expected `u16`, found `u32` @@ -673,7 +673,7 @@ LL | id_u16(b32); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:28:8 + --> $DIR/integer-literal-suffix-inference.rs:30:8 | LL | fn id_u16(n: u16) -> u16 { n } | ^^^^^^ ------ @@ -683,7 +683,7 @@ LL | id_u16(b32.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:172:12 + --> $DIR/integer-literal-suffix-inference.rs:174:12 | LL | id_u16(b64); | ------ ^^^ expected `u16`, found `u64` @@ -691,7 +691,7 @@ LL | id_u16(b64); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:28:8 + --> $DIR/integer-literal-suffix-inference.rs:30:8 | LL | fn id_u16(n: u16) -> u16 { n } | ^^^^^^ ------ @@ -701,7 +701,7 @@ LL | id_u16(b64.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:175:12 + --> $DIR/integer-literal-suffix-inference.rs:177:12 | LL | id_u16(bsize); | ------ ^^^^^ expected `u16`, found `usize` @@ -709,7 +709,7 @@ LL | id_u16(bsize); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:28:8 + --> $DIR/integer-literal-suffix-inference.rs:30:8 | LL | fn id_u16(n: u16) -> u16 { n } | ^^^^^^ ------ @@ -719,7 +719,7 @@ LL | id_u16(bsize.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:179:12 + --> $DIR/integer-literal-suffix-inference.rs:181:12 | LL | id_u32(b8); | ------ ^^ expected `u32`, found `u8` @@ -727,7 +727,7 @@ LL | id_u32(b8); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:29:8 + --> $DIR/integer-literal-suffix-inference.rs:31:8 | LL | fn id_u32(n: u32) -> u32 { n } | ^^^^^^ ------ @@ -737,7 +737,7 @@ LL | id_u32(b8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:182:12 + --> $DIR/integer-literal-suffix-inference.rs:184:12 | LL | id_u32(b16); | ------ ^^^ expected `u32`, found `u16` @@ -745,7 +745,7 @@ LL | id_u32(b16); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:29:8 + --> $DIR/integer-literal-suffix-inference.rs:31:8 | LL | fn id_u32(n: u32) -> u32 { n } | ^^^^^^ ------ @@ -755,7 +755,7 @@ LL | id_u32(b16.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:186:12 + --> $DIR/integer-literal-suffix-inference.rs:188:12 | LL | id_u32(b64); | ------ ^^^ expected `u32`, found `u64` @@ -763,7 +763,7 @@ LL | id_u32(b64); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:29:8 + --> $DIR/integer-literal-suffix-inference.rs:31:8 | LL | fn id_u32(n: u32) -> u32 { n } | ^^^^^^ ------ @@ -773,7 +773,7 @@ LL | id_u32(b64.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:189:12 + --> $DIR/integer-literal-suffix-inference.rs:191:12 | LL | id_u32(bsize); | ------ ^^^^^ expected `u32`, found `usize` @@ -781,7 +781,7 @@ LL | id_u32(bsize); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:29:8 + --> $DIR/integer-literal-suffix-inference.rs:31:8 | LL | fn id_u32(n: u32) -> u32 { n } | ^^^^^^ ------ @@ -791,7 +791,7 @@ LL | id_u32(bsize.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:193:12 + --> $DIR/integer-literal-suffix-inference.rs:195:12 | LL | id_u64(b8); | ------ ^^ expected `u64`, found `u8` @@ -799,7 +799,7 @@ LL | id_u64(b8); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:30:8 + --> $DIR/integer-literal-suffix-inference.rs:32:8 | LL | fn id_u64(n: u64) -> u64 { n } | ^^^^^^ ------ @@ -809,7 +809,7 @@ LL | id_u64(b8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:196:12 + --> $DIR/integer-literal-suffix-inference.rs:198:12 | LL | id_u64(b16); | ------ ^^^ expected `u64`, found `u16` @@ -817,7 +817,7 @@ LL | id_u64(b16); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:30:8 + --> $DIR/integer-literal-suffix-inference.rs:32:8 | LL | fn id_u64(n: u64) -> u64 { n } | ^^^^^^ ------ @@ -827,7 +827,7 @@ LL | id_u64(b16.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:199:12 + --> $DIR/integer-literal-suffix-inference.rs:201:12 | LL | id_u64(b32); | ------ ^^^ expected `u64`, found `u32` @@ -835,7 +835,7 @@ LL | id_u64(b32); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:30:8 + --> $DIR/integer-literal-suffix-inference.rs:32:8 | LL | fn id_u64(n: u64) -> u64 { n } | ^^^^^^ ------ @@ -845,7 +845,7 @@ LL | id_u64(b32.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:203:12 + --> $DIR/integer-literal-suffix-inference.rs:205:12 | LL | id_u64(bsize); | ------ ^^^^^ expected `u64`, found `usize` @@ -853,7 +853,7 @@ LL | id_u64(bsize); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:30:8 + --> $DIR/integer-literal-suffix-inference.rs:32:8 | LL | fn id_u64(n: u64) -> u64 { n } | ^^^^^^ ------ @@ -863,7 +863,7 @@ LL | id_u64(bsize.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:207:14 + --> $DIR/integer-literal-suffix-inference.rs:209:14 | LL | id_usize(b8); | -------- ^^ expected `usize`, found `u8` @@ -871,7 +871,7 @@ LL | id_usize(b8); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:31:8 + --> $DIR/integer-literal-suffix-inference.rs:33:8 | LL | fn id_usize(n: usize) -> usize { n } | ^^^^^^^^ -------- @@ -881,7 +881,7 @@ LL | id_usize(b8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:210:14 + --> $DIR/integer-literal-suffix-inference.rs:212:14 | LL | id_usize(b16); | -------- ^^^ expected `usize`, found `u16` @@ -889,7 +889,7 @@ LL | id_usize(b16); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:31:8 + --> $DIR/integer-literal-suffix-inference.rs:33:8 | LL | fn id_usize(n: usize) -> usize { n } | ^^^^^^^^ -------- @@ -899,7 +899,7 @@ LL | id_usize(b16.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:213:14 + --> $DIR/integer-literal-suffix-inference.rs:215:14 | LL | id_usize(b32); | -------- ^^^ expected `usize`, found `u32` @@ -907,7 +907,7 @@ LL | id_usize(b32); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:31:8 + --> $DIR/integer-literal-suffix-inference.rs:33:8 | LL | fn id_usize(n: usize) -> usize { n } | ^^^^^^^^ -------- @@ -917,7 +917,7 @@ LL | id_usize(b32.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/integer-literal-suffix-inference.rs:216:14 + --> $DIR/integer-literal-suffix-inference.rs:218:14 | LL | id_usize(b64); | -------- ^^^ expected `usize`, found `u64` @@ -925,7 +925,7 @@ LL | id_usize(b64); | arguments to this function are incorrect | note: function defined here - --> $DIR/integer-literal-suffix-inference.rs:31:8 + --> $DIR/integer-literal-suffix-inference.rs:33:8 | LL | fn id_usize(n: usize) -> usize { n } | ^^^^^^^^ -------- diff --git a/tests/ui/on-unimplemented/expected-comma-found-token.rs b/tests/ui/on-unimplemented/expected-comma-found-token.rs index 8fb34f21152..d60ab3341fd 100644 --- a/tests/ui/on-unimplemented/expected-comma-found-token.rs +++ b/tests/ui/on-unimplemented/expected-comma-found-token.rs @@ -1,7 +1,6 @@ -// Tests that two closures cannot simultaneously have mutable -// access to the variable, whether that mutable access be used -// for direct assignment or for taking mutable ref. Issue #6801. +//! Test for invalid MetaItem syntax in the attribute +#![crate_type = "lib"] #![feature(rustc_attrs)] #[rustc_on_unimplemented( @@ -9,5 +8,3 @@ label="the label" //~ ERROR expected `,`, found `label` )] trait T {} - -fn main() { } diff --git a/tests/ui/on-unimplemented/expected-comma-found-token.stderr b/tests/ui/on-unimplemented/expected-comma-found-token.stderr index 7c0874e36a6..2717100a1dc 100644 --- a/tests/ui/on-unimplemented/expected-comma-found-token.stderr +++ b/tests/ui/on-unimplemented/expected-comma-found-token.stderr @@ -1,5 +1,5 @@ error: expected `,`, found `label` - --> $DIR/expected-comma-found-token.rs:9:5 + --> $DIR/expected-comma-found-token.rs:8:5 | LL | message="the message" | - expected `,` diff --git a/tests/ui/panic-handler/panic-handler-wrong-location.rs b/tests/ui/panic-handler/panic-handler-wrong-location.rs index c91580ae0c4..8fff7067136 100644 --- a/tests/ui/panic-handler/panic-handler-wrong-location.rs +++ b/tests/ui/panic-handler/panic-handler-wrong-location.rs @@ -4,7 +4,6 @@ #![no_main] #[panic_handler] //~ ERROR `panic_impl` lang item must be applied to a function -#[no_mangle] static X: u32 = 42; //~? ERROR `#[panic_handler]` function required, but not found diff --git a/tests/ui/panics/catch-unwind-bang.rs b/tests/ui/panics/catch-unwind-bang.rs new file mode 100644 index 00000000000..80eb377e5ca --- /dev/null +++ b/tests/ui/panics/catch-unwind-bang.rs @@ -0,0 +1,15 @@ +//! Check that the unwind machinery handles uninhabited types correctly. +//! It used to call `std::mem::uninitialized::<!>();` at some point... +//! +//! See <https://github.com/rust-lang/rust/issues/39432> + +//@ run-pass +//@ needs-unwind + +fn worker() -> ! { + panic!() +} + +fn main() { + std::panic::catch_unwind(worker).unwrap_err(); +} diff --git a/tests/ui/parser/diagnostics-parenthesized-type-arguments-ice-issue-122345.rs b/tests/ui/parser/diagnostics-parenthesized-type-arguments-ice-issue-122345.rs index 47df107a261..6bfe16ae37d 100644 --- a/tests/ui/parser/diagnostics-parenthesized-type-arguments-ice-issue-122345.rs +++ b/tests/ui/parser/diagnostics-parenthesized-type-arguments-ice-issue-122345.rs @@ -1,7 +1,9 @@ +//@ dont-require-annotations: NOTE + fn main() { unsafe { dealloc(ptr2, Layout::(x: !)(1, 1)); //~ ERROR: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `:` //~^ ERROR: expected one of `.`, `;`, `?`, `}`, or an operator, found `)` - //~| while parsing this parenthesized list of type arguments starting here + //~| NOTE while parsing this parenthesized list of type arguments starting here } } diff --git a/tests/ui/parser/diagnostics-parenthesized-type-arguments-ice-issue-122345.stderr b/tests/ui/parser/diagnostics-parenthesized-type-arguments-ice-issue-122345.stderr index 8067c97ae4b..c12bf7f9e3f 100644 --- a/tests/ui/parser/diagnostics-parenthesized-type-arguments-ice-issue-122345.stderr +++ b/tests/ui/parser/diagnostics-parenthesized-type-arguments-ice-issue-122345.stderr @@ -1,5 +1,5 @@ error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `:` - --> $DIR/diagnostics-parenthesized-type-arguments-ice-issue-122345.rs:3:33 + --> $DIR/diagnostics-parenthesized-type-arguments-ice-issue-122345.rs:5:33 | LL | dealloc(ptr2, Layout::(x: !)(1, 1)); | --- ^ expected one of 7 possible tokens @@ -7,7 +7,7 @@ LL | dealloc(ptr2, Layout::(x: !)(1, 1)); | while parsing this parenthesized list of type arguments starting here error: expected one of `.`, `;`, `?`, `}`, or an operator, found `)` - --> $DIR/diagnostics-parenthesized-type-arguments-ice-issue-122345.rs:3:43 + --> $DIR/diagnostics-parenthesized-type-arguments-ice-issue-122345.rs:5:43 | LL | dealloc(ptr2, Layout::(x: !)(1, 1)); | ^ expected one of `.`, `;`, `?`, `}`, or an operator diff --git a/tests/ui/parser/do-catch-suggests-try.rs b/tests/ui/parser/do-catch-suggests-try.rs index fcd55ce4059..af85373e120 100644 --- a/tests/ui/parser/do-catch-suggests-try.rs +++ b/tests/ui/parser/do-catch-suggests-try.rs @@ -1,10 +1,12 @@ +//@ dont-require-annotations: NOTE + #![feature(try_blocks)] fn main() { let _: Option<()> = do catch {}; //~^ ERROR found removed `do catch` syntax //~| HELP replace with the new syntax - //~| following RFC #2388, the new non-placeholder syntax is `try` + //~| NOTE following RFC #2388, the new non-placeholder syntax is `try` let _recovery_witness: () = 1; //~ ERROR mismatched types } diff --git a/tests/ui/parser/do-catch-suggests-try.stderr b/tests/ui/parser/do-catch-suggests-try.stderr index 2eaab836075..eecf588c5e9 100644 --- a/tests/ui/parser/do-catch-suggests-try.stderr +++ b/tests/ui/parser/do-catch-suggests-try.stderr @@ -1,5 +1,5 @@ error: found removed `do catch` syntax - --> $DIR/do-catch-suggests-try.rs:4:25 + --> $DIR/do-catch-suggests-try.rs:6:25 | LL | let _: Option<()> = do catch {}; | ^^^^^^^^ @@ -12,7 +12,7 @@ LL + let _: Option<()> = try {}; | error[E0308]: mismatched types - --> $DIR/do-catch-suggests-try.rs:9:33 + --> $DIR/do-catch-suggests-try.rs:11:33 | LL | let _recovery_witness: () = 1; | -- ^ expected `()`, found integer diff --git a/tests/ui/parser/mut-patterns.rs b/tests/ui/parser/mut-patterns.rs index ed33968c627..a2af8160740 100644 --- a/tests/ui/parser/mut-patterns.rs +++ b/tests/ui/parser/mut-patterns.rs @@ -1,6 +1,7 @@ // Can't put mut in non-ident pattern //@ edition:2018 +//@ dont-require-annotations: HELP #![feature(box_patterns)] #![allow(warnings)] @@ -13,20 +14,20 @@ pub fn main() { let mut mut x = 0; //~^ ERROR `mut` on a binding may not be repeated - //~| remove the additional `mut`s + //~| HELP remove the additional `mut`s let mut mut mut mut mut x = 0; //~^ ERROR `mut` on a binding may not be repeated - //~| remove the additional `mut`s + //~| HELP remove the additional `mut`s struct Foo { x: isize } let mut Foo { x: x } = Foo { x: 3 }; //~^ ERROR `mut` must be attached to each individual binding - //~| add `mut` to each binding + //~| HELP add `mut` to each binding let mut Foo { x } = Foo { x: 3 }; //~^ ERROR `mut` must be attached to each individual binding - //~| add `mut` to each binding + //~| HELP add `mut` to each binding struct r#yield(u8, u8); let mut mut yield(become, await) = r#yield(0, 0); diff --git a/tests/ui/parser/mut-patterns.stderr b/tests/ui/parser/mut-patterns.stderr index 9dda2499f03..70099989c9f 100644 --- a/tests/ui/parser/mut-patterns.stderr +++ b/tests/ui/parser/mut-patterns.stderr @@ -1,5 +1,5 @@ error: `mut` must be followed by a named binding - --> $DIR/mut-patterns.rs:9:9 + --> $DIR/mut-patterns.rs:10:9 | LL | let mut _ = 0; | ^^^^ @@ -12,7 +12,7 @@ LL + let _ = 0; | error: `mut` must be followed by a named binding - --> $DIR/mut-patterns.rs:10:9 + --> $DIR/mut-patterns.rs:11:9 | LL | let mut (_, _) = (0, 0); | ^^^^ @@ -25,7 +25,7 @@ LL + let (_, _) = (0, 0); | error: `mut` must be attached to each individual binding - --> $DIR/mut-patterns.rs:12:9 + --> $DIR/mut-patterns.rs:13:9 | LL | let mut (x @ y) = 0; | ^^^^^^^^^^^ @@ -38,7 +38,7 @@ LL + let (mut x @ mut y) = 0; | error: `mut` on a binding may not be repeated - --> $DIR/mut-patterns.rs:14:13 + --> $DIR/mut-patterns.rs:15:13 | LL | let mut mut x = 0; | ^^^ @@ -50,7 +50,7 @@ LL + let mut x = 0; | error: `mut` on a binding may not be repeated - --> $DIR/mut-patterns.rs:18:13 + --> $DIR/mut-patterns.rs:19:13 | LL | let mut mut mut mut mut x = 0; | ^^^^^^^^^^^^^^^ @@ -62,7 +62,7 @@ LL + let mut x = 0; | error: `mut` must be attached to each individual binding - --> $DIR/mut-patterns.rs:23:9 + --> $DIR/mut-patterns.rs:24:9 | LL | let mut Foo { x: x } = Foo { x: 3 }; | ^^^^^^^^^^^^^^^^ @@ -75,7 +75,7 @@ LL + let Foo { x: mut x } = Foo { x: 3 }; | error: `mut` must be attached to each individual binding - --> $DIR/mut-patterns.rs:27:9 + --> $DIR/mut-patterns.rs:28:9 | LL | let mut Foo { x } = Foo { x: 3 }; | ^^^^^^^^^^^^^ @@ -88,7 +88,7 @@ LL + let Foo { mut x } = Foo { x: 3 }; | error: `mut` on a binding may not be repeated - --> $DIR/mut-patterns.rs:32:13 + --> $DIR/mut-patterns.rs:33:13 | LL | let mut mut yield(become, await) = r#yield(0, 0); | ^^^ @@ -100,7 +100,7 @@ LL + let mut yield(become, await) = r#yield(0, 0); | error: expected identifier, found reserved keyword `yield` - --> $DIR/mut-patterns.rs:32:17 + --> $DIR/mut-patterns.rs:33:17 | LL | let mut mut yield(become, await) = r#yield(0, 0); | ^^^^^ expected identifier, found reserved keyword @@ -111,7 +111,7 @@ LL | let mut mut r#yield(become, await) = r#yield(0, 0); | ++ error: expected identifier, found reserved keyword `become` - --> $DIR/mut-patterns.rs:32:23 + --> $DIR/mut-patterns.rs:33:23 | LL | let mut mut yield(become, await) = r#yield(0, 0); | ^^^^^^ expected identifier, found reserved keyword @@ -122,7 +122,7 @@ LL | let mut mut yield(r#become, await) = r#yield(0, 0); | ++ error: expected identifier, found keyword `await` - --> $DIR/mut-patterns.rs:32:31 + --> $DIR/mut-patterns.rs:33:31 | LL | let mut mut yield(become, await) = r#yield(0, 0); | ^^^^^ expected identifier, found keyword @@ -133,7 +133,7 @@ LL | let mut mut yield(become, r#await) = r#yield(0, 0); | ++ error: `mut` must be followed by a named binding - --> $DIR/mut-patterns.rs:32:9 + --> $DIR/mut-patterns.rs:33:9 | LL | let mut mut yield(become, await) = r#yield(0, 0); | ^^^^^^^^ @@ -146,7 +146,7 @@ LL + let yield(become, await) = r#yield(0, 0); | error: `mut` must be attached to each individual binding - --> $DIR/mut-patterns.rs:41:9 + --> $DIR/mut-patterns.rs:42:9 | LL | let mut W(mut a, W(b, W(ref c, W(d, B { box f })))) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -159,7 +159,7 @@ LL + let W(mut a, W(mut b, W(ref c, W(mut d, B { box mut f })))) | error: expected identifier, found metavariable - --> $DIR/mut-patterns.rs:48:21 + --> $DIR/mut-patterns.rs:49:21 | LL | let mut $p = 0; | ^^ expected identifier, found metavariable diff --git a/tests/ui/parser/or-in-let-chain.edition2021.stderr b/tests/ui/parser/or-in-let-chain.edition2021.stderr new file mode 100644 index 00000000000..a97095cc3b8 --- /dev/null +++ b/tests/ui/parser/or-in-let-chain.edition2021.stderr @@ -0,0 +1,28 @@ +error: `||` operators are not supported in let chain conditions + --> $DIR/or-in-let-chain.rs:6:24 + | +LL | if let true = true || false {} + | ^^ + +error: expected expression, found `let` statement + --> $DIR/or-in-let-chain.rs:9:9 + | +LL | if (let true = true) || false {} + | ^^^^^^^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `||` operators are not supported in let chain conditions + --> $DIR/or-in-let-chain.rs:12:24 + | +LL | if let true = true || false || true {} + | ^^ + +error: `||` operators are not supported in let chain conditions + --> $DIR/or-in-let-chain.rs:15:33 + | +LL | if let true = true && false || true {} + | ^^ + +error: aborting due to 4 previous errors + diff --git a/tests/ui/parser/or-in-let-chain.edition2024.stderr b/tests/ui/parser/or-in-let-chain.edition2024.stderr new file mode 100644 index 00000000000..a97095cc3b8 --- /dev/null +++ b/tests/ui/parser/or-in-let-chain.edition2024.stderr @@ -0,0 +1,28 @@ +error: `||` operators are not supported in let chain conditions + --> $DIR/or-in-let-chain.rs:6:24 + | +LL | if let true = true || false {} + | ^^ + +error: expected expression, found `let` statement + --> $DIR/or-in-let-chain.rs:9:9 + | +LL | if (let true = true) || false {} + | ^^^^^^^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `||` operators are not supported in let chain conditions + --> $DIR/or-in-let-chain.rs:12:24 + | +LL | if let true = true || false || true {} + | ^^ + +error: `||` operators are not supported in let chain conditions + --> $DIR/or-in-let-chain.rs:15:33 + | +LL | if let true = true && false || true {} + | ^^ + +error: aborting due to 4 previous errors + diff --git a/tests/ui/parser/or-in-let-chain.rs b/tests/ui/parser/or-in-let-chain.rs new file mode 100644 index 00000000000..4c4372bb00f --- /dev/null +++ b/tests/ui/parser/or-in-let-chain.rs @@ -0,0 +1,17 @@ +//@ revisions: edition2021 edition2024 +//@ [edition2021] edition: 2021 +//@ [edition2024] edition: 2024 + +fn main() { + if let true = true || false {} + //~^ ERROR `||` operators are not supported in let chain conditions + // With parentheses + if (let true = true) || false {} + //~^ ERROR expected expression, found `let` statement + // Multiple || operators + if let true = true || false || true {} + //~^ ERROR `||` operators are not supported in let chain conditions + // Mixed operators (should still show error for ||) + if let true = true && false || true {} + //~^ ERROR `||` operators are not supported in let chain conditions +} diff --git a/tests/ui/parser/recover/recover-pat-exprs.rs b/tests/ui/parser/recover/recover-pat-exprs.rs index a78bb82828d..41b44ec9642 100644 --- a/tests/ui/parser/recover/recover-pat-exprs.rs +++ b/tests/ui/parser/recover/recover-pat-exprs.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: HELP + // FieldExpression, TupleIndexingExpression fn field_access() { match 0 { @@ -28,7 +30,7 @@ fn array_indexing() { { let x[0; 20]; } //~ error: expected one of `:`, `;`, `=`, `@`, or `|`, found `[` { let x[]; } //~ error: expected one of `:`, `;`, `=`, `@`, or `|`, found `[` { let (x[]); } //~ error: expected one of `)`, `,`, `@`, `if`, or `|`, found `[` - //~^ missing `,` + //~^ HELP missing `,` } // MethodCallExpression, CallExpression, ErrorPropagationExpression diff --git a/tests/ui/parser/recover/recover-pat-exprs.stderr b/tests/ui/parser/recover/recover-pat-exprs.stderr index 69bc5107cca..33000022b8f 100644 --- a/tests/ui/parser/recover/recover-pat-exprs.stderr +++ b/tests/ui/parser/recover/recover-pat-exprs.stderr @@ -1,5 +1,5 @@ error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:5:9 + --> $DIR/recover-pat-exprs.rs:7:9 | LL | x.y => (), | ^^^ not a pattern @@ -19,7 +19,7 @@ LL ~ VAL => (), | error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:6:9 + --> $DIR/recover-pat-exprs.rs:8:9 | LL | x.0 => (), | ^^^ not a pattern @@ -40,7 +40,7 @@ LL ~ VAL => (), | error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:7:9 + --> $DIR/recover-pat-exprs.rs:9:9 | LL | x._0 => (), | ^^^^ not a pattern @@ -62,7 +62,7 @@ LL ~ VAL => (), | error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:8:9 + --> $DIR/recover-pat-exprs.rs:10:9 | LL | x.0.1 => (), | ^^^^^ not a pattern @@ -84,7 +84,7 @@ LL ~ VAL => (), | error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:9:9 + --> $DIR/recover-pat-exprs.rs:11:9 | LL | x.4.y.17.__z => (), | ^^^^^^^^^^^^ not a pattern @@ -106,37 +106,37 @@ LL ~ VAL => (), | error: expected one of `:`, `;`, `=`, `@`, or `|`, found `.` - --> $DIR/recover-pat-exprs.rs:12:12 + --> $DIR/recover-pat-exprs.rs:14:12 | LL | { let x.0e0; } | ^ expected one of `:`, `;`, `=`, `@`, or `|` error: expected one of `:`, `;`, `=`, `@`, or `|`, found `.` - --> $DIR/recover-pat-exprs.rs:13:12 + --> $DIR/recover-pat-exprs.rs:15:12 | LL | { let x.-0.0; } | ^ expected one of `:`, `;`, `=`, `@`, or `|` error: expected one of `:`, `;`, `=`, `@`, or `|`, found `.` - --> $DIR/recover-pat-exprs.rs:14:12 + --> $DIR/recover-pat-exprs.rs:16:12 | LL | { let x.-0; } | ^ expected one of `:`, `;`, `=`, `@`, or `|` error: expected one of `:`, `;`, `=`, `@`, or `|`, found `.` - --> $DIR/recover-pat-exprs.rs:16:12 + --> $DIR/recover-pat-exprs.rs:18:12 | LL | { let x.0u32; } | ^ expected one of `:`, `;`, `=`, `@`, or `|` error: expected one of `:`, `;`, `=`, `@`, or `|`, found `.` - --> $DIR/recover-pat-exprs.rs:17:12 + --> $DIR/recover-pat-exprs.rs:19:12 | LL | { let x.0.0_f64; } | ^ expected one of `:`, `;`, `=`, `@`, or `|` error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:23:9 + --> $DIR/recover-pat-exprs.rs:25:9 | LL | x[0] => (), | ^^^^ not a pattern @@ -155,7 +155,7 @@ LL ~ VAL => (), | error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:24:9 + --> $DIR/recover-pat-exprs.rs:26:9 | LL | x[..] => (), | ^^^^^ not a pattern @@ -175,25 +175,25 @@ LL ~ VAL => (), | error: expected one of `:`, `;`, `=`, `@`, or `|`, found `[` - --> $DIR/recover-pat-exprs.rs:27:12 + --> $DIR/recover-pat-exprs.rs:29:12 | LL | { let x[0, 1, 2]; } | ^ expected one of `:`, `;`, `=`, `@`, or `|` error: expected one of `:`, `;`, `=`, `@`, or `|`, found `[` - --> $DIR/recover-pat-exprs.rs:28:12 + --> $DIR/recover-pat-exprs.rs:30:12 | LL | { let x[0; 20]; } | ^ expected one of `:`, `;`, `=`, `@`, or `|` error: expected one of `:`, `;`, `=`, `@`, or `|`, found `[` - --> $DIR/recover-pat-exprs.rs:29:12 + --> $DIR/recover-pat-exprs.rs:31:12 | LL | { let x[]; } | ^ expected one of `:`, `;`, `=`, `@`, or `|` error: expected one of `)`, `,`, `@`, `if`, or `|`, found `[` - --> $DIR/recover-pat-exprs.rs:30:13 + --> $DIR/recover-pat-exprs.rs:32:13 | LL | { let (x[]); } | ^ @@ -202,7 +202,7 @@ LL | { let (x[]); } | help: missing `,` error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:37:9 + --> $DIR/recover-pat-exprs.rs:39:9 | LL | x.f() => (), | ^^^^^ not a pattern @@ -221,7 +221,7 @@ LL ~ VAL => (), | error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:38:9 + --> $DIR/recover-pat-exprs.rs:40:9 | LL | x._f() => (), | ^^^^^^ not a pattern @@ -241,7 +241,7 @@ LL ~ VAL => (), | error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:39:9 + --> $DIR/recover-pat-exprs.rs:41:9 | LL | x? => (), | ^^ not a pattern @@ -262,7 +262,7 @@ LL ~ VAL => (), | error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:40:9 + --> $DIR/recover-pat-exprs.rs:42:9 | LL | ().f() => (), | ^^^^^^ not a pattern @@ -284,7 +284,7 @@ LL ~ VAL => (), | error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:41:9 + --> $DIR/recover-pat-exprs.rs:43:9 | LL | (0, x)?.f() => (), | ^^^^^^^^^^^ not a pattern @@ -306,7 +306,7 @@ LL ~ VAL => (), | error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:42:9 + --> $DIR/recover-pat-exprs.rs:44:9 | LL | x.f().g() => (), | ^^^^^^^^^ not a pattern @@ -328,7 +328,7 @@ LL ~ VAL => (), | error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:43:9 + --> $DIR/recover-pat-exprs.rs:45:9 | LL | 0.f()?.g()?? => (), | ^^^^^^^^^^^^ not a pattern @@ -350,7 +350,7 @@ LL ~ VAL => (), | error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:50:9 + --> $DIR/recover-pat-exprs.rs:52:9 | LL | x as usize => (), | ^^^^^^^^^^ not a pattern @@ -369,7 +369,7 @@ LL ~ VAL => (), | error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:51:9 + --> $DIR/recover-pat-exprs.rs:53:9 | LL | 0 as usize => (), | ^^^^^^^^^^ not a pattern @@ -389,7 +389,7 @@ LL ~ VAL => (), | error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:52:9 + --> $DIR/recover-pat-exprs.rs:54:9 | LL | x.f().0.4 as f32 => (), | ^^^^^^^^^^^^^^^^ not a pattern @@ -410,7 +410,7 @@ LL ~ VAL => (), | error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:59:9 + --> $DIR/recover-pat-exprs.rs:61:9 | LL | 1 + 1 => (), | ^^^^^ not a pattern @@ -429,7 +429,7 @@ LL ~ VAL => (), | error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:60:9 + --> $DIR/recover-pat-exprs.rs:62:9 | LL | (1 + 2) * 3 => (), | ^^^^^^^^^^^ not a pattern @@ -449,7 +449,7 @@ LL ~ VAL => (), | error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:63:9 + --> $DIR/recover-pat-exprs.rs:65:9 | LL | x.0 > 2 => (), | ^^^^^^^ not a pattern @@ -471,7 +471,7 @@ LL ~ VAL => (), | error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:64:9 + --> $DIR/recover-pat-exprs.rs:66:9 | LL | x.0 == 2 => (), | ^^^^^^^^ not a pattern @@ -493,7 +493,7 @@ LL ~ VAL => (), | error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:69:13 + --> $DIR/recover-pat-exprs.rs:71:13 | LL | (x, y.0 > 2) if x != 0 => (), | ^^^^^^^ not a pattern @@ -512,7 +512,7 @@ LL ~ (x, VAL) if x != 0 => (), | error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:70:13 + --> $DIR/recover-pat-exprs.rs:72:13 | LL | (x, y.0 > 2) if x != 0 || x != 1 => (), | ^^^^^^^ not a pattern @@ -532,7 +532,7 @@ LL ~ (x, VAL) if x != 0 || x != 1 => (), | error: left-hand side of `@` must be a binding - --> $DIR/recover-pat-exprs.rs:83:9 + --> $DIR/recover-pat-exprs.rs:85:9 | LL | x.sqrt() @ .. => (), | --------^^^-- @@ -543,13 +543,13 @@ LL | x.sqrt() @ .. => (), = note: bindings are `x`, `mut x`, `ref x`, and `ref mut x` error: expected one of `)`, `,`, `if`, or `|`, found `+` - --> $DIR/recover-pat-exprs.rs:97:12 + --> $DIR/recover-pat-exprs.rs:99:12 | LL | (_ + 1) => (), | ^ expected one of `)`, `,`, `if`, or `|` error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:81:9 + --> $DIR/recover-pat-exprs.rs:83:9 | LL | u8::MAX.abs() => (), | ^^^^^^^^^^^^^ not a pattern @@ -568,7 +568,7 @@ LL ~ VAL => (), | error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:86:17 + --> $DIR/recover-pat-exprs.rs:88:17 | LL | z @ w @ v.u() => (), | ^^^^^ not a pattern @@ -590,7 +590,7 @@ LL ~ z @ w @ VAL => (), | error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:88:9 + --> $DIR/recover-pat-exprs.rs:90:9 | LL | y.ilog(3) => (), | ^^^^^^^^^ not a pattern @@ -612,7 +612,7 @@ LL ~ VAL => (), | error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:90:9 + --> $DIR/recover-pat-exprs.rs:92:9 | LL | n + 1 => (), | ^^^^^ not a pattern @@ -634,7 +634,7 @@ LL ~ VAL => (), | error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:92:10 + --> $DIR/recover-pat-exprs.rs:94:10 | LL | ("".f() + 14 * 8) => (), | ^^^^^^^^^^^^^^^ not a pattern @@ -656,7 +656,7 @@ LL ~ (VAL) => (), | error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:95:9 + --> $DIR/recover-pat-exprs.rs:97:9 | LL | f?() => (), | ^^^^ not a pattern @@ -678,7 +678,7 @@ LL ~ VAL => (), | error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:101:9 + --> $DIR/recover-pat-exprs.rs:103:9 | LL | let 1 + 1 = 2; | ^^^^^ not a pattern @@ -686,7 +686,7 @@ LL | let 1 + 1 = 2; = note: arbitrary expressions are not allowed in patterns: <https://doc.rust-lang.org/book/ch19-00-patterns.html> error: expected one of `)`, `,`, `@`, `if`, or `|`, found `*` - --> $DIR/recover-pat-exprs.rs:104:28 + --> $DIR/recover-pat-exprs.rs:106:28 | LL | let b = matches!(x, (x * x | x.f()) | x[0]); | ^ expected one of `)`, `,`, `@`, `if`, or `|` @@ -695,7 +695,7 @@ LL | let b = matches!(x, (x * x | x.f()) | x[0]); = note: while parsing argument for this `pat` macro fragment error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:60:10 + --> $DIR/recover-pat-exprs.rs:62:10 | LL | (1 + 2) * 3 => (), | ^^^^^ not a pattern @@ -703,7 +703,7 @@ LL | (1 + 2) * 3 => (), = note: arbitrary expressions are not allowed in patterns: <https://doc.rust-lang.org/book/ch19-00-patterns.html> error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:75:5 + --> $DIR/recover-pat-exprs.rs:77:5 | LL | 1 + 2 * PI.cos() => 2, | ^^^^^^^^^^^^^^^^ not a pattern @@ -711,7 +711,7 @@ LL | 1 + 2 * PI.cos() => 2, = note: arbitrary expressions are not allowed in patterns: <https://doc.rust-lang.org/book/ch19-00-patterns.html> error: expected a pattern, found an expression - --> $DIR/recover-pat-exprs.rs:83:9 + --> $DIR/recover-pat-exprs.rs:85:9 | LL | x.sqrt() @ .. => (), | ^^^^^^^^ not a pattern diff --git a/tests/ui/parser/ty-path-followed-by-single-colon.rs b/tests/ui/parser/ty-path-followed-by-single-colon.rs new file mode 100644 index 00000000000..a9082ea317a --- /dev/null +++ b/tests/ui/parser/ty-path-followed-by-single-colon.rs @@ -0,0 +1,22 @@ +// Paths in type contexts may be followed by single colons. +// This means we can't generally assume that the user typo'ed a double colon. +// issue: <https://github.com/rust-lang/rust/issues/140227> +//@ check-pass +#![crate_type = "lib"] +#![expect(non_camel_case_types)] + +#[rustfmt::skip] +mod garden { + + fn f<path>() where path:to::somewhere {} // OK! + + fn g(_: impl Take<path:to::somewhere>) {} // OK! + + #[cfg(any())] fn h() where a::path:to::nowhere {} // OK! + + fn i(_: impl Take<path::<>:to::somewhere>) {} // OK! + + mod to { pub(super) trait somewhere {} } + trait Take { type path; } + +} diff --git a/tests/ui/path.rs b/tests/ui/path.rs deleted file mode 100644 index bd7b99ac01a..00000000000 --- a/tests/ui/path.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ run-pass - -mod foo { - pub fn bar(_offset: usize) { } -} - -pub fn main() { foo::bar(0); } diff --git a/tests/ui/pattern/byte-string-mutability-mismatch.rs b/tests/ui/pattern/byte-string-mutability-mismatch.rs new file mode 100644 index 00000000000..9f7054ae82e --- /dev/null +++ b/tests/ui/pattern/byte-string-mutability-mismatch.rs @@ -0,0 +1,21 @@ +//! Byte string literal patterns use the mutability of the literal, rather than the mutability of +//! the pattern's scrutinee. Since byte string literals are always shared references, it's a +//! mismatch to use a byte string literal pattern to match on a mutable array or slice reference. + +//@ dont-require-annotations: NOTE + +fn main() { + let mut val = [97u8, 10u8]; + match &mut val { + b"a\n" => {}, + //~^ ERROR mismatched types + //~| NOTE types differ in mutability + _ => {}, + } + match &mut val[..] { + b"a\n" => {}, + //~^ ERROR mismatched types + //~| NOTE types differ in mutability + _ => {}, + } +} diff --git a/tests/ui/pattern/byte-string-mutability-mismatch.stderr b/tests/ui/pattern/byte-string-mutability-mismatch.stderr new file mode 100644 index 00000000000..f64b452b594 --- /dev/null +++ b/tests/ui/pattern/byte-string-mutability-mismatch.stderr @@ -0,0 +1,25 @@ +error[E0308]: mismatched types + --> $DIR/byte-string-mutability-mismatch.rs:10:9 + | +LL | match &mut val { + | -------- this expression has type `&mut [u8; 2]` +LL | b"a\n" => {}, + | ^^^^^^ types differ in mutability + | + = note: expected mutable reference `&mut _` + found reference `&'static _` + +error[E0308]: mismatched types + --> $DIR/byte-string-mutability-mismatch.rs:16:10 + | +LL | match &mut val[..] { + | ------------ this expression has type `&mut [u8]` +LL | b"a\n" => {}, + | ^^^^^^ types differ in mutability + | + = note: expected mutable reference `&mut _` + found reference `&'static _` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/pattern/deref-patterns/bindings.rs b/tests/ui/pattern/deref-patterns/bindings.rs index c14d57f3f24..ac48e3ffefc 100644 --- a/tests/ui/pattern/deref-patterns/bindings.rs +++ b/tests/ui/pattern/deref-patterns/bindings.rs @@ -3,6 +3,8 @@ #![feature(deref_patterns)] #![allow(incomplete_features)] +use std::rc::Rc; + #[cfg(explicit)] fn simple_vec(vec: Vec<u32>) -> u32 { match vec { @@ -53,29 +55,29 @@ fn nested_vec(vecvec: Vec<Vec<u32>>) -> u32 { #[cfg(explicit)] fn ref_mut(val: u32) -> u32 { - let mut b = Box::new(0u32); + let mut b = vec![0u32]; match &mut b { - deref!(_x) if false => unreachable!(), - deref!(x) => { + deref!([_x]) if false => unreachable!(), + deref!([x]) => { *x = val; } _ => unreachable!(), } - let deref!(x) = &b else { unreachable!() }; + let deref!([x]) = &b else { unreachable!() }; *x } #[cfg(implicit)] fn ref_mut(val: u32) -> u32 { - let mut b = Box::new((0u32,)); + let mut b = vec![0u32]; match &mut b { - (_x,) if false => unreachable!(), - (x,) => { + [_x] if false => unreachable!(), + [x] => { *x = val; } _ => unreachable!(), } - let (x,) = &b else { unreachable!() }; + let [x] = &b else { unreachable!() }; *x } @@ -83,7 +85,7 @@ fn ref_mut(val: u32) -> u32 { #[rustfmt::skip] fn or_and_guard(tuple: (u32, u32)) -> u32 { let mut sum = 0; - let b = Box::new(tuple); + let b = Rc::new(tuple); match b { deref!((x, _) | (_, x)) if { sum += x; false } => {}, _ => {}, @@ -95,7 +97,7 @@ fn or_and_guard(tuple: (u32, u32)) -> u32 { #[rustfmt::skip] fn or_and_guard(tuple: (u32, u32)) -> u32 { let mut sum = 0; - let b = Box::new(tuple); + let b = Rc::new(tuple); match b { (x, _) | (_, x) if { sum += x; false } => {}, _ => {}, diff --git a/tests/ui/pattern/deref-patterns/byte-string-type-errors.rs b/tests/ui/pattern/deref-patterns/byte-string-type-errors.rs new file mode 100644 index 00000000000..64acc4748af --- /dev/null +++ b/tests/ui/pattern/deref-patterns/byte-string-type-errors.rs @@ -0,0 +1,36 @@ +//! Test type errors for byte string literal patterns. `deref_patterns` allows byte string literal +//! patterns to have type `[u8]` or `[u8; N]` when matching on a slice or array; this can affect the +//! "found" type reported in error messages when matching on a slice or array of the wrong type. + +//@ dont-require-annotations: NOTE + +#![feature(deref_patterns)] +#![expect(incomplete_features)] + +fn main() { + // Baseline 1: under normal circumstances, byte string literal patterns have type `&[u8; N]`, + // the same as byte string literals. + if let b"test" = () {} + //~^ ERROR mismatched types + //~| NOTE expected `()`, found `&[u8; 4]` + + // Baseline 2: there's a special case for byte string patterns in stable rust, allowing them to + // match on slice references. This affects the error when matching on a non-`&[u8]` slice ref, + // reporting the "found" type as `&[u8]`. + if let b"test" = &[] as &[i8] {} + //~^ ERROR mismatched types + //~| NOTE expected `&[i8]`, found `&[u8]` + + // Test matching on a non-`[u8]` slice: the pattern has type `[u8]` if a slice is expected. + if let b"test" = *(&[] as &[i8]) {} + //~^ ERROR mismatched types + //~| NOTE expected `[i8]`, found `[u8]` + + // Test matching on a non-`[u8;4]` array: the pattern has type `[u8;4]` if an array is expected. + if let b"test" = [()] {} + //~^ ERROR mismatched types + //~| NOTE expected `[(); 1]`, found `[u8; 4]` + if let b"test" = *b"this array is too long" {} + //~^ ERROR mismatched types + //~| NOTE expected an array with a size of 22, found one with a size of 4 +} diff --git a/tests/ui/pattern/deref-patterns/byte-string-type-errors.stderr b/tests/ui/pattern/deref-patterns/byte-string-type-errors.stderr new file mode 100644 index 00000000000..0317b7209e1 --- /dev/null +++ b/tests/ui/pattern/deref-patterns/byte-string-type-errors.stderr @@ -0,0 +1,52 @@ +error[E0308]: mismatched types + --> $DIR/byte-string-type-errors.rs:13:12 + | +LL | if let b"test" = () {} + | ^^^^^^^ -- this expression has type `()` + | | + | expected `()`, found `&[u8; 4]` + +error[E0308]: mismatched types + --> $DIR/byte-string-type-errors.rs:20:12 + | +LL | if let b"test" = &[] as &[i8] {} + | ^^^^^^^ ------------ this expression has type `&[i8]` + | | + | expected `&[i8]`, found `&[u8]` + | + = note: expected reference `&[i8]` + found reference `&'static [u8]` + +error[E0308]: mismatched types + --> $DIR/byte-string-type-errors.rs:25:12 + | +LL | if let b"test" = *(&[] as &[i8]) {} + | ^^^^^^^ --------------- this expression has type `[i8]` + | | + | expected `[i8]`, found `[u8]` + | + = note: expected slice `[i8]` + found slice `[u8]` + +error[E0308]: mismatched types + --> $DIR/byte-string-type-errors.rs:30:12 + | +LL | if let b"test" = [()] {} + | ^^^^^^^ ---- this expression has type `[(); 1]` + | | + | expected `[(); 1]`, found `[u8; 4]` + | + = note: expected array `[(); 1]` + found array `[u8; 4]` + +error[E0308]: mismatched types + --> $DIR/byte-string-type-errors.rs:33:12 + | +LL | if let b"test" = *b"this array is too long" {} + | ^^^^^^^ -------------------------- this expression has type `[u8; 22]` + | | + | expected an array with a size of 22, found one with a size of 4 + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/pattern/deref-patterns/cant_move_out_of_pattern.rs b/tests/ui/pattern/deref-patterns/cant_move_out_of_pattern.rs index 791776be5ac..2b4746e33e6 100644 --- a/tests/ui/pattern/deref-patterns/cant_move_out_of_pattern.rs +++ b/tests/ui/pattern/deref-patterns/cant_move_out_of_pattern.rs @@ -5,11 +5,11 @@ use std::rc::Rc; struct Struct; -fn cant_move_out_box(b: Box<Struct>) -> Struct { +fn cant_move_out_vec(b: Vec<Struct>) -> Struct { match b { - //~^ ERROR: cannot move out of a shared reference - deref!(x) => x, - _ => unreachable!(), + //~^ ERROR: cannot move out of type `[Struct]`, a non-copy slice + deref!([x]) => x, + _ => panic!(), } } @@ -21,16 +21,16 @@ fn cant_move_out_rc(rc: Rc<Struct>) -> Struct { } } -struct Container(Struct); - -fn cant_move_out_box_implicit(b: Box<Container>) -> Struct { +fn cant_move_out_vec_implicit(b: Vec<Struct>) -> Struct { match b { - //~^ ERROR: cannot move out of a shared reference - Container(x) => x, - _ => unreachable!(), + //~^ ERROR: cannot move out of type `[Struct]`, a non-copy slice + [x] => x, + _ => panic!(), } } +struct Container(Struct); + fn cant_move_out_rc_implicit(rc: Rc<Container>) -> Struct { match rc { //~^ ERROR: cannot move out of a shared reference diff --git a/tests/ui/pattern/deref-patterns/cant_move_out_of_pattern.stderr b/tests/ui/pattern/deref-patterns/cant_move_out_of_pattern.stderr index 1887800fc38..a548ac5909a 100644 --- a/tests/ui/pattern/deref-patterns/cant_move_out_of_pattern.stderr +++ b/tests/ui/pattern/deref-patterns/cant_move_out_of_pattern.stderr @@ -1,19 +1,19 @@ -error[E0507]: cannot move out of a shared reference +error[E0508]: cannot move out of type `[Struct]`, a non-copy slice --> $DIR/cant_move_out_of_pattern.rs:9:11 | LL | match b { - | ^ + | ^ cannot move out of here LL | -LL | deref!(x) => x, - | - - | | - | data moved here - | move occurs because `x` has type `Struct`, which does not implement the `Copy` trait +LL | deref!([x]) => x, + | - + | | + | data moved here + | move occurs because `x` has type `Struct`, which does not implement the `Copy` trait | help: consider borrowing the pattern binding | -LL | deref!(ref x) => x, - | +++ +LL | deref!([ref x]) => x, + | +++ error[E0507]: cannot move out of a shared reference --> $DIR/cant_move_out_of_pattern.rs:17:11 @@ -32,22 +32,22 @@ help: consider borrowing the pattern binding LL | deref!(ref x) => x, | +++ -error[E0507]: cannot move out of a shared reference - --> $DIR/cant_move_out_of_pattern.rs:27:11 +error[E0508]: cannot move out of type `[Struct]`, a non-copy slice + --> $DIR/cant_move_out_of_pattern.rs:25:11 | LL | match b { - | ^ + | ^ cannot move out of here LL | -LL | Container(x) => x, - | - - | | - | data moved here - | move occurs because `x` has type `Struct`, which does not implement the `Copy` trait +LL | [x] => x, + | - + | | + | data moved here + | move occurs because `x` has type `Struct`, which does not implement the `Copy` trait | help: consider borrowing the pattern binding | -LL | Container(ref x) => x, - | +++ +LL | [ref x] => x, + | +++ error[E0507]: cannot move out of a shared reference --> $DIR/cant_move_out_of_pattern.rs:35:11 @@ -68,4 +68,5 @@ LL | Container(ref x) => x, error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0507`. +Some errors have detailed explanations: E0507, E0508. +For more information about an error, try `rustc --explain E0507`. diff --git a/tests/ui/pattern/deref-patterns/closure_capture.rs b/tests/ui/pattern/deref-patterns/closure_capture.rs index 08586b6c7ab..cf78eeda1d5 100644 --- a/tests/ui/pattern/deref-patterns/closure_capture.rs +++ b/tests/ui/pattern/deref-patterns/closure_capture.rs @@ -2,8 +2,12 @@ #![feature(deref_patterns)] #![allow(incomplete_features)] +use std::rc::Rc; + +struct NoCopy; + fn main() { - let b = Box::new("aaa".to_string()); + let b = Rc::new("aaa".to_string()); let f = || { let deref!(ref s) = b else { unreachable!() }; assert_eq!(s.len(), 3); @@ -20,13 +24,13 @@ fn main() { assert_eq!(v, [1, 2, 3]); f(); - let mut b = Box::new("aaa".to_string()); + let mut b = "aaa".to_string(); let mut f = || { let deref!(ref mut s) = b else { unreachable!() }; - s.push_str("aa"); + s.make_ascii_uppercase(); }; f(); - assert_eq!(b.len(), 5); + assert_eq!(b, "AAA"); let mut v = vec![1, 2, 3]; let mut f = || { @@ -45,4 +49,20 @@ fn main() { }; f(); assert_eq!(v, [1, 2, 4]); + + let b = Box::new(NoCopy); + let f = || { + // this should move out of the box rather than borrow. + let deref!(x) = b else { unreachable!() }; + drop::<NoCopy>(x); + }; + f(); + + let b = Box::new((NoCopy,)); + let f = || { + // this should move out of the box rather than borrow. + let (x,) = b else { unreachable!() }; + drop::<NoCopy>(x); + }; + f(); } diff --git a/tests/ui/pattern/deref-patterns/deref-box.rs b/tests/ui/pattern/deref-patterns/deref-box.rs new file mode 100644 index 00000000000..2d0a8d01972 --- /dev/null +++ b/tests/ui/pattern/deref-patterns/deref-box.rs @@ -0,0 +1,37 @@ +//@ run-pass +//! Deref patterns on boxes are lowered using built-in derefs, rather than generic `Deref::deref` +//! and `DerefMut::deref_mut`. Test that they work as expected. + +#![feature(deref_patterns)] +#![expect(incomplete_features)] + +fn unbox_1<T>(b: Box<T>) -> T { + let deref!(x) = b else { unreachable!() }; + x +} + +fn unbox_2<T>(b: Box<(T,)>) -> T { + let (x,) = b else { unreachable!() }; + x +} + +fn unbox_separately<T>(b: Box<(T, T)>) -> (T, T) { + let (x, _) = b else { unreachable!() }; + let (_, y) = b else { unreachable!() }; + (x, y) +} + +fn main() { + // test that deref patterns can move out of boxes + let b1 = Box::new(0); + let b2 = Box::new((0,)); + assert_eq!(unbox_1(b1), unbox_2(b2)); + let b3 = Box::new((1, 2)); + assert_eq!(unbox_separately(b3), (1, 2)); + + // test that borrowing from a box also works + let mut b = "hi".to_owned().into_boxed_str(); + let deref!(ref mut s) = b else { unreachable!() }; + s.make_ascii_uppercase(); + assert_eq!(&*b, "HI"); +} diff --git a/tests/ui/pattern/deref-patterns/fake_borrows.rs b/tests/ui/pattern/deref-patterns/fake_borrows.rs index bf614d7d66f..fba2873fd02 100644 --- a/tests/ui/pattern/deref-patterns/fake_borrows.rs +++ b/tests/ui/pattern/deref-patterns/fake_borrows.rs @@ -3,6 +3,23 @@ #[rustfmt::skip] fn main() { + let mut v = vec![false]; + match v { + deref!([true]) => {} + _ if { v[0] = true; false } => {} + //~^ ERROR cannot borrow `v` as mutable because it is also borrowed as immutable + deref!([false]) => {} + _ => {}, + } + match v { + [true] => {} + _ if { v[0] = true; false } => {} + //~^ ERROR cannot borrow `v` as mutable because it is also borrowed as immutable + [false] => {} + _ => {}, + } + + // deref patterns on boxes are lowered specially; test them separately. let mut b = Box::new(false); match b { deref!(true) => {} diff --git a/tests/ui/pattern/deref-patterns/fake_borrows.stderr b/tests/ui/pattern/deref-patterns/fake_borrows.stderr index 8c060236d0d..7dc3001739e 100644 --- a/tests/ui/pattern/deref-patterns/fake_borrows.stderr +++ b/tests/ui/pattern/deref-patterns/fake_borrows.stderr @@ -1,6 +1,28 @@ -error[E0510]: cannot assign `*b` in match guard +error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable --> $DIR/fake_borrows.rs:9:16 | +LL | match v { + | - immutable borrow occurs here +LL | deref!([true]) => {} +LL | _ if { v[0] = true; false } => {} + | ^ - immutable borrow later used here + | | + | mutable borrow occurs here + +error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable + --> $DIR/fake_borrows.rs:16:16 + | +LL | match v { + | - immutable borrow occurs here +LL | [true] => {} +LL | _ if { v[0] = true; false } => {} + | ^ - immutable borrow later used here + | | + | mutable borrow occurs here + +error[E0510]: cannot assign `*b` in match guard + --> $DIR/fake_borrows.rs:26:16 + | LL | match b { | - value is immutable in match guard LL | deref!(true) => {} @@ -8,7 +30,7 @@ LL | _ if { *b = true; false } => {} | ^^^^^^^^^ cannot assign error[E0510]: cannot assign `*b` in match guard - --> $DIR/fake_borrows.rs:16:16 + --> $DIR/fake_borrows.rs:33:16 | LL | match b { | - value is immutable in match guard @@ -16,6 +38,7 @@ LL | true => {} LL | _ if { *b = true; false } => {} | ^^^^^^^^^ cannot assign -error: aborting due to 2 previous errors +error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0510`. +Some errors have detailed explanations: E0502, E0510. +For more information about an error, try `rustc --explain E0502`. diff --git a/tests/ui/pattern/deref-patterns/implicit-cow-deref.rs b/tests/ui/pattern/deref-patterns/implicit-cow-deref.rs index a9b8de86010..04c83d4c33f 100644 --- a/tests/ui/pattern/deref-patterns/implicit-cow-deref.rs +++ b/tests/ui/pattern/deref-patterns/implicit-cow-deref.rs @@ -4,6 +4,7 @@ #![allow(incomplete_features)] use std::borrow::Cow; +use std::rc::Rc; fn main() { let cow: Cow<'static, [u8]> = Cow::Borrowed(&[1, 2, 3]); @@ -18,7 +19,7 @@ fn main() { Cow::Owned(_) => unreachable!(), } - match Box::new(&cow) { + match Rc::new(&cow) { Cow::Borrowed { 0: _ } => {} Cow::Owned { 0: _ } => unreachable!(), _ => unreachable!(), @@ -37,7 +38,7 @@ fn main() { Cow::Owned(_) => {} } - match Box::new(&cow_of_cow) { + match Rc::new(&cow_of_cow) { Cow::Borrowed { 0: _ } => unreachable!(), Cow::Owned { 0: _ } => {} _ => unreachable!(), diff --git a/tests/ui/pattern/deref-patterns/needs-gate.rs b/tests/ui/pattern/deref-patterns/needs-gate.rs index 2d5ec45217f..7944744ee83 100644 --- a/tests/ui/pattern/deref-patterns/needs-gate.rs +++ b/tests/ui/pattern/deref-patterns/needs-gate.rs @@ -12,4 +12,21 @@ fn main() { //~^ ERROR: mismatched types _ => {} } + + // `deref_patterns` allows string and byte string literals to have non-ref types. + match *"test" { + "test" => {} + //~^ ERROR: mismatched types + _ => {} + } + match *b"test" { + b"test" => {} + //~^ ERROR: mismatched types + _ => {} + } + match *(b"test" as &[u8]) { + b"test" => {} + //~^ ERROR: mismatched types + _ => {} + } } diff --git a/tests/ui/pattern/deref-patterns/needs-gate.stderr b/tests/ui/pattern/deref-patterns/needs-gate.stderr index 8687b5dc977..e886ca98055 100644 --- a/tests/ui/pattern/deref-patterns/needs-gate.stderr +++ b/tests/ui/pattern/deref-patterns/needs-gate.stderr @@ -23,7 +23,31 @@ help: consider dereferencing to access the inner value using the Deref trait LL | match *Box::new(0) { | + -error: aborting due to 2 previous errors +error[E0308]: mismatched types + --> $DIR/needs-gate.rs:18:9 + | +LL | match *"test" { + | ------- this expression has type `str` +LL | "test" => {} + | ^^^^^^ expected `str`, found `&str` + +error[E0308]: mismatched types + --> $DIR/needs-gate.rs:23:9 + | +LL | match *b"test" { + | -------- this expression has type `[u8; 4]` +LL | b"test" => {} + | ^^^^^^^ expected `[u8; 4]`, found `&[u8; 4]` + +error[E0308]: mismatched types + --> $DIR/needs-gate.rs:28:9 + | +LL | match *(b"test" as &[u8]) { + | ------------------- this expression has type `[u8]` +LL | b"test" => {} + | ^^^^^^^ expected `[u8]`, found `&[u8; 4]` + +error: aborting due to 5 previous errors Some errors have detailed explanations: E0308, E0658. For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/pattern/deref-patterns/strings.rs b/tests/ui/pattern/deref-patterns/strings.rs new file mode 100644 index 00000000000..536e943b3f6 --- /dev/null +++ b/tests/ui/pattern/deref-patterns/strings.rs @@ -0,0 +1,66 @@ +//@ run-pass +//! Test deref patterns using string and bytestring literals. + +#![feature(deref_patterns)] +#![allow(incomplete_features)] + +fn main() { + for (test_in, test_expect) in [("zero", 0), ("one", 1), ("two", 2)] { + // Test string literal patterns having type `str`. + let test_actual = match *test_in { + "zero" => 0, + "one" => 1, + _ => 2, + }; + assert_eq!(test_actual, test_expect); + + // Test string literals in explicit `deref!(_)` patterns. + let test_actual = match test_in.to_string() { + deref!("zero") => 0, + deref!("one") => 1, + _ => 2, + }; + assert_eq!(test_actual, test_expect); + } + + // Test that we can still mutate in the match arm after using a literal to test equality: + let mut test = "test".to_string(); + if let deref!(s @ "test") = &mut test { + s.make_ascii_uppercase(); + } + assert_eq!(test, "TEST"); + + for (test_in, test_expect) in [(b"0", 0), (b"1", 1), (b"2", 2)] { + // Test byte string literal patterns having type `[u8; N]` + let test_actual = match *test_in { + b"0" => 0, + b"1" => 1, + _ => 2, + }; + assert_eq!(test_actual, test_expect); + + // Test byte string literal patterns having type `[u8]` + let test_actual = match *(test_in as &[u8]) { + b"0" => 0, + b"1" => 1, + _ => 2, + }; + assert_eq!(test_actual, test_expect); + + // Test byte string literals used as arrays in explicit `deref!(_)` patterns. + let test_actual = match Box::new(*test_in) { + deref!(b"0") => 0, + deref!(b"1") => 1, + _ => 2, + }; + assert_eq!(test_actual, test_expect); + + // Test byte string literals used as slices in explicit `deref!(_)` patterns. + let test_actual = match test_in.to_vec() { + deref!(b"0") => 0, + deref!(b"1") => 1, + _ => 2, + }; + assert_eq!(test_actual, test_expect); + } +} diff --git a/tests/ui/pattern/deref-patterns/typeck_fail.rs b/tests/ui/pattern/deref-patterns/typeck_fail.rs index 4b9ad7d25f0..52d84f7a34d 100644 --- a/tests/ui/pattern/deref-patterns/typeck_fail.rs +++ b/tests/ui/pattern/deref-patterns/typeck_fail.rs @@ -2,18 +2,14 @@ #![allow(incomplete_features)] fn main() { - // FIXME(deref_patterns): fails to typecheck because `"foo"` has type &str but deref creates a - // place of type `str`. + // FIXME(deref_patterns): fails to typecheck because string literal patterns don't peel + // references from the scrutinee. match "foo".to_string() { - deref!("foo") => {} - //~^ ERROR: mismatched types "foo" => {} //~^ ERROR: mismatched types _ => {} } match &"foo".to_string() { - deref!("foo") => {} - //~^ ERROR: mismatched types "foo" => {} //~^ ERROR: mismatched types _ => {} diff --git a/tests/ui/pattern/deref-patterns/typeck_fail.stderr b/tests/ui/pattern/deref-patterns/typeck_fail.stderr index 3e2f3561882..e87528c1c51 100644 --- a/tests/ui/pattern/deref-patterns/typeck_fail.stderr +++ b/tests/ui/pattern/deref-patterns/typeck_fail.stderr @@ -1,34 +1,16 @@ error[E0308]: mismatched types - --> $DIR/typeck_fail.rs:8:16 + --> $DIR/typeck_fail.rs:8:9 | LL | match "foo".to_string() { | ----------------- this expression has type `String` -LL | deref!("foo") => {} - | ^^^^^ expected `str`, found `&str` - -error[E0308]: mismatched types - --> $DIR/typeck_fail.rs:10:9 - | -LL | match "foo".to_string() { - | ----------------- this expression has type `String` -... LL | "foo" => {} | ^^^^^ expected `String`, found `&str` error[E0308]: mismatched types - --> $DIR/typeck_fail.rs:15:16 - | -LL | match &"foo".to_string() { - | ------------------ this expression has type `&String` -LL | deref!("foo") => {} - | ^^^^^ expected `str`, found `&str` - -error[E0308]: mismatched types - --> $DIR/typeck_fail.rs:17:9 + --> $DIR/typeck_fail.rs:13:9 | LL | match &"foo".to_string() { | ------------------ this expression has type `&String` -... LL | "foo" => {} | ^^^^^ expected `&String`, found `&str` | @@ -36,7 +18,7 @@ LL | "foo" => {} found reference `&'static str` error[E0308]: mismatched types - --> $DIR/typeck_fail.rs:24:9 + --> $DIR/typeck_fail.rs:20:9 | LL | match Some(0) { | ------- this expression has type `Option<{integer}>` @@ -46,6 +28,6 @@ LL | Ok(0) => {} = note: expected enum `Option<{integer}>` found enum `Result<_, _>` -error: aborting due to 5 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/pattern/deref-patterns/unsatisfied-bounds.rs b/tests/ui/pattern/deref-patterns/unsatisfied-bounds.rs index 00064b2320c..9e95f4ec409 100644 --- a/tests/ui/pattern/deref-patterns/unsatisfied-bounds.rs +++ b/tests/ui/pattern/deref-patterns/unsatisfied-bounds.rs @@ -15,7 +15,7 @@ fn main() { // FIXME(deref_patterns): there should be a special diagnostic for missing `DerefPure`. match MyPointer { () => {} - //~^ the trait bound `MyPointer: DerefPure` is not satisfied + //~^ ERROR the trait bound `MyPointer: DerefPure` is not satisfied _ => {} } } diff --git a/tests/ui/pattern/pattern-error-continue.rs b/tests/ui/pattern/pattern-error-continue.rs index bed94943923..664d4e80ef5 100644 --- a/tests/ui/pattern/pattern-error-continue.rs +++ b/tests/ui/pattern/pattern-error-continue.rs @@ -1,5 +1,7 @@ // Test that certain pattern-match type errors are non-fatal +//@ dont-require-annotations: NOTE + enum A { B(isize, isize), C(isize, isize, isize), @@ -21,13 +23,13 @@ fn main() { match 'c' { S { .. } => (), //~^ ERROR mismatched types - //~| expected `char`, found `S` + //~| NOTE expected `char`, found `S` _ => () } f(true); //~^ ERROR mismatched types - //~| expected `char`, found `bool` + //~| NOTE expected `char`, found `bool` match () { E::V => {} //~ ERROR failed to resolve: use of undeclared type `E` diff --git a/tests/ui/pattern/pattern-error-continue.stderr b/tests/ui/pattern/pattern-error-continue.stderr index bb5582dd873..a9ac96e3eaf 100644 --- a/tests/ui/pattern/pattern-error-continue.stderr +++ b/tests/ui/pattern/pattern-error-continue.stderr @@ -1,5 +1,5 @@ error[E0532]: expected tuple struct or tuple variant, found unit variant `A::D` - --> $DIR/pattern-error-continue.rs:18:9 + --> $DIR/pattern-error-continue.rs:20:9 | LL | B(isize, isize), | --------------- similarly named tuple variant `B` defined here @@ -22,7 +22,7 @@ LL + A::B(_) => (), | error[E0023]: this pattern has 3 fields, but the corresponding tuple variant has 2 fields - --> $DIR/pattern-error-continue.rs:17:14 + --> $DIR/pattern-error-continue.rs:19:14 | LL | B(isize, isize), | ----- ----- tuple variant has 2 fields @@ -31,7 +31,7 @@ LL | A::B(_, _, _) => (), | ^ ^ ^ expected 2 fields, found 3 error[E0308]: mismatched types - --> $DIR/pattern-error-continue.rs:22:9 + --> $DIR/pattern-error-continue.rs:24:9 | LL | match 'c' { | --- this expression has type `char` @@ -39,7 +39,7 @@ LL | S { .. } => (), | ^^^^^^^^ expected `char`, found `S` error[E0308]: mismatched types - --> $DIR/pattern-error-continue.rs:28:7 + --> $DIR/pattern-error-continue.rs:30:7 | LL | f(true); | - ^^^^ expected `char`, found `bool` @@ -47,13 +47,13 @@ LL | f(true); | arguments to this function are incorrect | note: function defined here - --> $DIR/pattern-error-continue.rs:13:4 + --> $DIR/pattern-error-continue.rs:15:4 | LL | fn f(_c: char) {} | ^ -------- error[E0433]: failed to resolve: use of undeclared type `E` - --> $DIR/pattern-error-continue.rs:33:9 + --> $DIR/pattern-error-continue.rs:35:9 | LL | E::V => {} | ^ diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.classic2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.classic2021.stderr index 355a8af6760..4d795d5c385 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.classic2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.classic2021.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of a shared reference - --> $DIR/borrowck-errors.rs:31:29 + --> $DIR/borrowck-errors.rs:33:29 | LL | if let Some(&Some(x)) = Some(&Some(&mut 0)) { | - ^^^^^^^^^^^^^^^^^^^ @@ -14,19 +14,19 @@ LL + if let Some(Some(x)) = Some(&Some(&mut 0)) { | error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-errors.rs:36:10 + --> $DIR/borrowck-errors.rs:38:10 | LL | let &ref mut x = &0; | ^^^^^^^^^ cannot borrow as mutable error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-errors.rs:41:23 + --> $DIR/borrowck-errors.rs:43:23 | LL | if let &Some(Some(x)) = &Some(&mut Some(0)) { | ^ cannot borrow as mutable error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-errors.rs:46:11 + --> $DIR/borrowck-errors.rs:48:11 | LL | let &[x] = &&mut [0]; | ^ cannot borrow as mutable diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.classic2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.classic2024.stderr index d40bdb9111b..6cc6c58bf7a 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.classic2024.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.classic2024.stderr @@ -1,5 +1,5 @@ error[E0508]: cannot move out of type `[&mut i32; 1]`, a non-copy array - --> $DIR/borrowck-errors.rs:15:16 + --> $DIR/borrowck-errors.rs:17:16 | LL | let [&x] = &[&mut 0]; | - ^^^^^^^^^ cannot move out of here @@ -13,7 +13,7 @@ LL | let [&ref x] = &[&mut 0]; | +++ error[E0508]: cannot move out of type `[&mut i32; 1]`, a non-copy array - --> $DIR/borrowck-errors.rs:22:16 + --> $DIR/borrowck-errors.rs:24:16 | LL | let [&x] = &mut [&mut 0]; | - ^^^^^^^^^^^^^ cannot move out of here @@ -27,7 +27,7 @@ LL | let [&ref x] = &mut [&mut 0]; | +++ error[E0507]: cannot move out of a shared reference - --> $DIR/borrowck-errors.rs:31:29 + --> $DIR/borrowck-errors.rs:33:29 | LL | if let Some(&Some(x)) = Some(&Some(&mut 0)) { | - ^^^^^^^^^^^^^^^^^^^ @@ -42,25 +42,25 @@ LL + if let Some(Some(x)) = Some(&Some(&mut 0)) { | error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-errors.rs:36:10 + --> $DIR/borrowck-errors.rs:38:10 | LL | let &ref mut x = &0; | ^^^^^^^^^ cannot borrow as mutable error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-errors.rs:41:23 + --> $DIR/borrowck-errors.rs:43:23 | LL | if let &Some(Some(x)) = &Some(&mut Some(0)) { | ^ cannot borrow as mutable error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-errors.rs:46:11 + --> $DIR/borrowck-errors.rs:48:11 | LL | let &[x] = &&mut [0]; | ^ cannot borrow as mutable error[E0508]: cannot move out of type `[&mut i32; 1]`, a non-copy array - --> $DIR/borrowck-errors.rs:50:20 + --> $DIR/borrowck-errors.rs:52:20 | LL | let [&mut x] = &mut [&mut 0]; | - ^^^^^^^^^^^^^ cannot move out of here diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.rs b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.rs index c171dcf0ca6..15575510e16 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.rs +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.rs @@ -4,6 +4,8 @@ //@[structural2021] edition: 2021 //@[classic2024] edition: 2024 //@[structural2024] edition: 2024 +//@ dont-require-annotations: NOTE + //! Tests for pattern errors not handled by the pattern typing rules, but by borrowck. #![allow(incomplete_features)] #![cfg_attr(any(classic2021, classic2024), feature(ref_pat_eat_one_layer_2024))] @@ -14,14 +16,14 @@ fn errors_caught_in_hir_typeck_on_stable() { let [&x] = &[&mut 0]; //[stable2021]~^ ERROR mismatched types - //[stable2021]~| types differ in mutability + //[stable2021]~| NOTE types differ in mutability //[classic2024]~^^^ ERROR: cannot move out of type #[cfg(any(classic2021, structural2021))] let _: u32 = x; #[cfg(structural2024)] let _: &u32 = x; let [&x] = &mut [&mut 0]; //[stable2021]~^ ERROR mismatched types - //[stable2021]~| types differ in mutability + //[stable2021]~| NOTE types differ in mutability //[classic2024]~^^^ ERROR: cannot move out of type #[cfg(any(classic2021, structural2021))] let _: u32 = x; #[cfg(structural2024)] let _: &u32 = x; diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.stable2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.stable2021.stderr index edcf9f30357..036b3dbeae3 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.stable2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.stable2021.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/borrowck-errors.rs:15:10 + --> $DIR/borrowck-errors.rs:17:10 | LL | let [&x] = &[&mut 0]; | ^^ --------- this expression has type `&[&mut {integer}; 1]` @@ -15,7 +15,7 @@ LL + let [x] = &[&mut 0]; | error[E0308]: mismatched types - --> $DIR/borrowck-errors.rs:22:10 + --> $DIR/borrowck-errors.rs:24:10 | LL | let [&x] = &mut [&mut 0]; | ^^ ------------- this expression has type `&mut [&mut {integer}; 1]` @@ -31,7 +31,7 @@ LL + let [x] = &mut [&mut 0]; | error[E0507]: cannot move out of a shared reference - --> $DIR/borrowck-errors.rs:31:29 + --> $DIR/borrowck-errors.rs:33:29 | LL | if let Some(&Some(x)) = Some(&Some(&mut 0)) { | - ^^^^^^^^^^^^^^^^^^^ @@ -46,19 +46,19 @@ LL + if let Some(Some(x)) = Some(&Some(&mut 0)) { | error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-errors.rs:36:10 + --> $DIR/borrowck-errors.rs:38:10 | LL | let &ref mut x = &0; | ^^^^^^^^^ cannot borrow as mutable error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-errors.rs:41:23 + --> $DIR/borrowck-errors.rs:43:23 | LL | if let &Some(Some(x)) = &Some(&mut Some(0)) { | ^ cannot borrow as mutable error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-errors.rs:46:11 + --> $DIR/borrowck-errors.rs:48:11 | LL | let &[x] = &&mut [0]; | ^ cannot borrow as mutable diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.structural2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.structural2021.stderr index 208f6c8bbed..e1764fa1d55 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.structural2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.structural2021.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of a shared reference - --> $DIR/borrowck-errors.rs:31:29 + --> $DIR/borrowck-errors.rs:33:29 | LL | if let Some(&Some(x)) = Some(&Some(&mut 0)) { | - ^^^^^^^^^^^^^^^^^^^ @@ -14,7 +14,7 @@ LL + if let Some(Some(x)) = Some(&Some(&mut 0)) { | error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-errors.rs:36:10 + --> $DIR/borrowck-errors.rs:38:10 | LL | let &ref mut x = &0; | ^^^^^^^^^ cannot borrow as mutable diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.structural2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.structural2024.stderr index 208f6c8bbed..e1764fa1d55 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.structural2024.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.structural2024.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of a shared reference - --> $DIR/borrowck-errors.rs:31:29 + --> $DIR/borrowck-errors.rs:33:29 | LL | if let Some(&Some(x)) = Some(&Some(&mut 0)) { | - ^^^^^^^^^^^^^^^^^^^ @@ -14,7 +14,7 @@ LL + if let Some(Some(x)) = Some(&Some(&mut 0)) { | error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-errors.rs:36:10 + --> $DIR/borrowck-errors.rs:38:10 | LL | let &ref mut x = &0; | ^^^^^^^^^ cannot borrow as mutable diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mut-ref-mut.classic2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mut-ref-mut.classic2024.stderr index 6ddced3d168..97c74b5c448 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mut-ref-mut.classic2024.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mut-ref-mut.classic2024.stderr @@ -1,5 +1,5 @@ error[E0658]: binding cannot be both mutable and by-reference - --> $DIR/mut-ref-mut.rs:18:13 + --> $DIR/mut-ref-mut.rs:20:13 | LL | let Foo(mut a) = &Foo(0); | ^^^^ @@ -9,7 +9,7 @@ LL | let Foo(mut a) = &Foo(0); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: binding cannot be both mutable and by-reference - --> $DIR/mut-ref-mut.rs:23:13 + --> $DIR/mut-ref-mut.rs:25:13 | LL | let Foo(mut a) = &mut Foo(0); | ^^^^ @@ -19,7 +19,7 @@ LL | let Foo(mut a) = &mut Foo(0); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0308]: mismatched types - --> $DIR/mut-ref-mut.rs:28:10 + --> $DIR/mut-ref-mut.rs:30:10 | LL | let [&mut mut x] = &[&mut 0]; | ^^^^^ diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mut-ref-mut.rs b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mut-ref-mut.rs index 94691e77bd8..814c7d90c8c 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mut-ref-mut.rs +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mut-ref-mut.rs @@ -7,6 +7,8 @@ //@[stable2021] run-pass //@[classic2021] run-pass //@[structural2021] run-pass +//@ dont-require-annotations: NOTE + //! Test diagnostics for binding with `mut` when the default binding mode is by-ref. #![allow(incomplete_features, unused_assignments, unused_variables)] #![cfg_attr(any(classic2021, classic2024), feature(ref_pat_eat_one_layer_2024))] @@ -27,7 +29,7 @@ pub fn main() { let [&mut mut x] = &[&mut 0]; //[classic2024]~^ ERROR: mismatched types - //[classic2024]~| cannot match inherited `&` with `&mut` pattern + //[classic2024]~| NOTE cannot match inherited `&` with `&mut` pattern //[structural2024]~^^^ ERROR binding cannot be both mutable and by-reference #[cfg(any(stable2021, classic2021, structural2021))] { x = 0 } } diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mut-ref-mut.structural2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mut-ref-mut.structural2024.stderr index c0c0f966b68..a3e8f2af6e9 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mut-ref-mut.structural2024.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mut-ref-mut.structural2024.stderr @@ -1,5 +1,5 @@ error[E0658]: binding cannot be both mutable and by-reference - --> $DIR/mut-ref-mut.rs:18:13 + --> $DIR/mut-ref-mut.rs:20:13 | LL | let Foo(mut a) = &Foo(0); | ^^^^ @@ -9,7 +9,7 @@ LL | let Foo(mut a) = &Foo(0); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: binding cannot be both mutable and by-reference - --> $DIR/mut-ref-mut.rs:23:13 + --> $DIR/mut-ref-mut.rs:25:13 | LL | let Foo(mut a) = &mut Foo(0); | ^^^^ @@ -19,7 +19,7 @@ LL | let Foo(mut a) = &mut Foo(0); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: binding cannot be both mutable and by-reference - --> $DIR/mut-ref-mut.rs:28:15 + --> $DIR/mut-ref-mut.rs:30:15 | LL | let [&mut mut x] = &[&mut 0]; | ^^^^ diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.classic2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.classic2021.stderr index a856a0eaf2a..208873c1bab 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.classic2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.classic2021.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:20:27 + --> $DIR/pattern-errors.rs:22:27 | LL | if let Some(&mut Some(&x)) = &Some(&mut Some(0)) { | ^^ ------------------- this expression has type `&Option<&mut Option<{integer}>>` @@ -15,7 +15,7 @@ LL + if let Some(&mut Some(x)) = &Some(&mut Some(0)) { | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:33:17 + --> $DIR/pattern-errors.rs:35:17 | LL | if let Some(&mut Some(&_)) = &Some(&Some(0)) { | ^^^^^^^^^^^^^ --------------- this expression has type `&Option<&Option<{integer}>>` @@ -26,7 +26,7 @@ LL | if let Some(&mut Some(&_)) = &Some(&Some(0)) { found mutable reference `&mut _` error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:38:23 + --> $DIR/pattern-errors.rs:40:23 | LL | if let Some(&Some(&mut x)) = &Some(&mut Some(0)) { | ^^^^^^ ------------------- this expression has type `&Option<&mut Option<{integer}>>` @@ -36,7 +36,7 @@ LL | if let Some(&Some(&mut x)) = &Some(&mut Some(0)) { = note: expected type `{integer}` found mutable reference `&mut _` note: to declare a mutable binding use: `mut x` - --> $DIR/pattern-errors.rs:38:23 + --> $DIR/pattern-errors.rs:40:23 | LL | if let Some(&Some(&mut x)) = &Some(&mut Some(0)) { | ^^^^^^ @@ -47,7 +47,7 @@ LL + if let Some(&Some(x)) = &Some(&mut Some(0)) { | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:45:23 + --> $DIR/pattern-errors.rs:47:23 | LL | if let Some(&Some(&mut _)) = &mut Some(&Some(0)) { | ^^^^^^ ------------------- this expression has type `&mut Option<&Option<{integer}>>` @@ -58,7 +58,7 @@ LL | if let Some(&Some(&mut _)) = &mut Some(&Some(0)) { found mutable reference `&mut _` error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:56:17 + --> $DIR/pattern-errors.rs:58:17 | LL | if let Some(&mut Some(x)) = &Some(Some(0)) { | ^^^^^ @@ -71,7 +71,7 @@ LL + if let Some(&Some(x)) = &Some(Some(0)) { | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:114:11 + --> $DIR/pattern-errors.rs:116:11 | LL | let [&&mut x] = &[&mut 0]; | ^^^^^^ --------- this expression has type `&[&mut {integer}; 1]` @@ -87,7 +87,7 @@ LL + let [&x] = &[&mut 0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:121:11 + --> $DIR/pattern-errors.rs:123:11 | LL | let [&&mut x] = &mut [&mut 0]; | ^^^^^^ ------------- this expression has type `&mut [&mut {integer}; 1]` @@ -103,7 +103,7 @@ LL + let [&x] = &mut [&mut 0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:128:11 + --> $DIR/pattern-errors.rs:130:11 | LL | let [&&mut ref x] = &[&mut 0]; | ^^^^^^^^^^ --------- this expression has type `&[&mut {integer}; 1]` @@ -119,7 +119,7 @@ LL + let [&ref x] = &[&mut 0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:135:11 + --> $DIR/pattern-errors.rs:137:11 | LL | let [&&mut ref x] = &mut [&mut 0]; | ^^^^^^^^^^ ------------- this expression has type `&mut [&mut {integer}; 1]` @@ -135,7 +135,7 @@ LL + let [&ref x] = &mut [&mut 0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:142:11 + --> $DIR/pattern-errors.rs:144:11 | LL | let [&&mut mut x] = &[&mut 0]; | ^^^^^^^^^^ --------- this expression has type `&[&mut {integer}; 1]` @@ -151,7 +151,7 @@ LL + let [&mut x] = &[&mut 0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:149:11 + --> $DIR/pattern-errors.rs:151:11 | LL | let [&&mut mut x] = &mut [&mut 0]; | ^^^^^^^^^^ ------------- this expression has type `&mut [&mut {integer}; 1]` @@ -167,7 +167,7 @@ LL + let [&mut x] = &mut [&mut 0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:164:15 + --> $DIR/pattern-errors.rs:166:15 | LL | let [&mut &x] = &[&mut 0]; | ^^ --------- this expression has type `&[&mut {integer}; 1]` @@ -183,7 +183,7 @@ LL + let [&mut x] = &[&mut 0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:170:15 + --> $DIR/pattern-errors.rs:172:15 | LL | let [&mut &ref x] = &[&mut 0]; | ^^^^^^ --------- this expression has type `&[&mut {integer}; 1]` @@ -199,7 +199,7 @@ LL + let [&mut ref x] = &[&mut 0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:176:15 + --> $DIR/pattern-errors.rs:178:15 | LL | let [&mut &(mut x)] = &[&mut 0]; | ^^^^^^^^ --------- this expression has type `&[&mut {integer}; 1]` diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.classic2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.classic2024.stderr index 90510d23e66..4f778e04ece 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.classic2024.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.classic2024.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:14:17 + --> $DIR/pattern-errors.rs:16:17 | LL | if let Some(&mut x) = &Some(&mut 0) { | ^^^^^ @@ -12,7 +12,7 @@ LL + if let Some(&x) = &Some(&mut 0) { | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:20:17 + --> $DIR/pattern-errors.rs:22:17 | LL | if let Some(&mut Some(&x)) = &Some(&mut Some(0)) { | ^^^^^ @@ -25,7 +25,7 @@ LL + if let Some(&Some(&x)) = &Some(&mut Some(0)) { | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:26:22 + --> $DIR/pattern-errors.rs:28:22 | LL | if let Some(Some(&mut x)) = &Some(Some(&mut 0)) { | ^^^^^ @@ -38,7 +38,7 @@ LL + if let Some(Some(&x)) = &Some(Some(&mut 0)) { | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:33:17 + --> $DIR/pattern-errors.rs:35:17 | LL | if let Some(&mut Some(&_)) = &Some(&Some(0)) { | ^^^^^ @@ -51,7 +51,7 @@ LL + if let Some(&Some(&_)) = &Some(&Some(0)) { | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:45:23 + --> $DIR/pattern-errors.rs:47:23 | LL | if let Some(&Some(&mut _)) = &mut Some(&Some(0)) { | ^^^^^ @@ -64,7 +64,7 @@ LL + if let Some(&Some(&_)) = &mut Some(&Some(0)) { | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:56:17 + --> $DIR/pattern-errors.rs:58:17 | LL | if let Some(&mut Some(x)) = &Some(Some(0)) { | ^^^^^ @@ -77,7 +77,7 @@ LL + if let Some(&Some(x)) = &Some(Some(0)) { | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:158:10 + --> $DIR/pattern-errors.rs:160:10 | LL | let [&mut x] = &[&mut 0]; | ^^^^^ @@ -90,7 +90,7 @@ LL + let [&x] = &[&mut 0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:164:10 + --> $DIR/pattern-errors.rs:166:10 | LL | let [&mut &x] = &[&mut 0]; | ^^^^^ @@ -103,7 +103,7 @@ LL + let [&&x] = &[&mut 0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:170:10 + --> $DIR/pattern-errors.rs:172:10 | LL | let [&mut &ref x] = &[&mut 0]; | ^^^^^ @@ -116,7 +116,7 @@ LL + let [&&ref x] = &[&mut 0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:176:10 + --> $DIR/pattern-errors.rs:178:10 | LL | let [&mut &(mut x)] = &[&mut 0]; | ^^^^^ diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.rs b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.rs index 5e677445644..70a5bde5e89 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.rs +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.rs @@ -4,6 +4,8 @@ //@[structural2021] edition: 2021 //@[classic2024] edition: 2024 //@[structural2024] edition: 2024 +//@ dont-require-annotations: NOTE + //! Test cases for poorly-typed patterns in edition 2024 which are caught by HIR typeck. These must //! be separate from cases caught by MIR borrowck or the latter errors may not be emitted. #![allow(incomplete_features)] @@ -13,88 +15,88 @@ pub fn main() { if let Some(&mut x) = &Some(&mut 0) { //[classic2024]~^ ERROR: mismatched types - //[classic2024]~| cannot match inherited `&` with `&mut` pattern + //[classic2024]~| NOTE cannot match inherited `&` with `&mut` pattern #[cfg(any(stable2021, classic2021, structural2021))] let _: u32 = x; #[cfg(structural2024)] let _: &u32 = x; } if let Some(&mut Some(&x)) = &Some(&mut Some(0)) { //[stable2021,classic2021,structural2021,classic2024]~^ ERROR: mismatched types - //[stable2021,classic2021,structural2021]~| expected integer, found `&_` - //[classic2024]~| cannot match inherited `&` with `&mut` pattern + //[stable2021,classic2021,structural2021]~| NOTE expected integer, found `&_` + //[classic2024]~| NOTE cannot match inherited `&` with `&mut` pattern #[cfg(structural2024)] let _: u32 = x; } if let Some(Some(&mut x)) = &Some(Some(&mut 0)) { //[classic2024]~^ ERROR: mismatched types - //[classic2024]~| cannot match inherited `&` with `&mut` pattern + //[classic2024]~| NOTE cannot match inherited `&` with `&mut` pattern #[cfg(any(stable2021, classic2021, structural2021))] let _: u32 = x; #[cfg(structural2024)] let _: &u32 = x; } if let Some(&mut Some(&_)) = &Some(&Some(0)) { //~^ ERROR: mismatched types - //[stable2021,classic2021,structural2021]~| types differ in mutability - //[classic2024,structural2024]~| cannot match inherited `&` with `&mut` pattern + //[stable2021,classic2021,structural2021]~| NOTE types differ in mutability + //[classic2024,structural2024]~| NOTE cannot match inherited `&` with `&mut` pattern } if let Some(&Some(&mut x)) = &Some(&mut Some(0)) { //[stable2021,classic2021,structural2021,structural2024]~^ ERROR: mismatched types - //[stable2021]~| types differ in mutability - //[classic2021,structural2021]~| expected integer, found `&mut _` - //[structural2024]~| cannot match inherited `&` with `&mut` pattern + //[stable2021]~| NOTE types differ in mutability + //[classic2021,structural2021]~| NOTE expected integer, found `&mut _` + //[structural2024]~| NOTE cannot match inherited `&` with `&mut` pattern #[cfg(classic2024)] let _: u32 = x; } if let Some(&Some(&mut _)) = &mut Some(&Some(0)) { //~^ ERROR: mismatched types - //[stable2021,classic2021,structural2021]~| expected integer, found `&mut _` - //[classic2024,structural2024]~| cannot match inherited `&` with `&mut` pattern + //[stable2021,classic2021,structural2021]~| NOTE expected integer, found `&mut _` + //[classic2024,structural2024]~| NOTE cannot match inherited `&` with `&mut` pattern } if let Some(&Some(Some(&mut x))) = &Some(Some(&mut Some(0))) { //[stable2021,structural2021,structural2024]~^ ERROR: mismatched types - //[stable2021]~| expected `Option<&mut Option<{integer}>>`, found `&_` - //[structural2021,structural2024]~| cannot match inherited `&` with `&mut` pattern + //[stable2021]~| NOTE expected `Option<&mut Option<{integer}>>`, found `&_` + //[structural2021,structural2024]~| NOTE cannot match inherited `&` with `&mut` pattern #[cfg(any(classic2021, classic2024))] let _: u32 = x; } if let Some(&mut Some(x)) = &Some(Some(0)) { //~^ ERROR: mismatched types - //[stable2021]~| expected `Option<{integer}>`, found `&mut _` - //[classic2021,structural2021,classic2024,structural2024]~| cannot match inherited `&` with `&mut` pattern + //[stable2021]~| NOTE expected `Option<{integer}>`, found `&mut _` + //[classic2021,structural2021,classic2024,structural2024]~| NOTE cannot match inherited `&` with `&mut` pattern } } fn structural_errors_0() { let &[&mut x] = &&mut [0]; //[stable2021,structural2021,structural2024]~^ ERROR: mismatched types - //[stable2021]~| expected integer, found `&mut _` - //[structural2021,structural2024]~| cannot match inherited `&` with `&mut` pattern + //[stable2021]~| NOTE expected integer, found `&mut _` + //[structural2021,structural2024]~| NOTE cannot match inherited `&` with `&mut` pattern #[cfg(any(classic2021, classic2024))] let _: u32 = x; let &[&mut x] = &mut &mut [0]; //[stable2021,structural2021,structural2024]~^ ERROR: mismatched types - //[stable2021]~| types differ in mutability - //[structural2021,structural2024]~| cannot match inherited `&` with `&mut` pattern + //[stable2021]~| NOTE types differ in mutability + //[structural2021,structural2024]~| NOTE cannot match inherited `&` with `&mut` pattern #[cfg(any(classic2021, classic2024))] let _: u32 = x; let &[&mut ref x] = &&mut [0]; //[stable2021,structural2021,structural2024]~^ ERROR: mismatched types - //[stable2021]~| expected integer, found `&mut _` - //[structural2021,structural2024]~| cannot match inherited `&` with `&mut` pattern + //[stable2021]~| NOTE expected integer, found `&mut _` + //[structural2021,structural2024]~| NOTE cannot match inherited `&` with `&mut` pattern #[cfg(any(classic2021, classic2024))] let _: &u32 = x; let &[&mut ref x] = &mut &mut [0]; //[stable2021,structural2021,structural2024]~^ ERROR: mismatched types - //[stable2021]~| types differ in mutability - //[structural2021,structural2024]~| cannot match inherited `&` with `&mut` pattern + //[stable2021]~| NOTE types differ in mutability + //[structural2021,structural2024]~| NOTE cannot match inherited `&` with `&mut` pattern #[cfg(any(classic2021, classic2024))] let _: &u32 = x; let &[&mut mut x] = &&mut [0]; //[stable2021,structural2021,structural2024]~^ ERROR: mismatched types - //[stable2021]~| expected integer, found `&mut _` - //[structural2021,structural2024]~| cannot match inherited `&` with `&mut` pattern + //[stable2021]~| NOTE expected integer, found `&mut _` + //[structural2021,structural2024]~| NOTE cannot match inherited `&` with `&mut` pattern #[cfg(any(classic2021, classic2024))] let _: u32 = x; let &[&mut mut x] = &mut &mut [0]; //[stable2021,structural2021,structural2024]~^ ERROR: mismatched types - //[stable2021]~| types differ in mutability - //[structural2021,structural2024]~| cannot match inherited `&` with `&mut` pattern + //[stable2021]~| NOTE types differ in mutability + //[structural2021,structural2024]~| NOTE cannot match inherited `&` with `&mut` pattern #[cfg(any(classic2021, classic2024))] let _: u32 = x; } @@ -113,69 +115,69 @@ fn structural_errors_1() { fn structural_errors_2() { let [&&mut x] = &[&mut 0]; //[stable2021,classic2021,structural2021,structural2024]~^ ERROR: mismatched types - //[stable2021]~| types differ in mutability - //[classic2021,structural2021] expected integer, found `&mut _` - //[structural2024]~| cannot match inherited `&` with `&mut` pattern + //[stable2021]~| NOTE types differ in mutability + //[classic2021,structural2021] NOTE expected integer, found `&mut _` + //[structural2024]~| NOTE cannot match inherited `&` with `&mut` pattern #[cfg(classic2024)] let _: u32 = x; let [&&mut x] = &mut [&mut 0]; //[stable2021,classic2021,structural2021,structural2024]~^ ERROR: mismatched types - //[stable2021]~| types differ in mutability - //[classic2021,structural2021] expected integer, found `&mut _` - //[structural2024]~| cannot match inherited `&` with `&mut` pattern + //[stable2021]~| NOTE types differ in mutability + //[classic2021,structural2021] NOTE expected integer, found `&mut _` + //[structural2024]~| NOTE cannot match inherited `&` with `&mut` pattern #[cfg(classic2024)] let _: u32 = x; let [&&mut ref x] = &[&mut 0]; //[stable2021,classic2021,structural2021,structural2024]~^ ERROR: mismatched types - //[stable2021]~| types differ in mutability - //[classic2021,structural2021] expected integer, found `&mut _` - //[structural2024]~| cannot match inherited `&` with `&mut` pattern + //[stable2021]~| NOTE types differ in mutability + //[classic2021,structural2021] NOTE expected integer, found `&mut _` + //[structural2024]~| NOTE cannot match inherited `&` with `&mut` pattern #[cfg(classic2024)] let _: &u32 = x; let [&&mut ref x] = &mut [&mut 0]; //[stable2021,classic2021,structural2021,structural2024]~^ ERROR: mismatched types - //[stable2021]~| types differ in mutability - //[classic2021,structural2021] expected integer, found `&mut _` - //[structural2024]~| cannot match inherited `&` with `&mut` pattern + //[stable2021]~| NOTE types differ in mutability + //[classic2021,structural2021] NOTE expected integer, found `&mut _` + //[structural2024]~| NOTE cannot match inherited `&` with `&mut` pattern #[cfg(classic2024)] let _: &u32 = x; let [&&mut mut x] = &[&mut 0]; //[stable2021,classic2021,structural2021,structural2024]~^ ERROR: mismatched types - //[stable2021]~| types differ in mutability - //[classic2021,structural2021] expected integer, found `&mut _` - //[structural2024]~| cannot match inherited `&` with `&mut` pattern + //[stable2021]~| NOTE types differ in mutability + //[classic2021,structural2021] NOTE expected integer, found `&mut _` + //[structural2024]~| NOTE cannot match inherited `&` with `&mut` pattern #[cfg(classic2024)] let _: u32 = x; let [&&mut mut x] = &mut [&mut 0]; //[stable2021,classic2021,structural2021,structural2024]~^ ERROR: mismatched types - //[stable2021]~| types differ in mutability - //[classic2021,structural2021] expected integer, found `&mut _` - //[structural2024]~| cannot match inherited `&` with `&mut` pattern + //[stable2021]~| NOTE types differ in mutability + //[classic2021,structural2021] NOTE expected integer, found `&mut _` + //[structural2024]~| NOTE cannot match inherited `&` with `&mut` pattern #[cfg(classic2024)] let _: u32 = x; } fn classic_errors_0() { let [&mut x] = &[&mut 0]; //[classic2024]~^ ERROR: mismatched types - //[classic2024]~| cannot match inherited `&` with `&mut` pattern + //[classic2024]~| NOTE cannot match inherited `&` with `&mut` pattern #[cfg(any(stable2021, classic2021, structural2021))] let _: u32 = x; #[cfg(structural2024)] let _: &u32 = x; let [&mut &x] = &[&mut 0]; //[stable2021,classic2021,structural2021,classic2024]~^ ERROR: mismatched types - //[stable2021]~| expected integer, found `&_` - //[classic2024]~| cannot match inherited `&` with `&mut` pattern + //[stable2021]~| NOTE expected integer, found `&_` + //[classic2024]~| NOTE cannot match inherited `&` with `&mut` pattern #[cfg(structural2024)] let _: u32 = x; let [&mut &ref x] = &[&mut 0]; //[stable2021,classic2021,structural2021,classic2024]~^ ERROR: mismatched types - //[stable2021]~| expected integer, found `&_` - //[classic2024]~| cannot match inherited `&` with `&mut` pattern + //[stable2021]~| NOTE expected integer, found `&_` + //[classic2024]~| NOTE cannot match inherited `&` with `&mut` pattern #[cfg(structural2024)] let _: &u32 = x; let [&mut &(mut x)] = &[&mut 0]; //[stable2021,classic2021,structural2021,classic2024]~^ ERROR: mismatched types - //[stable2021]~| expected integer, found `&_` - //[classic2024]~| cannot match inherited `&` with `&mut` pattern + //[stable2021]~| NOTE expected integer, found `&_` + //[classic2024]~| NOTE cannot match inherited `&` with `&mut` pattern #[cfg(structural2024)] let _: u32 = x; } diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.stable2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.stable2021.stderr index 76e6d2f562a..8b32e4f7c02 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.stable2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.stable2021.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:20:27 + --> $DIR/pattern-errors.rs:22:27 | LL | if let Some(&mut Some(&x)) = &Some(&mut Some(0)) { | ^^ ------------------- this expression has type `&Option<&mut Option<{integer}>>` @@ -15,7 +15,7 @@ LL + if let Some(&mut Some(x)) = &Some(&mut Some(0)) { | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:33:17 + --> $DIR/pattern-errors.rs:35:17 | LL | if let Some(&mut Some(&_)) = &Some(&Some(0)) { | ^^^^^^^^^^^^^ --------------- this expression has type `&Option<&Option<{integer}>>` @@ -26,7 +26,7 @@ LL | if let Some(&mut Some(&_)) = &Some(&Some(0)) { found mutable reference `&mut _` error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:38:17 + --> $DIR/pattern-errors.rs:40:17 | LL | if let Some(&Some(&mut x)) = &Some(&mut Some(0)) { | ^^^^^^^^^^^^^ ------------------- this expression has type `&Option<&mut Option<{integer}>>` @@ -37,7 +37,7 @@ LL | if let Some(&Some(&mut x)) = &Some(&mut Some(0)) { found reference `&_` error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:45:23 + --> $DIR/pattern-errors.rs:47:23 | LL | if let Some(&Some(&mut _)) = &mut Some(&Some(0)) { | ^^^^^^ ------------------- this expression has type `&mut Option<&Option<{integer}>>` @@ -48,7 +48,7 @@ LL | if let Some(&Some(&mut _)) = &mut Some(&Some(0)) { found mutable reference `&mut _` error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:50:17 + --> $DIR/pattern-errors.rs:52:17 | LL | if let Some(&Some(Some(&mut x))) = &Some(Some(&mut Some(0))) { | ^^^^^^^^^^^^^^^^^^^ ------------------------- this expression has type `&Option<Option<&mut Option<{integer}>>>` @@ -59,7 +59,7 @@ LL | if let Some(&Some(Some(&mut x))) = &Some(Some(&mut Some(0))) { found reference `&_` error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:56:17 + --> $DIR/pattern-errors.rs:58:17 | LL | if let Some(&mut Some(x)) = &Some(Some(0)) { | ^^^^^^^^^^^^ -------------- this expression has type `&Option<Option<{integer}>>` @@ -70,7 +70,7 @@ LL | if let Some(&mut Some(x)) = &Some(Some(0)) { found mutable reference `&mut _` error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:64:11 + --> $DIR/pattern-errors.rs:66:11 | LL | let &[&mut x] = &&mut [0]; | ^^^^^^ --------- this expression has type `&&mut [{integer}; 1]` @@ -80,7 +80,7 @@ LL | let &[&mut x] = &&mut [0]; = note: expected type `{integer}` found mutable reference `&mut _` note: to declare a mutable binding use: `mut x` - --> $DIR/pattern-errors.rs:64:11 + --> $DIR/pattern-errors.rs:66:11 | LL | let &[&mut x] = &&mut [0]; | ^^^^^^ @@ -91,7 +91,7 @@ LL + let &[x] = &&mut [0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:70:9 + --> $DIR/pattern-errors.rs:72:9 | LL | let &[&mut x] = &mut &mut [0]; | ^^^^^^^^^ ------------- this expression has type `&mut &mut [{integer}; 1]` @@ -102,7 +102,7 @@ LL | let &[&mut x] = &mut &mut [0]; found reference `&_` error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:76:11 + --> $DIR/pattern-errors.rs:78:11 | LL | let &[&mut ref x] = &&mut [0]; | ^^^^^^^^^^ --------- this expression has type `&&mut [{integer}; 1]` @@ -112,7 +112,7 @@ LL | let &[&mut ref x] = &&mut [0]; = note: expected type `{integer}` found mutable reference `&mut _` note: to declare a mutable binding use: `mut x` - --> $DIR/pattern-errors.rs:76:11 + --> $DIR/pattern-errors.rs:78:11 | LL | let &[&mut ref x] = &&mut [0]; | ^^^^^^^^^^ @@ -123,7 +123,7 @@ LL + let &[ref x] = &&mut [0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:82:9 + --> $DIR/pattern-errors.rs:84:9 | LL | let &[&mut ref x] = &mut &mut [0]; | ^^^^^^^^^^^^^ ------------- this expression has type `&mut &mut [{integer}; 1]` @@ -134,7 +134,7 @@ LL | let &[&mut ref x] = &mut &mut [0]; found reference `&_` error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:88:11 + --> $DIR/pattern-errors.rs:90:11 | LL | let &[&mut mut x] = &&mut [0]; | ^^^^^^^^^^ --------- this expression has type `&&mut [{integer}; 1]` @@ -144,7 +144,7 @@ LL | let &[&mut mut x] = &&mut [0]; = note: expected type `{integer}` found mutable reference `&mut _` note: to declare a mutable binding use: `mut x` - --> $DIR/pattern-errors.rs:88:11 + --> $DIR/pattern-errors.rs:90:11 | LL | let &[&mut mut x] = &&mut [0]; | ^^^^^^^^^^ @@ -155,7 +155,7 @@ LL + let &[mut x] = &&mut [0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:94:9 + --> $DIR/pattern-errors.rs:96:9 | LL | let &[&mut mut x] = &mut &mut [0]; | ^^^^^^^^^^^^^ ------------- this expression has type `&mut &mut [{integer}; 1]` @@ -166,7 +166,7 @@ LL | let &[&mut mut x] = &mut &mut [0]; found reference `&_` error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:114:10 + --> $DIR/pattern-errors.rs:116:10 | LL | let [&&mut x] = &[&mut 0]; | ^^^^^^^ --------- this expression has type `&[&mut {integer}; 1]` @@ -177,7 +177,7 @@ LL | let [&&mut x] = &[&mut 0]; found reference `&_` error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:121:10 + --> $DIR/pattern-errors.rs:123:10 | LL | let [&&mut x] = &mut [&mut 0]; | ^^^^^^^ ------------- this expression has type `&mut [&mut {integer}; 1]` @@ -188,7 +188,7 @@ LL | let [&&mut x] = &mut [&mut 0]; found reference `&_` error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:128:10 + --> $DIR/pattern-errors.rs:130:10 | LL | let [&&mut ref x] = &[&mut 0]; | ^^^^^^^^^^^ --------- this expression has type `&[&mut {integer}; 1]` @@ -199,7 +199,7 @@ LL | let [&&mut ref x] = &[&mut 0]; found reference `&_` error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:135:10 + --> $DIR/pattern-errors.rs:137:10 | LL | let [&&mut ref x] = &mut [&mut 0]; | ^^^^^^^^^^^ ------------- this expression has type `&mut [&mut {integer}; 1]` @@ -210,7 +210,7 @@ LL | let [&&mut ref x] = &mut [&mut 0]; found reference `&_` error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:142:10 + --> $DIR/pattern-errors.rs:144:10 | LL | let [&&mut mut x] = &[&mut 0]; | ^^^^^^^^^^^ --------- this expression has type `&[&mut {integer}; 1]` @@ -221,7 +221,7 @@ LL | let [&&mut mut x] = &[&mut 0]; found reference `&_` error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:149:10 + --> $DIR/pattern-errors.rs:151:10 | LL | let [&&mut mut x] = &mut [&mut 0]; | ^^^^^^^^^^^ ------------- this expression has type `&mut [&mut {integer}; 1]` @@ -232,7 +232,7 @@ LL | let [&&mut mut x] = &mut [&mut 0]; found reference `&_` error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:164:15 + --> $DIR/pattern-errors.rs:166:15 | LL | let [&mut &x] = &[&mut 0]; | ^^ --------- this expression has type `&[&mut {integer}; 1]` @@ -248,7 +248,7 @@ LL + let [&mut x] = &[&mut 0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:170:15 + --> $DIR/pattern-errors.rs:172:15 | LL | let [&mut &ref x] = &[&mut 0]; | ^^^^^^ --------- this expression has type `&[&mut {integer}; 1]` @@ -264,7 +264,7 @@ LL + let [&mut ref x] = &[&mut 0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:176:15 + --> $DIR/pattern-errors.rs:178:15 | LL | let [&mut &(mut x)] = &[&mut 0]; | ^^^^^^^^ --------- this expression has type `&[&mut {integer}; 1]` diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.structural2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.structural2021.stderr index 1ca6bff3f38..09cff1f8e92 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.structural2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.structural2021.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:20:27 + --> $DIR/pattern-errors.rs:22:27 | LL | if let Some(&mut Some(&x)) = &Some(&mut Some(0)) { | ^^ ------------------- this expression has type `&Option<&mut Option<{integer}>>` @@ -15,7 +15,7 @@ LL + if let Some(&mut Some(x)) = &Some(&mut Some(0)) { | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:33:17 + --> $DIR/pattern-errors.rs:35:17 | LL | if let Some(&mut Some(&_)) = &Some(&Some(0)) { | ^^^^^^^^^^^^^ --------------- this expression has type `&Option<&Option<{integer}>>` @@ -26,7 +26,7 @@ LL | if let Some(&mut Some(&_)) = &Some(&Some(0)) { found mutable reference `&mut _` error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:38:23 + --> $DIR/pattern-errors.rs:40:23 | LL | if let Some(&Some(&mut x)) = &Some(&mut Some(0)) { | ^^^^^^ ------------------- this expression has type `&Option<&mut Option<{integer}>>` @@ -36,7 +36,7 @@ LL | if let Some(&Some(&mut x)) = &Some(&mut Some(0)) { = note: expected type `{integer}` found mutable reference `&mut _` note: to declare a mutable binding use: `mut x` - --> $DIR/pattern-errors.rs:38:23 + --> $DIR/pattern-errors.rs:40:23 | LL | if let Some(&Some(&mut x)) = &Some(&mut Some(0)) { | ^^^^^^ @@ -47,7 +47,7 @@ LL + if let Some(&Some(x)) = &Some(&mut Some(0)) { | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:45:23 + --> $DIR/pattern-errors.rs:47:23 | LL | if let Some(&Some(&mut _)) = &mut Some(&Some(0)) { | ^^^^^^ ------------------- this expression has type `&mut Option<&Option<{integer}>>` @@ -58,7 +58,7 @@ LL | if let Some(&Some(&mut _)) = &mut Some(&Some(0)) { found mutable reference `&mut _` error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:50:28 + --> $DIR/pattern-errors.rs:52:28 | LL | if let Some(&Some(Some(&mut x))) = &Some(Some(&mut Some(0))) { | ^^^^^ @@ -71,7 +71,7 @@ LL + if let Some(&Some(Some(&x))) = &Some(Some(&mut Some(0))) { | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:56:17 + --> $DIR/pattern-errors.rs:58:17 | LL | if let Some(&mut Some(x)) = &Some(Some(0)) { | ^^^^^ @@ -84,7 +84,7 @@ LL + if let Some(&Some(x)) = &Some(Some(0)) { | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:64:11 + --> $DIR/pattern-errors.rs:66:11 | LL | let &[&mut x] = &&mut [0]; | ^^^^^ @@ -97,7 +97,7 @@ LL + let &[&x] = &&mut [0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:70:11 + --> $DIR/pattern-errors.rs:72:11 | LL | let &[&mut x] = &mut &mut [0]; | ^^^^^ @@ -110,7 +110,7 @@ LL + let &[&x] = &mut &mut [0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:76:11 + --> $DIR/pattern-errors.rs:78:11 | LL | let &[&mut ref x] = &&mut [0]; | ^^^^^ @@ -123,7 +123,7 @@ LL + let &[&ref x] = &&mut [0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:82:11 + --> $DIR/pattern-errors.rs:84:11 | LL | let &[&mut ref x] = &mut &mut [0]; | ^^^^^ @@ -136,7 +136,7 @@ LL + let &[&ref x] = &mut &mut [0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:88:11 + --> $DIR/pattern-errors.rs:90:11 | LL | let &[&mut mut x] = &&mut [0]; | ^^^^^ @@ -149,7 +149,7 @@ LL + let &[&mut x] = &&mut [0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:94:11 + --> $DIR/pattern-errors.rs:96:11 | LL | let &[&mut mut x] = &mut &mut [0]; | ^^^^^ @@ -162,7 +162,7 @@ LL + let &[&mut x] = &mut &mut [0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:114:11 + --> $DIR/pattern-errors.rs:116:11 | LL | let [&&mut x] = &[&mut 0]; | ^^^^^^ --------- this expression has type `&[&mut {integer}; 1]` @@ -178,7 +178,7 @@ LL + let [&x] = &[&mut 0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:121:11 + --> $DIR/pattern-errors.rs:123:11 | LL | let [&&mut x] = &mut [&mut 0]; | ^^^^^^ ------------- this expression has type `&mut [&mut {integer}; 1]` @@ -194,7 +194,7 @@ LL + let [&x] = &mut [&mut 0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:128:11 + --> $DIR/pattern-errors.rs:130:11 | LL | let [&&mut ref x] = &[&mut 0]; | ^^^^^^^^^^ --------- this expression has type `&[&mut {integer}; 1]` @@ -210,7 +210,7 @@ LL + let [&ref x] = &[&mut 0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:135:11 + --> $DIR/pattern-errors.rs:137:11 | LL | let [&&mut ref x] = &mut [&mut 0]; | ^^^^^^^^^^ ------------- this expression has type `&mut [&mut {integer}; 1]` @@ -226,7 +226,7 @@ LL + let [&ref x] = &mut [&mut 0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:142:11 + --> $DIR/pattern-errors.rs:144:11 | LL | let [&&mut mut x] = &[&mut 0]; | ^^^^^^^^^^ --------- this expression has type `&[&mut {integer}; 1]` @@ -242,7 +242,7 @@ LL + let [&mut x] = &[&mut 0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:149:11 + --> $DIR/pattern-errors.rs:151:11 | LL | let [&&mut mut x] = &mut [&mut 0]; | ^^^^^^^^^^ ------------- this expression has type `&mut [&mut {integer}; 1]` @@ -258,7 +258,7 @@ LL + let [&mut x] = &mut [&mut 0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:164:15 + --> $DIR/pattern-errors.rs:166:15 | LL | let [&mut &x] = &[&mut 0]; | ^^ --------- this expression has type `&[&mut {integer}; 1]` @@ -274,7 +274,7 @@ LL + let [&mut x] = &[&mut 0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:170:15 + --> $DIR/pattern-errors.rs:172:15 | LL | let [&mut &ref x] = &[&mut 0]; | ^^^^^^ --------- this expression has type `&[&mut {integer}; 1]` @@ -290,7 +290,7 @@ LL + let [&mut ref x] = &[&mut 0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:176:15 + --> $DIR/pattern-errors.rs:178:15 | LL | let [&mut &(mut x)] = &[&mut 0]; | ^^^^^^^^ --------- this expression has type `&[&mut {integer}; 1]` diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.structural2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.structural2024.stderr index 3658893df9c..d3d2c47c29c 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.structural2024.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.structural2024.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:33:17 + --> $DIR/pattern-errors.rs:35:17 | LL | if let Some(&mut Some(&_)) = &Some(&Some(0)) { | ^^^^^ @@ -12,7 +12,7 @@ LL + if let Some(&Some(&_)) = &Some(&Some(0)) { | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:38:23 + --> $DIR/pattern-errors.rs:40:23 | LL | if let Some(&Some(&mut x)) = &Some(&mut Some(0)) { | ^^^^^ @@ -25,7 +25,7 @@ LL + if let Some(&Some(&x)) = &Some(&mut Some(0)) { | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:45:23 + --> $DIR/pattern-errors.rs:47:23 | LL | if let Some(&Some(&mut _)) = &mut Some(&Some(0)) { | ^^^^^ @@ -38,7 +38,7 @@ LL + if let Some(&Some(&_)) = &mut Some(&Some(0)) { | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:50:28 + --> $DIR/pattern-errors.rs:52:28 | LL | if let Some(&Some(Some(&mut x))) = &Some(Some(&mut Some(0))) { | ^^^^^ @@ -51,7 +51,7 @@ LL + if let Some(&Some(Some(&x))) = &Some(Some(&mut Some(0))) { | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:56:17 + --> $DIR/pattern-errors.rs:58:17 | LL | if let Some(&mut Some(x)) = &Some(Some(0)) { | ^^^^^ @@ -64,7 +64,7 @@ LL + if let Some(&Some(x)) = &Some(Some(0)) { | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:64:11 + --> $DIR/pattern-errors.rs:66:11 | LL | let &[&mut x] = &&mut [0]; | ^^^^^ @@ -77,7 +77,7 @@ LL + let &[&x] = &&mut [0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:70:11 + --> $DIR/pattern-errors.rs:72:11 | LL | let &[&mut x] = &mut &mut [0]; | ^^^^^ @@ -90,7 +90,7 @@ LL + let &[&x] = &mut &mut [0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:76:11 + --> $DIR/pattern-errors.rs:78:11 | LL | let &[&mut ref x] = &&mut [0]; | ^^^^^ @@ -103,7 +103,7 @@ LL + let &[&ref x] = &&mut [0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:82:11 + --> $DIR/pattern-errors.rs:84:11 | LL | let &[&mut ref x] = &mut &mut [0]; | ^^^^^ @@ -116,7 +116,7 @@ LL + let &[&ref x] = &mut &mut [0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:88:11 + --> $DIR/pattern-errors.rs:90:11 | LL | let &[&mut mut x] = &&mut [0]; | ^^^^^ @@ -129,7 +129,7 @@ LL + let &[&mut x] = &&mut [0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:94:11 + --> $DIR/pattern-errors.rs:96:11 | LL | let &[&mut mut x] = &mut &mut [0]; | ^^^^^ @@ -142,7 +142,7 @@ LL + let &[&mut x] = &mut &mut [0]; | error[E0658]: binding cannot be both mutable and by-reference - --> $DIR/pattern-errors.rs:102:12 + --> $DIR/pattern-errors.rs:104:12 | LL | let [&(mut x)] = &[&0]; | ^^^^ @@ -152,7 +152,7 @@ LL | let [&(mut x)] = &[&0]; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: binding cannot be both mutable and by-reference - --> $DIR/pattern-errors.rs:107:12 + --> $DIR/pattern-errors.rs:109:12 | LL | let [&(mut x)] = &mut [&0]; | ^^^^ @@ -162,7 +162,7 @@ LL | let [&(mut x)] = &mut [&0]; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:114:11 + --> $DIR/pattern-errors.rs:116:11 | LL | let [&&mut x] = &[&mut 0]; | ^^^^^ @@ -175,7 +175,7 @@ LL + let [&&x] = &[&mut 0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:121:11 + --> $DIR/pattern-errors.rs:123:11 | LL | let [&&mut x] = &mut [&mut 0]; | ^^^^^ @@ -188,7 +188,7 @@ LL + let [&&x] = &mut [&mut 0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:128:11 + --> $DIR/pattern-errors.rs:130:11 | LL | let [&&mut ref x] = &[&mut 0]; | ^^^^^ @@ -201,7 +201,7 @@ LL + let [&&ref x] = &[&mut 0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:135:11 + --> $DIR/pattern-errors.rs:137:11 | LL | let [&&mut ref x] = &mut [&mut 0]; | ^^^^^ @@ -214,7 +214,7 @@ LL + let [&&ref x] = &mut [&mut 0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:142:11 + --> $DIR/pattern-errors.rs:144:11 | LL | let [&&mut mut x] = &[&mut 0]; | ^^^^^ @@ -227,7 +227,7 @@ LL + let [&&mut x] = &[&mut 0]; | error[E0308]: mismatched types - --> $DIR/pattern-errors.rs:149:11 + --> $DIR/pattern-errors.rs:151:11 | LL | let [&&mut mut x] = &mut [&mut 0]; | ^^^^^ diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2021.stderr index 1dda2dca4a4..dbb8ae87b66 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2021.stderr @@ -1,5 +1,5 @@ error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/ref-binding-on-inh-ref-errors.rs:71:10 + --> $DIR/ref-binding-on-inh-ref-errors.rs:73:10 | LL | let [ref mut x] = &[0]; | ^^^^^^^^^ cannot borrow as mutable diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2024.stderr index 44cb005a748..04e53e06a22 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2024.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2024.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/ref-binding-on-inh-ref-errors.rs:58:10 + --> $DIR/ref-binding-on-inh-ref-errors.rs:60:10 | LL | let [&mut ref x] = &[&mut 0]; | ^^^^^ @@ -12,14 +12,14 @@ LL + let [&ref x] = &[&mut 0]; | error: binding modifiers may only be written when the default binding mode is `move` - --> $DIR/ref-binding-on-inh-ref-errors.rs:71:10 + --> $DIR/ref-binding-on-inh-ref-errors.rs:73:10 | LL | let [ref mut x] = &[0]; | ^^^^^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> note: matching on a reference type with a non-reference pattern changes the default binding mode - --> $DIR/ref-binding-on-inh-ref-errors.rs:71:9 + --> $DIR/ref-binding-on-inh-ref-errors.rs:73:9 | LL | let [ref mut x] = &[0]; | ^^^^^^^^^^^ this matches on type `&_` @@ -29,20 +29,20 @@ LL | let &[ref mut x] = &[0]; | + error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/ref-binding-on-inh-ref-errors.rs:71:10 + --> $DIR/ref-binding-on-inh-ref-errors.rs:73:10 | LL | let [ref mut x] = &[0]; | ^^^^^^^^^ cannot borrow as mutable error: binding modifiers may only be written when the default binding mode is `move` - --> $DIR/ref-binding-on-inh-ref-errors.rs:79:10 + --> $DIR/ref-binding-on-inh-ref-errors.rs:81:10 | LL | let [ref x] = &[0]; | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> note: matching on a reference type with a non-reference pattern changes the default binding mode - --> $DIR/ref-binding-on-inh-ref-errors.rs:79:9 + --> $DIR/ref-binding-on-inh-ref-errors.rs:81:9 | LL | let [ref x] = &[0]; | ^^^^^^^ this matches on type `&_` @@ -52,14 +52,14 @@ LL | let &[ref x] = &[0]; | + error: binding modifiers may only be written when the default binding mode is `move` - --> $DIR/ref-binding-on-inh-ref-errors.rs:83:10 + --> $DIR/ref-binding-on-inh-ref-errors.rs:85:10 | LL | let [ref x] = &mut [0]; | ^^^ binding modifier not allowed under `ref mut` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> note: matching on a reference type with a non-reference pattern changes the default binding mode - --> $DIR/ref-binding-on-inh-ref-errors.rs:83:9 + --> $DIR/ref-binding-on-inh-ref-errors.rs:85:9 | LL | let [ref x] = &mut [0]; | ^^^^^^^ this matches on type `&mut _` @@ -69,14 +69,14 @@ LL | let &mut [ref x] = &mut [0]; | ++++ error: binding modifiers may only be written when the default binding mode is `move` - --> $DIR/ref-binding-on-inh-ref-errors.rs:87:10 + --> $DIR/ref-binding-on-inh-ref-errors.rs:89:10 | LL | let [ref mut x] = &mut [0]; | ^^^^^^^ binding modifier not allowed under `ref mut` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> note: matching on a reference type with a non-reference pattern changes the default binding mode - --> $DIR/ref-binding-on-inh-ref-errors.rs:87:9 + --> $DIR/ref-binding-on-inh-ref-errors.rs:89:9 | LL | let [ref mut x] = &mut [0]; | ^^^^^^^^^^^ this matches on type `&mut _` diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.rs b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.rs index ea6f028fe4b..c9e3f75cf17 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.rs +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.rs @@ -4,6 +4,8 @@ //@[structural2021] edition: 2021 //@[classic2024] edition: 2024 //@[structural2024] edition: 2024 +//@ dont-require-annotations: NOTE + //! Tests for errors from binding with `ref x` under a by-ref default binding mode in edition 2024. //! These can't be in the same body as tests for other errors, since they're emitted during THIR //! construction. The errors on stable edition 2021 Rust are unrelated. @@ -40,14 +42,14 @@ fn errors_from_eating_the_real_reference() { fn errors_from_eating_the_real_reference_caught_in_hir_typeck_on_stable() { let [&ref x] = &[&mut 0]; //[stable2021]~^ ERROR: mismatched types - //[stable2021]~| types differ in mutability + //[stable2021]~| NOTE types differ in mutability //[structural2024]~^^^ ERROR: binding modifiers may only be written when the default binding mode is `move` #[cfg(any(classic2021, structural2021))] let _: &u32 = x; #[cfg(classic2024)] let _: &&mut u32 = x; let [&ref x] = &mut [&mut 0]; //[stable2021]~^ ERROR: mismatched types - //[stable2021]~| types differ in mutability + //[stable2021]~| NOTE types differ in mutability //[structural2024]~^^^ ERROR: binding modifiers may only be written when the default binding mode is `move` #[cfg(any(classic2021, structural2021))] let _: &u32 = x; #[cfg(classic2024)] let _: &&mut u32 = x; @@ -57,7 +59,7 @@ fn errors_from_eating_the_real_reference_caught_in_hir_typeck_on_stable() { fn errors_dependent_on_eating_order_caught_in_hir_typeck_when_eating_outer() { let [&mut ref x] = &[&mut 0]; //[classic2024]~^ ERROR: mismatched types - //[classic2024]~| cannot match inherited `&` with `&mut` pattern + //[classic2024]~| NOTE cannot match inherited `&` with `&mut` pattern //[structural2024]~^^^ ERROR: binding modifiers may only be written when the default binding mode is `move` #[cfg(any(stable2021, classic2021, structural2021))] let _: &u32 = x; } diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.stable2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.stable2021.stderr index 2ec6650dd7d..33119c4447a 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.stable2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.stable2021.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/ref-binding-on-inh-ref-errors.rs:41:10 + --> $DIR/ref-binding-on-inh-ref-errors.rs:43:10 | LL | let [&ref x] = &[&mut 0]; | ^^^^^^ --------- this expression has type `&[&mut {integer}; 1]` @@ -15,7 +15,7 @@ LL + let [ref x] = &[&mut 0]; | error[E0308]: mismatched types - --> $DIR/ref-binding-on-inh-ref-errors.rs:48:10 + --> $DIR/ref-binding-on-inh-ref-errors.rs:50:10 | LL | let [&ref x] = &mut [&mut 0]; | ^^^^^^ ------------- this expression has type `&mut [&mut {integer}; 1]` @@ -31,7 +31,7 @@ LL + let [ref x] = &mut [&mut 0]; | error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/ref-binding-on-inh-ref-errors.rs:71:10 + --> $DIR/ref-binding-on-inh-ref-errors.rs:73:10 | LL | let [ref mut x] = &[0]; | ^^^^^^^^^ cannot borrow as mutable diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2021.stderr index 1dda2dca4a4..dbb8ae87b66 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2021.stderr @@ -1,5 +1,5 @@ error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/ref-binding-on-inh-ref-errors.rs:71:10 + --> $DIR/ref-binding-on-inh-ref-errors.rs:73:10 | LL | let [ref mut x] = &[0]; | ^^^^^^^^^ cannot borrow as mutable diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2024.stderr index 6f62ad06cc4..def6deb325a 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2024.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2024.stderr @@ -1,12 +1,12 @@ error: binding modifiers may only be written when the default binding mode is `move` - --> $DIR/ref-binding-on-inh-ref-errors.rs:17:11 + --> $DIR/ref-binding-on-inh-ref-errors.rs:19:11 | LL | let [&ref x] = &[&0]; | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> note: matching on a reference type with a non-reference pattern changes the default binding mode - --> $DIR/ref-binding-on-inh-ref-errors.rs:17:9 + --> $DIR/ref-binding-on-inh-ref-errors.rs:19:9 | LL | let [&ref x] = &[&0]; | ^^^^^^^^ this matches on type `&_` @@ -16,14 +16,14 @@ LL | let &[&ref x] = &[&0]; | + error: binding modifiers may only be written when the default binding mode is `move` - --> $DIR/ref-binding-on-inh-ref-errors.rs:22:11 + --> $DIR/ref-binding-on-inh-ref-errors.rs:24:11 | LL | let [&ref x] = &mut [&0]; | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> note: matching on a reference type with a non-reference pattern changes the default binding mode - --> $DIR/ref-binding-on-inh-ref-errors.rs:22:9 + --> $DIR/ref-binding-on-inh-ref-errors.rs:24:9 | LL | let [&ref x] = &mut [&0]; | ^^^^^^^^ this matches on type `&mut _` @@ -33,14 +33,14 @@ LL | let &mut [&ref x] = &mut [&0]; | ++++ error: binding modifiers may only be written when the default binding mode is `move` - --> $DIR/ref-binding-on-inh-ref-errors.rs:27:15 + --> $DIR/ref-binding-on-inh-ref-errors.rs:29:15 | LL | let [&mut ref x] = &mut [&mut 0]; | ^^^ binding modifier not allowed under `ref mut` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> note: matching on a reference type with a non-reference pattern changes the default binding mode - --> $DIR/ref-binding-on-inh-ref-errors.rs:27:9 + --> $DIR/ref-binding-on-inh-ref-errors.rs:29:9 | LL | let [&mut ref x] = &mut [&mut 0]; | ^^^^^^^^^^^^ this matches on type `&mut _` @@ -50,14 +50,14 @@ LL | let &mut [&mut ref x] = &mut [&mut 0]; | ++++ error: binding modifiers may only be written when the default binding mode is `move` - --> $DIR/ref-binding-on-inh-ref-errors.rs:32:15 + --> $DIR/ref-binding-on-inh-ref-errors.rs:34:15 | LL | let [&mut ref mut x] = &mut [&mut 0]; | ^^^^^^^ binding modifier not allowed under `ref mut` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> note: matching on a reference type with a non-reference pattern changes the default binding mode - --> $DIR/ref-binding-on-inh-ref-errors.rs:32:9 + --> $DIR/ref-binding-on-inh-ref-errors.rs:34:9 | LL | let [&mut ref mut x] = &mut [&mut 0]; | ^^^^^^^^^^^^^^^^ this matches on type `&mut _` @@ -67,14 +67,14 @@ LL | let &mut [&mut ref mut x] = &mut [&mut 0]; | ++++ error: binding modifiers may only be written when the default binding mode is `move` - --> $DIR/ref-binding-on-inh-ref-errors.rs:41:11 + --> $DIR/ref-binding-on-inh-ref-errors.rs:43:11 | LL | let [&ref x] = &[&mut 0]; | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> note: matching on a reference type with a non-reference pattern changes the default binding mode - --> $DIR/ref-binding-on-inh-ref-errors.rs:41:9 + --> $DIR/ref-binding-on-inh-ref-errors.rs:43:9 | LL | let [&ref x] = &[&mut 0]; | ^^^^^^^^ this matches on type `&_` @@ -84,14 +84,14 @@ LL | let &[&ref x] = &[&mut 0]; | + error: binding modifiers may only be written when the default binding mode is `move` - --> $DIR/ref-binding-on-inh-ref-errors.rs:48:11 + --> $DIR/ref-binding-on-inh-ref-errors.rs:50:11 | LL | let [&ref x] = &mut [&mut 0]; | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> note: matching on a reference type with a non-reference pattern changes the default binding mode - --> $DIR/ref-binding-on-inh-ref-errors.rs:48:9 + --> $DIR/ref-binding-on-inh-ref-errors.rs:50:9 | LL | let [&ref x] = &mut [&mut 0]; | ^^^^^^^^ this matches on type `&mut _` @@ -101,14 +101,14 @@ LL | let &mut [&ref x] = &mut [&mut 0]; | ++++ error: binding modifiers may only be written when the default binding mode is `move` - --> $DIR/ref-binding-on-inh-ref-errors.rs:58:15 + --> $DIR/ref-binding-on-inh-ref-errors.rs:60:15 | LL | let [&mut ref x] = &[&mut 0]; | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> note: matching on a reference type with a non-reference pattern changes the default binding mode - --> $DIR/ref-binding-on-inh-ref-errors.rs:58:9 + --> $DIR/ref-binding-on-inh-ref-errors.rs:60:9 | LL | let [&mut ref x] = &[&mut 0]; | ^^^^^^^^^^^^ this matches on type `&_` @@ -118,14 +118,14 @@ LL | let &[&mut ref x] = &[&mut 0]; | + error: binding modifiers may only be written when the default binding mode is `move` - --> $DIR/ref-binding-on-inh-ref-errors.rs:71:10 + --> $DIR/ref-binding-on-inh-ref-errors.rs:73:10 | LL | let [ref mut x] = &[0]; | ^^^^^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> note: matching on a reference type with a non-reference pattern changes the default binding mode - --> $DIR/ref-binding-on-inh-ref-errors.rs:71:9 + --> $DIR/ref-binding-on-inh-ref-errors.rs:73:9 | LL | let [ref mut x] = &[0]; | ^^^^^^^^^^^ this matches on type `&_` @@ -135,20 +135,20 @@ LL | let &[ref mut x] = &[0]; | + error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/ref-binding-on-inh-ref-errors.rs:71:10 + --> $DIR/ref-binding-on-inh-ref-errors.rs:73:10 | LL | let [ref mut x] = &[0]; | ^^^^^^^^^ cannot borrow as mutable error: binding modifiers may only be written when the default binding mode is `move` - --> $DIR/ref-binding-on-inh-ref-errors.rs:79:10 + --> $DIR/ref-binding-on-inh-ref-errors.rs:81:10 | LL | let [ref x] = &[0]; | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> note: matching on a reference type with a non-reference pattern changes the default binding mode - --> $DIR/ref-binding-on-inh-ref-errors.rs:79:9 + --> $DIR/ref-binding-on-inh-ref-errors.rs:81:9 | LL | let [ref x] = &[0]; | ^^^^^^^ this matches on type `&_` @@ -158,14 +158,14 @@ LL | let &[ref x] = &[0]; | + error: binding modifiers may only be written when the default binding mode is `move` - --> $DIR/ref-binding-on-inh-ref-errors.rs:83:10 + --> $DIR/ref-binding-on-inh-ref-errors.rs:85:10 | LL | let [ref x] = &mut [0]; | ^^^ binding modifier not allowed under `ref mut` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> note: matching on a reference type with a non-reference pattern changes the default binding mode - --> $DIR/ref-binding-on-inh-ref-errors.rs:83:9 + --> $DIR/ref-binding-on-inh-ref-errors.rs:85:9 | LL | let [ref x] = &mut [0]; | ^^^^^^^ this matches on type `&mut _` @@ -175,14 +175,14 @@ LL | let &mut [ref x] = &mut [0]; | ++++ error: binding modifiers may only be written when the default binding mode is `move` - --> $DIR/ref-binding-on-inh-ref-errors.rs:87:10 + --> $DIR/ref-binding-on-inh-ref-errors.rs:89:10 | LL | let [ref mut x] = &mut [0]; | ^^^^^^^ binding modifier not allowed under `ref mut` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> note: matching on a reference type with a non-reference pattern changes the default binding mode - --> $DIR/ref-binding-on-inh-ref-errors.rs:87:9 + --> $DIR/ref-binding-on-inh-ref-errors.rs:89:9 | LL | let [ref mut x] = &mut [0]; | ^^^^^^^^^^^ this matches on type `&mut _` diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.classic2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.classic2021.stderr index f8c2bd9a921..9bf5c9544e5 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.classic2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.classic2021.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:32:23 + --> $DIR/well-typed-edition-2024.rs:34:23 | LL | if let Some(Some(&&x)) = &Some(Some(&0)) { | ^^ --------------- this expression has type `&Option<Option<&{integer}>>` @@ -15,7 +15,7 @@ LL + if let Some(Some(&x)) = &Some(Some(&0)) { | error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:63:23 + --> $DIR/well-typed-edition-2024.rs:65:23 | LL | if let Some(&Some(&x)) = &Some(&Some(0)) { | ^^ --------------- this expression has type `&Option<&Option<{integer}>>` @@ -31,7 +31,7 @@ LL + if let Some(&Some(x)) = &Some(&Some(0)) { | error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:82:23 + --> $DIR/well-typed-edition-2024.rs:84:23 | LL | if let Some(&Some(&x)) = &Some(&mut Some(0)) { | ^^ ------------------- this expression has type `&Option<&mut Option<{integer}>>` @@ -47,7 +47,7 @@ LL + if let Some(&Some(x)) = &Some(&mut Some(0)) { | error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:88:23 + --> $DIR/well-typed-edition-2024.rs:90:23 | LL | if let Some(&Some(&x)) = &mut Some(&Some(0)) { | ^^ ------------------- this expression has type `&mut Option<&Option<{integer}>>` @@ -63,7 +63,7 @@ LL + if let Some(&Some(x)) = &mut Some(&Some(0)) { | error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:123:15 + --> $DIR/well-typed-edition-2024.rs:125:15 | LL | let [&mut &x] = &mut [&0]; | ^^ --------- this expression has type `&mut [&{integer}; 1]` @@ -79,7 +79,7 @@ LL + let [&mut x] = &mut [&0]; | error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:129:15 + --> $DIR/well-typed-edition-2024.rs:131:15 | LL | let [&mut &ref x] = &mut [&0]; | ^^^^^^ --------- this expression has type `&mut [&{integer}; 1]` @@ -95,7 +95,7 @@ LL + let [&mut ref x] = &mut [&0]; | error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:135:15 + --> $DIR/well-typed-edition-2024.rs:137:15 | LL | let [&mut &(mut x)] = &mut [&0]; | ^^^^^^^^ --------- this expression has type `&mut [&{integer}; 1]` @@ -111,7 +111,7 @@ LL + let [&mut mut x)] = &mut [&0]; | error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/well-typed-edition-2024.rs:109:19 + --> $DIR/well-typed-edition-2024.rs:111:19 | LL | let [&mut ref mut x] = &mut [&0]; | ^^^^^^^^^ cannot borrow as mutable diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.rs b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.rs index 877b10dcfd5..e2913e0f60a 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.rs +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.rs @@ -6,6 +6,8 @@ //@[structural2024] edition: 2024 //@[classic2024] run-pass //@[structural2024] run-pass +//@ dont-require-annotations: NOTE + //! Test cases for well-typed patterns in edition 2024. These are in their own file to ensure we //! pass both HIR typeck and MIR borrowck, as we may skip the latter if grouped with failing tests. #![allow(incomplete_features, unused_mut)] @@ -31,63 +33,63 @@ pub fn main() { } if let Some(Some(&&x)) = &Some(Some(&0)) { //[stable2021,classic2021,structural2021]~^ ERROR mismatched types - //[stable2021,classic2021,structural2021]~| expected integer, found `&_` + //[stable2021,classic2021,structural2021]~| NOTE expected integer, found `&_` #[cfg(any(classic2024, structural2024))] let _: u32 = x; } // Tests for eating a lone inherited reference if let Some(Some(&x)) = &Some(&Some(0)) { //[stable2021]~^ ERROR mismatched types - //[stable2021]~| expected integer, found `&_` + //[stable2021]~| NOTE expected integer, found `&_` #[cfg(any(classic2021, structural2021, classic2024, structural2024))] let _: u32 = x; } if let Some(&Some(x)) = &Some(Some(0)) { //[stable2021]~^ ERROR mismatched types - //[stable2021]~| expected `Option<{integer}>`, found `&_` + //[stable2021]~| NOTE expected `Option<{integer}>`, found `&_` #[cfg(any(classic2021, structural2021, classic2024, structural2024))] let _: u32 = x; } if let Some(Some(&mut x)) = &mut Some(&mut Some(0)) { //[stable2021]~^ ERROR mismatched types - //[stable2021]~| expected integer, found `&mut _` + //[stable2021]~| NOTE expected integer, found `&mut _` #[cfg(any(classic2021, structural2021, classic2024, structural2024))] let _: u32 = x; } // Tests for `&` patterns matching real `&mut` reference types if let Some(&Some(&x)) = Some(&Some(&mut 0)) { //[stable2021]~^ ERROR mismatched types - //[stable2021]~| types differ in mutability + //[stable2021]~| NOTE types differ in mutability #[cfg(any(classic2021, structural2021, classic2024, structural2024))] let _: u32 = x; } // Tests for eating only one layer and also eating a lone inherited reference if let Some(&Some(&x)) = &Some(&Some(0)) { //[stable2021,classic2021,structural2021]~^ ERROR mismatched types - //[stable2021,classic2021,structural2021]~| expected integer, found `&_` + //[stable2021,classic2021,structural2021]~| NOTE expected integer, found `&_` #[cfg(any(classic2024, structural2024))] let _: u32 = x; } // Tests for `&` matching a lone inherited possibly-`&mut` reference if let Some(&Some(Some(&x))) = &Some(Some(&mut Some(0))) { //[stable2021]~^ ERROR mismatched types - //[stable2021]~| expected `Option<&mut Option<{integer}>>`, found `&_` + //[stable2021]~| NOTE expected `Option<&mut Option<{integer}>>`, found `&_` #[cfg(any(classic2021, structural2021, classic2024, structural2024))] let _: u32 = x; } if let Some(&Some(x)) = &mut Some(Some(0)) { //[stable2021]~^ ERROR mismatched types - //[stable2021]~| expected `Option<{integer}>`, found `&_` + //[stable2021]~| NOTE expected `Option<{integer}>`, found `&_` #[cfg(any(classic2021, structural2021, classic2024, structural2024))] let _: u32 = x; } // Tests eating one layer, eating a lone inherited ref, and `&` eating `&mut` (realness varies) if let Some(&Some(&x)) = &Some(&mut Some(0)) { //[stable2021,classic2021,structural2021]~^ ERROR mismatched types - //[stable2021]~| types differ in mutability - //[classic2021,structural2021]~| expected integer, found `&_` + //[stable2021]~| NOTE types differ in mutability + //[classic2021,structural2021]~| NOTE expected integer, found `&_` #[cfg(any(classic2024, structural2024))] let _: u32 = x; } if let Some(&Some(&x)) = &mut Some(&Some(0)) { //[stable2021,classic2021,structural2021]~^ ERROR mismatched types - //[stable2021,classic2021,structural2021]~| expected integer, found `&_` + //[stable2021,classic2021,structural2021]~| NOTE expected integer, found `&_` #[cfg(any(classic2024, structural2024))] let _: u32 = x; } @@ -95,20 +97,20 @@ pub fn main() { // inner reference causes a mutability mismatch. i.e. tests for "fallback-to-outer" deref rules. let [&mut x] = &mut [&0]; //[stable2021]~^ ERROR mismatched types - //[stable2021]~| types differ in mutability + //[stable2021]~| NOTE types differ in mutability #[cfg(any(classic2021, structural2021))] let _: u32 = x; #[cfg(any(classic2024, structural2024))] let _: &u32 = x; let [&mut ref x] = &mut [&0]; //[stable2021]~^ ERROR mismatched types - //[stable2021]~| types differ in mutability + //[stable2021]~| NOTE types differ in mutability #[cfg(any(classic2021, structural2021))] let _: &u32 = x; #[cfg(any(classic2024, structural2024))] let _: &&u32 = x; fn borrowck_error_on_structural2021() { let [&mut ref mut x] = &mut [&0]; //[stable2021]~^ ERROR mismatched types - //[stable2021]~| types differ in mutability + //[stable2021]~| NOTE types differ in mutability //[classic2021,structural2021]~^^^ ERROR cannot borrow data in a `&` reference as mutable #[cfg(any(classic2024, structural2024))] let _: &mut &u32 = x; } @@ -116,25 +118,25 @@ pub fn main() { let [&mut mut x] = &mut [&0]; //[stable2021]~^ ERROR mismatched types - //[stable2021]~| types differ in mutability + //[stable2021]~| NOTE types differ in mutability #[cfg(any(classic2021, structural2021))] let _: u32 = x; #[cfg(any(classic2024, structural2024))] let _: &u32 = x; let [&mut &x] = &mut [&0]; //[stable2021,classic2021,structural2021]~^ ERROR mismatched types - //[stable2021]~| types differ in mutability - //[classic2021,structural2021]~| expected integer, found `&_` + //[stable2021]~| NOTE types differ in mutability + //[classic2021,structural2021]~| NOTE expected integer, found `&_` #[cfg(any(classic2024, structural2024))] let _: u32 = x; let [&mut &ref x] = &mut [&0]; //[stable2021,classic2021,structural2021]~^ ERROR mismatched types - //[stable2021]~| types differ in mutability - //[classic2021,structural2021]~| expected integer, found `&_` + //[stable2021]~| NOTE types differ in mutability + //[classic2021,structural2021]~| NOTE expected integer, found `&_` #[cfg(any(classic2024, structural2024))] let _: &u32 = x; let [&mut &(mut x)] = &mut [&0]; //[stable2021,classic2021,structural2021]~^ ERROR mismatched types - //[stable2021]~| types differ in mutability - //[classic2021,structural2021]~| expected integer, found `&_` + //[stable2021]~| NOTE types differ in mutability + //[classic2021,structural2021]~| NOTE expected integer, found `&_` #[cfg(any(classic2024, structural2024))] let _: u32 = x; } diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.stable2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.stable2021.stderr index adb47172f34..4f9dfaf639c 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.stable2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.stable2021.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:32:23 + --> $DIR/well-typed-edition-2024.rs:34:23 | LL | if let Some(Some(&&x)) = &Some(Some(&0)) { | ^^ --------------- this expression has type `&Option<Option<&{integer}>>` @@ -15,7 +15,7 @@ LL + if let Some(Some(&x)) = &Some(Some(&0)) { | error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:39:22 + --> $DIR/well-typed-edition-2024.rs:41:22 | LL | if let Some(Some(&x)) = &Some(&Some(0)) { | ^^ --------------- this expression has type `&Option<&Option<{integer}>>` @@ -31,7 +31,7 @@ LL + if let Some(Some(x)) = &Some(&Some(0)) { | error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:44:17 + --> $DIR/well-typed-edition-2024.rs:46:17 | LL | if let Some(&Some(x)) = &Some(Some(0)) { | ^^^^^^^^ -------------- this expression has type `&Option<Option<{integer}>>` @@ -42,7 +42,7 @@ LL | if let Some(&Some(x)) = &Some(Some(0)) { found reference `&_` error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:49:22 + --> $DIR/well-typed-edition-2024.rs:51:22 | LL | if let Some(Some(&mut x)) = &mut Some(&mut Some(0)) { | ^^^^^^ ----------------------- this expression has type `&mut Option<&mut Option<{integer}>>` @@ -52,7 +52,7 @@ LL | if let Some(Some(&mut x)) = &mut Some(&mut Some(0)) { = note: expected type `{integer}` found mutable reference `&mut _` note: to declare a mutable binding use: `mut x` - --> $DIR/well-typed-edition-2024.rs:49:22 + --> $DIR/well-typed-edition-2024.rs:51:22 | LL | if let Some(Some(&mut x)) = &mut Some(&mut Some(0)) { | ^^^^^^ @@ -63,7 +63,7 @@ LL + if let Some(Some(x)) = &mut Some(&mut Some(0)) { | error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:56:23 + --> $DIR/well-typed-edition-2024.rs:58:23 | LL | if let Some(&Some(&x)) = Some(&Some(&mut 0)) { | ^^ ------------------- this expression has type `Option<&Option<&mut {integer}>>` @@ -79,7 +79,7 @@ LL + if let Some(&Some(x)) = Some(&Some(&mut 0)) { | error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:63:23 + --> $DIR/well-typed-edition-2024.rs:65:23 | LL | if let Some(&Some(&x)) = &Some(&Some(0)) { | ^^ --------------- this expression has type `&Option<&Option<{integer}>>` @@ -95,7 +95,7 @@ LL + if let Some(&Some(x)) = &Some(&Some(0)) { | error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:70:17 + --> $DIR/well-typed-edition-2024.rs:72:17 | LL | if let Some(&Some(Some(&x))) = &Some(Some(&mut Some(0))) { | ^^^^^^^^^^^^^^^ ------------------------- this expression has type `&Option<Option<&mut Option<{integer}>>>` @@ -106,7 +106,7 @@ LL | if let Some(&Some(Some(&x))) = &Some(Some(&mut Some(0))) { found reference `&_` error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:75:17 + --> $DIR/well-typed-edition-2024.rs:77:17 | LL | if let Some(&Some(x)) = &mut Some(Some(0)) { | ^^^^^^^^ ------------------ this expression has type `&mut Option<Option<{integer}>>` @@ -117,7 +117,7 @@ LL | if let Some(&Some(x)) = &mut Some(Some(0)) { found reference `&_` error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:82:17 + --> $DIR/well-typed-edition-2024.rs:84:17 | LL | if let Some(&Some(&x)) = &Some(&mut Some(0)) { | ^^^^^^^^^ ------------------- this expression has type `&Option<&mut Option<{integer}>>` @@ -128,7 +128,7 @@ LL | if let Some(&Some(&x)) = &Some(&mut Some(0)) { found reference `&_` error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:88:23 + --> $DIR/well-typed-edition-2024.rs:90:23 | LL | if let Some(&Some(&x)) = &mut Some(&Some(0)) { | ^^ ------------------- this expression has type `&mut Option<&Option<{integer}>>` @@ -144,7 +144,7 @@ LL + if let Some(&Some(x)) = &mut Some(&Some(0)) { | error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:96:10 + --> $DIR/well-typed-edition-2024.rs:98:10 | LL | let [&mut x] = &mut [&0]; | ^^^^^^ --------- this expression has type `&mut [&{integer}; 1]` @@ -154,7 +154,7 @@ LL | let [&mut x] = &mut [&0]; = note: expected reference `&{integer}` found mutable reference `&mut _` note: to declare a mutable binding use: `mut x` - --> $DIR/well-typed-edition-2024.rs:96:10 + --> $DIR/well-typed-edition-2024.rs:98:10 | LL | let [&mut x] = &mut [&0]; | ^^^^^^ @@ -165,7 +165,7 @@ LL + let [x] = &mut [&0]; | error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:102:10 + --> $DIR/well-typed-edition-2024.rs:104:10 | LL | let [&mut ref x] = &mut [&0]; | ^^^^^^^^^^ --------- this expression has type `&mut [&{integer}; 1]` @@ -175,7 +175,7 @@ LL | let [&mut ref x] = &mut [&0]; = note: expected reference `&{integer}` found mutable reference `&mut _` note: to declare a mutable binding use: `mut x` - --> $DIR/well-typed-edition-2024.rs:102:10 + --> $DIR/well-typed-edition-2024.rs:104:10 | LL | let [&mut ref x] = &mut [&0]; | ^^^^^^^^^^ @@ -186,7 +186,7 @@ LL + let [ref x] = &mut [&0]; | error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:117:10 + --> $DIR/well-typed-edition-2024.rs:119:10 | LL | let [&mut mut x] = &mut [&0]; | ^^^^^^^^^^ --------- this expression has type `&mut [&{integer}; 1]` @@ -196,7 +196,7 @@ LL | let [&mut mut x] = &mut [&0]; = note: expected reference `&{integer}` found mutable reference `&mut _` note: to declare a mutable binding use: `mut x` - --> $DIR/well-typed-edition-2024.rs:117:10 + --> $DIR/well-typed-edition-2024.rs:119:10 | LL | let [&mut mut x] = &mut [&0]; | ^^^^^^^^^^ @@ -207,7 +207,7 @@ LL + let [mut x] = &mut [&0]; | error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:123:10 + --> $DIR/well-typed-edition-2024.rs:125:10 | LL | let [&mut &x] = &mut [&0]; | ^^^^^^^ --------- this expression has type `&mut [&{integer}; 1]` @@ -218,7 +218,7 @@ LL | let [&mut &x] = &mut [&0]; found mutable reference `&mut _` error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:129:10 + --> $DIR/well-typed-edition-2024.rs:131:10 | LL | let [&mut &ref x] = &mut [&0]; | ^^^^^^^^^^^ --------- this expression has type `&mut [&{integer}; 1]` @@ -229,7 +229,7 @@ LL | let [&mut &ref x] = &mut [&0]; found mutable reference `&mut _` error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:135:10 + --> $DIR/well-typed-edition-2024.rs:137:10 | LL | let [&mut &(mut x)] = &mut [&0]; | ^^^^^^^^^^^^^ --------- this expression has type `&mut [&{integer}; 1]` @@ -240,7 +240,7 @@ LL | let [&mut &(mut x)] = &mut [&0]; found mutable reference `&mut _` error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:109:14 + --> $DIR/well-typed-edition-2024.rs:111:14 | LL | let [&mut ref mut x] = &mut [&0]; | ^^^^^^^^^^^^^^ --------- this expression has type `&mut [&{integer}; 1]` @@ -250,7 +250,7 @@ LL | let [&mut ref mut x] = &mut [&0]; = note: expected reference `&{integer}` found mutable reference `&mut _` note: to declare a mutable binding use: `mut x` - --> $DIR/well-typed-edition-2024.rs:109:14 + --> $DIR/well-typed-edition-2024.rs:111:14 | LL | let [&mut ref mut x] = &mut [&0]; | ^^^^^^^^^^^^^^ diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.structural2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.structural2021.stderr index f8c2bd9a921..9bf5c9544e5 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.structural2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.structural2021.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:32:23 + --> $DIR/well-typed-edition-2024.rs:34:23 | LL | if let Some(Some(&&x)) = &Some(Some(&0)) { | ^^ --------------- this expression has type `&Option<Option<&{integer}>>` @@ -15,7 +15,7 @@ LL + if let Some(Some(&x)) = &Some(Some(&0)) { | error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:63:23 + --> $DIR/well-typed-edition-2024.rs:65:23 | LL | if let Some(&Some(&x)) = &Some(&Some(0)) { | ^^ --------------- this expression has type `&Option<&Option<{integer}>>` @@ -31,7 +31,7 @@ LL + if let Some(&Some(x)) = &Some(&Some(0)) { | error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:82:23 + --> $DIR/well-typed-edition-2024.rs:84:23 | LL | if let Some(&Some(&x)) = &Some(&mut Some(0)) { | ^^ ------------------- this expression has type `&Option<&mut Option<{integer}>>` @@ -47,7 +47,7 @@ LL + if let Some(&Some(x)) = &Some(&mut Some(0)) { | error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:88:23 + --> $DIR/well-typed-edition-2024.rs:90:23 | LL | if let Some(&Some(&x)) = &mut Some(&Some(0)) { | ^^ ------------------- this expression has type `&mut Option<&Option<{integer}>>` @@ -63,7 +63,7 @@ LL + if let Some(&Some(x)) = &mut Some(&Some(0)) { | error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:123:15 + --> $DIR/well-typed-edition-2024.rs:125:15 | LL | let [&mut &x] = &mut [&0]; | ^^ --------- this expression has type `&mut [&{integer}; 1]` @@ -79,7 +79,7 @@ LL + let [&mut x] = &mut [&0]; | error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:129:15 + --> $DIR/well-typed-edition-2024.rs:131:15 | LL | let [&mut &ref x] = &mut [&0]; | ^^^^^^ --------- this expression has type `&mut [&{integer}; 1]` @@ -95,7 +95,7 @@ LL + let [&mut ref x] = &mut [&0]; | error[E0308]: mismatched types - --> $DIR/well-typed-edition-2024.rs:135:15 + --> $DIR/well-typed-edition-2024.rs:137:15 | LL | let [&mut &(mut x)] = &mut [&0]; | ^^^^^^^^ --------- this expression has type `&mut [&{integer}; 1]` @@ -111,7 +111,7 @@ LL + let [&mut mut x)] = &mut [&0]; | error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/well-typed-edition-2024.rs:109:19 + --> $DIR/well-typed-edition-2024.rs:111:19 | LL | let [&mut ref mut x] = &mut [&0]; | ^^^^^^^^^ cannot borrow as mutable diff --git a/tests/ui/pattern/usefulness/issue-31561.rs b/tests/ui/pattern/usefulness/issue-31561.rs index 82414f0418b..fe1b2bb4f83 100644 --- a/tests/ui/pattern/usefulness/issue-31561.rs +++ b/tests/ui/pattern/usefulness/issue-31561.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + enum Thing { Foo(u8), Bar, @@ -7,5 +9,5 @@ enum Thing { fn main() { let Thing::Foo(y) = Thing::Foo(1); //~^ ERROR refutable pattern in local binding - //~| `Thing::Bar` and `Thing::Baz` not covered + //~| NOTE `Thing::Bar` and `Thing::Baz` not covered } diff --git a/tests/ui/pattern/usefulness/issue-31561.stderr b/tests/ui/pattern/usefulness/issue-31561.stderr index ba7ae3fa9a0..382b2337ffa 100644 --- a/tests/ui/pattern/usefulness/issue-31561.stderr +++ b/tests/ui/pattern/usefulness/issue-31561.stderr @@ -1,5 +1,5 @@ error[E0005]: refutable pattern in local binding - --> $DIR/issue-31561.rs:8:9 + --> $DIR/issue-31561.rs:10:9 | LL | let Thing::Foo(y) = Thing::Foo(1); | ^^^^^^^^^^^^^ patterns `Thing::Bar` and `Thing::Baz` not covered @@ -7,7 +7,7 @@ LL | let Thing::Foo(y) = Thing::Foo(1); = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html note: `Thing` defined here - --> $DIR/issue-31561.rs:1:6 + --> $DIR/issue-31561.rs:3:6 | LL | enum Thing { | ^^^^^ diff --git a/tests/ui/pattern/usefulness/issue-39362.rs b/tests/ui/pattern/usefulness/issue-39362.rs index ea3c8f88e0b..0db3980359c 100644 --- a/tests/ui/pattern/usefulness/issue-39362.rs +++ b/tests/ui/pattern/usefulness/issue-39362.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + enum Foo { Bar { bar: Bar, id: usize } } @@ -9,7 +11,7 @@ enum Bar { fn test(f: Foo) { match f { //~^ ERROR non-exhaustive patterns - //~| patterns + //~| NOTE patterns Foo::Bar { bar: Bar::A, .. } => (), Foo::Bar { bar: Bar::B, .. } => (), } diff --git a/tests/ui/pattern/usefulness/issue-39362.stderr b/tests/ui/pattern/usefulness/issue-39362.stderr index 9cce87a1c65..18d542cc6ad 100644 --- a/tests/ui/pattern/usefulness/issue-39362.stderr +++ b/tests/ui/pattern/usefulness/issue-39362.stderr @@ -1,11 +1,11 @@ error[E0004]: non-exhaustive patterns: `Foo::Bar { bar: Bar::C, .. }`, `Foo::Bar { bar: Bar::D, .. }`, `Foo::Bar { bar: Bar::E, .. }` and 1 more not covered - --> $DIR/issue-39362.rs:10:11 + --> $DIR/issue-39362.rs:12:11 | LL | match f { | ^ patterns `Foo::Bar { bar: Bar::C, .. }`, `Foo::Bar { bar: Bar::D, .. }`, `Foo::Bar { bar: Bar::E, .. }` and 1 more not covered | note: `Foo` defined here - --> $DIR/issue-39362.rs:1:6 + --> $DIR/issue-39362.rs:3:6 | LL | enum Foo { | ^^^ diff --git a/tests/ui/pattern/usefulness/issue-72377.rs b/tests/ui/pattern/usefulness/issue-72377.rs index b5ad3075ca7..782a9963f2e 100644 --- a/tests/ui/pattern/usefulness/issue-72377.rs +++ b/tests/ui/pattern/usefulness/issue-72377.rs @@ -7,7 +7,8 @@ fn main() { match (x, y) { //~^ ERROR non-exhaustive patterns: `(X::A, Some(X::A))`, `(X::A, Some(X::B))`, `(X::B, Some(X::B))` and 2 - //~| more not covered + //~| NOTE more not covered + //~| NOTE the matched value is of type `(X, Option<X>)` (_, None) => false, (v, Some(w)) if v == w => true, (X::B, Some(X::C)) => false, diff --git a/tests/ui/pattern/usefulness/refutable-pattern-errors.rs b/tests/ui/pattern/usefulness/refutable-pattern-errors.rs index 7603da1bb2c..de9fc24bbd0 100644 --- a/tests/ui/pattern/usefulness/refutable-pattern-errors.rs +++ b/tests/ui/pattern/usefulness/refutable-pattern-errors.rs @@ -1,9 +1,11 @@ +//@ dont-require-annotations: NOTE + fn func((1, (Some(1), 2..=3)): (isize, (Option<isize>, isize))) {} //~^ ERROR refutable pattern in function argument -//~| `(..=0_isize, _)` and `(2_isize.., _)` not covered +//~| NOTE `(..=0_isize, _)` and `(2_isize.., _)` not covered fn main() { let (1, (Some(1), 2..=3)) = (1, (None, 2)); //~^ ERROR refutable pattern in local binding - //~| `(i32::MIN..=0_i32, _)` and `(2_i32..=i32::MAX, _)` not covered + //~| NOTE `(i32::MIN..=0_i32, _)` and `(2_i32..=i32::MAX, _)` not covered } diff --git a/tests/ui/pattern/usefulness/refutable-pattern-errors.stderr b/tests/ui/pattern/usefulness/refutable-pattern-errors.stderr index 23a5d895d6c..37d1dc3efe9 100644 --- a/tests/ui/pattern/usefulness/refutable-pattern-errors.stderr +++ b/tests/ui/pattern/usefulness/refutable-pattern-errors.stderr @@ -1,5 +1,5 @@ error[E0005]: refutable pattern in function argument - --> $DIR/refutable-pattern-errors.rs:1:9 + --> $DIR/refutable-pattern-errors.rs:3:9 | LL | fn func((1, (Some(1), 2..=3)): (isize, (Option<isize>, isize))) {} | ^^^^^^^^^^^^^^^^^^^^^ patterns `(..=0_isize, _)` and `(2_isize.., _)` not covered @@ -7,7 +7,7 @@ LL | fn func((1, (Some(1), 2..=3)): (isize, (Option<isize>, isize))) {} = note: the matched value is of type `(isize, (Option<isize>, isize))` error[E0005]: refutable pattern in local binding - --> $DIR/refutable-pattern-errors.rs:6:9 + --> $DIR/refutable-pattern-errors.rs:8:9 | LL | let (1, (Some(1), 2..=3)) = (1, (None, 2)); | ^^^^^^^^^^^^^^^^^^^^^ patterns `(i32::MIN..=0_i32, _)` and `(2_i32..=i32::MAX, _)` not covered diff --git a/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.rs b/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.rs index 51ff641509d..416564d94dc 100644 --- a/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.rs +++ b/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.rs @@ -1,6 +1,7 @@ fn main() { let f = |3: isize| println!("hello"); //~^ ERROR refutable pattern in closure argument - //~| `..=2_isize` and `4_isize..` not covered + //~| NOTE `..=2_isize` and `4_isize..` not covered + //~| NOTE the matched value is of type `isize` f(4); } diff --git a/tests/ui/pptypedef.rs b/tests/ui/pptypedef.rs index e28d323f883..d5f43df9d85 100644 --- a/tests/ui/pptypedef.rs +++ b/tests/ui/pptypedef.rs @@ -1,11 +1,13 @@ +//@ dont-require-annotations: NOTE + fn let_in<T, F>(x: T, f: F) where F: FnOnce(T) {} fn main() { let_in(3u32, |i| { assert!(i == 3i32); }); //~^ ERROR mismatched types - //~| expected `u32`, found `i32` + //~| NOTE expected `u32`, found `i32` let_in(3i32, |i| { assert!(i == 3u32); }); //~^ ERROR mismatched types - //~| expected `i32`, found `u32` + //~| NOTE expected `i32`, found `u32` } diff --git a/tests/ui/pptypedef.stderr b/tests/ui/pptypedef.stderr index 96327cfcc65..a6d673e61c6 100644 --- a/tests/ui/pptypedef.stderr +++ b/tests/ui/pptypedef.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/pptypedef.rs:4:37 + --> $DIR/pptypedef.rs:6:37 | LL | let_in(3u32, |i| { assert!(i == 3i32); }); | - ^^^^ expected `u32`, found `i32` @@ -13,7 +13,7 @@ LL + let_in(3u32, |i| { assert!(i == 3u32); }); | error[E0308]: mismatched types - --> $DIR/pptypedef.rs:8:37 + --> $DIR/pptypedef.rs:10:37 | LL | let_in(3i32, |i| { assert!(i == 3u32); }); | - ^^^^ expected `i32`, found `u32` diff --git a/tests/ui/privacy/privacy2.rs b/tests/ui/privacy/privacy2.rs index c82cd442559..e44100a8059 100644 --- a/tests/ui/privacy/privacy2.rs +++ b/tests/ui/privacy/privacy2.rs @@ -1,4 +1,5 @@ //@ compile-flags: -Zdeduplicate-diagnostics=yes +//@ dont-require-annotations: NOTE #![feature(no_core)] #![no_core] // makes debugging this test *a lot* easier (during resolve) @@ -20,7 +21,7 @@ fn test1() { //~^ ERROR requires `sized` lang_item use bar::foo; //~^ ERROR unresolved import `bar::foo` [E0432] - //~| no `foo` in `bar` + //~| NOTE no `foo` in `bar` } fn test2() { diff --git a/tests/ui/privacy/privacy2.stderr b/tests/ui/privacy/privacy2.stderr index 39bab67a660..b70134965fa 100644 --- a/tests/ui/privacy/privacy2.stderr +++ b/tests/ui/privacy/privacy2.stderr @@ -1,34 +1,34 @@ error[E0432]: unresolved import `bar::foo` - --> $DIR/privacy2.rs:21:9 + --> $DIR/privacy2.rs:22:9 | LL | use bar::foo; | ^^^^^^^^ no `foo` in `bar` error[E0603]: function import `foo` is private - --> $DIR/privacy2.rs:28:20 + --> $DIR/privacy2.rs:29:20 | LL | use bar::glob::foo; | ^^^ private function import | note: the function import `foo` is defined here... - --> $DIR/privacy2.rs:12:13 + --> $DIR/privacy2.rs:13:13 | LL | use foo; | ^^^ note: ...and refers to the function `foo` which is defined here - --> $DIR/privacy2.rs:16:1 + --> $DIR/privacy2.rs:17:1 | LL | pub fn foo() {} | ^^^^^^^^^^^^ you could import this directly error: requires `sized` lang_item - --> $DIR/privacy2.rs:16:14 + --> $DIR/privacy2.rs:17:14 | LL | pub fn foo() {} | ^^ error: requires `sized` lang_item - --> $DIR/privacy2.rs:19:12 + --> $DIR/privacy2.rs:20:12 | LL | fn test1() { | ____________^ @@ -39,7 +39,7 @@ LL | | } | |_^ error: requires `sized` lang_item - --> $DIR/privacy2.rs:26:12 + --> $DIR/privacy2.rs:27:12 | LL | fn test2() { | ____________^ @@ -50,7 +50,7 @@ LL | | } | |_^ error: requires `sized` lang_item - --> $DIR/privacy2.rs:32:11 + --> $DIR/privacy2.rs:33:11 | LL | fn main() {} | ^^ diff --git a/tests/ui/proc-macro/attr-complex-fn.stdout b/tests/ui/proc-macro/attr-complex-fn.stdout index 7c23d1ecae4..9bbb746bb4d 100644 --- a/tests/ui/proc-macro/attr-complex-fn.stdout +++ b/tests/ui/proc-macro/attr-complex-fn.stdout @@ -77,7 +77,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ span: $DIR/attr-complex-fn.rs:19:42: 19:44 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): impl<T> MyTrait<T> for MyStruct<{ true }> { #![rustc_dummy] } +PRINT-ATTR INPUT (DISPLAY): impl<T> MyTrait<T> for MyStruct<{true}> { #![rustc_dummy] } PRINT-ATTR RE-COLLECTED (DISPLAY): impl < T > MyTrait < T > for MyStruct < { true } > { #![rustc_dummy] } PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): impl < T > MyTrait < T > for MyStruct < { true } > { #! [rustc_dummy] } PRINT-ATTR INPUT (DEBUG): TokenStream [ diff --git a/tests/ui/proc-macro/quote/debug.stdout b/tests/ui/proc-macro/quote/debug.stdout index 6ebb3a37951..3acb472d9c0 100644 --- a/tests/ui/proc-macro/quote/debug.stdout +++ b/tests/ui/proc-macro/quote/debug.stdout @@ -32,12 +32,12 @@ fn main() { let mut iter = "\"world\"".parse::<crate::TokenStream>().unwrap().into_iter(); if let (Some(crate::TokenTree::Literal(mut lit)), None) = - (iter.next(), iter.next()) { - lit.set_span(crate::Span::recover_proc_macro_span(2)); - lit - } else { - ::core::panicking::panic("internal error: entered unreachable code") - } + (iter.next(), iter.next()) { + lit.set_span(crate::Span::recover_proc_macro_span(2)); + lit + } else { + ::core::panicking::panic("internal error: entered unreachable code") + } }), &mut ts); crate::ToTokens::to_tokens(&crate::TokenTree::Punct(crate::Punct::new(';', crate::Spacing::Alone)), &mut ts); @@ -51,12 +51,12 @@ fn main() { let mut iter = "r#\"raw\"literal\"#".parse::<crate::TokenStream>().unwrap().into_iter(); if let (Some(crate::TokenTree::Literal(mut lit)), None) = - (iter.next(), iter.next()) { - lit.set_span(crate::Span::recover_proc_macro_span(5)); - lit - } else { - ::core::panicking::panic("internal error: entered unreachable code") - } + (iter.next(), iter.next()) { + lit.set_span(crate::Span::recover_proc_macro_span(5)); + lit + } else { + ::core::panicking::panic("internal error: entered unreachable code") + } }), &mut ts); crate::ToTokens::to_tokens(&crate::TokenTree::Punct(crate::Punct::new(';', crate::Spacing::Alone)), &mut ts); diff --git a/tests/ui/proc-macro/weird-braces.stdout b/tests/ui/proc-macro/weird-braces.stdout index 7da769ef0d2..0215deb05c3 100644 --- a/tests/ui/proc-macro/weird-braces.stdout +++ b/tests/ui/proc-macro/weird-braces.stdout @@ -5,7 +5,7 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [ span: $DIR/weird-braces.rs:16:25: 16:36 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): #[print_target_and_args(second_outer)] impl Bar<{ 1 > 0 }> for Foo<{ true }> +PRINT-ATTR INPUT (DISPLAY): #[print_target_and_args(second_outer)] impl Bar<{1 > 0}> for Foo<{true}> { #![print_target_and_args(first_inner)] #![print_target_and_args(second_inner)] @@ -191,7 +191,7 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [ span: $DIR/weird-braces.rs:17:25: 17:37 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): impl Bar<{ 1 > 0 }> for Foo<{ true }> +PRINT-ATTR INPUT (DISPLAY): impl Bar<{1 > 0}> for Foo<{true}> { #![print_target_and_args(first_inner)] #![print_target_and_args(second_inner)] @@ -350,8 +350,7 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [ span: $DIR/weird-braces.rs:19:30: 19:41 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): impl Bar<{ 1 > 0 }> for Foo<{ true }> -{ #![print_target_and_args(second_inner)] } +PRINT-ATTR INPUT (DISPLAY): impl Bar<{1 > 0}> for Foo<{true}> { #![print_target_and_args(second_inner)] } PRINT-ATTR RE-COLLECTED (DISPLAY): impl Bar < { 1 > 0 } > for Foo < { true } > { #![print_target_and_args(second_inner)] } PRINT-ATTR DEEP-RE-COLLECTED (DISPLAY): impl Bar < { 1 > 0 } > for Foo < { true } > @@ -470,7 +469,7 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [ span: $DIR/weird-braces.rs:20:30: 20:42 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): impl Bar<{ 1 > 0 }> for Foo<{ true }> {} +PRINT-ATTR INPUT (DISPLAY): impl Bar<{1 > 0}> for Foo<{true}> {} PRINT-ATTR RE-COLLECTED (DISPLAY): impl Bar < { 1 > 0 } > for Foo < { true } > {} PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { diff --git a/tests/ui/ptr-coercion.rs b/tests/ui/ptr-coercion.rs index 193899034c7..2549bd6f134 100644 --- a/tests/ui/ptr-coercion.rs +++ b/tests/ui/ptr-coercion.rs @@ -1,23 +1,25 @@ // Test coercions between pointers which don't do anything fancy like unsizing. // These are testing that we don't lose mutability when converting to raw pointers. +//@ dont-require-annotations: NOTE + pub fn main() { // *const -> *mut let x: *const isize = &42; let x: *mut isize = x; //~ ERROR mismatched types - //~| expected raw pointer `*mut isize` - //~| found raw pointer `*const isize` - //~| types differ in mutability + //~| NOTE expected raw pointer `*mut isize` + //~| NOTE found raw pointer `*const isize` + //~| NOTE types differ in mutability // & -> *mut let x: *mut isize = &42; //~ ERROR mismatched types - //~| expected raw pointer `*mut isize` - //~| found reference `&isize` - //~| types differ in mutability + //~| NOTE expected raw pointer `*mut isize` + //~| NOTE found reference `&isize` + //~| NOTE types differ in mutability let x: *const isize = &42; let x: *mut isize = x; //~ ERROR mismatched types - //~| expected raw pointer `*mut isize` - //~| found raw pointer `*const isize` - //~| types differ in mutability + //~| NOTE expected raw pointer `*mut isize` + //~| NOTE found raw pointer `*const isize` + //~| NOTE types differ in mutability } diff --git a/tests/ui/ptr-coercion.stderr b/tests/ui/ptr-coercion.stderr index 29b7e5da849..8de41d2c382 100644 --- a/tests/ui/ptr-coercion.stderr +++ b/tests/ui/ptr-coercion.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/ptr-coercion.rs:7:25 + --> $DIR/ptr-coercion.rs:9:25 | LL | let x: *mut isize = x; | ---------- ^ types differ in mutability @@ -10,7 +10,7 @@ LL | let x: *mut isize = x; found raw pointer `*const isize` error[E0308]: mismatched types - --> $DIR/ptr-coercion.rs:13:25 + --> $DIR/ptr-coercion.rs:15:25 | LL | let x: *mut isize = &42; | ---------- ^^^ types differ in mutability @@ -21,7 +21,7 @@ LL | let x: *mut isize = &42; found reference `&isize` error[E0308]: mismatched types - --> $DIR/ptr-coercion.rs:19:25 + --> $DIR/ptr-coercion.rs:21:25 | LL | let x: *mut isize = x; | ---------- ^ types differ in mutability diff --git a/tests/ui/recursion_limit/empty.rs b/tests/ui/recursion_limit/empty.rs index 59dae106c00..5987fa2f881 100644 --- a/tests/ui/recursion_limit/empty.rs +++ b/tests/ui/recursion_limit/empty.rs @@ -1,8 +1,9 @@ // Test the parse error for an empty recursion_limit #![recursion_limit = ""] //~ ERROR `limit` must be a non-negative integer - //~| `limit` must be a non-negative integer + //~| NOTE `limit` must be a non-negative integer //~| ERROR `limit` must be a non-negative integer - //~| `limit` must be a non-negative integer + //~| NOTE `limit` must be a non-negative integer + //~| NOTE duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` fn main() {} diff --git a/tests/ui/recursion_limit/invalid_digit.rs b/tests/ui/recursion_limit/invalid_digit.rs index 03df3e7a927..79d8f3708ba 100644 --- a/tests/ui/recursion_limit/invalid_digit.rs +++ b/tests/ui/recursion_limit/invalid_digit.rs @@ -1,7 +1,8 @@ // Test the parse error for an invalid digit in recursion_limit #![recursion_limit = "-100"] //~ ERROR `limit` must be a non-negative integer - //~| not a valid integer + //~| NOTE not a valid integer //~| ERROR `limit` must be a non-negative integer - //~| not a valid integer + //~| NOTE not a valid integer + //~| NOTE duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` fn main() {} diff --git a/tests/ui/recursion_limit/overflow.rs b/tests/ui/recursion_limit/overflow.rs index c733ba6b93c..7cd1d572e09 100644 --- a/tests/ui/recursion_limit/overflow.rs +++ b/tests/ui/recursion_limit/overflow.rs @@ -2,8 +2,9 @@ #![recursion_limit = "999999999999999999999999"] //~^ ERROR `limit` must be a non-negative integer -//~| `limit` is too large +//~| NOTE `limit` is too large //~| ERROR `limit` must be a non-negative integer -//~| `limit` is too large +//~| NOTE `limit` is too large +//~| NOTE duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` fn main() {} diff --git a/tests/ui/repeat-expr/repeat_count.rs b/tests/ui/repeat-expr/repeat_count.rs index 18610bc5bb0..2febcdc07c2 100644 --- a/tests/ui/repeat-expr/repeat_count.rs +++ b/tests/ui/repeat-expr/repeat_count.rs @@ -1,34 +1,36 @@ // Regression test for issue #3645 +//@ dont-require-annotations: NOTE + fn main() { let n = 1; let a = [0; n]; //~^ ERROR attempt to use a non-constant value in a constant [E0435] let b = [0; ()]; //~^ ERROR mismatched types - //~| expected `usize`, found `()` + //~| NOTE expected `usize`, found `()` let c = [0; true]; //~^ ERROR mismatched types - //~| expected `usize`, found `bool` + //~| NOTE expected `usize`, found `bool` let d = [0; 0.5]; //~^ ERROR mismatched types - //~| expected `usize`, found floating-point number + //~| NOTE expected `usize`, found floating-point number let e = [0; "foo"]; //~^ ERROR mismatched types - //~| expected `usize`, found `&str` + //~| NOTE expected `usize`, found `&str` let f = [0; -4_isize]; //~^ ERROR mismatched types - //~| expected `usize`, found `isize` + //~| NOTE expected `usize`, found `isize` let f = [0_usize; -1_isize]; //~^ ERROR mismatched types - //~| expected `usize`, found `isize` + //~| NOTE expected `usize`, found `isize` let f = [0; 4u8]; //~^ ERROR mismatched types - //~| expected `usize`, found `u8` + //~| NOTE expected `usize`, found `u8` struct G { g: (), } let g = [0; G { g: () }]; //~^ ERROR mismatched types - //~| expected `usize`, found `G` + //~| NOTE expected `usize`, found `G` } diff --git a/tests/ui/repeat-expr/repeat_count.stderr b/tests/ui/repeat-expr/repeat_count.stderr index 34e29e83666..cf94ad41ee3 100644 --- a/tests/ui/repeat-expr/repeat_count.stderr +++ b/tests/ui/repeat-expr/repeat_count.stderr @@ -1,5 +1,5 @@ error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/repeat_count.rs:5:17 + --> $DIR/repeat_count.rs:7:17 | LL | let a = [0; n]; | ^ non-constant value @@ -11,37 +11,37 @@ LL + const n: /* Type */ = 1; | error[E0308]: mismatched types - --> $DIR/repeat_count.rs:7:17 + --> $DIR/repeat_count.rs:9:17 | LL | let b = [0; ()]; | ^^ expected `usize`, found `()` error[E0308]: mismatched types - --> $DIR/repeat_count.rs:31:17 + --> $DIR/repeat_count.rs:33:17 | LL | let g = [0; G { g: () }]; | ^^^^^^^^^^^ expected `usize`, found `G` error[E0308]: mismatched types - --> $DIR/repeat_count.rs:10:17 + --> $DIR/repeat_count.rs:12:17 | LL | let c = [0; true]; | ^^^^ expected `usize`, found `bool` error[E0308]: mismatched types - --> $DIR/repeat_count.rs:13:17 + --> $DIR/repeat_count.rs:15:17 | LL | let d = [0; 0.5]; | ^^^ expected `usize`, found floating-point number error[E0308]: mismatched types - --> $DIR/repeat_count.rs:16:17 + --> $DIR/repeat_count.rs:18:17 | LL | let e = [0; "foo"]; | ^^^^^ expected `usize`, found `&str` error[E0308]: mismatched types - --> $DIR/repeat_count.rs:19:17 + --> $DIR/repeat_count.rs:21:17 | LL | let f = [0; -4_isize]; | ^^^^^^^^ expected `usize`, found `isize` @@ -49,7 +49,7 @@ LL | let f = [0; -4_isize]; = note: `-4_isize` cannot fit into type `usize` error[E0308]: mismatched types - --> $DIR/repeat_count.rs:22:23 + --> $DIR/repeat_count.rs:24:23 | LL | let f = [0_usize; -1_isize]; | ^^^^^^^^ expected `usize`, found `isize` @@ -57,7 +57,7 @@ LL | let f = [0_usize; -1_isize]; = note: `-1_isize` cannot fit into type `usize` error[E0308]: mismatched types - --> $DIR/repeat_count.rs:25:17 + --> $DIR/repeat_count.rs:27:17 | LL | let f = [0; 4u8]; | ^^^ expected `usize`, found `u8` diff --git a/tests/ui/capture1.rs b/tests/ui/resolve/fn-item-cant-capture-dynamic-env.rs index 4f8c04e3fa9..4f8c04e3fa9 100644 --- a/tests/ui/capture1.rs +++ b/tests/ui/resolve/fn-item-cant-capture-dynamic-env.rs diff --git a/tests/ui/capture1.stderr b/tests/ui/resolve/fn-item-cant-capture-dynamic-env.stderr index 8027430de52..6b3e8792011 100644 --- a/tests/ui/capture1.stderr +++ b/tests/ui/resolve/fn-item-cant-capture-dynamic-env.stderr @@ -1,5 +1,5 @@ error[E0434]: can't capture dynamic environment in a fn item - --> $DIR/capture1.rs:3:32 + --> $DIR/fn-item-cant-capture-dynamic-env.rs:3:32 | LL | fn foo() -> isize { return bar; } | ^^^ diff --git a/tests/ui/resolve/issue-23716.rs b/tests/ui/resolve/issue-23716.rs index e9139c0aa14..61b42e29f10 100644 --- a/tests/ui/resolve/issue-23716.rs +++ b/tests/ui/resolve/issue-23716.rs @@ -1,8 +1,10 @@ +//@ dont-require-annotations: NOTE + static foo: i32 = 0; fn bar(foo: i32) {} //~^ ERROR function parameters cannot shadow statics -//~| cannot be named the same as a static +//~| NOTE cannot be named the same as a static mod submod { pub static answer: i32 = 42; @@ -12,6 +14,6 @@ use self::submod::answer; fn question(answer: i32) {} //~^ ERROR function parameters cannot shadow statics -//~| cannot be named the same as a static +//~| NOTE cannot be named the same as a static fn main() { } diff --git a/tests/ui/resolve/issue-23716.stderr b/tests/ui/resolve/issue-23716.stderr index 8b89c350c84..23650c48ac4 100644 --- a/tests/ui/resolve/issue-23716.stderr +++ b/tests/ui/resolve/issue-23716.stderr @@ -1,5 +1,5 @@ error[E0530]: function parameters cannot shadow statics - --> $DIR/issue-23716.rs:3:8 + --> $DIR/issue-23716.rs:5:8 | LL | static foo: i32 = 0; | -------------------- the static `foo` is defined here @@ -8,7 +8,7 @@ LL | fn bar(foo: i32) {} | ^^^ cannot be named the same as a static error[E0530]: function parameters cannot shadow statics - --> $DIR/issue-23716.rs:13:13 + --> $DIR/issue-23716.rs:15:13 | LL | use self::submod::answer; | -------------------- the static `answer` is imported here diff --git a/tests/ui/resolve/issue-5035.rs b/tests/ui/resolve/issue-5035.rs index 49fa312f9d2..82c4bc0d5ef 100644 --- a/tests/ui/resolve/issue-5035.rs +++ b/tests/ui/resolve/issue-5035.rs @@ -1,9 +1,11 @@ +//@ dont-require-annotations: NOTE + trait I {} type K = dyn I; impl K for isize {} //~ ERROR expected trait, found type alias `K` use ImportError; //~ ERROR unresolved import `ImportError` [E0432] - //~^ no `ImportError` in the root + //~^ NOTE no `ImportError` in the root impl ImportError for () {} // check that this is not an additional error (cf. issue #35142) fn main() {} diff --git a/tests/ui/resolve/issue-5035.stderr b/tests/ui/resolve/issue-5035.stderr index b249aaa4b28..f5717438fc8 100644 --- a/tests/ui/resolve/issue-5035.stderr +++ b/tests/ui/resolve/issue-5035.stderr @@ -1,11 +1,11 @@ error[E0432]: unresolved import `ImportError` - --> $DIR/issue-5035.rs:5:5 + --> $DIR/issue-5035.rs:7:5 | LL | use ImportError; | ^^^^^^^^^^^ no `ImportError` in the root error[E0404]: expected trait, found type alias `K` - --> $DIR/issue-5035.rs:3:6 + --> $DIR/issue-5035.rs:5:6 | LL | trait I {} | ------- similarly named trait `I` defined here diff --git a/tests/ui/resolve/resolve-conflict-item-vs-import.rs b/tests/ui/resolve/resolve-conflict-item-vs-import.rs index 4308c7a2750..830f02cdcbe 100644 --- a/tests/ui/resolve/resolve-conflict-item-vs-import.rs +++ b/tests/ui/resolve/resolve-conflict-item-vs-import.rs @@ -1,8 +1,8 @@ -use std::mem::transmute; +use std::mem::transmute; //~ NOTE previous import of the value `transmute` here fn transmute() {} //~^ ERROR the name `transmute` is defined multiple times -//~| `transmute` redefined here -//~| `transmute` must be defined only once in the value namespace of this module +//~| NOTE `transmute` redefined here +//~| NOTE `transmute` must be defined only once in the value namespace of this module fn main() { } diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.rs index 69a283c3163..167f90b28d5 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.rs @@ -1,22 +1,24 @@ +//@ dont-require-annotations: NOTE + #![deny(unreachable_patterns)] #[non_exhaustive] pub enum NonExhaustiveEnum { Unit, - //~^ not covered + //~^ NOTE not covered Tuple(u32), - //~^ not covered + //~^ NOTE not covered Struct { field: u32 } - //~^ not covered + //~^ NOTE not covered } pub enum NormalEnum { Unit, - //~^ not covered + //~^ NOTE not covered Tuple(u32), - //~^ not covered + //~^ NOTE not covered Struct { field: u32 } - //~^ not covered + //~^ NOTE not covered } #[non_exhaustive] diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr index 100e0a501e0..2112344fe6e 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr @@ -1,5 +1,5 @@ error: unreachable pattern - --> $DIR/enum_same_crate_empty_match.rs:28:9 + --> $DIR/enum_same_crate_empty_match.rs:30:9 | LL | _ => {} | ^------ @@ -9,19 +9,19 @@ LL | _ => {} | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types note: the lint level is defined here - --> $DIR/enum_same_crate_empty_match.rs:1:9 + --> $DIR/enum_same_crate_empty_match.rs:3:9 | LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ error[E0004]: non-exhaustive patterns: `NonExhaustiveEnum::Unit`, `NonExhaustiveEnum::Tuple(_)` and `NonExhaustiveEnum::Struct { .. }` not covered - --> $DIR/enum_same_crate_empty_match.rs:33:11 + --> $DIR/enum_same_crate_empty_match.rs:35:11 | LL | match NonExhaustiveEnum::Unit {} | ^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonExhaustiveEnum::Unit`, `NonExhaustiveEnum::Tuple(_)` and `NonExhaustiveEnum::Struct { .. }` not covered | note: `NonExhaustiveEnum` defined here - --> $DIR/enum_same_crate_empty_match.rs:4:10 + --> $DIR/enum_same_crate_empty_match.rs:6:10 | LL | pub enum NonExhaustiveEnum { | ^^^^^^^^^^^^^^^^^ @@ -42,13 +42,13 @@ LL ~ } | error[E0004]: non-exhaustive patterns: `NormalEnum::Unit`, `NormalEnum::Tuple(_)` and `NormalEnum::Struct { .. }` not covered - --> $DIR/enum_same_crate_empty_match.rs:35:11 + --> $DIR/enum_same_crate_empty_match.rs:37:11 | LL | match NormalEnum::Unit {} | ^^^^^^^^^^^^^^^^ patterns `NormalEnum::Unit`, `NormalEnum::Tuple(_)` and `NormalEnum::Struct { .. }` not covered | note: `NormalEnum` defined here - --> $DIR/enum_same_crate_empty_match.rs:13:10 + --> $DIR/enum_same_crate_empty_match.rs:15:10 | LL | pub enum NormalEnum { | ^^^^^^^^^^ diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.rs index ba800e315b1..1e746fdbbea 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.rs @@ -1,5 +1,7 @@ // Test that the `non_exhaustive_omitted_patterns` lint is triggered correctly. +//@ dont-require-annotations: NOTE + #![feature(non_exhaustive_omitted_patterns_lint, unstable_test_feature)] #![deny(unreachable_patterns)] @@ -231,7 +233,7 @@ fn main() { // Check that matching on a reference results in a correct diagnostic match &non_enum { //~^ ERROR some variants are not matched explicitly - //~| pattern `&NonExhaustiveEnum::Struct { .. }` not covered + //~| NOTE pattern `&NonExhaustiveEnum::Struct { .. }` not covered NonExhaustiveEnum::Unit => {} NonExhaustiveEnum::Tuple(_) => {} _ => {} @@ -239,21 +241,21 @@ fn main() { match (true, &non_enum) { //~^ ERROR some variants are not matched explicitly - //~| patterns `(_, &NonExhaustiveEnum::Tuple(_))` and `(_, &NonExhaustiveEnum::Struct { .. })` not covered + //~| NOTE patterns `(_, &NonExhaustiveEnum::Tuple(_))` and `(_, &NonExhaustiveEnum::Struct { .. })` not covered (true, NonExhaustiveEnum::Unit) => {} _ => {} } match (&non_enum, true) { //~^ ERROR some variants are not matched explicitly - //~| patterns `(&NonExhaustiveEnum::Tuple(_), _)` and `(&NonExhaustiveEnum::Struct { .. }, _)` not covered + //~| NOTE patterns `(&NonExhaustiveEnum::Tuple(_), _)` and `(&NonExhaustiveEnum::Struct { .. }, _)` not covered (NonExhaustiveEnum::Unit, true) => {} _ => {} } match Some(&non_enum) { //~^ ERROR some variants are not matched explicitly - //~| pattern `Some(&NonExhaustiveEnum::Struct { .. })` not covered + //~| NOTE pattern `Some(&NonExhaustiveEnum::Struct { .. })` not covered Some(NonExhaustiveEnum::Unit | NonExhaustiveEnum::Tuple(_)) => {} _ => {} } diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.stderr index f89ae241f44..c2c9ac15ab2 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.stderr +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.stderr @@ -1,5 +1,5 @@ error: some fields are not explicitly listed - --> $DIR/omitted-patterns.rs:139:9 + --> $DIR/omitted-patterns.rs:141:9 | LL | VariantNonExhaustive::Bar { x, .. } => {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `y` not listed @@ -7,13 +7,13 @@ LL | VariantNonExhaustive::Bar { x, .. } => {} = help: ensure that all fields are mentioned explicitly by adding the suggested fields = note: the pattern is of type `VariantNonExhaustive` and the `non_exhaustive_omitted_patterns` attribute was found note: the lint level is defined here - --> $DIR/omitted-patterns.rs:45:8 + --> $DIR/omitted-patterns.rs:47:8 | LL | #[deny(non_exhaustive_omitted_patterns)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: some fields are not explicitly listed - --> $DIR/omitted-patterns.rs:143:9 + --> $DIR/omitted-patterns.rs:145:9 | LL | let FunctionalRecord { first_field, second_field, .. } = FunctionalRecord::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `third_field` not listed @@ -22,7 +22,7 @@ LL | let FunctionalRecord { first_field, second_field, .. } = FunctionalReco = note: the pattern is of type `FunctionalRecord` and the `non_exhaustive_omitted_patterns` attribute was found error: some fields are not explicitly listed - --> $DIR/omitted-patterns.rs:149:29 + --> $DIR/omitted-patterns.rs:151:29 | LL | let NestedStruct { bar: NormalStruct { first_field, .. }, .. } = NestedStruct::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `second_field` not listed @@ -31,7 +31,7 @@ LL | let NestedStruct { bar: NormalStruct { first_field, .. }, .. } = Nested = note: the pattern is of type `NormalStruct` and the `non_exhaustive_omitted_patterns` attribute was found error: some fields are not explicitly listed - --> $DIR/omitted-patterns.rs:149:9 + --> $DIR/omitted-patterns.rs:151:9 | LL | let NestedStruct { bar: NormalStruct { first_field, .. }, .. } = NestedStruct::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `foo` not listed @@ -40,7 +40,7 @@ LL | let NestedStruct { bar: NormalStruct { first_field, .. }, .. } = Nested = note: the pattern is of type `NestedStruct` and the `non_exhaustive_omitted_patterns` attribute was found error: some fields are not explicitly listed - --> $DIR/omitted-patterns.rs:212:9 + --> $DIR/omitted-patterns.rs:214:9 | LL | let OnlyUnstableStruct { unstable, .. } = OnlyUnstableStruct::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `unstable2` not listed @@ -49,7 +49,7 @@ LL | let OnlyUnstableStruct { unstable, .. } = OnlyUnstableStruct::new(); = note: the pattern is of type `OnlyUnstableStruct` and the `non_exhaustive_omitted_patterns` attribute was found error: some fields are not explicitly listed - --> $DIR/omitted-patterns.rs:218:9 + --> $DIR/omitted-patterns.rs:220:9 | LL | let UnstableStruct { stable, stable2, .. } = UnstableStruct::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `unstable` not listed @@ -58,7 +58,7 @@ LL | let UnstableStruct { stable, stable2, .. } = UnstableStruct::default(); = note: the pattern is of type `UnstableStruct` and the `non_exhaustive_omitted_patterns` attribute was found error: some variants are not matched explicitly - --> $DIR/omitted-patterns.rs:65:11 + --> $DIR/omitted-patterns.rs:67:11 | LL | match non_enum { | ^^^^^^^^ pattern `NonExhaustiveEnum::Struct { .. }` not covered @@ -67,7 +67,7 @@ LL | match non_enum { = note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found error: some variants are not matched explicitly - --> $DIR/omitted-patterns.rs:72:11 + --> $DIR/omitted-patterns.rs:74:11 | LL | match non_enum { | ^^^^^^^^ pattern `NonExhaustiveEnum::Tuple(_)` not covered @@ -76,7 +76,7 @@ LL | match non_enum { = note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found error: some variants are not matched explicitly - --> $DIR/omitted-patterns.rs:93:11 + --> $DIR/omitted-patterns.rs:95:11 | LL | match (non_enum, true) { | ^^^^^^^^^^^^^^^^ pattern `(NonExhaustiveEnum::Struct { .. }, _)` not covered @@ -85,7 +85,7 @@ LL | match (non_enum, true) { = note: the matched value is of type `(NonExhaustiveEnum, bool)` and the `non_exhaustive_omitted_patterns` attribute was found error: some variants are not matched explicitly - --> $DIR/omitted-patterns.rs:106:11 + --> $DIR/omitted-patterns.rs:108:11 | LL | match (true, non_enum) { | ^^^^^^^^^^^^^^^^ pattern `(_, NonExhaustiveEnum::Struct { .. })` not covered @@ -94,7 +94,7 @@ LL | match (true, non_enum) { = note: the matched value is of type `(bool, NonExhaustiveEnum)` and the `non_exhaustive_omitted_patterns` attribute was found error: some variants are not matched explicitly - --> $DIR/omitted-patterns.rs:113:11 + --> $DIR/omitted-patterns.rs:115:11 | LL | match Some(non_enum) { | ^^^^^^^^^^^^^^ pattern `Some(NonExhaustiveEnum::Struct { .. })` not covered @@ -103,7 +103,7 @@ LL | match Some(non_enum) { = note: the matched value is of type `Option<NonExhaustiveEnum>` and the `non_exhaustive_omitted_patterns` attribute was found error: some variants are not matched explicitly - --> $DIR/omitted-patterns.rs:129:11 + --> $DIR/omitted-patterns.rs:131:11 | LL | match NestedNonExhaustive::B { | ^^^^^^^^^^^^^^^^^^^^^^ patterns `NestedNonExhaustive::C`, `NestedNonExhaustive::A(NonExhaustiveEnum::Tuple(_))` and `NestedNonExhaustive::A(NonExhaustiveEnum::Struct { .. })` not covered @@ -112,7 +112,7 @@ LL | match NestedNonExhaustive::B { = note: the matched value is of type `NestedNonExhaustive` and the `non_exhaustive_omitted_patterns` attribute was found error: some variants are not matched explicitly - --> $DIR/omitted-patterns.rs:184:11 + --> $DIR/omitted-patterns.rs:186:11 | LL | match UnstableEnum::Stable { | ^^^^^^^^^^^^^^^^^^^^ pattern `UnstableEnum::Unstable` not covered @@ -121,7 +121,7 @@ LL | match UnstableEnum::Stable { = note: the matched value is of type `UnstableEnum` and the `non_exhaustive_omitted_patterns` attribute was found error: some variants are not matched explicitly - --> $DIR/omitted-patterns.rs:206:11 + --> $DIR/omitted-patterns.rs:208:11 | LL | match OnlyUnstableEnum::Unstable { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `OnlyUnstableEnum::Unstable2` not covered @@ -130,7 +130,7 @@ LL | match OnlyUnstableEnum::Unstable { = note: the matched value is of type `OnlyUnstableEnum` and the `non_exhaustive_omitted_patterns` attribute was found error[E0005]: refutable pattern in local binding - --> $DIR/omitted-patterns.rs:228:9 + --> $DIR/omitted-patterns.rs:230:9 | LL | let local_refutable @ NonExhaustiveEnum::Unit = NonExhaustiveEnum::Unit; | ^^^^^^^^^^^^^^^ pattern `_` not covered @@ -144,7 +144,7 @@ LL | let local_refutable @ NonExhaustiveEnum::Unit = NonExhaustiveEnum::Unit | ++++++++++++++++ error: some variants are not matched explicitly - --> $DIR/omitted-patterns.rs:232:11 + --> $DIR/omitted-patterns.rs:234:11 | LL | match &non_enum { | ^^^^^^^^^ pattern `&NonExhaustiveEnum::Struct { .. }` not covered @@ -153,7 +153,7 @@ LL | match &non_enum { = note: the matched value is of type `&NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found error: some variants are not matched explicitly - --> $DIR/omitted-patterns.rs:240:11 + --> $DIR/omitted-patterns.rs:242:11 | LL | match (true, &non_enum) { | ^^^^^^^^^^^^^^^^^ patterns `(_, &NonExhaustiveEnum::Tuple(_))` and `(_, &NonExhaustiveEnum::Struct { .. })` not covered @@ -162,7 +162,7 @@ LL | match (true, &non_enum) { = note: the matched value is of type `(bool, &NonExhaustiveEnum)` and the `non_exhaustive_omitted_patterns` attribute was found error: some variants are not matched explicitly - --> $DIR/omitted-patterns.rs:247:11 + --> $DIR/omitted-patterns.rs:249:11 | LL | match (&non_enum, true) { | ^^^^^^^^^^^^^^^^^ patterns `(&NonExhaustiveEnum::Tuple(_), _)` and `(&NonExhaustiveEnum::Struct { .. }, _)` not covered @@ -171,7 +171,7 @@ LL | match (&non_enum, true) { = note: the matched value is of type `(&NonExhaustiveEnum, bool)` and the `non_exhaustive_omitted_patterns` attribute was found error: some variants are not matched explicitly - --> $DIR/omitted-patterns.rs:254:11 + --> $DIR/omitted-patterns.rs:256:11 | LL | match Some(&non_enum) { | ^^^^^^^^^^^^^^^ pattern `Some(&NonExhaustiveEnum::Struct { .. })` not covered diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/ast-validate-guards.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/ast-validate-guards.rs index ae13f7c76ba..ed461af66aa 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/ast-validate-guards.rs +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/ast-validate-guards.rs @@ -3,7 +3,7 @@ fn let_or_guard(x: Result<Option<i32>, ()>) { match x { Ok(opt) if let Some(4) = opt || false => {} - //~^ ERROR expected expression, found `let` statement + //~^ ERROR `||` operators are not supported in let chain conditions _ => {} } } diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/ast-validate-guards.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/ast-validate-guards.stderr index 4b85fdd5050..0566d96fddc 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/ast-validate-guards.stderr +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/ast-validate-guards.stderr @@ -1,11 +1,4 @@ -error: expected expression, found `let` statement - --> $DIR/ast-validate-guards.rs:5:20 - | -LL | Ok(opt) if let Some(4) = opt || false => {} - | ^^^^^^^^^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `||` operators are not supported in let chain expressions +error: `||` operators are not supported in let chain conditions --> $DIR/ast-validate-guards.rs:5:38 | LL | Ok(opt) if let Some(4) = opt || false => {} diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.feature.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.feature.stderr index 817e226bc45..141a6d255d0 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.feature.stderr +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.feature.stderr @@ -272,14 +272,7 @@ LL | if (let 0 = 0)? {} | = note: only supported directly in conditions of `if` and `while` expressions -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:121:16 - | -LL | if true || let 0 = 0 {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `||` operators are not supported in let chain expressions +error: `||` operators are not supported in let chain conditions --> $DIR/disallowed-positions.rs:121:13 | LL | if true || let 0 = 0 {} @@ -485,14 +478,7 @@ LL | while (let 0 = 0)? {} | = note: only supported directly in conditions of `if` and `while` expressions -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:212:19 - | -LL | while true || let 0 = 0 {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `||` operators are not supported in let chain expressions +error: `||` operators are not supported in let chain conditions --> $DIR/disallowed-positions.rs:212:16 | LL | while true || let 0 = 0 {} diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.no_feature.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.no_feature.stderr index bab50c22c03..dda09de4c53 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.no_feature.stderr +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.no_feature.stderr @@ -272,14 +272,7 @@ LL | if (let 0 = 0)? {} | = note: only supported directly in conditions of `if` and `while` expressions -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:121:16 - | -LL | if true || let 0 = 0 {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `||` operators are not supported in let chain expressions +error: `||` operators are not supported in let chain conditions --> $DIR/disallowed-positions.rs:121:13 | LL | if true || let 0 = 0 {} @@ -485,14 +478,7 @@ LL | while (let 0 = 0)? {} | = note: only supported directly in conditions of `if` and `while` expressions -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:212:19 - | -LL | while true || let 0 = 0 {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `||` operators are not supported in let chain expressions +error: `||` operators are not supported in let chain conditions --> $DIR/disallowed-positions.rs:212:16 | LL | while true || let 0 = 0 {} diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.nothing.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.nothing.stderr index 943956feb4e..5b53691cbf5 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.nothing.stderr +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.nothing.stderr @@ -272,14 +272,7 @@ LL | if (let 0 = 0)? {} | = note: only supported directly in conditions of `if` and `while` expressions -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:121:16 - | -LL | if true || let 0 = 0 {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `||` operators are not supported in let chain expressions +error: `||` operators are not supported in let chain conditions --> $DIR/disallowed-positions.rs:121:13 | LL | if true || let 0 = 0 {} @@ -485,14 +478,7 @@ LL | while (let 0 = 0)? {} | = note: only supported directly in conditions of `if` and `while` expressions -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:212:19 - | -LL | while true || let 0 = 0 {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `||` operators are not supported in let chain expressions +error: `||` operators are not supported in let chain conditions --> $DIR/disallowed-positions.rs:212:16 | LL | while true || let 0 = 0 {} diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.rs index 0b0abe6ec17..65beccf2214 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.rs +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.rs @@ -119,7 +119,7 @@ fn nested_within_if_expr() { //~^ ERROR expected expression, found `let` statement if true || let 0 = 0 {} - //~^ ERROR expected expression, found `let` statement + //~^ ERROR `||` operators are not supported in let chain conditions if (true || let 0 = 0) {} //~^ ERROR expected expression, found `let` statement if true && (true || let 0 = 0) {} @@ -210,7 +210,7 @@ fn nested_within_while_expr() { //~^ ERROR expected expression, found `let` statement while true || let 0 = 0 {} - //~^ ERROR expected expression, found `let` statement + //~^ ERROR `||` operators are not supported in let chain conditions while (true || let 0 = 0) {} //~^ ERROR expected expression, found `let` statement while true && (true || let 0 = 0) {} diff --git a/tests/ui/rust-2018/auxiliary/dummy-crate.rs b/tests/ui/rust-2018/auxiliary/dummy-crate.rs new file mode 100644 index 00000000000..c9e8881600d --- /dev/null +++ b/tests/ui/rust-2018/auxiliary/dummy-crate.rs @@ -0,0 +1,2 @@ +// intentionally blank, used because we need an extern crate for +// `removing-extern-crate.rs` but don't care about what's in it. diff --git a/tests/ui/removing-extern-crate.fixed b/tests/ui/rust-2018/removing-extern-crate.fixed index 477161fba80..e88a84cc93e 100644 --- a/tests/ui/removing-extern-crate.fixed +++ b/tests/ui/rust-2018/removing-extern-crate.fixed @@ -1,5 +1,5 @@ //@ edition:2018 -//@ aux-build:removing-extern-crate.rs +//@ aux-build:dummy-crate.rs //@ run-rustfix //@ check-pass diff --git a/tests/ui/removing-extern-crate.rs b/tests/ui/rust-2018/removing-extern-crate.rs index 0b819482c71..844377945e0 100644 --- a/tests/ui/removing-extern-crate.rs +++ b/tests/ui/rust-2018/removing-extern-crate.rs @@ -1,15 +1,15 @@ //@ edition:2018 -//@ aux-build:removing-extern-crate.rs +//@ aux-build:dummy-crate.rs //@ run-rustfix //@ check-pass #![warn(rust_2018_idioms)] -extern crate removing_extern_crate as foo; //~ WARNING unused extern crate +extern crate dummy_crate as foo; //~ WARNING unused extern crate extern crate core; //~ WARNING unused extern crate mod another { - extern crate removing_extern_crate as foo; //~ WARNING unused extern crate + extern crate dummy_crate as foo; //~ WARNING unused extern crate extern crate core; //~ WARNING unused extern crate } diff --git a/tests/ui/removing-extern-crate.stderr b/tests/ui/rust-2018/removing-extern-crate.stderr index 4dddf160ce2..57312542640 100644 --- a/tests/ui/removing-extern-crate.stderr +++ b/tests/ui/rust-2018/removing-extern-crate.stderr @@ -1,8 +1,8 @@ warning: unused extern crate --> $DIR/removing-extern-crate.rs:8:1 | -LL | extern crate removing_extern_crate as foo; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it +LL | extern crate dummy_crate as foo; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it | note: the lint level is defined here --> $DIR/removing-extern-crate.rs:6:9 @@ -20,8 +20,8 @@ LL | extern crate core; warning: unused extern crate --> $DIR/removing-extern-crate.rs:12:5 | -LL | extern crate removing_extern_crate as foo; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it +LL | extern crate dummy_crate as foo; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it warning: unused extern crate --> $DIR/removing-extern-crate.rs:13:5 diff --git a/tests/ui/sanitizer/asan_odr_windows.rs b/tests/ui/sanitizer/asan_odr_windows.rs index c618ac02a66..28c24716761 100644 --- a/tests/ui/sanitizer/asan_odr_windows.rs +++ b/tests/ui/sanitizer/asan_odr_windows.rs @@ -5,6 +5,8 @@ //@ compile-flags:-Zsanitizer=address //@ aux-build: asan_odr_win-2.rs //@ only-windows-msvc +//@ needs-sanitizer-support +//@ needs-sanitizer-address extern crate othercrate; diff --git a/tests/ui/simd/const-err-trumps-simd-err.rs b/tests/ui/simd/const-err-trumps-simd-err.rs index fb87fe1cbca..05a224d037a 100644 --- a/tests/ui/simd/const-err-trumps-simd-err.rs +++ b/tests/ui/simd/const-err-trumps-simd-err.rs @@ -1,4 +1,6 @@ //@build-fail +//@ dont-require-annotations: NOTE + //! Make sure that monomorphization-time const errors from `static_assert` take priority over the //! error from simd_extract. Basically this checks that if a const fails to evaluate in some //! function, we don't bother codegen'ing the function. @@ -15,7 +17,7 @@ struct int8x4_t([u8; 4]); fn get_elem<const LANE: u32>(a: int8x4_t) -> u8 { const { assert!(LANE < 4); } // the error should be here... //~^ ERROR failed - //~| assertion failed + //~| NOTE assertion failed unsafe { simd_extract(a, LANE) } // ...not here } diff --git a/tests/ui/simd/const-err-trumps-simd-err.stderr b/tests/ui/simd/const-err-trumps-simd-err.stderr index a0f1c664a4f..389f75492c6 100644 --- a/tests/ui/simd/const-err-trumps-simd-err.stderr +++ b/tests/ui/simd/const-err-trumps-simd-err.stderr @@ -1,17 +1,17 @@ error[E0080]: evaluation of `get_elem::<4>::{constant#0}` failed - --> $DIR/const-err-trumps-simd-err.rs:16:13 + --> $DIR/const-err-trumps-simd-err.rs:18:13 | LL | const { assert!(LANE < 4); } // the error should be here... | ^^^^^^^^^^^^^^^^^ evaluation panicked: assertion failed: LANE < 4 note: erroneous constant encountered - --> $DIR/const-err-trumps-simd-err.rs:16:5 + --> $DIR/const-err-trumps-simd-err.rs:18:5 | LL | const { assert!(LANE < 4); } // the error should be here... | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: the above error was encountered while instantiating `fn get_elem::<4>` - --> $DIR/const-err-trumps-simd-err.rs:23:5 + --> $DIR/const-err-trumps-simd-err.rs:25:5 | LL | get_elem::<4>(int8x4_t([0, 0, 0, 0])); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/simd/intrinsic/generic-comparison-pass.rs b/tests/ui/simd/intrinsic/generic-comparison-pass.rs index 2ee164cdfd8..50a05eecb03 100644 --- a/tests/ui/simd/intrinsic/generic-comparison-pass.rs +++ b/tests/ui/simd/intrinsic/generic-comparison-pass.rs @@ -1,6 +1,6 @@ //@ run-pass -#![feature(repr_simd, core_intrinsics, concat_idents)] +#![feature(repr_simd, core_intrinsics, macro_metavar_expr_concat)] #![allow(non_camel_case_types)] use std::intrinsics::simd::{simd_eq, simd_ge, simd_gt, simd_le, simd_lt, simd_ne}; @@ -19,7 +19,7 @@ macro_rules! cmp { ($method: ident($lhs: expr, $rhs: expr)) => {{ let lhs = $lhs; let rhs = $rhs; - let e: u32x4 = concat_idents!(simd_, $method)($lhs, $rhs); + let e: u32x4 = ${concat(simd_, $method)}($lhs, $rhs); // assume the scalar version is correct/the behaviour we want. assert!((e.0[0] != 0) == lhs.0[0].$method(&rhs.0[0])); assert!((e.0[1] != 0) == lhs.0[1].$method(&rhs.0[1])); diff --git a/tests/ui/specialization/prefer-specializing-impl-over-default.current.stderr b/tests/ui/specialization/prefer-specializing-impl-over-default.current.stderr new file mode 100644 index 00000000000..7e3df0c83f9 --- /dev/null +++ b/tests/ui/specialization/prefer-specializing-impl-over-default.current.stderr @@ -0,0 +1,12 @@ +warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/prefer-specializing-impl-over-default.rs:5:12 + | +LL | #![feature(specialization)] + | ^^^^^^^^^^^^^^ + | + = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information + = help: consider using `min_specialization` instead, which is more stable and complete + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/specialization/prefer-specializing-impl-over-default.next.stderr b/tests/ui/specialization/prefer-specializing-impl-over-default.next.stderr new file mode 100644 index 00000000000..7e3df0c83f9 --- /dev/null +++ b/tests/ui/specialization/prefer-specializing-impl-over-default.next.stderr @@ -0,0 +1,12 @@ +warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/prefer-specializing-impl-over-default.rs:5:12 + | +LL | #![feature(specialization)] + | ^^^^^^^^^^^^^^ + | + = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information + = help: consider using `min_specialization` instead, which is more stable and complete + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/specialization/prefer-specializing-impl-over-default.rs b/tests/ui/specialization/prefer-specializing-impl-over-default.rs new file mode 100644 index 00000000000..af6837b30ca --- /dev/null +++ b/tests/ui/specialization/prefer-specializing-impl-over-default.rs @@ -0,0 +1,29 @@ +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@ check-pass +#![feature(specialization)] +//~^ WARN the feature `specialization` is incomplete + +trait WithAssoc: 'static { + type Assoc; +} +impl<T: 'static> WithAssoc for (T,) { + type Assoc = (); +} + +struct GenericArray<U: WithAssoc>(U::Assoc); + +trait AbiExample { + fn example(); +} +impl<U: WithAssoc> AbiExample for GenericArray<U> { + fn example() {} +} +impl<T> AbiExample for T { + default fn example() {} +} + +fn main() { + let _ = GenericArray::<((),)>::example(); +} diff --git a/tests/ui/specialization/specialization-default-projection.stderr b/tests/ui/specialization/specialization-default-projection.current.stderr index b8b81876d81..038c379c43e 100644 --- a/tests/ui/specialization/specialization-default-projection.stderr +++ b/tests/ui/specialization/specialization-default-projection.current.stderr @@ -1,5 +1,5 @@ warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/specialization-default-projection.rs:1:12 + --> $DIR/specialization-default-projection.rs:5:12 | LL | #![feature(specialization)] | ^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | #![feature(specialization)] = note: `#[warn(incomplete_features)]` on by default error[E0308]: mismatched types - --> $DIR/specialization-default-projection.rs:21:5 + --> $DIR/specialization-default-projection.rs:25:5 | LL | fn generic<T>() -> <T as Foo>::Assoc { | ----------------- expected `<T as Foo>::Assoc` because of return type @@ -23,7 +23,7 @@ LL | () = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error[E0308]: mismatched types - --> $DIR/specialization-default-projection.rs:28:5 + --> $DIR/specialization-default-projection.rs:32:5 | LL | fn monomorphic() -> () { | -- expected `()` because of return type diff --git a/tests/ui/specialization/specialization-default-projection.next.stderr b/tests/ui/specialization/specialization-default-projection.next.stderr new file mode 100644 index 00000000000..9111f173a9c --- /dev/null +++ b/tests/ui/specialization/specialization-default-projection.next.stderr @@ -0,0 +1,43 @@ +warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/specialization-default-projection.rs:5:12 + | +LL | #![feature(specialization)] + | ^^^^^^^^^^^^^^ + | + = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information + = help: consider using `min_specialization` instead, which is more stable and complete + = note: `#[warn(incomplete_features)]` on by default + +error[E0308]: mismatched types + --> $DIR/specialization-default-projection.rs:25:5 + | +LL | fn generic<T>() -> <T as Foo>::Assoc { + | ----------------- expected `<T as Foo>::Assoc` because of return type +... +LL | () + | ^^ types differ + | + = note: expected associated type `<T as Foo>::Assoc` + found unit type `()` + = help: consider constraining the associated type `<T as Foo>::Assoc` to `()` or calling a method that returns `<T as Foo>::Assoc` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html + +error[E0308]: mismatched types + --> $DIR/specialization-default-projection.rs:32:5 + | +LL | fn monomorphic() -> () { + | -- expected `()` because of return type +... +LL | generic::<()>() + | ^^^^^^^^^^^^^^^- help: consider using a semicolon here: `;` + | | + | types differ + | + = note: expected unit type `()` + found associated type `<() as Foo>::Assoc` + = help: consider constraining the associated type `<() as Foo>::Assoc` to `()` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html + +error: aborting due to 2 previous errors; 1 warning emitted + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/specialization/specialization-default-projection.rs b/tests/ui/specialization/specialization-default-projection.rs index 7f3ae951287..4f69ccb5974 100644 --- a/tests/ui/specialization/specialization-default-projection.rs +++ b/tests/ui/specialization/specialization-default-projection.rs @@ -1,3 +1,7 @@ +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver + #![feature(specialization)] //~ WARN the feature `specialization` is incomplete // Make sure we can't project defaulted associated types diff --git a/tests/ui/specialization/specialization-default-types.stderr b/tests/ui/specialization/specialization-default-types.current.stderr index 774ac953617..67477f9a6d5 100644 --- a/tests/ui/specialization/specialization-default-types.stderr +++ b/tests/ui/specialization/specialization-default-types.current.stderr @@ -1,5 +1,5 @@ warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/specialization-default-types.rs:5:12 + --> $DIR/specialization-default-types.rs:9:12 | LL | #![feature(specialization)] | ^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | #![feature(specialization)] = note: `#[warn(incomplete_features)]` on by default error[E0308]: mismatched types - --> $DIR/specialization-default-types.rs:15:9 + --> $DIR/specialization-default-types.rs:19:9 | LL | default type Output = Box<T>; | ----------------------------- associated type is `default` and may be overridden @@ -22,7 +22,7 @@ LL | Box::new(self) found struct `Box<T>` error[E0308]: mismatched types - --> $DIR/specialization-default-types.rs:25:5 + --> $DIR/specialization-default-types.rs:29:5 | LL | fn trouble<T>(t: T) -> Box<T> { | ------ expected `Box<T>` because of return type diff --git a/tests/ui/specialization/specialization-default-types.next.stderr b/tests/ui/specialization/specialization-default-types.next.stderr new file mode 100644 index 00000000000..4f7c4765446 --- /dev/null +++ b/tests/ui/specialization/specialization-default-types.next.stderr @@ -0,0 +1,39 @@ +warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/specialization-default-types.rs:9:12 + | +LL | #![feature(specialization)] + | ^^^^^^^^^^^^^^ + | + = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information + = help: consider using `min_specialization` instead, which is more stable and complete + = note: `#[warn(incomplete_features)]` on by default + +error[E0308]: mismatched types + --> $DIR/specialization-default-types.rs:19:9 + | +LL | default type Output = Box<T>; + | ----------------------------- associated type is `default` and may be overridden +LL | default fn generate(self) -> Self::Output { + | ------------ expected `<T as Example>::Output` because of return type +LL | Box::new(self) + | ^^^^^^^^^^^^^^ types differ + | + = note: expected associated type `<T as Example>::Output` + found struct `Box<T>` + +error[E0308]: mismatched types + --> $DIR/specialization-default-types.rs:29:5 + | +LL | fn trouble<T>(t: T) -> Box<T> { + | ------ expected `Box<T>` because of return type +LL | Example::generate(t) + | ^^^^^^^^^^^^^^^^^^^^ types differ + | + = note: expected struct `Box<T>` + found associated type `<T as Example>::Output` + = help: consider constraining the associated type `<T as Example>::Output` to `Box<T>` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html + +error: aborting due to 2 previous errors; 1 warning emitted + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/specialization/specialization-default-types.rs b/tests/ui/specialization/specialization-default-types.rs index 346471f11e4..77817abea12 100644 --- a/tests/ui/specialization/specialization-default-types.rs +++ b/tests/ui/specialization/specialization-default-types.rs @@ -1,3 +1,7 @@ +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver + // It should not be possible to use the concrete value of a defaulted // associated type in the impl defining it -- otherwise, what happens // if it's overridden? diff --git a/tests/ui/statics/issue-15261.rs b/tests/ui/statics/issue-15261.rs index ed79a201488..f8c5ebaa548 100644 --- a/tests/ui/statics/issue-15261.rs +++ b/tests/ui/statics/issue-15261.rs @@ -2,10 +2,9 @@ #![allow(dead_code)] #![allow(non_upper_case_globals)] - static mut n_mut: usize = 0; static n: &'static usize = unsafe { &n_mut }; -//~^ WARN shared reference to mutable static is discouraged [static_mut_refs] +//~^ WARN shared reference to mutable static [static_mut_refs] fn main() {} diff --git a/tests/ui/statics/issue-15261.stderr b/tests/ui/statics/issue-15261.stderr index 7e6aebcbb1f..d2dd762aa66 100644 --- a/tests/ui/statics/issue-15261.stderr +++ b/tests/ui/statics/issue-15261.stderr @@ -1,5 +1,5 @@ -warning: creating a shared reference to mutable static is discouraged - --> $DIR/issue-15261.rs:8:37 +warning: creating a shared reference to mutable static + --> $DIR/issue-15261.rs:7:37 | LL | static n: &'static usize = unsafe { &n_mut }; | ^^^^^^ shared reference to mutable static diff --git a/tests/ui/statics/static-mut-shared-parens.rs b/tests/ui/statics/static-mut-shared-parens.rs index 8e58152e27a..7eda7d67d92 100644 --- a/tests/ui/statics/static-mut-shared-parens.rs +++ b/tests/ui/statics/static-mut-shared-parens.rs @@ -1,13 +1,12 @@ //Missing paren in diagnostic msg: https://github.com/rust-lang/rust/issues/131977 //@check-pass - static mut TEST: usize = 0; fn main() { let _ = unsafe { (&TEST) as *const usize }; - //~^WARN creating a shared reference to mutable static is discouraged + //~^WARN creating a shared reference to mutable static - let _ = unsafe { ((&mut TEST)) as *const usize }; - //~^WARN creating a mutable reference to mutable static is discouraged + let _ = unsafe { (&mut TEST) as *const usize }; + //~^WARN creating a mutable reference to mutable static } diff --git a/tests/ui/statics/static-mut-shared-parens.stderr b/tests/ui/statics/static-mut-shared-parens.stderr index 30a586c286a..3825e8efc42 100644 --- a/tests/ui/statics/static-mut-shared-parens.stderr +++ b/tests/ui/statics/static-mut-shared-parens.stderr @@ -1,5 +1,5 @@ -warning: creating a shared reference to mutable static is discouraged - --> $DIR/static-mut-shared-parens.rs:8:22 +warning: creating a shared reference to mutable static + --> $DIR/static-mut-shared-parens.rs:7:22 | LL | let _ = unsafe { (&TEST) as *const usize }; | ^^^^^^^ shared reference to mutable static @@ -12,18 +12,18 @@ help: use `&raw const` instead to create a raw pointer LL | let _ = unsafe { (&raw const TEST) as *const usize }; | +++++++++ -warning: creating a mutable reference to mutable static is discouraged - --> $DIR/static-mut-shared-parens.rs:11:22 +warning: creating a mutable reference to mutable static + --> $DIR/static-mut-shared-parens.rs:10:22 | -LL | let _ = unsafe { ((&mut TEST)) as *const usize }; - | ^^^^^^^^^^^^^ mutable reference to mutable static +LL | let _ = unsafe { (&mut TEST) as *const usize }; + | ^^^^^^^^^^^ mutable reference to mutable static | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html> = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives help: use `&raw mut` instead to create a raw pointer | -LL | let _ = unsafe { ((&raw mut TEST)) as *const usize }; - | +++ +LL | let _ = unsafe { (&raw mut TEST) as *const usize }; + | +++ warning: 2 warnings emitted diff --git a/tests/ui/statics/static-mut-xc.rs b/tests/ui/statics/static-mut-xc.rs index c23cc822ce7..878f5a8e0f7 100644 --- a/tests/ui/statics/static-mut-xc.rs +++ b/tests/ui/statics/static-mut-xc.rs @@ -17,23 +17,23 @@ fn static_bound_set(a: &'static mut isize) { unsafe fn run() { assert_eq!(static_mut_xc::a, 3); - //~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs] + //~^ WARN creating a shared reference to mutable static [static_mut_refs] static_mut_xc::a = 4; assert_eq!(static_mut_xc::a, 4); - //~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs] + //~^ WARN creating a shared reference to mutable static [static_mut_refs] static_mut_xc::a += 1; assert_eq!(static_mut_xc::a, 5); - //~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs] + //~^ WARN creating a shared reference to mutable static [static_mut_refs] static_mut_xc::a *= 3; assert_eq!(static_mut_xc::a, 15); - //~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs] + //~^ WARN creating a shared reference to mutable static [static_mut_refs] static_mut_xc::a = -3; assert_eq!(static_mut_xc::a, -3); - //~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs] + //~^ WARN creating a shared reference to mutable static [static_mut_refs] static_bound(&static_mut_xc::a); - //~^ WARN shared reference to mutable static is discouraged [static_mut_refs] + //~^ WARN shared reference to mutable static [static_mut_refs] static_bound_set(&mut static_mut_xc::a); - //~^ WARN mutable reference to mutable static is discouraged [static_mut_refs] + //~^ WARN mutable reference to mutable static [static_mut_refs] } pub fn main() { diff --git a/tests/ui/statics/static-mut-xc.stderr b/tests/ui/statics/static-mut-xc.stderr index 69f334a5636..2d7a0553e92 100644 --- a/tests/ui/statics/static-mut-xc.stderr +++ b/tests/ui/statics/static-mut-xc.stderr @@ -1,4 +1,4 @@ -warning: creating a shared reference to mutable static is discouraged +warning: creating a shared reference to mutable static --> $DIR/static-mut-xc.rs:19:16 | LL | assert_eq!(static_mut_xc::a, 3); @@ -8,7 +8,7 @@ LL | assert_eq!(static_mut_xc::a, 3); = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives = note: `#[warn(static_mut_refs)]` on by default -warning: creating a shared reference to mutable static is discouraged +warning: creating a shared reference to mutable static --> $DIR/static-mut-xc.rs:22:16 | LL | assert_eq!(static_mut_xc::a, 4); @@ -17,7 +17,7 @@ LL | assert_eq!(static_mut_xc::a, 4); = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html> = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives -warning: creating a shared reference to mutable static is discouraged +warning: creating a shared reference to mutable static --> $DIR/static-mut-xc.rs:25:16 | LL | assert_eq!(static_mut_xc::a, 5); @@ -26,7 +26,7 @@ LL | assert_eq!(static_mut_xc::a, 5); = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html> = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives -warning: creating a shared reference to mutable static is discouraged +warning: creating a shared reference to mutable static --> $DIR/static-mut-xc.rs:28:16 | LL | assert_eq!(static_mut_xc::a, 15); @@ -35,7 +35,7 @@ LL | assert_eq!(static_mut_xc::a, 15); = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html> = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives -warning: creating a shared reference to mutable static is discouraged +warning: creating a shared reference to mutable static --> $DIR/static-mut-xc.rs:31:16 | LL | assert_eq!(static_mut_xc::a, -3); @@ -44,7 +44,7 @@ LL | assert_eq!(static_mut_xc::a, -3); = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html> = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives -warning: creating a shared reference to mutable static is discouraged +warning: creating a shared reference to mutable static --> $DIR/static-mut-xc.rs:33:18 | LL | static_bound(&static_mut_xc::a); @@ -57,7 +57,7 @@ help: use `&raw const` instead to create a raw pointer LL | static_bound(&raw const static_mut_xc::a); | +++++++++ -warning: creating a mutable reference to mutable static is discouraged +warning: creating a mutable reference to mutable static --> $DIR/static-mut-xc.rs:35:22 | LL | static_bound_set(&mut static_mut_xc::a); diff --git a/tests/ui/statics/static-recursive.rs b/tests/ui/statics/static-recursive.rs index da23b54d1fc..dab60dd8641 100644 --- a/tests/ui/statics/static-recursive.rs +++ b/tests/ui/statics/static-recursive.rs @@ -1,7 +1,7 @@ //@ run-pass static mut S: *const u8 = unsafe { &S as *const *const u8 as *const u8 }; -//~^ WARN shared reference to mutable static is discouraged [static_mut_refs] +//~^ WARN shared reference to mutable static [static_mut_refs] struct StaticDoubleLinked { prev: &'static StaticDoubleLinked, @@ -17,7 +17,7 @@ static L3: StaticDoubleLinked = StaticDoubleLinked { prev: &L2, next: &L1, data: pub fn main() { unsafe { assert_eq!(S, *(S as *const *const u8)); - //~^ WARN creating a shared reference to mutable static is discouraged [static_mut_refs] + //~^ WARN creating a shared reference to mutable static [static_mut_refs] } let mut test_vec = Vec::new(); diff --git a/tests/ui/statics/static-recursive.stderr b/tests/ui/statics/static-recursive.stderr index 039934dfc69..252807e2e5d 100644 --- a/tests/ui/statics/static-recursive.stderr +++ b/tests/ui/statics/static-recursive.stderr @@ -1,4 +1,4 @@ -warning: creating a shared reference to mutable static is discouraged +warning: creating a shared reference to mutable static --> $DIR/static-recursive.rs:3:36 | LL | static mut S: *const u8 = unsafe { &S as *const *const u8 as *const u8 }; @@ -12,7 +12,7 @@ help: use `&raw const` instead to create a raw pointer LL | static mut S: *const u8 = unsafe { &raw const S as *const *const u8 as *const u8 }; | +++++++++ -warning: creating a shared reference to mutable static is discouraged +warning: creating a shared reference to mutable static --> $DIR/static-recursive.rs:19:20 | LL | assert_eq!(S, *(S as *const *const u8)); diff --git a/tests/ui/structs/default-field-values/failures.rs b/tests/ui/structs/default-field-values/failures.rs index 4461302e841..dee6566bd0e 100644 --- a/tests/ui/structs/default-field-values/failures.rs +++ b/tests/ui/structs/default-field-values/failures.rs @@ -1,4 +1,6 @@ - #![feature(default_field_values)] +//@ dont-require-annotations: HELP + +#![feature(default_field_values)] #[derive(Debug)] pub struct S; @@ -56,10 +58,10 @@ fn main () { let _ = Bar { bar: S, .. }; // ok let _ = Qux::<4> { .. }; let _ = Rak(..); //~ ERROR E0308 - //~^ you might have meant to use `..` to skip providing + //~^ HELP you might have meant to use `..` to skip providing let _ = Rak(0, ..); //~ ERROR E0061 - //~^ you might have meant to use `..` to skip providing + //~^ HELP you might have meant to use `..` to skip providing let _ = Rak(.., 0); //~ ERROR E0061 - //~^ you might have meant to use `..` to skip providing + //~^ HELP you might have meant to use `..` to skip providing let _ = Rak { .. }; // ok } diff --git a/tests/ui/structs/default-field-values/failures.stderr b/tests/ui/structs/default-field-values/failures.stderr index 21c9bfb44b4..aaa75fd3180 100644 --- a/tests/ui/structs/default-field-values/failures.stderr +++ b/tests/ui/structs/default-field-values/failures.stderr @@ -1,5 +1,5 @@ error: the `#[default]` attribute may only be used on unit enum variants or variants where every field has a default value - --> $DIR/failures.rs:47:5 + --> $DIR/failures.rs:49:5 | LL | Variant {} | ^^^^^^^ @@ -7,13 +7,13 @@ LL | Variant {} = help: consider a manual implementation of `Default` error: default fields are not supported in tuple structs - --> $DIR/failures.rs:26:22 + --> $DIR/failures.rs:28:22 | LL | pub struct Rak(i32 = 42); | ^^ default fields are only supported on structs error[E0277]: the trait bound `S: Default` is not satisfied - --> $DIR/failures.rs:14:5 + --> $DIR/failures.rs:16:5 | LL | #[derive(Debug, Default)] | ------- in this derive macro expansion @@ -28,19 +28,19 @@ LL | pub struct S; | error: missing field `bar` in initializer - --> $DIR/failures.rs:53:19 + --> $DIR/failures.rs:55:19 | LL | let _ = Bar { .. }; | ^ fields that do not have a defaulted value must be provided explicitly error: missing field `bar` in initializer - --> $DIR/failures.rs:54:27 + --> $DIR/failures.rs:56:27 | LL | let _ = Bar { baz: 0, .. }; | ^ fields that do not have a defaulted value must be provided explicitly error[E0308]: mismatched types - --> $DIR/failures.rs:58:17 + --> $DIR/failures.rs:60:17 | LL | let _ = Rak(..); | --- ^^ expected `i32`, found `RangeFull` @@ -48,29 +48,29 @@ LL | let _ = Rak(..); | arguments to this struct are incorrect | note: tuple struct defined here - --> $DIR/failures.rs:26:12 + --> $DIR/failures.rs:28:12 | LL | pub struct Rak(i32 = 42); | ^^^ help: you might have meant to use `..` to skip providing a value for expected fields, but this is only supported on non-tuple struct literals; it is instead interpreted as a `std::ops::RangeFull` literal - --> $DIR/failures.rs:58:17 + --> $DIR/failures.rs:60:17 | LL | let _ = Rak(..); | ^^ error[E0061]: this struct takes 1 argument but 2 arguments were supplied - --> $DIR/failures.rs:60:13 + --> $DIR/failures.rs:62:13 | LL | let _ = Rak(0, ..); | ^^^ -- unexpected argument #2 of type `RangeFull` | help: you might have meant to use `..` to skip providing a value for expected fields, but this is only supported on non-tuple struct literals; it is instead interpreted as a `std::ops::RangeFull` literal - --> $DIR/failures.rs:60:20 + --> $DIR/failures.rs:62:20 | LL | let _ = Rak(0, ..); | ^^ note: tuple struct defined here - --> $DIR/failures.rs:26:12 + --> $DIR/failures.rs:28:12 | LL | pub struct Rak(i32 = 42); | ^^^ @@ -81,18 +81,18 @@ LL + let _ = Rak(0); | error[E0061]: this struct takes 1 argument but 2 arguments were supplied - --> $DIR/failures.rs:62:13 + --> $DIR/failures.rs:64:13 | LL | let _ = Rak(.., 0); | ^^^ -- unexpected argument #1 of type `RangeFull` | help: you might have meant to use `..` to skip providing a value for expected fields, but this is only supported on non-tuple struct literals; it is instead interpreted as a `std::ops::RangeFull` literal - --> $DIR/failures.rs:62:17 + --> $DIR/failures.rs:64:17 | LL | let _ = Rak(.., 0); | ^^ note: tuple struct defined here - --> $DIR/failures.rs:26:12 + --> $DIR/failures.rs:28:12 | LL | pub struct Rak(i32 = 42); | ^^^ diff --git a/tests/ui/structs/structure-constructor-type-mismatch.rs b/tests/ui/structs/structure-constructor-type-mismatch.rs index 21cd9d08b21..495deb01ea9 100644 --- a/tests/ui/structs/structure-constructor-type-mismatch.rs +++ b/tests/ui/structs/structure-constructor-type-mismatch.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + struct Point<T> { x: T, y: T, @@ -16,32 +18,32 @@ fn main() { let pt = PointF { x: 1, //~^ ERROR mismatched types - //~| expected `f32`, found integer + //~| NOTE expected `f32`, found integer y: 2, //~^ ERROR mismatched types - //~| expected `f32`, found integer + //~| NOTE expected `f32`, found integer }; let pt2 = Point::<f32> { x: 3, //~^ ERROR mismatched types - //~| expected `f32`, found integer + //~| NOTE expected `f32`, found integer y: 4, //~^ ERROR mismatched types - //~| expected `f32`, found integer + //~| NOTE expected `f32`, found integer }; let pair = PairF { x: 5, //~^ ERROR mismatched types - //~| expected `f32`, found integer + //~| NOTE expected `f32`, found integer y: 6, }; let pair2 = PairF::<i32> { x: 7, //~^ ERROR mismatched types - //~| expected `f32`, found integer + //~| NOTE expected `f32`, found integer y: 8, }; diff --git a/tests/ui/structs/structure-constructor-type-mismatch.stderr b/tests/ui/structs/structure-constructor-type-mismatch.stderr index 819b65ffb71..70518919daa 100644 --- a/tests/ui/structs/structure-constructor-type-mismatch.stderr +++ b/tests/ui/structs/structure-constructor-type-mismatch.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/structure-constructor-type-mismatch.rs:17:12 + --> $DIR/structure-constructor-type-mismatch.rs:19:12 | LL | x: 1, | ^ expected `f32`, found integer @@ -10,7 +10,7 @@ LL | x: 1.0, | ++ error[E0308]: mismatched types - --> $DIR/structure-constructor-type-mismatch.rs:20:12 + --> $DIR/structure-constructor-type-mismatch.rs:22:12 | LL | y: 2, | ^ expected `f32`, found integer @@ -21,7 +21,7 @@ LL | y: 2.0, | ++ error[E0308]: mismatched types - --> $DIR/structure-constructor-type-mismatch.rs:26:12 + --> $DIR/structure-constructor-type-mismatch.rs:28:12 | LL | x: 3, | ^ expected `f32`, found integer @@ -32,7 +32,7 @@ LL | x: 3.0, | ++ error[E0308]: mismatched types - --> $DIR/structure-constructor-type-mismatch.rs:29:12 + --> $DIR/structure-constructor-type-mismatch.rs:31:12 | LL | y: 4, | ^ expected `f32`, found integer @@ -43,7 +43,7 @@ LL | y: 4.0, | ++ error[E0308]: mismatched types - --> $DIR/structure-constructor-type-mismatch.rs:35:12 + --> $DIR/structure-constructor-type-mismatch.rs:37:12 | LL | x: 5, | ^ expected `f32`, found integer @@ -54,7 +54,7 @@ LL | x: 5.0, | ++ error[E0308]: mismatched types - --> $DIR/structure-constructor-type-mismatch.rs:42:12 + --> $DIR/structure-constructor-type-mismatch.rs:44:12 | LL | x: 7, | ^ expected `f32`, found integer @@ -65,7 +65,7 @@ LL | x: 7.0, | ++ error[E0107]: type alias takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/structure-constructor-type-mismatch.rs:48:15 + --> $DIR/structure-constructor-type-mismatch.rs:50:15 | LL | let pt3 = PointF::<i32> { | ^^^^^^------- help: remove the unnecessary generics @@ -73,13 +73,13 @@ LL | let pt3 = PointF::<i32> { | expected 0 generic arguments | note: type alias defined here, with 0 generic parameters - --> $DIR/structure-constructor-type-mismatch.rs:6:6 + --> $DIR/structure-constructor-type-mismatch.rs:8:6 | LL | type PointF = Point<f32>; | ^^^^^^ error[E0308]: mismatched types - --> $DIR/structure-constructor-type-mismatch.rs:49:12 + --> $DIR/structure-constructor-type-mismatch.rs:51:12 | LL | x: 9, | ^ expected `f32`, found integer @@ -90,7 +90,7 @@ LL | x: 9.0, | ++ error[E0308]: mismatched types - --> $DIR/structure-constructor-type-mismatch.rs:50:12 + --> $DIR/structure-constructor-type-mismatch.rs:52:12 | LL | y: 10, | ^^ expected `f32`, found integer @@ -101,7 +101,7 @@ LL | y: 10.0, | ++ error[E0107]: type alias takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/structure-constructor-type-mismatch.rs:54:9 + --> $DIR/structure-constructor-type-mismatch.rs:56:9 | LL | PointF::<u32> { .. } => {} | ^^^^^^------- help: remove the unnecessary generics @@ -109,13 +109,13 @@ LL | PointF::<u32> { .. } => {} | expected 0 generic arguments | note: type alias defined here, with 0 generic parameters - --> $DIR/structure-constructor-type-mismatch.rs:6:6 + --> $DIR/structure-constructor-type-mismatch.rs:8:6 | LL | type PointF = Point<f32>; | ^^^^^^ error[E0308]: mismatched types - --> $DIR/structure-constructor-type-mismatch.rs:54:9 + --> $DIR/structure-constructor-type-mismatch.rs:56:9 | LL | match (Point { x: 1, y: 2 }) { | ---------------------- this expression has type `Point<{integer}>` @@ -126,7 +126,7 @@ LL | PointF::<u32> { .. } => {} found struct `Point<f32>` error[E0308]: mismatched types - --> $DIR/structure-constructor-type-mismatch.rs:59:9 + --> $DIR/structure-constructor-type-mismatch.rs:61:9 | LL | match (Point { x: 1, y: 2 }) { | ---------------------- this expression has type `Point<{integer}>` @@ -137,7 +137,7 @@ LL | PointF { .. } => {} found struct `Point<f32>` error[E0308]: mismatched types - --> $DIR/structure-constructor-type-mismatch.rs:67:9 + --> $DIR/structure-constructor-type-mismatch.rs:69:9 | LL | match (Pair { x: 1, y: 2 }) { | --------------------- this expression has type `Pair<{integer}, {integer}>` diff --git a/tests/ui/suggestions/argument-list-from-path-sep-error-129273.fixed b/tests/ui/suggestions/argument-list-from-path-sep-error-129273.fixed deleted file mode 100644 index f5dbf0c8b6f..00000000000 --- a/tests/ui/suggestions/argument-list-from-path-sep-error-129273.fixed +++ /dev/null @@ -1,15 +0,0 @@ -//@ run-rustfix - -use std::fmt; - -struct Hello; - -impl fmt::Display for Hello { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { //~ ERROR path separator must be a double colon - write!(f, "hello") - } -} - -fn main() { - let _ = Hello; -} diff --git a/tests/ui/suggestions/argument-list-from-path-sep-error-129273.rs b/tests/ui/suggestions/argument-list-from-path-sep-error-129273.rs deleted file mode 100644 index c41880a26f6..00000000000 --- a/tests/ui/suggestions/argument-list-from-path-sep-error-129273.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ run-rustfix - -use std::fmt; - -struct Hello; - -impl fmt::Display for Hello { - fn fmt(&self, f: &mut fmt:Formatter) -> fmt::Result { //~ ERROR path separator must be a double colon - write!(f, "hello") - } -} - -fn main() { - let _ = Hello; -} diff --git a/tests/ui/suggestions/argument-list-from-path-sep-error-129273.stderr b/tests/ui/suggestions/argument-list-from-path-sep-error-129273.stderr deleted file mode 100644 index 713b071a625..00000000000 --- a/tests/ui/suggestions/argument-list-from-path-sep-error-129273.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error: path separator must be a double colon - --> $DIR/argument-list-from-path-sep-error-129273.rs:8:30 - | -LL | fn fmt(&self, f: &mut fmt:Formatter) -> fmt::Result { - | ^ - | -help: use a double colon instead - | -LL | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - | + - -error: aborting due to 1 previous error - diff --git a/tests/ui/suggestions/const-pat-non-exaustive-let-new-var.rs b/tests/ui/suggestions/const-pat-non-exaustive-let-new-var.rs index 1a440a90cd7..ebe71170807 100644 --- a/tests/ui/suggestions/const-pat-non-exaustive-let-new-var.rs +++ b/tests/ui/suggestions/const-pat-non-exaustive-let-new-var.rs @@ -1,10 +1,12 @@ +//@ dont-require-annotations: NOTE + fn main() { let A = 3; //~^ ERROR refutable pattern in local binding - //~| patterns `i32::MIN..=1_i32` and `3_i32..=i32::MAX` not covered + //~| NOTE patterns `i32::MIN..=1_i32` and `3_i32..=i32::MAX` not covered //~| HELP introduce a variable instead //~| SUGGESTION A_var const A: i32 = 2; - //~^ missing patterns are not covered because `A` is interpreted as a constant pattern, not a new variable + //~^ NOTE missing patterns are not covered because `A` is interpreted as a constant pattern, not a new variable } diff --git a/tests/ui/suggestions/const-pat-non-exaustive-let-new-var.stderr b/tests/ui/suggestions/const-pat-non-exaustive-let-new-var.stderr index 0dc17f2c25c..e670bac2b33 100644 --- a/tests/ui/suggestions/const-pat-non-exaustive-let-new-var.stderr +++ b/tests/ui/suggestions/const-pat-non-exaustive-let-new-var.stderr @@ -1,5 +1,5 @@ error[E0005]: refutable pattern in local binding - --> $DIR/const-pat-non-exaustive-let-new-var.rs:2:9 + --> $DIR/const-pat-non-exaustive-let-new-var.rs:4:9 | LL | let A = 3; | ^ patterns `i32::MIN..=1_i32` and `3_i32..=i32::MAX` not covered diff --git a/tests/ui/suggestions/impl-trait-missing-lifetime-gated.rs b/tests/ui/suggestions/impl-trait-missing-lifetime-gated.rs index 443a7e3835e..f5c3da847c7 100644 --- a/tests/ui/suggestions/impl-trait-missing-lifetime-gated.rs +++ b/tests/ui/suggestions/impl-trait-missing-lifetime-gated.rs @@ -49,6 +49,17 @@ mod alone_in_path { //~| ERROR missing lifetime specifier } +mod alone_in_path2 { + trait Foo<'a> { fn next(&mut self) -> Option<&'a ()>; } + + fn f(_: impl Foo<>) {} + //~^ ERROR anonymous lifetimes in `impl Trait` are unstable + + fn g(mut x: impl Foo<>) -> Option<&()> { x.next() } + //~^ ERROR anonymous lifetimes in `impl Trait` are unstable + //~| ERROR missing lifetime specifier +} + mod in_path { trait Foo<'a, T> { fn next(&mut self) -> Option<&'a T>; } diff --git a/tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr b/tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr index 24013c85c87..92996ca8467 100644 --- a/tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr +++ b/tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr @@ -108,7 +108,28 @@ LL + fn g(mut x: impl Foo) -> Option<()> { x.next() } | error[E0106]: missing lifetime specifier - --> $DIR/impl-trait-missing-lifetime-gated.rs:58:41 + --> $DIR/impl-trait-missing-lifetime-gated.rs:58:39 + | +LL | fn g(mut x: impl Foo<>) -> Option<&()> { x.next() } + | ^ expected named lifetime parameter + | + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from +help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` + | +LL | fn g(mut x: impl Foo<>) -> Option<&'static ()> { x.next() } + | +++++++ +help: consider introducing a named lifetime parameter + | +LL | fn g<'a>(mut x: impl Foo<>) -> Option<&'a ()> { x.next() } + | ++++ ++ +help: alternatively, you might want to return an owned value + | +LL - fn g(mut x: impl Foo<>) -> Option<&()> { x.next() } +LL + fn g(mut x: impl Foo<>) -> Option<()> { x.next() } + | + +error[E0106]: missing lifetime specifier + --> $DIR/impl-trait-missing-lifetime-gated.rs:69:41 | LL | fn g(mut x: impl Foo<()>) -> Option<&()> { x.next() } | ^ expected named lifetime parameter @@ -129,7 +150,7 @@ LL + fn g(mut x: impl Foo<()>) -> Option<()> { x.next() } | warning: elided lifetime has a name - --> $DIR/impl-trait-missing-lifetime-gated.rs:64:57 + --> $DIR/impl-trait-missing-lifetime-gated.rs:75:57 | LL | fn resolved_anonymous<'a, T: 'a>(f: impl Fn(&'a str) -> &T) { | -- lifetime `'a` declared here ^ this elided lifetime gets resolved as `'a` @@ -219,6 +240,32 @@ LL | fn g<'a>(mut x: impl Foo<'a>) -> Option<&()> { x.next() } error[E0658]: anonymous lifetimes in `impl Trait` are unstable --> $DIR/impl-trait-missing-lifetime-gated.rs:55:22 | +LL | fn f(_: impl Foo<>) {} + | ^ expected named lifetime parameter + | + = help: add `#![feature(anonymous_lifetime_in_impl_trait)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date +help: consider introducing a named lifetime parameter + | +LL | fn f<'a>(_: impl Foo<'a>) {} + | ++++ ++ + +error[E0658]: anonymous lifetimes in `impl Trait` are unstable + --> $DIR/impl-trait-missing-lifetime-gated.rs:58:26 + | +LL | fn g(mut x: impl Foo<>) -> Option<&()> { x.next() } + | ^ expected named lifetime parameter + | + = help: add `#![feature(anonymous_lifetime_in_impl_trait)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date +help: consider introducing a named lifetime parameter + | +LL | fn g<'a>(mut x: impl Foo<'a>) -> Option<&()> { x.next() } + | ++++ ++ + +error[E0658]: anonymous lifetimes in `impl Trait` are unstable + --> $DIR/impl-trait-missing-lifetime-gated.rs:66:22 + | LL | fn f(_: impl Foo<()>) {} | ^ expected named lifetime parameter | @@ -230,7 +277,7 @@ LL | fn f<'a>(_: impl Foo<'a, ()>) {} | ++++ +++ error[E0658]: anonymous lifetimes in `impl Trait` are unstable - --> $DIR/impl-trait-missing-lifetime-gated.rs:58:26 + --> $DIR/impl-trait-missing-lifetime-gated.rs:69:26 | LL | fn g(mut x: impl Foo<()>) -> Option<&()> { x.next() } | ^ expected named lifetime parameter @@ -242,7 +289,7 @@ help: consider introducing a named lifetime parameter LL | fn g<'a>(mut x: impl Foo<'a, ()>) -> Option<&()> { x.next() } | ++++ +++ -error: aborting due to 14 previous errors; 1 warning emitted +error: aborting due to 17 previous errors; 1 warning emitted Some errors have detailed explanations: E0106, E0658. For more information about an error, try `rustc --explain E0106`. diff --git a/tests/ui/suggestions/raw-c-string-prefix.rs b/tests/ui/suggestions/raw-c-string-prefix.rs new file mode 100644 index 00000000000..6af72df4024 --- /dev/null +++ b/tests/ui/suggestions/raw-c-string-prefix.rs @@ -0,0 +1,10 @@ +// `rc` and `cr` are easy to confuse; check that we issue a suggestion to help. + +//@ edition:2021 + +fn main() { + rc"abc"; + //~^ ERROR: prefix `rc` is unknown + //~| HELP: use `cr` for a raw C-string + //~| ERROR: expected one of +} diff --git a/tests/ui/suggestions/raw-c-string-prefix.stderr b/tests/ui/suggestions/raw-c-string-prefix.stderr new file mode 100644 index 00000000000..5341e3d04e8 --- /dev/null +++ b/tests/ui/suggestions/raw-c-string-prefix.stderr @@ -0,0 +1,21 @@ +error: prefix `rc` is unknown + --> $DIR/raw-c-string-prefix.rs:6:5 + | +LL | rc"abc"; + | ^^ unknown prefix + | + = note: prefixed identifiers and literals are reserved since Rust 2021 +help: use `cr` for a raw C-string + | +LL - rc"abc"; +LL + cr"abc"; + | + +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `"abc"` + --> $DIR/raw-c-string-prefix.rs:6:7 + | +LL | rc"abc"; + | ^^^^^ expected one of 8 possible tokens + +error: aborting due to 2 previous errors + diff --git a/tests/ui/suggestions/struct-field-type-including-single-colon.rs b/tests/ui/suggestions/struct-field-type-including-single-colon.rs index a3111028895..482641fc7ca 100644 --- a/tests/ui/suggestions/struct-field-type-including-single-colon.rs +++ b/tests/ui/suggestions/struct-field-type-including-single-colon.rs @@ -7,14 +7,14 @@ mod foo { struct Foo { a: foo:A, - //~^ ERROR path separator must be a double colon - //~| ERROR struct `A` is private + //~^ ERROR found single colon in a struct field type path + //~| ERROR expected `,`, or `}`, found `:` } struct Bar { b: foo::bar:B, - //~^ ERROR path separator must be a double colon - //~| ERROR module `bar` is private + //~^ ERROR found single colon in a struct field type path + //~| ERROR expected `,`, or `}`, found `:` } fn main() {} diff --git a/tests/ui/suggestions/struct-field-type-including-single-colon.stderr b/tests/ui/suggestions/struct-field-type-including-single-colon.stderr index b9302b0453d..5ffc5b40849 100644 --- a/tests/ui/suggestions/struct-field-type-including-single-colon.stderr +++ b/tests/ui/suggestions/struct-field-type-including-single-colon.stderr @@ -1,51 +1,40 @@ -error: path separator must be a double colon +error: found single colon in a struct field type path --> $DIR/struct-field-type-including-single-colon.rs:9:11 | LL | a: foo:A, | ^ | -help: use a double colon instead +help: write a path separator here | LL | a: foo::A, | + -error: path separator must be a double colon +error: expected `,`, or `}`, found `:` + --> $DIR/struct-field-type-including-single-colon.rs:9:11 + | +LL | struct Foo { + | --- while parsing this struct +LL | a: foo:A, + | ^ + +error: found single colon in a struct field type path --> $DIR/struct-field-type-including-single-colon.rs:15:16 | LL | b: foo::bar:B, | ^ | -help: use a double colon instead +help: write a path separator here | LL | b: foo::bar::B, | + -error[E0603]: struct `A` is private - --> $DIR/struct-field-type-including-single-colon.rs:9:12 - | -LL | a: foo:A, - | ^ private struct - | -note: the struct `A` is defined here - --> $DIR/struct-field-type-including-single-colon.rs:2:5 - | -LL | struct A; - | ^^^^^^^^^ - -error[E0603]: module `bar` is private - --> $DIR/struct-field-type-including-single-colon.rs:15:13 +error: expected `,`, or `}`, found `:` + --> $DIR/struct-field-type-including-single-colon.rs:15:16 | +LL | struct Bar { + | --- while parsing this struct LL | b: foo::bar:B, - | ^^^ - struct `B` is not publicly re-exported - | | - | private module - | -note: the module `bar` is defined here - --> $DIR/struct-field-type-including-single-colon.rs:3:5 - | -LL | mod bar { - | ^^^^^^^ + | ^ error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0603`. diff --git a/tests/ui/syntax-extension-minor.rs b/tests/ui/syntax-extension-minor.rs index cdd572b50fc..826990a89a5 100644 --- a/tests/ui/syntax-extension-minor.rs +++ b/tests/ui/syntax-extension-minor.rs @@ -1,6 +1,7 @@ //@ run-pass #![feature(concat_idents)] +#![expect(deprecated)] // concat_idents is deprecated pub fn main() { struct Foo; diff --git a/tests/ui/target-feature/abi-incompatible-target-feature-attribute.riscv.stderr b/tests/ui/target-feature/abi-incompatible-target-feature-attribute.riscv.stderr new file mode 100644 index 00000000000..49c5479275f --- /dev/null +++ b/tests/ui/target-feature/abi-incompatible-target-feature-attribute.riscv.stderr @@ -0,0 +1,8 @@ +error: target feature `d` cannot be enabled with `#[target_feature]`: this feature is incompatible with the target ABI + --> $DIR/abi-incompatible-target-feature-attribute.rs:15:90 + | +LL | #[cfg_attr(x86, target_feature(enable = "soft-float"))] #[cfg_attr(riscv, target_feature(enable = "d"))] + | ^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/target-feature/abi-incompatible-target-feature-attribute.rs b/tests/ui/target-feature/abi-incompatible-target-feature-attribute.rs new file mode 100644 index 00000000000..a8733440759 --- /dev/null +++ b/tests/ui/target-feature/abi-incompatible-target-feature-attribute.rs @@ -0,0 +1,17 @@ +//! Ensure ABI-incompatible features cannot be enabled via `#[target_feature]`. +// ignore-tidy-linelength +//@ compile-flags: --crate-type=lib +//@ revisions: x86 riscv +//@[x86] compile-flags: --target=x86_64-unknown-linux-gnu +//@[x86] needs-llvm-components: x86 +//@[riscv] compile-flags: --target=riscv32e-unknown-none-elf +//@[riscv] needs-llvm-components: riscv +#![feature(no_core, lang_items, riscv_target_feature, x87_target_feature)] +#![no_core] + +#[lang = "sized"] +pub trait Sized {} + +#[cfg_attr(x86, target_feature(enable = "soft-float"))] #[cfg_attr(riscv, target_feature(enable = "d"))] +//~^ERROR: cannot be enabled with +pub unsafe fn my_fun() {} diff --git a/tests/ui/target-feature/abi-incompatible-target-feature-attribute.x86.stderr b/tests/ui/target-feature/abi-incompatible-target-feature-attribute.x86.stderr new file mode 100644 index 00000000000..81471fd7e30 --- /dev/null +++ b/tests/ui/target-feature/abi-incompatible-target-feature-attribute.x86.stderr @@ -0,0 +1,8 @@ +error: target feature `soft-float` cannot be enabled with `#[target_feature]`: this feature is incompatible with the target ABI + --> $DIR/abi-incompatible-target-feature-attribute.rs:15:32 + | +LL | #[cfg_attr(x86, target_feature(enable = "soft-float"))] #[cfg_attr(riscv, target_feature(enable = "d"))] + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.riscv.stderr b/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.riscv.stderr new file mode 100644 index 00000000000..2dca0c22033 --- /dev/null +++ b/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.riscv.stderr @@ -0,0 +1,19 @@ +warning: target feature `d` must be disabled to ensure that the ABI of the current target can be implemented correctly + | + = note: 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 #116344 <https://github.com/rust-lang/rust/issues/116344> + +warning: unstable feature specified for `-Ctarget-feature`: `d` + | + = note: this feature is not stably supported; its behavior can change in the future + +warning: unstable feature specified for `-Ctarget-feature`: `f` + | + = note: this feature is not stably supported; its behavior can change in the future + +warning: unstable feature specified for `-Ctarget-feature`: `zicsr` + | + = note: this feature is not stably supported; its behavior can change in the future + +warning: 4 warnings emitted + diff --git a/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.rs b/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.rs new file mode 100644 index 00000000000..68e1d3b9ddc --- /dev/null +++ b/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.rs @@ -0,0 +1,22 @@ +//! Ensure ABI-incompatible features cannot be enabled via `-Ctarget-feature`. +// These are just warnings for now. +//@ check-pass +//@ compile-flags: --crate-type=lib +//@ revisions: x86 riscv +//@[x86] compile-flags: --target=x86_64-unknown-linux-gnu -Ctarget-feature=+soft-float +//@[x86] needs-llvm-components: x86 +//@[riscv] compile-flags: --target=riscv32e-unknown-none-elf -Ctarget-feature=+d +//@[riscv] needs-llvm-components: riscv + +#![feature(no_core, lang_items, riscv_target_feature)] +#![no_core] + +#[lang = "sized"] +pub trait Sized {} +#[lang = "freeze"] +pub trait Freeze {} + +//~? WARN must be disabled to ensure that the ABI of the current target can be implemented correctly +//~? WARN unstable feature specified for `-Ctarget-feature` +//[riscv]~? WARN unstable feature specified for `-Ctarget-feature` +//[riscv]~? WARN unstable feature specified for `-Ctarget-feature` diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag.stderr b/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.x86.stderr index e49672f33b9..e49672f33b9 100644 --- a/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag.stderr +++ b/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.x86.stderr diff --git a/tests/ui/target-feature/allowed-softfloat-target-feature-flag-disable.rs b/tests/ui/target-feature/abi-irrelevant-target-feature-flag-disable.rs index 7368ef120fa..0013d033b9c 100644 --- a/tests/ui/target-feature/allowed-softfloat-target-feature-flag-disable.rs +++ b/tests/ui/target-feature/abi-irrelevant-target-feature-flag-disable.rs @@ -1,3 +1,6 @@ +//! `x87` is a required target feature on some x86 targets, but not on this one as this one +//! uses soft-floats. So ensure disabling the target feature here (which is a NOP) does +//! not trigger a warning. //@ compile-flags: --target=x86_64-unknown-none --crate-type=lib //@ needs-llvm-components: x86 //@ compile-flags: -Ctarget-feature=-x87 diff --git a/tests/ui/target-feature/allowed-softfloat-target-feature-flag-disable.stderr b/tests/ui/target-feature/abi-irrelevant-target-feature-flag-disable.stderr index 309b64afd92..309b64afd92 100644 --- a/tests/ui/target-feature/allowed-softfloat-target-feature-flag-disable.stderr +++ b/tests/ui/target-feature/abi-irrelevant-target-feature-flag-disable.stderr diff --git a/tests/ui/target-feature/allowed-softfloat-target-feature-attribute.rs b/tests/ui/target-feature/abi-required-target-feature-attribute.rs index 8b60820cc9b..95723c57f94 100644 --- a/tests/ui/target-feature/allowed-softfloat-target-feature-attribute.rs +++ b/tests/ui/target-feature/abi-required-target-feature-attribute.rs @@ -1,3 +1,5 @@ +//! Enabling a target feature that is anyway required changes nothing, so this is allowed +//! for `#[target_feature]`. //@ compile-flags: --target=x86_64-unknown-none --crate-type=lib //@ needs-llvm-components: x86 //@ build-pass diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable-neon.stderr b/tests/ui/target-feature/abi-required-target-feature-flag-disable.aarch64.stderr index b1186d5d5dc..b1186d5d5dc 100644 --- a/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable-neon.stderr +++ b/tests/ui/target-feature/abi-required-target-feature-flag-disable.aarch64.stderr diff --git a/tests/ui/target-feature/abi-required-target-feature-flag-disable.loongarch.stderr b/tests/ui/target-feature/abi-required-target-feature-flag-disable.loongarch.stderr new file mode 100644 index 00000000000..35102e0571f --- /dev/null +++ b/tests/ui/target-feature/abi-required-target-feature-flag-disable.loongarch.stderr @@ -0,0 +1,11 @@ +warning: target feature `d` must be enabled to ensure that the ABI of the current target can be implemented correctly + | + = note: 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 #116344 <https://github.com/rust-lang/rust/issues/116344> + +warning: unstable feature specified for `-Ctarget-feature`: `d` + | + = note: this feature is not stably supported; its behavior can change in the future + +warning: 2 warnings emitted + diff --git a/tests/ui/target-feature/abi-required-target-feature-flag-disable.riscv.stderr b/tests/ui/target-feature/abi-required-target-feature-flag-disable.riscv.stderr new file mode 100644 index 00000000000..35102e0571f --- /dev/null +++ b/tests/ui/target-feature/abi-required-target-feature-flag-disable.riscv.stderr @@ -0,0 +1,11 @@ +warning: target feature `d` must be enabled to ensure that the ABI of the current target can be implemented correctly + | + = note: 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 #116344 <https://github.com/rust-lang/rust/issues/116344> + +warning: unstable feature specified for `-Ctarget-feature`: `d` + | + = note: this feature is not stably supported; its behavior can change in the future + +warning: 2 warnings emitted + diff --git a/tests/ui/target-feature/abi-required-target-feature-flag-disable.rs b/tests/ui/target-feature/abi-required-target-feature-flag-disable.rs new file mode 100644 index 00000000000..c3ce05baa64 --- /dev/null +++ b/tests/ui/target-feature/abi-required-target-feature-flag-disable.rs @@ -0,0 +1,27 @@ +//! Ensure ABI-required features cannot be disabled via `-Ctarget-feature`. +//! Also covers the case of a feature indirectly disabling another via feature implications. +//@ compile-flags: --crate-type=lib +//@ revisions: x86 x86-implied aarch64 riscv loongarch +//@[x86] compile-flags: --target=x86_64-unknown-linux-gnu -Ctarget-feature=-x87 +//@[x86] needs-llvm-components: x86 +//@[x86-implied] compile-flags: --target=x86_64-unknown-linux-gnu -Ctarget-feature=-sse +//@[x86-implied] needs-llvm-components: x86 +//@[aarch64] compile-flags: --target=aarch64-unknown-linux-gnu -Ctarget-feature=-neon +//@[aarch64] needs-llvm-components: aarch64 +//@[riscv] compile-flags: --target=riscv64gc-unknown-none-elf -Ctarget-feature=-d +//@[riscv] needs-llvm-components: riscv +//@[loongarch] compile-flags: --target=loongarch64-unknown-none -Ctarget-feature=-d +//@[loongarch] needs-llvm-components: loongarch +// For now this is just a warning. +//@ build-pass +// Remove some LLVM warnings that only show up sometimes. +//@ normalize-stderr: "\n[^\n]*(target-abi|lp64f)[^\n]*" -> "" + +#![feature(no_core, lang_items)] +#![no_core] + +#[lang = "sized"] +pub trait Sized {} + +//~? WARN must be enabled to ensure that the ABI of the current target can be implemented correctly +//[x86,riscv,loongarch]~? WARN unstable feature specified for `-Ctarget-feature` diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable-implied.stderr b/tests/ui/target-feature/abi-required-target-feature-flag-disable.x86-implied.stderr index 7ec8b04cfce..7ec8b04cfce 100644 --- a/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable-implied.stderr +++ b/tests/ui/target-feature/abi-required-target-feature-flag-disable.x86-implied.stderr diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable.stderr b/tests/ui/target-feature/abi-required-target-feature-flag-disable.x86.stderr index 02398d27501..02398d27501 100644 --- a/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable.stderr +++ b/tests/ui/target-feature/abi-required-target-feature-flag-disable.x86.stderr diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute.rs b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-e-d.rs index 215e64979f7..215e64979f7 100644 --- a/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute.rs +++ b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-e-d.rs diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute.stderr b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-e-d.stderr index bfe767e5ffb..84d27463b38 100644 --- a/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute.stderr +++ b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-e-d.stderr @@ -1,5 +1,5 @@ error: target feature `d` cannot be enabled with `#[target_feature]`: this feature is incompatible with the target ABI - --> $DIR/forbidden-hardfloat-target-feature-attribute.rs:10:18 + --> $DIR/forbidden-hardfloat-target-feature-attribute-e-d.rs:10:18 | LL | #[target_feature(enable = "d")] | ^^^^^^^^^^^^ diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-f-zfinx.rs b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-f-zfinx.rs new file mode 100644 index 00000000000..d74f4a1d4b1 --- /dev/null +++ b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-f-zfinx.rs @@ -0,0 +1,12 @@ +//! Ensure ABI-incompatible features cannot be enabled via `#[target_feature]`. +//@ compile-flags: --target=riscv64gc-unknown-linux-gnu --crate-type=lib +//@ needs-llvm-components: riscv +#![feature(no_core, lang_items, riscv_target_feature)] +#![no_core] + +#[lang = "sized"] +pub trait Sized {} + +#[target_feature(enable = "zdinx")] +//~^ERROR: cannot be enabled with +pub unsafe fn my_fun() {} diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-f-zfinx.stderr b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-f-zfinx.stderr new file mode 100644 index 00000000000..af0e53f34f2 --- /dev/null +++ b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-f-zfinx.stderr @@ -0,0 +1,8 @@ +error: target feature `zfinx` cannot be enabled with `#[target_feature]`: this feature is incompatible with the target ABI + --> $DIR/forbidden-hardfloat-target-feature-attribute-f-zfinx.rs:10:18 + | +LL | #[target_feature(enable = "zdinx")] + | ^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable-implied.rs b/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable-implied.rs deleted file mode 100644 index 12e7e3bc45b..00000000000 --- a/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable-implied.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! Ensure that if disabling a target feature implies disabling an ABI-required target feature, -//! we complain. -//@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=lib -//@ needs-llvm-components: x86 -//@ compile-flags: -Ctarget-feature=-sse -// For now this is just a warning. -//@ build-pass - -#![feature(no_core, lang_items)] -#![no_core] - -#[lang = "sized"] -pub trait Sized {} - -//~? WARN target feature `sse2` must be enabled to ensure that the ABI of the current target can be implemented correctly diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable-neon.rs b/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable-neon.rs deleted file mode 100644 index 33e4f12694f..00000000000 --- a/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable-neon.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ compile-flags: --target=aarch64-unknown-linux-gnu --crate-type=lib -//@ needs-llvm-components: aarch64 -//@ compile-flags: -Ctarget-feature=-neon -// For now this is just a warning. -//@ build-pass - -#![feature(no_core, lang_items)] -#![no_core] - -#[lang = "sized"] -pub trait Sized {} - -//~? WARN target feature `neon` must be enabled to ensure that the ABI of the current target can be implemented correctly diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable.rs b/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable.rs deleted file mode 100644 index e1bd25ffad1..00000000000 --- a/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! Ensure ABI-required features cannot be disabled via `-Ctarget-feature`. -//@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=lib -//@ needs-llvm-components: x86 -//@ compile-flags: -Ctarget-feature=-x87 -// For now this is just a warning. -//@ build-pass - -#![feature(no_core, lang_items)] -#![no_core] - -#[lang = "sized"] -pub trait Sized {} - -//~? WARN target feature `x87` must be enabled to ensure that the ABI of the current target can be implemented correctly -//~? WARN unstable feature specified for `-Ctarget-feature`: `x87` diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag.rs b/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag.rs deleted file mode 100644 index 4ccc6e0e941..00000000000 --- a/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! Ensure ABI-incompatible features cannot be enabled via `-Ctarget-feature`. -//@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=lib -//@ needs-llvm-components: x86 -//@ compile-flags: -Ctarget-feature=+soft-float -// For now this is just a warning. -//@ build-pass - -#![feature(no_core, lang_items, riscv_target_feature)] -#![no_core] - -#[lang = "sized"] -pub trait Sized {} - -//~? WARN target feature `soft-float` must be disabled to ensure that the ABI of the current target can be implemented correctl -//~? WARN unstable feature specified for `-Ctarget-feature`: `soft-float` diff --git a/tests/ui/test-attrs/test-should-panic-failed-show-span.run.stdout b/tests/ui/test-attrs/test-should-panic-failed-show-span.run.stdout index 75600b4d3d6..93204abb968 100644 --- a/tests/ui/test-attrs/test-should-panic-failed-show-span.run.stdout +++ b/tests/ui/test-attrs/test-should-panic-failed-show-span.run.stdout @@ -15,12 +15,12 @@ note: test did not panic as expected at $DIR/test-should-panic-failed-show-span. note: test did not panic as expected at $DIR/test-should-panic-failed-show-span.rs:31:4 ---- should_panic_with_substring_panics_with_incorrect_string stdout ---- note: panic did not contain expected string - panic message: `"ZOMGWTFBBQ"`, - expected substring: `"message"` + panic message: "ZOMGWTFBBQ" + expected substring: "message" ---- should_panic_with_substring_panics_with_non_string_value stdout ---- note: expected panic with string value, found non-string value: `TypeId($HEX)` - expected substring: `"message"` + expected substring: "message" failures: should_panic_with_any_message_does_not_panic diff --git a/tests/ui/traits/bound/same-crate-name.rs b/tests/ui/traits/bound/same-crate-name.rs index 06d79a0c8b8..395b963031a 100644 --- a/tests/ui/traits/bound/same-crate-name.rs +++ b/tests/ui/traits/bound/same-crate-name.rs @@ -1,5 +1,7 @@ //@ aux-build:crate_a1.rs //@ aux-build:crate_a2.rs +//@ dont-require-annotations: HELP +//@ dont-require-annotations: NOTE // Issue 22750 // This tests the extra help message reported when a trait bound @@ -30,8 +32,8 @@ fn main() { extern crate crate_a1 as a; a::try_foo(foo); //~^ ERROR E0277 - //~| trait impl with same name found - //~| perhaps two different versions of crate `crate_a2` + //~| HELP trait impl with same name found + //~| NOTE perhaps two different versions of crate `crate_a2` // We don't want to see the "version mismatch" help message here // because `implements_no_traits` has no impl for `Foo` @@ -50,6 +52,6 @@ fn main() { // impls for the correct trait where the path is not misleading. a::try_foo(other_variant_implements_correct_trait); //~^ ERROR E0277 - //~| the trait `main::a::Bar` is implemented for `ImplementsTraitForUsize<usize>` + //~| HELP the trait `main::a::Bar` is implemented for `ImplementsTraitForUsize<usize>` } } diff --git a/tests/ui/traits/bound/same-crate-name.stderr b/tests/ui/traits/bound/same-crate-name.stderr index f66cad77fcd..71a8159fd89 100644 --- a/tests/ui/traits/bound/same-crate-name.stderr +++ b/tests/ui/traits/bound/same-crate-name.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `Foo: main::a::Bar` is not satisfied - --> $DIR/same-crate-name.rs:31:20 + --> $DIR/same-crate-name.rs:33:20 | LL | a::try_foo(foo); | ---------- ^^^ the trait `main::a::Bar` is not implemented for `Foo` @@ -20,7 +20,7 @@ LL | pub fn try_foo(x: impl Bar) {} | ^^^ required by this bound in `try_foo` error[E0277]: the trait bound `DoesNotImplementTrait: main::a::Bar` is not satisfied - --> $DIR/same-crate-name.rs:38:20 + --> $DIR/same-crate-name.rs:40:20 | LL | a::try_foo(implements_no_traits); | ---------- ^^^^^^^^^^^^^^^^^^^^ the trait `main::a::Bar` is not implemented for `DoesNotImplementTrait` @@ -35,7 +35,7 @@ LL | pub fn try_foo(x: impl Bar) {} | ^^^ required by this bound in `try_foo` error[E0277]: the trait bound `ImplementsWrongTraitConditionally<isize>: main::a::Bar` is not satisfied - --> $DIR/same-crate-name.rs:45:20 + --> $DIR/same-crate-name.rs:47:20 | LL | a::try_foo(other_variant_implements_mismatched_trait); | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `main::a::Bar` is not implemented for `ImplementsWrongTraitConditionally<isize>` @@ -56,7 +56,7 @@ LL | pub fn try_foo(x: impl Bar) {} | ^^^ required by this bound in `try_foo` error[E0277]: the trait bound `ImplementsTraitForUsize<isize>: main::a::Bar` is not satisfied - --> $DIR/same-crate-name.rs:51:20 + --> $DIR/same-crate-name.rs:53:20 | LL | a::try_foo(other_variant_implements_correct_trait); | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `main::a::Bar` is not implemented for `ImplementsTraitForUsize<isize>` diff --git a/tests/ui/traits/const-traits/drop-manually-drop-no-drop-impl.rs b/tests/ui/traits/const-traits/drop-manually-drop-no-drop-impl.rs new file mode 100644 index 00000000000..060a543d6c3 --- /dev/null +++ b/tests/ui/traits/const-traits/drop-manually-drop-no-drop-impl.rs @@ -0,0 +1,17 @@ +//@[new] compile-flags: -Znext-solver +//@ revisions: old new +//@ check-pass + +use std::mem::ManuallyDrop; + +struct Moose; + +impl Drop for Moose { + fn drop(&mut self) {} +} + +struct ConstDropper<T>(ManuallyDrop<T>); + +const fn foo(_var: ConstDropper<Moose>) {} + +fn main() {} diff --git a/tests/ui/traits/const-traits/drop-manually-drop.rs b/tests/ui/traits/const-traits/drop-manually-drop.rs new file mode 100644 index 00000000000..62e8a815f10 --- /dev/null +++ b/tests/ui/traits/const-traits/drop-manually-drop.rs @@ -0,0 +1,24 @@ +//@[new] compile-flags: -Znext-solver +//@ revisions: old new +//@ check-pass + +#![feature(const_destruct)] +#![feature(const_trait_impl)] + +use std::mem::ManuallyDrop; + +struct Moose; + +impl Drop for Moose { + fn drop(&mut self) {} +} + +struct ConstDropper<T>(ManuallyDrop<T>); + +impl<T> const Drop for ConstDropper<T> { + fn drop(&mut self) {} +} + +const fn foo(_var: ConstDropper<Moose>) {} + +fn main() {} diff --git a/tests/ui/traits/impl-method-mismatch.rs b/tests/ui/traits/impl-method-mismatch.rs index 62580755c81..a7de5e38113 100644 --- a/tests/ui/traits/impl-method-mismatch.rs +++ b/tests/ui/traits/impl-method-mismatch.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + trait Mumbo { fn jumbo(&self, x: &usize) -> usize; } @@ -6,8 +8,8 @@ impl Mumbo for usize { // Cannot have a larger effect than the trait: unsafe fn jumbo(&self, x: &usize) { *self + *x; } //~^ ERROR method `jumbo` has an incompatible type for trait - //~| expected signature `fn - //~| found signature `unsafe fn + //~| NOTE expected signature `fn + //~| NOTE found signature `unsafe fn } fn main() {} diff --git a/tests/ui/traits/impl-method-mismatch.stderr b/tests/ui/traits/impl-method-mismatch.stderr index db457b77a23..ca8b35e06c7 100644 --- a/tests/ui/traits/impl-method-mismatch.stderr +++ b/tests/ui/traits/impl-method-mismatch.stderr @@ -1,11 +1,11 @@ error[E0053]: method `jumbo` has an incompatible type for trait - --> $DIR/impl-method-mismatch.rs:7:5 + --> $DIR/impl-method-mismatch.rs:9:5 | LL | unsafe fn jumbo(&self, x: &usize) { *self + *x; } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected safe fn, found unsafe fn | note: type in trait - --> $DIR/impl-method-mismatch.rs:2:5 + --> $DIR/impl-method-mismatch.rs:4:5 | LL | fn jumbo(&self, x: &usize) -> usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/traits/next-solver/coerce-depth.rs b/tests/ui/traits/next-solver/coerce-depth.rs new file mode 100644 index 00000000000..c8fc3fcab59 --- /dev/null +++ b/tests/ui/traits/next-solver/coerce-depth.rs @@ -0,0 +1,31 @@ +//@ check-pass +//@ compile-flags: -Znext-solver + +// Ensure that a stack of coerce predicates doesn't end up overflowing when they get procesed +// in *reverse* order, which may require O(N) iterations of the fulfillment loop. + +#![recursion_limit = "16"] + +fn main() { + match 0 { + 0 => None, + 1 => None, + 2 => None, + 3 => None, + 4 => None, + 5 => None, + 6 => None, + 7 => None, + 8 => None, + 9 => None, + 10 => None, + 11 => None, + 12 => None, + 13 => None, + 14 => None, + 15 => None, + 16 => None, + 17 => None, + _ => Some(1u32), + }; +} diff --git a/tests/ui/traits/next-solver/normalize/eager-norm-pre-normalizes-to.rs b/tests/ui/traits/next-solver/normalize/eager-norm-pre-normalizes-to.rs new file mode 100644 index 00000000000..ea18ac54c05 --- /dev/null +++ b/tests/ui/traits/next-solver/normalize/eager-norm-pre-normalizes-to.rs @@ -0,0 +1,44 @@ +//@ check-pass +//@ compile-flags: -Znext-solver + +// A regression test for trait-system-refactor-initiative#184. +// +// When adding nested goals we replace aliases with infer vars +// and add `AliasRelate` goals to constrain them. When doing this +// for `NormalizesTo` goals, we then first tries to prove the +// `NormalizesTo` goal and then normalized the nested aliases. + +trait Trait<T> { + type Assoc; +} +impl<T, U> Trait<U> for T { + type Assoc = (); +} + +trait Id { + type This; +} +impl<T> Id for T { + type This = T; +} +trait Relate<T> { + type Alias; +} +impl<T, U> Relate<U> for T { + type Alias = <T as Trait<<U as Id>::This>>::Assoc; +} + + +fn guide_me<T: Trait<u32>>() { + // Normalizing `<T as Relate<i32>>::Alias` relates the associated type with an unconstrained + // term. This resulted in a `NormalizesTo(<T as Trait<<U as Id>::This>>::Assoc, ?x)` goal. + // We replace `<i32 as Id>::This` with an infer var `?y`, resulting in the following goals: + // - `NormalizesTo(<T as Trait<?y>::Assoc, ?x)` + // - `AliasRelate(<i32 as Id>::This, ?y)` + // + // When proving the `NormalizesTo` goal first, we incompletely constrain `?y` to `u32`, + // causing an unexpected type mismatch. + let _: <T as Relate<i32>>::Alias; +} + +fn main() {} diff --git a/tests/ui/traits/next-solver/normalize/normalize-allow-too-many-vars.rs b/tests/ui/traits/next-solver/normalize/normalize-allow-too-many-vars.rs index 5284220ac38..3150d9a88d0 100644 --- a/tests/ui/traits/next-solver/normalize/normalize-allow-too-many-vars.rs +++ b/tests/ui/traits/next-solver/normalize/normalize-allow-too-many-vars.rs @@ -1,4 +1,5 @@ //@ check-pass +//@ compile-flags: -Znext-solver // When canonicalizing a response in the trait solver, we bail with overflow // if there are too many non-region inference variables. Doing so in normalizes-to diff --git a/tests/ui/traits/next-solver/specialization-transmute.rs b/tests/ui/traits/next-solver/specialization-transmute.rs index 376fa22ae19..f1447cd6a9e 100644 --- a/tests/ui/traits/next-solver/specialization-transmute.rs +++ b/tests/ui/traits/next-solver/specialization-transmute.rs @@ -10,11 +10,8 @@ trait Default { impl<T> Default for T { default type Id = T; - // This will be fixed by #111994 fn intu(&self) -> &Self::Id { - //~^ ERROR type annotations needed - //~| ERROR cannot normalize `<T as Default>::Id: '_` - self //~ ERROR cannot satisfy + self //~ ERROR mismatched types } } @@ -25,6 +22,7 @@ fn transmute<T: Default<Id = U>, U: Copy>(t: T) -> U { use std::num::NonZero; fn main() { - let s = transmute::<u8, Option<NonZero<u8>>>(0); //~ ERROR cannot satisfy + let s = transmute::<u8, Option<NonZero<u8>>>(0); + //~^ ERROR type mismatch resolving `<u8 as Default>::Id == Option<NonZero<u8>>` assert_eq!(s, None); } diff --git a/tests/ui/traits/next-solver/specialization-transmute.stderr b/tests/ui/traits/next-solver/specialization-transmute.stderr index eeb101911c4..8bd290ea197 100644 --- a/tests/ui/traits/next-solver/specialization-transmute.stderr +++ b/tests/ui/traits/next-solver/specialization-transmute.stderr @@ -8,37 +8,32 @@ LL | #![feature(specialization)] = help: consider using `min_specialization` instead, which is more stable and complete = note: `#[warn(incomplete_features)]` on by default -error: cannot normalize `<T as Default>::Id: '_` - --> $DIR/specialization-transmute.rs:14:5 +error[E0308]: mismatched types + --> $DIR/specialization-transmute.rs:14:9 | LL | fn intu(&self) -> &Self::Id { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0282]: type annotations needed - --> $DIR/specialization-transmute.rs:14:23 - | -LL | fn intu(&self) -> &Self::Id { - | ^^^^^^^^^ cannot infer type for reference `&<T as Default>::Id` - -error[E0284]: type annotations needed: cannot satisfy `<T as Default>::Id normalizes-to T` - --> $DIR/specialization-transmute.rs:17:9 - | + | --------- expected `&<T as Default>::Id` because of return type LL | self - | ^^^^ cannot satisfy `<T as Default>::Id normalizes-to T` + | ^^^^ types differ + | + = note: expected reference `&<T as Default>::Id` + found reference `&T` -error[E0284]: type annotations needed: cannot satisfy `<u8 as Default>::Id normalizes-to Option<NonZero<u8>>` - --> $DIR/specialization-transmute.rs:28:13 +error[E0271]: type mismatch resolving `<u8 as Default>::Id == Option<NonZero<u8>>` + --> $DIR/specialization-transmute.rs:25:50 | LL | let s = transmute::<u8, Option<NonZero<u8>>>(0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot satisfy `<u8 as Default>::Id normalizes-to Option<NonZero<u8>>` + | ------------------------------------ ^ types differ + | | + | required by a bound introduced by this call | note: required by a bound in `transmute` - --> $DIR/specialization-transmute.rs:21:25 + --> $DIR/specialization-transmute.rs:18:25 | LL | fn transmute<T: Default<Id = U>, U: Copy>(t: T) -> U { | ^^^^^^ required by this bound in `transmute` -error: aborting due to 4 previous errors; 1 warning emitted +error: aborting due to 2 previous errors; 1 warning emitted -Some errors have detailed explanations: E0282, E0284. -For more information about an error, try `rustc --explain E0282`. +Some errors have detailed explanations: E0271, E0308. +For more information about an error, try `rustc --explain E0271`. diff --git a/tests/ui/traits/next-solver/specialization-unconstrained.rs b/tests/ui/traits/next-solver/specialization-unconstrained.rs index 2bbe7840110..6835c0764d6 100644 --- a/tests/ui/traits/next-solver/specialization-unconstrained.rs +++ b/tests/ui/traits/next-solver/specialization-unconstrained.rs @@ -18,5 +18,5 @@ fn test<T: Default<Id = U>, U>() {} fn main() { test::<u32, ()>(); - //~^ ERROR cannot satisfy `<u32 as Default>::Id normalizes-to ()` + //~^ ERROR type mismatch resolving `<u32 as Default>::Id == ()` } diff --git a/tests/ui/traits/next-solver/specialization-unconstrained.stderr b/tests/ui/traits/next-solver/specialization-unconstrained.stderr index e1d785b554b..1bcf5eddb5b 100644 --- a/tests/ui/traits/next-solver/specialization-unconstrained.stderr +++ b/tests/ui/traits/next-solver/specialization-unconstrained.stderr @@ -8,11 +8,11 @@ LL | #![feature(specialization)] = help: consider using `min_specialization` instead, which is more stable and complete = note: `#[warn(incomplete_features)]` on by default -error[E0284]: type annotations needed: cannot satisfy `<u32 as Default>::Id normalizes-to ()` - --> $DIR/specialization-unconstrained.rs:20:5 +error[E0271]: type mismatch resolving `<u32 as Default>::Id == ()` + --> $DIR/specialization-unconstrained.rs:20:12 | LL | test::<u32, ()>(); - | ^^^^^^^^^^^^^^^^^ cannot satisfy `<u32 as Default>::Id normalizes-to ()` + | ^^^ types differ | note: required by a bound in `test` --> $DIR/specialization-unconstrained.rs:17:20 @@ -22,4 +22,4 @@ LL | fn test<T: Default<Id = U>, U>() {} error: aborting due to 1 previous error; 1 warning emitted -For more information about this error, try `rustc --explain E0284`. +For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/traits/trait-impl-self-mismatch.rs b/tests/ui/traits/trait-impl-self-mismatch.rs new file mode 100644 index 00000000000..54226cf2c9a --- /dev/null +++ b/tests/ui/traits/trait-impl-self-mismatch.rs @@ -0,0 +1,19 @@ +//@compile-flags: -Zvalidate-mir -Zinline-mir -Zinline-mir-threshold=300 + +//! Ensure that a trait method implemented with the wrong signature +//! correctly triggers a compile error and not an ICE. +//! Regression test for <https://github.com/rust-lang/rust/issues/133065>. + +trait Bar { + fn bar(&self) {} +} + +impl<T> Bar for T { + fn bar() { //~ ERROR method `bar` has a `&self` declaration in the trait, but not in the impl + let _ = "Hello".bytes().nth(3); + } +} + +fn main() { + ().bar(); +} diff --git a/tests/ui/traits/trait-impl-self-mismatch.stderr b/tests/ui/traits/trait-impl-self-mismatch.stderr new file mode 100644 index 00000000000..4ee06787c7d --- /dev/null +++ b/tests/ui/traits/trait-impl-self-mismatch.stderr @@ -0,0 +1,12 @@ +error[E0186]: method `bar` has a `&self` declaration in the trait, but not in the impl + --> $DIR/trait-impl-self-mismatch.rs:12:5 + | +LL | fn bar(&self) {} + | ------------- `&self` used in trait +... +LL | fn bar() { + | ^^^^^^^^ expected `&self` in impl + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0186`. diff --git a/tests/ui/transmutability/char.rs b/tests/ui/transmutability/char.rs new file mode 100644 index 00000000000..55a61537329 --- /dev/null +++ b/tests/ui/transmutability/char.rs @@ -0,0 +1,41 @@ +#![feature(never_type)] +#![feature(transmutability)] + +use std::mem::{Assume, TransmuteFrom}; + +pub fn is_transmutable<Src, Dst>() +where + Dst: TransmuteFrom<Src, { Assume::SAFETY }>, +{ +} + +fn main() { + is_transmutable::<char, u32>(); + + // `char`s can be in the following ranges: + // - [0, 0xD7FF] + // - [0xE000, 10FFFF] + // + // `Char` has variants whose tags are in the top and bottom of each range. + // It also has generic variants which are out of bounds of these ranges, but + // are generic on types which may be set to `!` to "disable" them in the + // transmutability analysis. + #[repr(u32)] + enum Char<B, C, D> { + A = 0, + B = 0xD7FF, + OverB(B) = 0xD800, + UnderC(C) = 0xDFFF, + C = 0xE000, + D = 0x10FFFF, + OverD(D) = 0x110000, + } + + is_transmutable::<Char<!, !, !>, char>(); + is_transmutable::<Char<(), !, !>, char>(); + //~^ ERROR cannot be safely transmuted into `char` + is_transmutable::<Char<!, (), !>, char>(); + //~^ ERROR cannot be safely transmuted into `char` + is_transmutable::<Char<!, !, ()>, char>(); + //~^ ERROR cannot be safely transmuted into `char` +} diff --git a/tests/ui/transmutability/char.stderr b/tests/ui/transmutability/char.stderr new file mode 100644 index 00000000000..98e7ae9c0d4 --- /dev/null +++ b/tests/ui/transmutability/char.stderr @@ -0,0 +1,48 @@ +error[E0277]: `main::Char<(), !, !>` cannot be safely transmuted into `char` + --> $DIR/char.rs:35:39 + | +LL | is_transmutable::<Char<(), !, !>, char>(); + | ^^^^ at least one value of `main::Char<(), !, !>` isn't a bit-valid value of `char` + | +note: required by a bound in `is_transmutable` + --> $DIR/char.rs:8:10 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: TransmuteFrom<Src, { Assume::SAFETY }>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `main::Char<!, (), !>` cannot be safely transmuted into `char` + --> $DIR/char.rs:37:39 + | +LL | is_transmutable::<Char<!, (), !>, char>(); + | ^^^^ at least one value of `main::Char<!, (), !>` isn't a bit-valid value of `char` + | +note: required by a bound in `is_transmutable` + --> $DIR/char.rs:8:10 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: TransmuteFrom<Src, { Assume::SAFETY }>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `main::Char<!, !, ()>` cannot be safely transmuted into `char` + --> $DIR/char.rs:39:39 + | +LL | is_transmutable::<Char<!, !, ()>, char>(); + | ^^^^ at least one value of `main::Char<!, !, ()>` isn't a bit-valid value of `char` + | +note: required by a bound in `is_transmutable` + --> $DIR/char.rs:8:10 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: TransmuteFrom<Src, { Assume::SAFETY }>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/unions/extension.rs b/tests/ui/transmutability/unions/extension.rs new file mode 100644 index 00000000000..eb4dcd4dff3 --- /dev/null +++ b/tests/ui/transmutability/unions/extension.rs @@ -0,0 +1,12 @@ +#![crate_type = "lib"] +#![feature(transmutability)] +use std::mem::{Assume, MaybeUninit, TransmuteFrom}; + +pub fn is_maybe_transmutable<Src, Dst>() + where Dst: TransmuteFrom<Src, { Assume::VALIDITY.and(Assume::SAFETY) }> +{} + +fn extension() { + is_maybe_transmutable::<(), MaybeUninit<u8>>(); + is_maybe_transmutable::<MaybeUninit<u8>, [u8; 2]>(); //~ ERROR `MaybeUninit<u8>` cannot be safely transmuted into `[u8; 2]` +} diff --git a/tests/ui/transmutability/unions/extension.stderr b/tests/ui/transmutability/unions/extension.stderr new file mode 100644 index 00000000000..c99e46f3d12 --- /dev/null +++ b/tests/ui/transmutability/unions/extension.stderr @@ -0,0 +1,17 @@ +error[E0277]: `MaybeUninit<u8>` cannot be safely transmuted into `[u8; 2]` + --> $DIR/extension.rs:11:46 + | +LL | is_maybe_transmutable::<MaybeUninit<u8>, [u8; 2]>(); + | ^^^^^^^ the size of `MaybeUninit<u8>` is smaller than the size of `[u8; 2]` + | +note: required by a bound in `is_maybe_transmutable` + --> $DIR/extension.rs:6:16 + | +LL | pub fn is_maybe_transmutable<Src, Dst>() + | --------------------- required by a bound in this function +LL | where Dst: TransmuteFrom<Src, { Assume::VALIDITY.and(Assume::SAFETY) }> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/unions/init_as_uninit.rs b/tests/ui/transmutability/unions/init_as_uninit.rs new file mode 100644 index 00000000000..d14eca800ef --- /dev/null +++ b/tests/ui/transmutability/unions/init_as_uninit.rs @@ -0,0 +1,26 @@ +//@ check-pass +// Regression test for issue #140337. +#![crate_type = "lib"] +#![feature(transmutability)] +#![allow(dead_code)] +use std::mem::{Assume, MaybeUninit, TransmuteFrom}; + +pub fn is_transmutable<Src, Dst>() +where + Dst: TransmuteFrom<Src, { Assume::SAFETY }> +{} + +#[derive(Copy, Clone)] +#[repr(u8)] +pub enum B0 { Value = 0 } + +#[derive(Copy, Clone)] +#[repr(u8)] +pub enum B1 { Value = 1 } + +fn main() { + is_transmutable::<(B0, B0), MaybeUninit<(B0, B0)>>(); + is_transmutable::<(B0, B0), MaybeUninit<(B0, B1)>>(); + is_transmutable::<(B0, B0), MaybeUninit<(B1, B0)>>(); + is_transmutable::<(B0, B0), MaybeUninit<(B1, B1)>>(); +} diff --git a/tests/ui/transmutability/unions/should_permit_intersecting_if_validity_is_assumed.rs b/tests/ui/transmutability/unions/should_permit_intersecting_if_validity_is_assumed.rs index 359ba515439..24c6fa2e6ac 100644 --- a/tests/ui/transmutability/unions/should_permit_intersecting_if_validity_is_assumed.rs +++ b/tests/ui/transmutability/unions/should_permit_intersecting_if_validity_is_assumed.rs @@ -34,4 +34,19 @@ fn test() { assert::is_maybe_transmutable::<A, B>(); assert::is_maybe_transmutable::<B, A>(); + + #[repr(C)] + struct C { + a: Ox00, + b: Ox00, + } + + #[repr(C, align(2))] + struct D { + a: Ox00, + } + + assert::is_maybe_transmutable::<C, D>(); + // With Assume::VALIDITY a padding byte can hold any value. + assert::is_maybe_transmutable::<D, C>(); } diff --git a/tests/ui/transmute/auxiliary/unnecessary-transmute-path-remap-ice-140277-trans.rs b/tests/ui/transmute/auxiliary/unnecessary-transmute-path-remap-ice-140277-trans.rs new file mode 100644 index 00000000000..0f273a6f536 --- /dev/null +++ b/tests/ui/transmute/auxiliary/unnecessary-transmute-path-remap-ice-140277-trans.rs @@ -0,0 +1,10 @@ +//@ compile-flags: --remap-path-prefix=/=/non-existent +// helper for ../unnecessary-transmute-path-remap-ice-140277.rs + +#[macro_export] +macro_rules! transmute { + ($e:expr) => {{ + let e = $e; + std::mem::transmute(e) + }}; +} diff --git a/tests/ui/transmute/unnecessary-transmutation.fixed b/tests/ui/transmute/unnecessary-transmutation.fixed new file mode 100644 index 00000000000..1a0df143cc5 --- /dev/null +++ b/tests/ui/transmute/unnecessary-transmutation.fixed @@ -0,0 +1,85 @@ +//@ run-rustfix +#![deny(unnecessary_transmutes)] +#![allow(unused_unsafe, unused_imports, unused_variables, unused_parens)] +use std::mem::transmute; + +pub fn bytes_at_home(x: u32) -> [u8; 4] { + unsafe { u32::to_ne_bytes(x) } + //~^ ERROR +} + +fn main() { + unsafe { + let x: u16 = u16::from_ne_bytes(*b"01"); + //~^ ERROR + let x: [u8; 2] = u16::to_ne_bytes(x); + //~^ ERROR + let x: u32 = u32::from_ne_bytes(*b"0123"); + //~^ ERROR + let x: [u8; 4] = u32::to_ne_bytes(x); + //~^ ERROR + let x: u64 = u64::from_ne_bytes(*b"feriscat"); + //~^ ERROR + let x: [u8; 8] = u64::to_ne_bytes(x); + //~^ ERROR + + let y: i16 = i16::from_ne_bytes(*b"01"); + //~^ ERROR + let y: [u8; 2] = i16::to_ne_bytes(y); + //~^ ERROR + let y: i32 = i32::from_ne_bytes(*b"0123"); + //~^ ERROR + let y: [u8; 4] = i32::to_ne_bytes(y); + //~^ ERROR + let y: i64 = i64::from_ne_bytes(*b"feriscat"); + //~^ ERROR + let y: [u8; 8] = i64::to_ne_bytes(y); + //~^ ERROR + + let z: f32 = f32::from_ne_bytes(*b"0123"); + //~^ ERROR + let z: [u8; 4] = f32::to_ne_bytes(z); + //~^ ERROR + let z: f64 = f64::from_ne_bytes(*b"feriscat"); + //~^ ERROR + let z: [u8; 8] = f64::to_ne_bytes(z); + //~^ ERROR + + let y: u32 = u32::from('🦀'); + //~^ ERROR + let y: char = char::from_u32_unchecked(y); + //~^ ERROR + + let x: u16 = i16::cast_unsigned(8i16); + //~^ ERROR + let x: i16 = u16::cast_signed(x); + //~^ ERROR + let x: u32 = i32::cast_unsigned(4i32); + //~^ ERROR + let x: i32 = u32::cast_signed(x); + //~^ ERROR + let x: u64 = i64::cast_unsigned(7i64); + //~^ ERROR + let x: i64 = u64::cast_signed(x); + //~^ ERROR + + let y: f32 = f32::from_bits(1u32); + //~^ ERROR + let y: u32 = f32::to_bits(y); + //~^ ERROR + let y: f64 = f64::from_bits(3u64); + //~^ ERROR + let y: u64 = f64::to_bits(2.0); + //~^ ERROR + + let z: bool = (1u8 == 1); + //~^ ERROR + let z: u8 = (z) as u8; + //~^ ERROR + + let z: bool = transmute(1i8); + // no error! + let z: i8 = (z) as i8; + //~^ ERROR + } +} diff --git a/tests/ui/transmute/unnecessary-transmutation.rs b/tests/ui/transmute/unnecessary-transmutation.rs new file mode 100644 index 00000000000..6b979263c56 --- /dev/null +++ b/tests/ui/transmute/unnecessary-transmutation.rs @@ -0,0 +1,85 @@ +//@ run-rustfix +#![deny(unnecessary_transmutes)] +#![allow(unused_unsafe, unused_imports, unused_variables, unused_parens)] +use std::mem::transmute; + +pub fn bytes_at_home(x: u32) -> [u8; 4] { + unsafe { transmute(x) } + //~^ ERROR +} + +fn main() { + unsafe { + let x: u16 = transmute(*b"01"); + //~^ ERROR + let x: [u8; 2] = transmute(x); + //~^ ERROR + let x: u32 = transmute(*b"0123"); + //~^ ERROR + let x: [u8; 4] = transmute(x); + //~^ ERROR + let x: u64 = transmute(*b"feriscat"); + //~^ ERROR + let x: [u8; 8] = transmute(x); + //~^ ERROR + + let y: i16 = transmute(*b"01"); + //~^ ERROR + let y: [u8; 2] = transmute(y); + //~^ ERROR + let y: i32 = transmute(*b"0123"); + //~^ ERROR + let y: [u8; 4] = transmute(y); + //~^ ERROR + let y: i64 = transmute(*b"feriscat"); + //~^ ERROR + let y: [u8; 8] = transmute(y); + //~^ ERROR + + let z: f32 = transmute(*b"0123"); + //~^ ERROR + let z: [u8; 4] = transmute(z); + //~^ ERROR + let z: f64 = transmute(*b"feriscat"); + //~^ ERROR + let z: [u8; 8] = transmute(z); + //~^ ERROR + + let y: u32 = transmute('🦀'); + //~^ ERROR + let y: char = transmute(y); + //~^ ERROR + + let x: u16 = transmute(8i16); + //~^ ERROR + let x: i16 = transmute(x); + //~^ ERROR + let x: u32 = transmute(4i32); + //~^ ERROR + let x: i32 = transmute(x); + //~^ ERROR + let x: u64 = transmute(7i64); + //~^ ERROR + let x: i64 = transmute(x); + //~^ ERROR + + let y: f32 = transmute(1u32); + //~^ ERROR + let y: u32 = transmute(y); + //~^ ERROR + let y: f64 = transmute(3u64); + //~^ ERROR + let y: u64 = transmute(2.0); + //~^ ERROR + + let z: bool = transmute(1u8); + //~^ ERROR + let z: u8 = transmute(z); + //~^ ERROR + + let z: bool = transmute(1i8); + // no error! + let z: i8 = transmute(z); + //~^ ERROR + } +} diff --git a/tests/ui/transmute/unnecessary-transmutation.stderr b/tests/ui/transmute/unnecessary-transmutation.stderr new file mode 100644 index 00000000000..b661aa13c98 --- /dev/null +++ b/tests/ui/transmute/unnecessary-transmutation.stderr @@ -0,0 +1,235 @@ +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:7:14 + | +LL | unsafe { transmute(x) } + | ^^^^^^^^^^^^ help: replace this with: `u32::to_ne_bytes(x)` + | + = help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order +note: the lint level is defined here + --> $DIR/unnecessary-transmutation.rs:2:9 + | +LL | #![deny(unnecessary_transmutes)] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:13:22 + | +LL | let x: u16 = transmute(*b"01"); + | ^^^^^^^^^^^^^^^^^ help: replace this with: `u16::from_ne_bytes(*b"01")` + | + = help: there's also `from_le_bytes` and `from_be_bytes` if you expect a particular byte order + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:15:26 + | +LL | let x: [u8; 2] = transmute(x); + | ^^^^^^^^^^^^ help: replace this with: `u16::to_ne_bytes(x)` + | + = help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:17:22 + | +LL | let x: u32 = transmute(*b"0123"); + | ^^^^^^^^^^^^^^^^^^^ help: replace this with: `u32::from_ne_bytes(*b"0123")` + | + = help: there's also `from_le_bytes` and `from_be_bytes` if you expect a particular byte order + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:19:26 + | +LL | let x: [u8; 4] = transmute(x); + | ^^^^^^^^^^^^ help: replace this with: `u32::to_ne_bytes(x)` + | + = help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:21:22 + | +LL | let x: u64 = transmute(*b"feriscat"); + | ^^^^^^^^^^^^^^^^^^^^^^^ help: replace this with: `u64::from_ne_bytes(*b"feriscat")` + | + = help: there's also `from_le_bytes` and `from_be_bytes` if you expect a particular byte order + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:23:26 + | +LL | let x: [u8; 8] = transmute(x); + | ^^^^^^^^^^^^ help: replace this with: `u64::to_ne_bytes(x)` + | + = help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:26:22 + | +LL | let y: i16 = transmute(*b"01"); + | ^^^^^^^^^^^^^^^^^ help: replace this with: `i16::from_ne_bytes(*b"01")` + | + = help: there's also `from_le_bytes` and `from_be_bytes` if you expect a particular byte order + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:28:26 + | +LL | let y: [u8; 2] = transmute(y); + | ^^^^^^^^^^^^ help: replace this with: `i16::to_ne_bytes(y)` + | + = help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:30:22 + | +LL | let y: i32 = transmute(*b"0123"); + | ^^^^^^^^^^^^^^^^^^^ help: replace this with: `i32::from_ne_bytes(*b"0123")` + | + = help: there's also `from_le_bytes` and `from_be_bytes` if you expect a particular byte order + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:32:26 + | +LL | let y: [u8; 4] = transmute(y); + | ^^^^^^^^^^^^ help: replace this with: `i32::to_ne_bytes(y)` + | + = help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:34:22 + | +LL | let y: i64 = transmute(*b"feriscat"); + | ^^^^^^^^^^^^^^^^^^^^^^^ help: replace this with: `i64::from_ne_bytes(*b"feriscat")` + | + = help: there's also `from_le_bytes` and `from_be_bytes` if you expect a particular byte order + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:36:26 + | +LL | let y: [u8; 8] = transmute(y); + | ^^^^^^^^^^^^ help: replace this with: `i64::to_ne_bytes(y)` + | + = help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:39:22 + | +LL | let z: f32 = transmute(*b"0123"); + | ^^^^^^^^^^^^^^^^^^^ help: replace this with: `f32::from_ne_bytes(*b"0123")` + | + = help: there's also `from_le_bytes` and `from_be_bytes` if you expect a particular byte order + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:41:26 + | +LL | let z: [u8; 4] = transmute(z); + | ^^^^^^^^^^^^ help: replace this with: `f32::to_ne_bytes(z)` + | + = help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:43:22 + | +LL | let z: f64 = transmute(*b"feriscat"); + | ^^^^^^^^^^^^^^^^^^^^^^^ help: replace this with: `f64::from_ne_bytes(*b"feriscat")` + | + = help: there's also `from_le_bytes` and `from_be_bytes` if you expect a particular byte order + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:45:26 + | +LL | let z: [u8; 8] = transmute(z); + | ^^^^^^^^^^^^ help: replace this with: `f64::to_ne_bytes(z)` + | + = help: there's also `to_le_bytes` and `to_be_bytes` if you expect a particular byte order + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:48:22 + | +LL | let y: u32 = transmute('🦀'); + | ^^^^^^^^^^^^^^^ help: replace this with: `u32::from('🦀')` + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:50:23 + | +LL | let y: char = transmute(y); + | ^^^^^^^^^^^^ help: replace this with: `char::from_u32_unchecked(y)` + | + = help: consider `char::from_u32(…).unwrap()` + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:53:22 + | +LL | let x: u16 = transmute(8i16); + | ^^^^^^^^^^^^^^^ help: replace this with: `i16::cast_unsigned(8i16)` + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:55:22 + | +LL | let x: i16 = transmute(x); + | ^^^^^^^^^^^^ help: replace this with: `u16::cast_signed(x)` + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:57:22 + | +LL | let x: u32 = transmute(4i32); + | ^^^^^^^^^^^^^^^ help: replace this with: `i32::cast_unsigned(4i32)` + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:59:22 + | +LL | let x: i32 = transmute(x); + | ^^^^^^^^^^^^ help: replace this with: `u32::cast_signed(x)` + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:61:22 + | +LL | let x: u64 = transmute(7i64); + | ^^^^^^^^^^^^^^^ help: replace this with: `i64::cast_unsigned(7i64)` + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:63:22 + | +LL | let x: i64 = transmute(x); + | ^^^^^^^^^^^^ help: replace this with: `u64::cast_signed(x)` + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:66:22 + | +LL | let y: f32 = transmute(1u32); + | ^^^^^^^^^^^^^^^ help: replace this with: `f32::from_bits(1u32)` + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:68:22 + | +LL | let y: u32 = transmute(y); + | ^^^^^^^^^^^^ help: replace this with: `f32::to_bits(y)` + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:70:22 + | +LL | let y: f64 = transmute(3u64); + | ^^^^^^^^^^^^^^^ help: replace this with: `f64::from_bits(3u64)` + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:72:22 + | +LL | let y: u64 = transmute(2.0); + | ^^^^^^^^^^^^^^ help: replace this with: `f64::to_bits(2.0)` + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:75:23 + | +LL | let z: bool = transmute(1u8); + | ^^^^^^^^^^^^^^ help: replace this with: `(1u8 == 1)` + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:77:21 + | +LL | let z: u8 = transmute(z); + | ^^^^^^^^^^^^ help: replace this with: `(z) as u8` + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:82:21 + | +LL | let z: i8 = transmute(z); + | ^^^^^^^^^^^^ help: replace this with: `(z) as i8` + +error: aborting due to 32 previous errors + diff --git a/tests/ui/transmute/unnecessary-transmute-path-remap-ice-140277.rs b/tests/ui/transmute/unnecessary-transmute-path-remap-ice-140277.rs new file mode 100644 index 00000000000..756ce7b3d50 --- /dev/null +++ b/tests/ui/transmute/unnecessary-transmute-path-remap-ice-140277.rs @@ -0,0 +1,10 @@ +//@ aux-crate: zerocopy=unnecessary-transmute-path-remap-ice-140277-trans.rs +//@ check-pass +// tests for a regression in linting for unnecessary transmutes +// where a span was inacessible for snippet procuring, +// when remap-path-prefix was set, causing a panic. + +fn bytes_at_home(x: [u8; 4]) -> u32 { + unsafe { zerocopy::transmute!(x) } +} +fn main() {} diff --git a/tests/ui/tuple/tuple-arity-mismatch.rs b/tests/ui/tuple/tuple-arity-mismatch.rs index f1e525c93e1..0b7c9deec9f 100644 --- a/tests/ui/tuple/tuple-arity-mismatch.rs +++ b/tests/ui/tuple/tuple-arity-mismatch.rs @@ -1,17 +1,19 @@ // Issue #6155 +//@ dont-require-annotations: NOTE + fn first((value, _): (isize, f64)) -> isize { value } fn main() { let y = first ((1,2.0,3)); //~^ ERROR mismatched types - //~| expected tuple `(isize, f64)` - //~| found tuple `(isize, f64, {integer})` - //~| expected a tuple with 2 elements, found one with 3 elements + //~| NOTE expected tuple `(isize, f64)` + //~| NOTE found tuple `(isize, f64, {integer})` + //~| NOTE expected a tuple with 2 elements, found one with 3 elements let y = first ((1,)); //~^ ERROR mismatched types - //~| expected tuple `(isize, f64)` - //~| found tuple `(isize,)` - //~| expected a tuple with 2 elements, found one with 1 element + //~| NOTE expected tuple `(isize, f64)` + //~| NOTE found tuple `(isize,)` + //~| NOTE expected a tuple with 2 elements, found one with 1 element } diff --git a/tests/ui/tuple/tuple-arity-mismatch.stderr b/tests/ui/tuple/tuple-arity-mismatch.stderr index fff7be987f2..49dd98b6e73 100644 --- a/tests/ui/tuple/tuple-arity-mismatch.stderr +++ b/tests/ui/tuple/tuple-arity-mismatch.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/tuple-arity-mismatch.rs:6:20 + --> $DIR/tuple-arity-mismatch.rs:8:20 | LL | let y = first ((1,2.0,3)); | ----- ^^^^^^^^^ expected a tuple with 2 elements, found one with 3 elements @@ -9,13 +9,13 @@ LL | let y = first ((1,2.0,3)); = note: expected tuple `(isize, f64)` found tuple `(isize, f64, {integer})` note: function defined here - --> $DIR/tuple-arity-mismatch.rs:3:4 + --> $DIR/tuple-arity-mismatch.rs:5:4 | LL | fn first((value, _): (isize, f64)) -> isize { value } | ^^^^^ ------------------------ error[E0308]: mismatched types - --> $DIR/tuple-arity-mismatch.rs:12:20 + --> $DIR/tuple-arity-mismatch.rs:14:20 | LL | let y = first ((1,)); | ----- ^^^^ expected a tuple with 2 elements, found one with 1 element @@ -25,7 +25,7 @@ LL | let y = first ((1,)); = note: expected tuple `(isize, f64)` found tuple `(isize,)` note: function defined here - --> $DIR/tuple-arity-mismatch.rs:3:4 + --> $DIR/tuple-arity-mismatch.rs:5:4 | LL | fn first((value, _): (isize, f64)) -> isize { value } | ^^^^^ ------------------------ diff --git a/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.rs b/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.rs index 4391bf01dc9..7a540d2a574 100644 --- a/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.rs +++ b/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.rs @@ -22,7 +22,7 @@ impl<In, Out> Trait<Bar, In> for Out { type Out = Out; #[define_opaque(Bar)] fn convert(_i: In) -> Self::Out { - //[next]~^ ERROR: cannot satisfy `Bar == _` + //[next]~^ ERROR: type annotations needed: cannot satisfy `Bar == _` //[current]~^^ ERROR: item does not constrain `Bar::{opaque#0}` unreachable!(); } diff --git a/tests/ui/type-alias/type-param.rs b/tests/ui/type-alias/type-param.rs new file mode 100644 index 00000000000..f8e73518bad --- /dev/null +++ b/tests/ui/type-alias/type-param.rs @@ -0,0 +1,11 @@ +//@ run-pass +// This is a smoke test to ensure that type aliases with type parameters +// are accepted by the compiler and that the parameters are correctly +// resolved in the aliased item type. + +#![allow(dead_code)] + +type Foo<T> = extern "C" fn(T) -> bool; +type Bar<T> = fn(T) -> bool; + +fn main() {} diff --git a/tests/ui/type-param.rs b/tests/ui/type-param.rs deleted file mode 100644 index e7cf0e5446b..00000000000 --- a/tests/ui/type-param.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass - -#![allow(non_camel_case_types)] -#![allow(dead_code)] - - - -type lteq<T> = extern "C" fn(T) -> bool; - -pub fn main() { } diff --git a/tests/ui/type/pattern_types/or_patterns.rs b/tests/ui/type/pattern_types/or_patterns.rs new file mode 100644 index 00000000000..25cb1867047 --- /dev/null +++ b/tests/ui/type/pattern_types/or_patterns.rs @@ -0,0 +1,45 @@ +//! Demonstrate some use cases of or patterns + +//@ normalize-stderr: "pref: Align\([1-8] bytes\)" -> "pref: $$SOME_ALIGN" +//@ normalize-stderr: "randomization_seed: \d+" -> "randomization_seed: $$SEED" + +#![feature( + pattern_type_macro, + pattern_types, + rustc_attrs, + const_trait_impl, + pattern_type_range_trait +)] + +use std::pat::pattern_type; + +#[rustc_layout(debug)] +type NonNullI8 = pattern_type!(i8 is ..0 | 1..); +//~^ ERROR: layout_of + +#[rustc_layout(debug)] +type NonNegOneI8 = pattern_type!(i8 is ..-1 | 0..); +//~^ ERROR: layout_of + +fn main() { + let _: NonNullI8 = 42; + let _: NonNullI8 = 1; + let _: NonNullI8 = 0; + //~^ ERROR: mismatched types + let _: NonNullI8 = -1; + //~^ ERROR: cannot apply unary operator + let _: NonNullI8 = -128; + //~^ ERROR: cannot apply unary operator + let _: NonNullI8 = 127; + + let _: NonNegOneI8 = 42; + let _: NonNegOneI8 = 1; + let _: NonNegOneI8 = 0; + let _: NonNegOneI8 = -1; + //~^ ERROR: cannot apply unary operator + let _: NonNegOneI8 = -2; + //~^ ERROR: cannot apply unary operator + let _: NonNegOneI8 = -128; + //~^ ERROR: cannot apply unary operator + let _: NonNegOneI8 = 127; +} diff --git a/tests/ui/type/pattern_types/or_patterns.stderr b/tests/ui/type/pattern_types/or_patterns.stderr new file mode 100644 index 00000000000..58ca585f4a9 --- /dev/null +++ b/tests/ui/type/pattern_types/or_patterns.stderr @@ -0,0 +1,123 @@ +error[E0308]: mismatched types + --> $DIR/or_patterns.rs:27:24 + | +LL | let _: NonNullI8 = 0; + | --------- ^ expected `(i8) is (i8::MIN..=-1 | 1..)`, found integer + | | + | expected due to this + | + = note: expected pattern type `(i8) is (i8::MIN..=-1 | 1..)` + found type `{integer}` + +error[E0600]: cannot apply unary operator `-` to type `(i8) is (i8::MIN..=-1 | 1..)` + --> $DIR/or_patterns.rs:29:24 + | +LL | let _: NonNullI8 = -1; + | ^^ cannot apply unary operator `-` + +error[E0600]: cannot apply unary operator `-` to type `(i8) is (i8::MIN..=-1 | 1..)` + --> $DIR/or_patterns.rs:31:24 + | +LL | let _: NonNullI8 = -128; + | ^^^^ cannot apply unary operator `-` + +error[E0600]: cannot apply unary operator `-` to type `(i8) is (i8::MIN..=-2 | 0..)` + --> $DIR/or_patterns.rs:38:26 + | +LL | let _: NonNegOneI8 = -1; + | ^^ cannot apply unary operator `-` + +error[E0600]: cannot apply unary operator `-` to type `(i8) is (i8::MIN..=-2 | 0..)` + --> $DIR/or_patterns.rs:40:26 + | +LL | let _: NonNegOneI8 = -2; + | ^^ cannot apply unary operator `-` + +error[E0600]: cannot apply unary operator `-` to type `(i8) is (i8::MIN..=-2 | 0..)` + --> $DIR/or_patterns.rs:42:26 + | +LL | let _: NonNegOneI8 = -128; + | ^^^^ cannot apply unary operator `-` + +error: layout_of((i8) is (i8::MIN..=-1 | 1..)) = Layout { + size: Size(1 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $SOME_ALIGN, + }, + backend_repr: Scalar( + Initialized { + value: Int( + I8, + true, + ), + valid_range: 1..=255, + }, + ), + fields: Primitive, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I8, + true, + ), + valid_range: 1..=255, + }, + ), + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), + randomization_seed: $SEED, + } + --> $DIR/or_patterns.rs:17:1 + | +LL | type NonNullI8 = pattern_type!(i8 is ..0 | 1..); + | ^^^^^^^^^^^^^^ + +error: layout_of((i8) is (i8::MIN..=-2 | 0..)) = Layout { + size: Size(1 bytes), + align: AbiAndPrefAlign { + abi: Align(1 bytes), + pref: $SOME_ALIGN, + }, + backend_repr: Scalar( + Initialized { + value: Int( + I8, + true, + ), + valid_range: 0..=254, + }, + ), + fields: Primitive, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I8, + true, + ), + valid_range: 0..=254, + }, + ), + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: Align(1 bytes), + randomization_seed: $SEED, + } + --> $DIR/or_patterns.rs:21:1 + | +LL | type NonNegOneI8 = pattern_type!(i8 is ..-1 | 0..); + | ^^^^^^^^^^^^^^^^ + +error: aborting due to 8 previous errors + +Some errors have detailed explanations: E0308, E0600. +For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/type/pattern_types/or_patterns_invalid.rs b/tests/ui/type/pattern_types/or_patterns_invalid.rs new file mode 100644 index 00000000000..d341927601d --- /dev/null +++ b/tests/ui/type/pattern_types/or_patterns_invalid.rs @@ -0,0 +1,26 @@ +//! Demonstrate some use cases of or patterns + +#![feature( + pattern_type_macro, + pattern_types, + rustc_attrs, + const_trait_impl, + pattern_type_range_trait +)] + +use std::pat::pattern_type; + +fn main() { + //~? ERROR: only non-overlapping pattern type ranges are allowed at present + let not_adjacent: pattern_type!(i8 is -127..0 | 1..) = unsafe { std::mem::transmute(0) }; + + //~? ERROR: one pattern needs to end at `i8::MAX`, but was 29 instead + let not_wrapping: pattern_type!(i8 is 10..20 | 20..30) = unsafe { std::mem::transmute(0) }; + + //~? ERROR: only signed integer base types are allowed for or-pattern pattern types + let not_signed: pattern_type!(u8 is 10.. | 0..5) = unsafe { std::mem::transmute(0) }; + + //~? ERROR: allowed are two range patterns that are directly connected + let not_simple_enough_for_mvp: pattern_type!(i8 is ..0 | 1..10 | 10..) = + unsafe { std::mem::transmute(0) }; +} diff --git a/tests/ui/type/pattern_types/or_patterns_invalid.stderr b/tests/ui/type/pattern_types/or_patterns_invalid.stderr new file mode 100644 index 00000000000..6964788a6c2 --- /dev/null +++ b/tests/ui/type/pattern_types/or_patterns_invalid.stderr @@ -0,0 +1,10 @@ +error: only non-overlapping pattern type ranges are allowed at present + +error: one pattern needs to end at `i8::MAX`, but was 29 instead + +error: only signed integer base types are allowed for or-pattern pattern types at present + +error: the only or-pattern types allowed are two range patterns that are directly connected at their overflow site + +error: aborting due to 4 previous errors + diff --git a/tests/ui/type/type-mismatch-multiple.rs b/tests/ui/type/type-mismatch-multiple.rs index 55d6ceef1de..faae52cad23 100644 --- a/tests/ui/type/type-mismatch-multiple.rs +++ b/tests/ui/type/type-mismatch-multiple.rs @@ -1,7 +1,9 @@ // Checking that the compiler reports multiple type errors at once +//@ dont-require-annotations: NOTE + fn main() { let a: bool = 1; let b: i32 = true; } //~^ ERROR mismatched types -//~| expected `bool`, found integer +//~| NOTE expected `bool`, found integer //~| ERROR mismatched types -//~| expected `i32`, found `bool` +//~| NOTE expected `i32`, found `bool` diff --git a/tests/ui/type/type-mismatch-multiple.stderr b/tests/ui/type/type-mismatch-multiple.stderr index 2e8654d3196..50078e5b03a 100644 --- a/tests/ui/type/type-mismatch-multiple.stderr +++ b/tests/ui/type/type-mismatch-multiple.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/type-mismatch-multiple.rs:3:27 + --> $DIR/type-mismatch-multiple.rs:5:27 | LL | fn main() { let a: bool = 1; let b: i32 = true; } | ---- ^ expected `bool`, found integer @@ -7,7 +7,7 @@ LL | fn main() { let a: bool = 1; let b: i32 = true; } | expected due to this error[E0308]: mismatched types - --> $DIR/type-mismatch-multiple.rs:3:43 + --> $DIR/type-mismatch-multiple.rs:5:43 | LL | fn main() { let a: bool = 1; let b: i32 = true; } | --- ^^^^ expected `i32`, found `bool` diff --git a/tests/ui/type/type-parameter-names.rs b/tests/ui/type/type-parameter-names.rs index b54a3fae0c1..fbd1885f543 100644 --- a/tests/ui/type/type-parameter-names.rs +++ b/tests/ui/type/type-parameter-names.rs @@ -1,12 +1,14 @@ // Test that we print out the names of type parameters correctly in // our error messages. +//@ dont-require-annotations: NOTE + fn foo<Foo, Bar>(x: Foo) -> Bar { x //~^ ERROR mismatched types -//~| expected type parameter `Bar`, found type parameter `Foo` -//~| expected type parameter `Bar` -//~| found type parameter `Foo` +//~| NOTE expected type parameter `Bar`, found type parameter `Foo` +//~| NOTE expected type parameter `Bar` +//~| NOTE found type parameter `Foo` } fn main() {} diff --git a/tests/ui/type/type-parameter-names.stderr b/tests/ui/type/type-parameter-names.stderr index be9000a99e4..795a260688c 100644 --- a/tests/ui/type/type-parameter-names.stderr +++ b/tests/ui/type/type-parameter-names.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/type-parameter-names.rs:5:5 + --> $DIR/type-parameter-names.rs:7:5 | LL | fn foo<Foo, Bar>(x: Foo) -> Bar { | --- --- --- expected `Bar` because of return type diff --git a/tests/ui/type/type-params-in-different-spaces-1.rs b/tests/ui/type/type-params-in-different-spaces-1.rs index 6efd14d3785..2cde1de1c0d 100644 --- a/tests/ui/type/type-params-in-different-spaces-1.rs +++ b/tests/ui/type/type-params-in-different-spaces-1.rs @@ -1,11 +1,13 @@ +//@ dont-require-annotations: NOTE + use std::ops::Add; trait BrokenAdd: Copy + Add<Output=Self> { fn broken_add<T>(&self, rhs: T) -> Self { *self + rhs //~ ERROR mismatched types - //~| expected type parameter `Self`, found type parameter `T` - //~| expected type parameter `Self` - //~| found type parameter `T` + //~| NOTE expected type parameter `Self`, found type parameter `T` + //~| NOTE expected type parameter `Self` + //~| NOTE found type parameter `T` } } diff --git a/tests/ui/type/type-params-in-different-spaces-1.stderr b/tests/ui/type/type-params-in-different-spaces-1.stderr index 1d0e097fdc3..e9480b0e58f 100644 --- a/tests/ui/type/type-params-in-different-spaces-1.stderr +++ b/tests/ui/type/type-params-in-different-spaces-1.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/type-params-in-different-spaces-1.rs:5:17 + --> $DIR/type-params-in-different-spaces-1.rs:7:17 | LL | trait BrokenAdd: Copy + Add<Output=Self> { | ---------------------------------------- expected type parameter diff --git a/tests/ui/typeck/issue-16338.rs b/tests/ui/typeck/issue-16338.rs index 321b3576cd6..6c02eb93890 100644 --- a/tests/ui/typeck/issue-16338.rs +++ b/tests/ui/typeck/issue-16338.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + struct Slice<T> { data: *const T, len: usize, @@ -6,5 +8,5 @@ struct Slice<T> { fn main() { let Slice { data: data, len: len } = "foo"; //~^ ERROR mismatched types - //~| found struct `Slice<_>` + //~| NOTE found struct `Slice<_>` } diff --git a/tests/ui/typeck/issue-16338.stderr b/tests/ui/typeck/issue-16338.stderr index e24b9bfa3c0..8c5c6ad7b8c 100644 --- a/tests/ui/typeck/issue-16338.stderr +++ b/tests/ui/typeck/issue-16338.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-16338.rs:7:9 + --> $DIR/issue-16338.rs:9:9 | LL | let Slice { data: data, len: len } = "foo"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ----- this expression has type `&str` diff --git a/tests/ui/typeck/suppressed-error.rs b/tests/ui/typeck/suppressed-error.rs index 1e39be46080..b7e5b22e9db 100644 --- a/tests/ui/typeck/suppressed-error.rs +++ b/tests/ui/typeck/suppressed-error.rs @@ -1,8 +1,9 @@ fn main() { let (x, y) = (); //~^ ERROR mismatched types -//~| expected unit type `()` -//~| found tuple `(_, _)` -//~| expected `()`, found +//~| NOTE expected unit type `()` +//~| NOTE found tuple `(_, _)` +//~| NOTE expected `()`, found +//~| NOTE this expression has type `()` return x; } diff --git a/tests/ui/typeck/tag-that-dare-not-speak-its-name.rs b/tests/ui/typeck/tag-that-dare-not-speak-its-name.rs index 0e76ec246d7..79aa1f27a78 100644 --- a/tests/ui/typeck/tag-that-dare-not-speak-its-name.rs +++ b/tests/ui/typeck/tag-that-dare-not-speak-its-name.rs @@ -10,7 +10,8 @@ fn main() { let y; let x : char = last(y); //~^ ERROR mismatched types - //~| expected type `char` - //~| found enum `Option<_>` - //~| expected `char`, found `Option<_>` + //~| NOTE expected type `char` + //~| NOTE found enum `Option<_>` + //~| NOTE expected `char`, found `Option<_>` + //~| NOTE expected due to this } diff --git a/tests/ui/typeck/terr-in-field.rs b/tests/ui/typeck/terr-in-field.rs index cfe350ef86d..1b8f76f40cb 100644 --- a/tests/ui/typeck/terr-in-field.rs +++ b/tests/ui/typeck/terr-in-field.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + struct Foo { a: isize, b: isize, @@ -11,7 +13,7 @@ struct Bar { fn want_foo(f: Foo) {} fn have_bar(b: Bar) { want_foo(b); //~ ERROR mismatched types - //~| expected `Foo`, found `Bar` + //~| NOTE expected `Foo`, found `Bar` } fn main() {} diff --git a/tests/ui/typeck/terr-in-field.stderr b/tests/ui/typeck/terr-in-field.stderr index adc336db501..37e55af84f7 100644 --- a/tests/ui/typeck/terr-in-field.stderr +++ b/tests/ui/typeck/terr-in-field.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/terr-in-field.rs:13:14 + --> $DIR/terr-in-field.rs:15:14 | LL | want_foo(b); | -------- ^ expected `Foo`, found `Bar` @@ -7,7 +7,7 @@ LL | want_foo(b); | arguments to this function are incorrect | note: function defined here - --> $DIR/terr-in-field.rs:11:4 + --> $DIR/terr-in-field.rs:13:4 | LL | fn want_foo(f: Foo) {} | ^^^^^^^^ ------ diff --git a/tests/ui/typeck/terr-sorts.rs b/tests/ui/typeck/terr-sorts.rs index c1e2f7daee5..439d27162f8 100644 --- a/tests/ui/typeck/terr-sorts.rs +++ b/tests/ui/typeck/terr-sorts.rs @@ -1,3 +1,5 @@ +//@ dont-require-annotations: NOTE + struct Foo { a: isize, b: isize, @@ -8,8 +10,8 @@ type Bar = Box<Foo>; fn want_foo(f: Foo) {} fn have_bar(b: Bar) { want_foo(b); //~ ERROR mismatched types - //~| expected struct `Foo` - //~| found struct `Box<Foo>` + //~| NOTE expected struct `Foo` + //~| NOTE found struct `Box<Foo>` } fn main() {} diff --git a/tests/ui/typeck/terr-sorts.stderr b/tests/ui/typeck/terr-sorts.stderr index 59d9392c236..0f649f2f035 100644 --- a/tests/ui/typeck/terr-sorts.stderr +++ b/tests/ui/typeck/terr-sorts.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/terr-sorts.rs:10:14 + --> $DIR/terr-sorts.rs:12:14 | LL | want_foo(b); | -------- ^ expected `Foo`, found `Box<Foo>` @@ -9,7 +9,7 @@ LL | want_foo(b); = note: expected struct `Foo` found struct `Box<Foo>` note: function defined here - --> $DIR/terr-sorts.rs:8:4 + --> $DIR/terr-sorts.rs:10:4 | LL | fn want_foo(f: Foo) {} | ^^^^^^^^ ------ diff --git a/tests/ui/typeck/typeck_type_placeholder_mismatch.rs b/tests/ui/typeck/typeck_type_placeholder_mismatch.rs index 718b6deed1b..cedda4a636e 100644 --- a/tests/ui/typeck/typeck_type_placeholder_mismatch.rs +++ b/tests/ui/typeck/typeck_type_placeholder_mismatch.rs @@ -1,6 +1,8 @@ // This test checks that genuine type errors with partial // type hints are understandable. +//@ dont-require-annotations: NOTE + use std::marker::PhantomData; struct Foo<T>(PhantomData<T>); @@ -12,16 +14,16 @@ pub fn main() { fn test1() { let x: Foo<_> = Bar::<usize>(PhantomData); //~^ ERROR mismatched types - //~| expected struct `Foo<_>` - //~| found struct `Bar<usize>` - //~| expected `Foo<_>`, found `Bar<usize>` + //~| NOTE expected struct `Foo<_>` + //~| NOTE found struct `Bar<usize>` + //~| NOTE expected `Foo<_>`, found `Bar<usize>` let y: Foo<usize> = x; } fn test2() { let x: Foo<_> = Bar::<usize>(PhantomData); //~^ ERROR mismatched types - //~| expected struct `Foo<_>` - //~| found struct `Bar<usize>` - //~| expected `Foo<_>`, found `Bar<usize>` + //~| NOTE expected struct `Foo<_>` + //~| NOTE found struct `Bar<usize>` + //~| NOTE expected `Foo<_>`, found `Bar<usize>` } diff --git a/tests/ui/typeck/typeck_type_placeholder_mismatch.stderr b/tests/ui/typeck/typeck_type_placeholder_mismatch.stderr index bf8e0bbb519..c6e42ececd2 100644 --- a/tests/ui/typeck/typeck_type_placeholder_mismatch.stderr +++ b/tests/ui/typeck/typeck_type_placeholder_mismatch.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/typeck_type_placeholder_mismatch.rs:13:21 + --> $DIR/typeck_type_placeholder_mismatch.rs:15:21 | LL | let x: Foo<_> = Bar::<usize>(PhantomData); | ------ ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Foo<_>`, found `Bar<usize>` @@ -10,7 +10,7 @@ LL | let x: Foo<_> = Bar::<usize>(PhantomData); found struct `Bar<usize>` error[E0308]: mismatched types - --> $DIR/typeck_type_placeholder_mismatch.rs:22:21 + --> $DIR/typeck_type_placeholder_mismatch.rs:24:21 | LL | let x: Foo<_> = Bar::<usize>(PhantomData); | ------ ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Foo<_>`, found `Bar<usize>` diff --git a/tests/ui/typeof/type_mismatch.rs b/tests/ui/typeof/type_mismatch.rs index 3f8339fa5be..a3444d6c207 100644 --- a/tests/ui/typeof/type_mismatch.rs +++ b/tests/ui/typeof/type_mismatch.rs @@ -1,9 +1,12 @@ // Test that using typeof results in the correct type mismatch errors instead of always assuming // `usize`, in addition to the pre-existing "typeof is reserved and unimplemented" error + +//@ dont-require-annotations: NOTE + fn main() { const a: u8 = 1; let b: typeof(a) = 1i8; //~^ ERROR `typeof` is a reserved keyword but unimplemented //~| ERROR mismatched types - //~| expected `u8`, found `i8` + //~| NOTE expected `u8`, found `i8` } diff --git a/tests/ui/typeof/type_mismatch.stderr b/tests/ui/typeof/type_mismatch.stderr index d5494922b16..6a414c11f38 100644 --- a/tests/ui/typeof/type_mismatch.stderr +++ b/tests/ui/typeof/type_mismatch.stderr @@ -1,5 +1,5 @@ error[E0516]: `typeof` is a reserved keyword but unimplemented - --> $DIR/type_mismatch.rs:5:12 + --> $DIR/type_mismatch.rs:8:12 | LL | let b: typeof(a) = 1i8; | ^^^^^^^^^ reserved keyword @@ -11,7 +11,7 @@ LL + let b: u8 = 1i8; | error[E0308]: mismatched types - --> $DIR/type_mismatch.rs:5:24 + --> $DIR/type_mismatch.rs:8:24 | LL | let b: typeof(a) = 1i8; | --------- ^^^ expected `u8`, found `i8` diff --git a/tests/ui/ufcs/ufcs-explicit-self-bad.rs b/tests/ui/ufcs/ufcs-explicit-self-bad.rs index 29586dccfc9..7039ab30428 100644 --- a/tests/ui/ufcs/ufcs-explicit-self-bad.rs +++ b/tests/ui/ufcs/ufcs-explicit-self-bad.rs @@ -1,13 +1,13 @@ +//@ dont-require-annotations: NOTE + struct Foo { f: isize, } - - impl Foo { fn foo(self: isize, x: isize) -> isize { //~^ ERROR invalid `self` parameter type - self.f + x //~ ERROR: doesn't have fields + self.f + x //~ ERROR doesn't have fields } } @@ -39,13 +39,13 @@ impl<'a, T> SomeTrait for &'a Bar<T> { //~| ERROR has an incompatible type for trait fn dummy3(self: &&Bar<T>) {} //~^ ERROR mismatched `self` parameter type - //~| expected reference `&'a Bar<_>` - //~| found reference `&Bar<_>` - //~| lifetime mismatch + //~| NOTE expected reference `&'a Bar<_>` + //~| NOTE found reference `&Bar<_>` + //~| NOTE lifetime mismatch //~| ERROR mismatched `self` parameter type - //~| expected reference `&'a Bar<_>` - //~| found reference `&Bar<_>` - //~| lifetime mismatch + //~| NOTE expected reference `&'a Bar<_>` + //~| NOTE found reference `&Bar<_>` + //~| NOTE lifetime mismatch } fn main() { diff --git a/tests/ui/unpretty/exhaustive-asm.expanded.stdout b/tests/ui/unpretty/exhaustive-asm.expanded.stdout new file mode 100644 index 00000000000..92829b0ab15 --- /dev/null +++ b/tests/ui/unpretty/exhaustive-asm.expanded.stdout @@ -0,0 +1,33 @@ +#![feature(prelude_import)] +#[prelude_import] +use std::prelude::rust_2024::*; +#[macro_use] +extern crate std; +//@ revisions: expanded hir +//@[expanded]compile-flags: -Zunpretty=expanded +//@[expanded]check-pass +//@[hir]compile-flags: -Zunpretty=hir +//@[hir]check-pass +//@ edition:2024 +//@ only-x86_64 +// +// asm parts of exhaustive.rs. Separate because we only run this on x86_64. + +mod expressions { + /// ExprKind::InlineAsm + fn expr_inline_asm() { + let x; + asm!("mov {1}, {0}\nshl {1}, 1\nshl {0}, 2\nadd {0}, {1}", + inout(reg) + x, + out(reg) + _); + } +} + +mod items { + /// ItemKind::GlobalAsm + mod item_global_asm { + global_asm! (".globl my_asm_func"); + } +} diff --git a/tests/ui/unpretty/exhaustive-asm.hir.stdout b/tests/ui/unpretty/exhaustive-asm.hir.stdout new file mode 100644 index 00000000000..810db69bff1 --- /dev/null +++ b/tests/ui/unpretty/exhaustive-asm.hir.stdout @@ -0,0 +1,32 @@ +#[prelude_import] +use std::prelude::rust_2024::*; +#[macro_use] +extern crate std; +//@ revisions: expanded hir +//@[expanded]compile-flags: -Zunpretty=expanded +//@[expanded]check-pass +//@[hir]compile-flags: -Zunpretty=hir +//@[hir]check-pass +//@ edition:2024 +//@ only-x86_64 +// +// asm parts of exhaustive.rs. Separate because we only run this on x86_64. + +mod expressions { + /// ExprKind::InlineAsm + fn expr_inline_asm() { + let x; + asm!("mov {1}, {0}\nshl {1}, 1\nshl {0}, 2\nadd {0}, {1}", + inout(reg) + x, + out(reg) + _); + } +} + +mod items { + /// ItemKind::GlobalAsm + mod item_global_asm {/// ItemKind::GlobalAsm + global_asm! (".globl my_asm_func"); + } +} diff --git a/tests/ui/unpretty/exhaustive-asm.rs b/tests/ui/unpretty/exhaustive-asm.rs new file mode 100644 index 00000000000..74a45447a20 --- /dev/null +++ b/tests/ui/unpretty/exhaustive-asm.rs @@ -0,0 +1,31 @@ +//@ revisions: expanded hir +//@[expanded]compile-flags: -Zunpretty=expanded +//@[expanded]check-pass +//@[hir]compile-flags: -Zunpretty=hir +//@[hir]check-pass +//@ edition:2024 +//@ only-x86_64 +// +// asm parts of exhaustive.rs. Separate because we only run this on x86_64. + +mod expressions { + /// ExprKind::InlineAsm + fn expr_inline_asm() { + let x; + core::arch::asm!( + "mov {tmp}, {x}", + "shl {tmp}, 1", + "shl {x}, 2", + "add {x}, {tmp}", + x = inout(reg) x, + tmp = out(reg) _, + ); + } +} + +mod items { + /// ItemKind::GlobalAsm + mod item_global_asm { + core::arch::global_asm!(".globl my_asm_func"); + } +} diff --git a/tests/ui/unpretty/expanded-exhaustive.stdout b/tests/ui/unpretty/exhaustive.expanded.stdout index 8febd2d6d49..9712ba58e62 100644 --- a/tests/ui/unpretty/expanded-exhaustive.stdout +++ b/tests/ui/unpretty/exhaustive.expanded.stdout @@ -1,7 +1,13 @@ #![feature(prelude_import)] -//@ compile-flags: -Zunpretty=expanded +//@ revisions: expanded hir +//@[expanded]compile-flags: -Zunpretty=expanded +//@[expanded]check-pass +//@[hir]compile-flags: -Zunpretty=hir +//@[hir]check-fail //@ edition:2024 -//@ check-pass + +// Note: the HIR revision includes a `.stderr` file because there are some +// errors that only occur once we get past the AST. #![feature(auto_traits)] #![feature(box_patterns)] @@ -211,7 +217,10 @@ mod expressions { } /// ExprKind::Await - fn expr_await() { let fut; fut.await; } + fn expr_await() { + let fut; + fut.await; + } /// ExprKind::TryBlock fn expr_try_block() { try {} try { return; } } @@ -242,7 +251,9 @@ mod expressions { } /// ExprKind::Underscore - fn expr_underscore() { _; } + fn expr_underscore() { + _; + } /// ExprKind::Path fn expr_path() { @@ -275,16 +286,8 @@ mod expressions { /// ExprKind::Ret fn expr_ret() { return; return true; } - /// ExprKind::InlineAsm - fn expr_inline_asm() { - let x; - asm!("mov {1}, {0}\nshl {1}, 1\nshl {0}, 2\nadd {0}, {1}", - inout(reg) - x, - out(reg) - _); - } + /// ExprKind::InlineAsm: see exhaustive-asm.rs /// ExprKind::OffsetOf fn expr_offset_of() { @@ -300,65 +303,13 @@ mod expressions { - - - - - - // ... - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // concat_idents is deprecated @@ -449,10 +400,7 @@ mod items { unsafe extern "C++" {} unsafe extern "C" {} } - /// ItemKind::GlobalAsm - mod item_global_asm { - global_asm! (".globl my_asm_func"); - } + /// ItemKind::GlobalAsm: see exhaustive-asm.rs /// ItemKind::TyAlias mod item_ty_alias { pub type Type<'a> where T: 'a = T; @@ -504,7 +452,7 @@ mod items { mod item_mac_call { } /// ItemKind::MacroDef mod item_macro_def { - macro_rules! mac { () => { ... }; } + macro_rules! mac { () => {...}; } pub macro stringify { () => {} } } /// ItemKind::Delegation @@ -674,6 +622,7 @@ mod types { /*! there is no syntax for this */ } /// TyKind::MacCall + #[expect(deprecated)] fn ty_mac_call() { let _: T; let _: T; let _: T; } /// TyKind::CVarArgs fn ty_c_var_args() { diff --git a/tests/ui/unpretty/exhaustive.hir.stderr b/tests/ui/unpretty/exhaustive.hir.stderr new file mode 100644 index 00000000000..58f7ff0f598 --- /dev/null +++ b/tests/ui/unpretty/exhaustive.hir.stderr @@ -0,0 +1,172 @@ +error[E0697]: closures cannot be static + --> $DIR/exhaustive.rs:211:9 + | +LL | static || value; + | ^^^^^^^^^ + +error[E0697]: closures cannot be static + --> $DIR/exhaustive.rs:212:9 + | +LL | static move || value; + | ^^^^^^^^^^^^^^ + +error[E0728]: `await` is only allowed inside `async` functions and blocks + --> $DIR/exhaustive.rs:241:13 + | +LL | fn expr_await() { + | --------------- this is not `async` +LL | let fut; +LL | fut.await; + | ^^^^^ only allowed inside `async` functions and blocks + +error: in expressions, `_` can only be used on the left-hand side of an assignment + --> $DIR/exhaustive.rs:290:9 + | +LL | _; + | ^ `_` not allowed here + +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/exhaustive.rs:300:9 + | +LL | x::(); + | ^^^^^ only `Fn` traits may use parentheses + +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/exhaustive.rs:301:9 + | +LL | x::(T, T) -> T; + | ^^^^^^^^^^^^^^ only `Fn` traits may use parentheses + | +help: use angle brackets instead + | +LL - x::(T, T) -> T; +LL + x::<T, T> -> T; + | + +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/exhaustive.rs:302:9 + | +LL | crate::() -> ()::expressions::() -> ()::expr_path; + | ^^^^^^^^^^^^^^^ only `Fn` traits may use parentheses + +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/exhaustive.rs:302:26 + | +LL | crate::() -> ()::expressions::() -> ()::expr_path; + | ^^^^^^^^^^^^^^^^^^^^^ only `Fn` traits may use parentheses + +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/exhaustive.rs:305:9 + | +LL | core::()::marker::()::PhantomData; + | ^^^^^^^^ only `Fn` traits may use parentheses + +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/exhaustive.rs:305:19 + | +LL | core::()::marker::()::PhantomData; + | ^^^^^^^^^^ only `Fn` traits may use parentheses + +error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks + --> $DIR/exhaustive.rs:392:9 + | +LL | yield; + | ^^^^^ + | +help: use `#[coroutine]` to make this closure a coroutine + | +LL | #[coroutine] fn expr_yield() { + | ++++++++++++ + +error[E0703]: invalid ABI: found `C++` + --> $DIR/exhaustive.rs:472:23 + | +LL | unsafe extern "C++" {} + | ^^^^^ invalid ABI + | + = note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions + +error: `..` patterns are not allowed here + --> $DIR/exhaustive.rs:679:13 + | +LL | let ..; + | ^^ + | + = note: only allowed in tuple, tuple struct, and slice patterns + +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/exhaustive.rs:794:16 + | +LL | let _: T() -> !; + | ^^^^^^^^ only `Fn` traits may use parentheses + +error[E0562]: `impl Trait` is not allowed in the type of variable bindings + --> $DIR/exhaustive.rs:809:16 + | +LL | let _: impl Send; + | ^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + = note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information + = help: add `#![feature(impl_trait_in_bindings)]` 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[E0562]: `impl Trait` is not allowed in the type of variable bindings + --> $DIR/exhaustive.rs:810:16 + | +LL | let _: impl Send + 'static; + | ^^^^^^^^^^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + = note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information + = help: add `#![feature(impl_trait_in_bindings)]` 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[E0562]: `impl Trait` is not allowed in the type of variable bindings + --> $DIR/exhaustive.rs:811:16 + | +LL | let _: impl 'static + Send; + | ^^^^^^^^^^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + = note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information + = help: add `#![feature(impl_trait_in_bindings)]` 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[E0562]: `impl Trait` is not allowed in the type of variable bindings + --> $DIR/exhaustive.rs:812:16 + | +LL | let _: impl ?Sized; + | ^^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + = note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information + = help: add `#![feature(impl_trait_in_bindings)]` 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[E0562]: `impl Trait` is not allowed in the type of variable bindings + --> $DIR/exhaustive.rs:813:16 + | +LL | let _: impl ~const Clone; + | ^^^^^^^^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + = note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information + = help: add `#![feature(impl_trait_in_bindings)]` 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[E0562]: `impl Trait` is not allowed in the type of variable bindings + --> $DIR/exhaustive.rs:814:16 + | +LL | let _: impl for<'a> Send; + | ^^^^^^^^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + = note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information + = help: add `#![feature(impl_trait_in_bindings)]` 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 20 previous errors + +Some errors have detailed explanations: E0214, E0562, E0697, E0703, E0728. +For more information about an error, try `rustc --explain E0214`. diff --git a/tests/ui/unpretty/exhaustive.hir.stdout b/tests/ui/unpretty/exhaustive.hir.stdout new file mode 100644 index 00000000000..c20f123b16e --- /dev/null +++ b/tests/ui/unpretty/exhaustive.hir.stdout @@ -0,0 +1,724 @@ +//@ revisions: expanded hir +//@[expanded]compile-flags: -Zunpretty=expanded +//@[expanded]check-pass +//@[hir]compile-flags: -Zunpretty=hir +//@[hir]check-fail +//@ edition:2024 + +// Note: the HIR revision includes a `.stderr` file because there are some +// errors that only occur once we get past the AST. + +#![feature(auto_traits)] +#![feature(box_patterns)] +#![feature(builtin_syntax)] +#![feature(concat_idents)] +#![feature(const_trait_impl)] +#![feature(decl_macro)] +#![feature(deref_patterns)] +#![feature(dyn_star)] +#![feature(explicit_tail_calls)] +#![feature(gen_blocks)] +#![feature(more_qualified_paths)] +#![feature(never_patterns)] +#![feature(never_type)] +#![feature(pattern_types)] +#![feature(pattern_type_macro)] +#![feature(prelude_import)] +#![feature(specialization)] +#![feature(trace_macros)] +#![feature(trait_alias)] +#![feature(try_blocks)] +#![feature(yeet_expr)] +#![allow(incomplete_features)] +#[prelude_import] +use std::prelude::rust_2024::*; +#[macro_use] +extern crate std; + +#[prelude_import] +use self::prelude::*; + +mod prelude { + use std::prelude::rust_2024::*; + + type T = _; + + trait Trait { + const + CONST: + (); + } +} + +//! inner single-line doc comment +/*! + * inner multi-line doc comment + */ +#[doc = "inner doc attribute"] +#[allow(dead_code, unused_variables)] +#[no_std] +mod attributes {//! inner single-line doc comment + /*! + * inner multi-line doc comment + */ + #![doc = "inner doc attribute"] + #![allow(dead_code, unused_variables)] + #![no_std] + + /// outer single-line doc comment + /** + * outer multi-line doc comment + */ + #[doc = "outer doc attribute"] + #[doc = "macro"] + #[allow()] + #[attr = Repr([ReprC])] + struct Struct; +} + +mod expressions { + /// ExprKind::Array + fn expr_array() { + []; + [true]; + [true]; + [true, true]; + ["long........................................................................"]; + ["long............................................................", + true]; + } + + /// ExprKind::ConstBlock + fn expr_const_block() { + const { }; + const { 1 }; + const + { + struct S; + }; + } + + /// ExprKind::Call + fn expr_call() { + let f; + f(); + f::<u8>(); + f::<1>(); + f::<'static, u8, 1>(); + f(true); + f(true); + ()(); + } + + /// ExprKind::MethodCall + fn expr_method_call() { + let x; + x.f(); + x.f::<u8>(); + x.collect::<Vec<_>>(); + } + + /// ExprKind::Tup + fn expr_tup() { (); (true,); (true, false); (true, false); } + + /// ExprKind::Binary + fn expr_binary() { + let (a, b, c, d, x, y); + true || false; + true || false && false; + a < 1 && 2 < b && c > 3 && 4 > d; + a & b & !c; + a + b * c - d + -1 * -2 - -3; + x = !y; + } + + /// ExprKind::Unary + fn expr_unary() { let expr; *expr; !expr; -expr; } + + /// ExprKind::Lit + fn expr_lit() { 'x'; 1000i8; 1.00000000000000000000001; } + + /// ExprKind::Cast + fn expr_cast() { let expr; expr as T; expr as T<u8>; } + + /// ExprKind::Type + fn expr_type() { let expr; type_ascribe!(expr, T); } + + /// ExprKind::Let + fn expr_let() { + let b; + if let Some(a) = b { } + if let _ = true && false { } + if let _ = (true && false) { } + } + + /// ExprKind::If + fn expr_if() { + if true { } + if !true { } + if let true = true { } else { } + if true { } else if false { } + if true { } else if false { } else { } + if true { return; } else if false { 0 } else { 0 } + } + + /// ExprKind::While + fn expr_while() { + loop { if false { } else { break; } } + 'a: loop { if false { } else { break; } } + loop { if let true = true { } else { break; } } + } + + /// ExprKind::ForLoop + fn expr_for_loop() { + let x; + { + let _t = + match #[lang = "into_iter"](x) { + mut iter => + loop { + match #[lang = "next"](&mut iter) { + #[lang = "None"] {} => break, + #[lang = "Some"] { 0: _ } => { } + } + }, + }; + _t + }; + { + let _t = + match #[lang = "into_iter"](x) { + mut iter => + 'a: loop { + match #[lang = "next"](&mut iter) { + #[lang = "None"] {} => break, + #[lang = "Some"] { 0: _ } => { } + } + }, + }; + _t + } + } + + /// ExprKind::Loop + fn expr_loop() { loop { } 'a: loop { } } + + /// ExprKind::Match + fn expr_match() { + let value; + match value { } + match value { ok => 1, } + match value { ok => 1, err => 0, } + } + + /// ExprKind::Closure + fn expr_closure() { + let value; + || { }; + |x| { }; + |x: u8| { }; + || (); + move || value; + || |mut _task_context: ResumeTy| { { let _t = value; _t } }; + move || |mut _task_context: ResumeTy| { { let _t = value; _t } }; + || value; + move || value; + || |mut _task_context: ResumeTy| { { let _t = value; _t } }; + move || |mut _task_context: ResumeTy| { { let _t = value; _t } }; + || -> u8 { value }; + 1 + (|| { }); + } + + /// ExprKind::Block + fn expr_block() { + { } + unsafe { } + 'a: { } + #[allow()] + { } + #[allow()] + { } + } + + /// ExprKind::Gen + fn expr_gen() { + |mut _task_context: ResumeTy| { }; + move |mut _task_context: ResumeTy| { }; + || { }; + move || { }; + |mut _task_context: ResumeTy| { }; + move |mut _task_context: ResumeTy| { }; + } + + /// ExprKind::Await + fn expr_await() { + let fut; + { + fut; + (/*ERROR*/) + }; + } + + /// ExprKind::TryBlock + fn expr_try_block() { + { #[lang = "from_output"](()) } + { return; #[lang = "from_output"](()) } + } + + /// ExprKind::Assign + fn expr_assign() { let expr; expr = true; } + + /// ExprKind::AssignOp + fn expr_assign_op() { let expr; expr += true; } + + /// ExprKind::Field + fn expr_field() { let expr; expr.field; expr.0; } + + /// ExprKind::Index + fn expr_index() { let expr; expr[true]; } + + /// ExprKind::Range + fn expr_range() { + let (lo, hi); + #[lang = "RangeFull"] { }; + #[lang = "RangeTo"] { end: hi }; + #[lang = "RangeFrom"] { start: lo }; + #[lang = "Range"] { start: lo, end: hi }; + #[lang = "Range"] { start: lo, end: hi }; + #[lang = "RangeToInclusive"] { end: hi }; + #[lang = "range_inclusive_new"](lo, hi); + #[lang = "range_inclusive_new"](-2, -1); + } + + /// ExprKind::Underscore + fn expr_underscore() { + (/*ERROR*/); + } + + /// ExprKind::Path + fn expr_path() { + let x; + crate::expressions::expr_path; + crate::expressions::expr_path::<'static>; + <T as Default>::default; + <T as ::core::default::Default>::default; + x; + x::<T, T>; + crate::expressions::expr_path; + core::marker::PhantomData; + } + + /// ExprKind::AddrOf + fn expr_addr_of() { + let expr; + &expr; + &mut expr; + &raw const expr; + &raw mut expr; + } + + /// ExprKind::Break + fn expr_break() { 'a: { break; break 'a; break true; break 'a true; } } + + /// ExprKind::Continue + fn expr_continue() { 'a: { continue; continue 'a; } } + + /// ExprKind::Ret + fn expr_ret() { return; return true; } + + + /// ExprKind::InlineAsm: see exhaustive-asm.rs + /// ExprKind::OffsetOf + fn expr_offset_of() { + + + + + + + + + + + + + + // ... + + + + + + // concat_idents is deprecated + + + + + { offset_of!(T, field) }; + } + /// ExprKind::MacCall + fn expr_mac_call() { "..."; "..."; "..."; } + /// ExprKind::Struct + fn expr_struct() { + struct Struct { + } + let (x, base); + Struct { }; + <Struct as ToOwned>::Owned { }; + Struct { .. }; + Struct { ..base }; + Struct { x }; + Struct { x, ..base }; + Struct { x: true }; + Struct { x: true, .. }; + Struct { x: true, ..base }; + Struct { 0: true, ..base }; + } + /// ExprKind::Repeat + fn expr_repeat() { [(); 0]; } + /// ExprKind::Paren + fn expr_paren() { let expr; expr; } + /// ExprKind::Try + fn expr_try() { + let expr; + match #[lang = "branch"](expr) { + #[lang = "Break"] { 0: residual } => #[allow(unreachable_code)] + return #[lang = "from_residual"](residual), + #[lang = "Continue"] { 0: val } => #[allow(unreachable_code)] + val, + }; + } + /// ExprKind::Yield + fn expr_yield() { yield (); yield true; } + /// ExprKind::Yeet + fn expr_yeet() { + return #[lang = "from_yeet"](()); + return #[lang = "from_yeet"](0); + } + /// ExprKind::Become + fn expr_become() { become true; } + /// ExprKind::IncludedBytes + fn expr_include_bytes() { + b"data for include_bytes in ../expanded-exhaustive.rs\n"; + } + /// ExprKind::FormatArgs + fn expr_format_args() { + let expr; + format_arguments::new_const(&[]); + format_arguments::new_v1(&[""], + &[format_argument::new_display(&expr)]); + } +} +mod items { + /// ItemKind::ExternCrate + mod item_extern_crate {/// ItemKind::ExternCrate + extern crate core; + extern crate self as unpretty; + extern crate core as _; + } + /// ItemKind::Use + mod item_use {/// ItemKind::Use + use ::{}; + use crate::expressions; + use crate::items::item_use; + use core::*; + } + /// ItemKind::Static + mod item_static {/// ItemKind::Static + static A: () = { }; + static mut B: () = { }; + } + /// ItemKind::Const + mod item_const {/// ItemKind::Const + const A: () = { }; + trait TraitItems { + const + B: + (); + const + C: + () + = + { }; + } + } + /// ItemKind::Fn + mod item_fn {/// ItemKind::Fn + const unsafe extern "C" fn f() { } + async unsafe extern "C" fn g() + -> + /*impl Trait*/ |mut _task_context: ResumeTy| + { { let _t = { }; _t } } + fn h<'a, T>() where T: 'a { } + trait TraitItems { + unsafe extern "C" fn f(); + } + impl TraitItems for _ { + unsafe extern "C" fn f() { } + } + } + /// ItemKind::Mod + mod item_mod {/// ItemKind::Mod + } + /// ItemKind::ForeignMod + mod item_foreign_mod {/// ItemKind::ForeignMod + extern "Rust" { } + extern "C" { } + } + /// ItemKind::GlobalAsm: see exhaustive-asm.rs + /// ItemKind::TyAlias + mod item_ty_alias {/// ItemKind::GlobalAsm: see exhaustive-asm.rs + /// ItemKind::TyAlias + type Type<'a> where T: 'a = T; + } + /// ItemKind::Enum + mod item_enum {/// ItemKind::Enum + enum Void { } + enum Empty { + Unit, + Tuple(), + Struct { + }, + } + enum Generic<'a, T> where T: 'a { + Tuple(T), + Struct { + t: T, + }, + } + } + /// ItemKind::Struct + mod item_struct {/// ItemKind::Struct + struct Unit; + struct Tuple(); + struct Newtype(Unit); + struct Struct { + } + struct Generic<'a, T> where T: 'a { + t: T, + } + } + /// ItemKind::Union + mod item_union {/// ItemKind::Union + union Generic<'a, T> where T: 'a { + t: T, + } + } + /// ItemKind::Trait + mod item_trait {/// ItemKind::Trait + auto unsafe trait Send { } + trait Trait<'a>: Sized where Self: 'a { } + } + /// ItemKind::TraitAlias + mod item_trait_alias {/// ItemKind::TraitAlias + trait Trait<T> = Sized where for<'a> T: 'a; + } + /// ItemKind::Impl + mod item_impl {/// ItemKind::Impl + impl () { } + impl <T> () { } + impl Default for () { } + impl const <T> Default for () { } + } + /// ItemKind::MacCall + mod item_mac_call {/// ItemKind::MacCall + } + /// ItemKind::MacroDef + mod item_macro_def {/// ItemKind::MacroDef + macro_rules! mac { () => {...}; } + macro stringify { () => {} } + } + /// ItemKind::Delegation + /*! FIXME: todo */ + mod item_delegation {/// ItemKind::Delegation + /*! FIXME: todo */ + } + /// ItemKind::DelegationMac + /*! FIXME: todo */ + mod item_delegation_mac {/// ItemKind::DelegationMac + /*! FIXME: todo */ + } +} +mod patterns { + /// PatKind::Missing + fn pat_missing() { let _: for fn(u32, T, &'_ str); } + /// PatKind::Wild + fn pat_wild() { let _; } + /// PatKind::Ident + fn pat_ident() { + let x; + let ref x; + let mut x; + let ref mut x; + let ref mut x@_; + } + /// PatKind::Struct + fn pat_struct() { + let T {}; + let T::<T> {}; + let T::<'static> {}; + let T { x }; + let T { x: _x }; + let T { .. }; + let T { x, .. }; + let T { x: _x, .. }; + let T { 0: _x, .. }; + let <T as ToOwned>::Owned {}; + } + /// PatKind::TupleStruct + fn pat_tuple_struct() { + struct Tuple(); + let Tuple(); + let Tuple::<T>(); + let Tuple::<'static>(); + let Tuple(x); + let Tuple(..); + let Tuple(x, ..); + } + /// PatKind::Or + fn pat_or() { let true | false; let true; let true | false; } + /// PatKind::Path + fn pat_path() { + let core::marker::PhantomData; + let core::marker::PhantomData::<T>; + let core::marker::PhantomData::<'static>; + let <T as Trait>::CONST; + } + /// PatKind::Tuple + fn pat_tuple() { let (); let (true,); let (true, false); } + /// PatKind::Box + fn pat_box() { let box pat; } + /// PatKind::Deref + fn pat_deref() { let deref!(pat); } + /// PatKind::Ref + fn pat_ref() { let &pat; let &mut pat; } + /// PatKind::Expr + fn pat_expr() { let 1000i8; let -""; } + /// PatKind::Range + fn pat_range() { let ..1; let 0...; let 0..1; let 0...1; let -2...-1; } + /// PatKind::Slice + fn pat_slice() { let []; let [true]; let [true]; let [true, false]; } + /// PatKind::Rest + fn pat_rest() { let _; } + /// PatKind::Never + fn pat_never() { let !; let Some(!); } + /// PatKind::Paren + fn pat_paren() { let pat; } + /// PatKind::MacCall + fn pat_mac_call() { let ""; let ""; let ""; } +} +mod statements { + /// StmtKind::Let + fn stmt_let() { + let _; + let _ = true; + let _: T = true; + let _ = true else { return; }; + } + /// StmtKind::Item + fn stmt_item() { + struct Struct { + } + struct Unit; + } + /// StmtKind::Expr + fn stmt_expr() { () } + /// StmtKind::Semi + fn stmt_semi() { 1 + 1; } + /// StmtKind::Empty + fn stmt_empty() { } + /// StmtKind::MacCall + fn stmt_mac_call() { "..."; "..."; "..."; } +} +mod types { + /// TyKind::Slice + fn ty_slice() { let _: [T]; } + /// TyKind::Array + fn ty_array() { let _: [T; 0]; } + /// TyKind::Ptr + fn ty_ptr() { let _: *const T; let _: *mut T; } + /// TyKind::Ref + fn ty_ref() { + let _: &T; + let _: &mut T; + let _: &'static T; + let _: &'static mut [T]; + let _: &T<T<T<T<T>>>>; + let _: &T<T<T<T<T>>>>; + } + /// TyKind::BareFn + fn ty_bare_fn() { + let _: fn(); + let _: fn() -> (); + let _: fn(T); + let _: fn(t: T); + let _: fn(); + let _: for<'a> fn(); + } + /// TyKind::Never + fn ty_never() { let _: !; } + /// TyKind::Tup + fn ty_tup() { let _: (); let _: (T,); let _: (T, T); } + /// TyKind::Path + fn ty_path() { + let _: T; + let _: T<'static>; + let _: T<T>; + let _: T<T>; + let _: T; + let _: <T as ToOwned>::Owned; + } + /// TyKind::TraitObject + fn ty_trait_object() { + let _: dyn Send; + let _: dyn Send + 'static; + let _: dyn Send + 'static; + let _: dyn for<'a> Send; + let _: dyn* Send; + } + /// TyKind::ImplTrait + const fn ty_impl_trait() { + let _: (/*ERROR*/); + let _: (/*ERROR*/); + let _: (/*ERROR*/); + let _: (/*ERROR*/); + let _: (/*ERROR*/); + let _: (/*ERROR*/); + } + /// TyKind::Paren + fn ty_paren() { let _: T; } + /// TyKind::Typeof + /*! unused for now */ + fn ty_typeof() { } + /// TyKind::Infer + fn ty_infer() { let _: _; } + /// TyKind::ImplicitSelf + /*! there is no syntax for this */ + fn ty_implicit_self() { } + /// TyKind::MacCall + #[expect(deprecated)] + fn ty_mac_call() { let _: T; let _: T; let _: T; } + /// TyKind::CVarArgs + /*! FIXME: todo */ + fn ty_c_var_args() { } + /// TyKind::Pat + fn ty_pat() { let _: u32 is 1..=RangeMax; } +} +mod visibilities { + /// VisibilityKind::Public + mod visibility_public {/// VisibilityKind::Public + struct Pub; + } + /// VisibilityKind::Restricted + mod visibility_restricted {/// VisibilityKind::Restricted + struct PubCrate; + struct PubSelf; + struct PubSuper; + struct PubInCrate; + struct PubInSelf; + struct PubInSuper; + struct PubInCrateVisibilities; + struct PubInSelfSuper; + struct PubInSuperMod; + } +} diff --git a/tests/ui/unpretty/expanded-exhaustive.rs b/tests/ui/unpretty/exhaustive.rs index 0fb5a26c5aa..60ad3564689 100644 --- a/tests/ui/unpretty/expanded-exhaustive.rs +++ b/tests/ui/unpretty/exhaustive.rs @@ -1,6 +1,12 @@ -//@ compile-flags: -Zunpretty=expanded +//@ revisions: expanded hir +//@[expanded]compile-flags: -Zunpretty=expanded +//@[expanded]check-pass +//@[hir]compile-flags: -Zunpretty=hir +//@[hir]check-fail //@ edition:2024 -//@ check-pass + +// Note: the HIR revision includes a `.stderr` file because there are some +// errors that only occur once we get past the AST. #![feature(auto_traits)] #![feature(box_patterns)] @@ -202,8 +208,8 @@ mod expressions { move || value; async || value; async move || value; - static || value; - static move || value; + static || value; //[hir]~ ERROR closures cannot be static + static move || value; //[hir]~ ERROR closures cannot be static (static async || value); (static async move || value); || -> u8 { value }; @@ -232,7 +238,7 @@ mod expressions { /// ExprKind::Await fn expr_await() { let fut; - fut.await; + fut.await; //[hir]~ ERROR `await` is only allowed } /// ExprKind::TryBlock @@ -281,7 +287,7 @@ mod expressions { /// ExprKind::Underscore fn expr_underscore() { - _; + _; //[hir]~ ERROR in expressions, `_` can only } /// ExprKind::Path @@ -291,10 +297,14 @@ mod expressions { crate::expressions::expr_path::<'static>; <T as Default>::default; <T as ::core::default::Default>::default::<>; - x::(); - x::(T, T) -> T; + x::(); //[hir]~ ERROR parenthesized type parameters + x::(T, T) -> T; //[hir]~ ERROR parenthesized type parameters crate::() -> ()::expressions::() -> ()::expr_path; + //[hir]~^ ERROR parenthesized type parameters + //[hir]~| ERROR parenthesized type parameters core::()::marker::()::PhantomData; + //[hir]~^ ERROR parenthesized type parameters + //[hir]~| ERROR parenthesized type parameters } /// ExprKind::AddrOf @@ -330,18 +340,7 @@ mod expressions { return true; } - /// ExprKind::InlineAsm - fn expr_inline_asm() { - let x; - core::arch::asm!( - "mov {tmp}, {x}", - "shl {tmp}, 1", - "shl {x}, 2", - "add {x}, {tmp}", - x = inout(reg) x, - tmp = out(reg) _, - ); - } + /// ExprKind::InlineAsm: see exhaustive-asm.rs /// ExprKind::OffsetOf fn expr_offset_of() { @@ -390,7 +389,7 @@ mod expressions { /// ExprKind::Yield fn expr_yield() { - yield; + yield; //[hir]~ ERROR `yield` can only be used yield true; } @@ -470,14 +469,11 @@ mod items { /// ItemKind::ForeignMod mod item_foreign_mod { - unsafe extern "C++" {} + unsafe extern "C++" {} //[hir]~ ERROR invalid ABI unsafe extern "C" {} } - /// ItemKind::GlobalAsm - mod item_global_asm { - core::arch::global_asm!(".globl my_asm_func"); - } + /// ItemKind::GlobalAsm: see exhaustive-asm.rs /// ItemKind::TyAlias mod item_ty_alias { @@ -680,7 +676,7 @@ mod patterns { /// PatKind::Rest fn pat_rest() { - let ..; + let ..; //[hir]~ ERROR `..` patterns are not allowed here } /// PatKind::Never @@ -795,7 +791,7 @@ mod types { let _: T<'static>; let _: T<T>; let _: T::<T>; - let _: T() -> !; + let _: T() -> !; //[hir]~ ERROR parenthesized type parameters let _: <T as ToOwned>::Owned; } @@ -810,12 +806,12 @@ mod types { /// TyKind::ImplTrait const fn ty_impl_trait() { - let _: impl Send; - let _: impl Send + 'static; - let _: impl 'static + Send; - let _: impl ?Sized; - let _: impl ~const Clone; - let _: impl for<'a> Send; + let _: impl Send; //[hir]~ ERROR `impl Trait` is not allowed + let _: impl Send + 'static; //[hir]~ ERROR `impl Trait` is not allowed + let _: impl 'static + Send; //[hir]~ ERROR `impl Trait` is not allowed + let _: impl ?Sized; //[hir]~ ERROR `impl Trait` is not allowed + let _: impl ~const Clone; //[hir]~ ERROR `impl Trait` is not allowed + let _: impl for<'a> Send; //[hir]~ ERROR `impl Trait` is not allowed } /// TyKind::Paren @@ -839,6 +835,7 @@ mod types { } /// TyKind::MacCall + #[expect(deprecated)] // concat_idents is deprecated fn ty_mac_call() { let _: concat_idents!(T); let _: concat_idents![T]; diff --git a/tests/ui/unpretty/expanded-interpolation.rs b/tests/ui/unpretty/interpolation-expanded.rs index 95280f97dac..95280f97dac 100644 --- a/tests/ui/unpretty/expanded-interpolation.rs +++ b/tests/ui/unpretty/interpolation-expanded.rs diff --git a/tests/ui/unpretty/expanded-interpolation.stdout b/tests/ui/unpretty/interpolation-expanded.stdout index d46b46b67f4..d46b46b67f4 100644 --- a/tests/ui/unpretty/expanded-interpolation.stdout +++ b/tests/ui/unpretty/interpolation-expanded.stdout diff --git a/tests/ui/unsafe/unsafe-trait-impl.rs b/tests/ui/unsafe/unsafe-trait-impl.rs index 9fd9ff65288..dc7e119ed7a 100644 --- a/tests/ui/unsafe/unsafe-trait-impl.rs +++ b/tests/ui/unsafe/unsafe-trait-impl.rs @@ -1,5 +1,7 @@ // Check that safe fns are not a subtype of unsafe fns. +//@ dont-require-annotations: NOTE + trait Foo { unsafe fn len(&self) -> u32; } @@ -7,8 +9,8 @@ trait Foo { impl Foo for u32 { fn len(&self) -> u32 { *self } //~^ ERROR method `len` has an incompatible type for trait - //~| expected signature `unsafe fn(&_) -> _` - //~| found signature `fn(&_) -> _` + //~| NOTE expected signature `unsafe fn(&_) -> _` + //~| NOTE found signature `fn(&_) -> _` } fn main() { } diff --git a/tests/ui/unsafe/unsafe-trait-impl.stderr b/tests/ui/unsafe/unsafe-trait-impl.stderr index b9f2e1cc869..8febbb73663 100644 --- a/tests/ui/unsafe/unsafe-trait-impl.stderr +++ b/tests/ui/unsafe/unsafe-trait-impl.stderr @@ -1,11 +1,11 @@ error[E0053]: method `len` has an incompatible type for trait - --> $DIR/unsafe-trait-impl.rs:8:5 + --> $DIR/unsafe-trait-impl.rs:10:5 | LL | fn len(&self) -> u32 { *self } | ^^^^^^^^^^^^^^^^^^^^ expected unsafe fn, found safe fn | note: type in trait - --> $DIR/unsafe-trait-impl.rs:4:5 + --> $DIR/unsafe-trait-impl.rs:6:5 | LL | unsafe fn len(&self) -> u32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/use/import_trait_associated_item_bad.rs b/tests/ui/use/import_trait_associated_item_bad.rs new file mode 100644 index 00000000000..d3d2a8e83cd --- /dev/null +++ b/tests/ui/use/import_trait_associated_item_bad.rs @@ -0,0 +1,18 @@ +#![feature(import_trait_associated_functions)] +#![feature(min_generic_const_args)] +#![allow(incomplete_features)] + +trait Trait { + type AssocTy; + const CONST: usize; +} + +use Trait::AssocTy; +type Alias1 = AssocTy; //~ ERROR ambiguous associated type +type Alias2 = self::AssocTy; //~ ERROR ambiguous associated type + +use Trait::CONST; +type Alias3 = [u8; CONST]; //~ ERROR ambiguous associated constant +type Alias4 = [u8; self::CONST]; //~ ERROR ambiguous associated constant + +fn main() {} diff --git a/tests/ui/use/import_trait_associated_item_bad.stderr b/tests/ui/use/import_trait_associated_item_bad.stderr new file mode 100644 index 00000000000..d5cd5d37bd7 --- /dev/null +++ b/tests/ui/use/import_trait_associated_item_bad.stderr @@ -0,0 +1,49 @@ +error[E0223]: ambiguous associated type + --> $DIR/import_trait_associated_item_bad.rs:11:15 + | +LL | type Alias1 = AssocTy; + | ^^^^^^^ + | +help: if there were a type named `Example` that implemented `Trait`, you could use the fully-qualified path + | +LL | type Alias1 = <Example as Trait>::AssocTy; + | ++++++++++++++++++++ + +error[E0223]: ambiguous associated type + --> $DIR/import_trait_associated_item_bad.rs:12:15 + | +LL | type Alias2 = self::AssocTy; + | ^^^^^^^^^^^^^ + | +help: if there were a type named `Example` that implemented `Trait`, you could use the fully-qualified path + | +LL - type Alias2 = self::AssocTy; +LL + type Alias2 = <Example as Trait>::AssocTy; + | + +error[E0223]: ambiguous associated constant + --> $DIR/import_trait_associated_item_bad.rs:15:20 + | +LL | type Alias3 = [u8; CONST]; + | ^^^^^ + | +help: if there were a type named `Example` that implemented `Trait`, you could use the fully-qualified path + | +LL | type Alias3 = [u8; <Example as Trait>::CONST]; + | ++++++++++++++++++++ + +error[E0223]: ambiguous associated constant + --> $DIR/import_trait_associated_item_bad.rs:16:20 + | +LL | type Alias4 = [u8; self::CONST]; + | ^^^^^^^^^^^ + | +help: if there were a type named `Example` that implemented `Trait`, you could use the fully-qualified path + | +LL - type Alias4 = [u8; self::CONST]; +LL + type Alias4 = [u8; <Example as Trait>::CONST]; + | + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0223`. diff --git a/tests/ui/use/import_trait_associated_item_glob.rs b/tests/ui/use/import_trait_associated_item_glob.rs new file mode 100644 index 00000000000..8a712514ed5 --- /dev/null +++ b/tests/ui/use/import_trait_associated_item_glob.rs @@ -0,0 +1,17 @@ +//@ check-pass + +#![feature(import_trait_associated_functions)] + +trait Trait: Default { + fn f() -> Self { Default::default() } + fn g() -> Self { Default::default() } +} + +impl Trait for u8 {} + +use Trait::*; + +fn main() { + let _: u8 = f(); + let _: u8 = g(); +} diff --git a/tests/ui/use/use-from-trait-xc.rs b/tests/ui/use/use-from-trait-xc.rs index b030892aa26..220bf8cad46 100644 --- a/tests/ui/use/use-from-trait-xc.rs +++ b/tests/ui/use/use-from-trait-xc.rs @@ -6,7 +6,7 @@ use use_from_trait_xc::Trait::foo; //~^ ERROR `use` associated items of traits is unstable [E0658] use use_from_trait_xc::Trait::Assoc; -//~^ ERROR `Assoc` is not directly importable +//~^ ERROR `use` associated items of traits is unstable [E0658] use use_from_trait_xc::Trait::CONST; //~^ ERROR `use` associated items of traits is unstable [E0658] diff --git a/tests/ui/use/use-from-trait-xc.stderr b/tests/ui/use/use-from-trait-xc.stderr index 0f8440aa530..c8ee29b18d0 100644 --- a/tests/ui/use/use-from-trait-xc.stderr +++ b/tests/ui/use/use-from-trait-xc.stderr @@ -8,11 +8,15 @@ LL | use use_from_trait_xc::Trait::foo; = help: add `#![feature(import_trait_associated_functions)]` 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[E0253]: `Assoc` is not directly importable +error[E0658]: `use` associated items of traits is unstable --> $DIR/use-from-trait-xc.rs:8:5 | LL | use use_from_trait_xc::Trait::Assoc; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot be imported directly + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #134691 <https://github.com/rust-lang/rust/issues/134691> for more information + = help: add `#![feature(import_trait_associated_functions)]` 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[E0658]: `use` associated items of traits is unstable --> $DIR/use-from-trait-xc.rs:11:5 @@ -74,5 +78,5 @@ LL | struct Foo; error: aborting due to 9 previous errors -Some errors have detailed explanations: E0253, E0432, E0603, E0658. -For more information about an error, try `rustc --explain E0253`. +Some errors have detailed explanations: E0432, E0603, E0658. +For more information about an error, try `rustc --explain E0432`. diff --git a/tests/ui/use/use-from-trait.rs b/tests/ui/use/use-from-trait.rs index 89b7aaa4ba3..cab661a29e8 100644 --- a/tests/ui/use/use-from-trait.rs +++ b/tests/ui/use/use-from-trait.rs @@ -1,5 +1,5 @@ use Trait::foo; //~ ERROR `use` associated items of traits is unstable [E0658] -use Trait::Assoc; //~ ERROR `Assoc` is not directly importable +use Trait::Assoc; //~ ERROR `use` associated items of traits is unstable [E0658] use Trait::C; //~ ERROR `use` associated items of traits is unstable [E0658] use Foo::new; //~ ERROR unresolved import `Foo` [E0432] diff --git a/tests/ui/use/use-from-trait.stderr b/tests/ui/use/use-from-trait.stderr index 2dd78a35452..63cfcc20750 100644 --- a/tests/ui/use/use-from-trait.stderr +++ b/tests/ui/use/use-from-trait.stderr @@ -8,11 +8,15 @@ LL | use Trait::foo; = help: add `#![feature(import_trait_associated_functions)]` 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[E0253]: `Assoc` is not directly importable +error[E0658]: `use` associated items of traits is unstable --> $DIR/use-from-trait.rs:2:5 | LL | use Trait::Assoc; - | ^^^^^^^^^^^^ cannot be imported directly + | ^^^^^^^^^^^^ + | + = note: see issue #134691 <https://github.com/rust-lang/rust/issues/134691> for more information + = help: add `#![feature(import_trait_associated_functions)]` 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[E0658]: `use` associated items of traits is unstable --> $DIR/use-from-trait.rs:3:5 @@ -38,5 +42,5 @@ LL | use Foo::C2; error: aborting due to 5 previous errors -Some errors have detailed explanations: E0253, E0432, E0658. -For more information about an error, try `rustc --explain E0253`. +Some errors have detailed explanations: E0432, E0658. +For more information about an error, try `rustc --explain E0432`. diff --git a/tests/ui/wf/range-expr-root-of-constant-issue-40749.rs b/tests/ui/wf/range-expr-root-of-constant-issue-40749.rs index 0a847853b12..7871612dc8b 100644 --- a/tests/ui/wf/range-expr-root-of-constant-issue-40749.rs +++ b/tests/ui/wf/range-expr-root-of-constant-issue-40749.rs @@ -1,6 +1,7 @@ fn main() { [0; ..10]; //~^ ERROR mismatched types - //~| expected type `usize` - //~| found struct `RangeTo<{integer}>` + //~| NOTE expected type `usize` + //~| NOTE found struct `RangeTo<{integer}>` + //~| NOTE expected `usize`, found `RangeTo<{integer}> } |
