diff options
Diffstat (limited to 'tests')
1512 files changed, 17504 insertions, 11092 deletions
diff --git a/tests/assembly/aarch64-xray.rs b/tests/assembly/aarch64-xray.rs new file mode 100644 index 00000000000..d5ee0111843 --- /dev/null +++ b/tests/assembly/aarch64-xray.rs @@ -0,0 +1,25 @@ +//@ assembly-output: emit-asm +//@ compile-flags: -Zinstrument-xray=always + +//@ revisions: aarch64-linux +//@[aarch64-linux] compile-flags: --target=aarch64-unknown-linux-gnu +//@[aarch64-linux] needs-llvm-components: aarch64 +//@[aarch64-linux] only-aarch64-unknown-linux-gnu + +//@ revisions: aarch64-darwin +//@[aarch64-darwin] compile-flags: --target=aarch64-apple-darwin +//@[aarch64-darwin] needs-llvm-components: aarch64 +//@[aarch64-darwin] only-aarch64-apple-darwin + +#![crate_type = "lib"] + +// CHECK-LABEL: xray_func: +#[no_mangle] +pub fn xray_func() { + // CHECK: nop + + std::hint::black_box(()); + + // CHECK: b #32 + // CHECK-NEXT: nop +} diff --git a/tests/assembly/asm/aarch64-types.rs b/tests/assembly/asm/aarch64-types.rs index ad2770d43e3..b7abeb02298 100644 --- a/tests/assembly/asm/aarch64-types.rs +++ b/tests/assembly/asm/aarch64-types.rs @@ -86,12 +86,11 @@ pub unsafe fn sym_static() { // Regression test for #75761 // CHECK-LABEL: {{("#)?}}issue_75761{{"?}} -// aarch64: str {{.*}}x30 -// arm64ec: stp {{.*}}x30 +// x29 holds the frame pointer, right next to x30, so ldp/stp happens sometimes +// CHECK: st[[MAY_PAIR:(r|p).*]]x30 // CHECK: //APP // CHECK: //NO_APP -// aarch64: ldr {{.*}}x30 -// arm64ec: ldp {{.*}}x30 +// CHECK: ld[[MAY_PAIR]]x30 #[no_mangle] pub unsafe fn issue_75761() { asm!("", out("v0") _, out("x30") _); diff --git a/tests/assembly/targets/targets-elf.rs b/tests/assembly/targets/targets-elf.rs index 32555911194..edf16548e7d 100644 --- a/tests/assembly/targets/targets-elf.rs +++ b/tests/assembly/targets/targets-elf.rs @@ -259,6 +259,12 @@ //@ revisions: i686_wrs_vxworks //@ [i686_wrs_vxworks] compile-flags: --target i686-wrs-vxworks //@ [i686_wrs_vxworks] needs-llvm-components: x86 +//@ revisions: loongarch32_unknown_none +//@ [loongarch32_unknown_none] compile-flags: --target loongarch32-unknown-none +//@ [loongarch32_unknown_none] needs-llvm-components: loongarch +//@ revisions: loongarch32_unknown_none_softfloat +//@ [loongarch32_unknown_none_softfloat] compile-flags: --target loongarch32-unknown-none-softfloat +//@ [loongarch32_unknown_none_softfloat] needs-llvm-components: loongarch //@ revisions: loongarch64_unknown_linux_gnu //@ [loongarch64_unknown_linux_gnu] compile-flags: --target loongarch64-unknown-linux-gnu //@ [loongarch64_unknown_linux_gnu] needs-llvm-components: loongarch diff --git a/tests/assembly/x86_64-xray.rs b/tests/assembly/x86_64-xray.rs new file mode 100644 index 00000000000..4cf3e8cda13 --- /dev/null +++ b/tests/assembly/x86_64-xray.rs @@ -0,0 +1,25 @@ +//@ assembly-output: emit-asm +//@ compile-flags: -Zinstrument-xray=always -Cllvm-args=-x86-asm-syntax=intel + +//@ revisions: x86_64-linux +//@[x86_64-linux] compile-flags: --target=x86_64-unknown-linux-gnu +//@[x86_64-linux] needs-llvm-components: x86 +//@[x86_64-linux] only-x86_64-unknown-linux-gnu + +//@ revisions: x86_64-darwin +//@[x86_64-darwin] compile-flags: --target=x86_64-apple-darwin +//@[x86_64-darwin] needs-llvm-components: x86 +//@[x86_64-darwin] only-x86_64-apple-darwin + +#![crate_type = "lib"] + +// CHECK-LABEL: xray_func: +#[no_mangle] +pub fn xray_func() { + // CHECK: nop word ptr [rax + rax + 512] + + std::hint::black_box(()); + + // CHECK: ret + // CHECK-NEXT: nop word ptr cs:[rax + rax + 512] +} diff --git a/tests/codegen/abi-x86-sse.rs b/tests/codegen/abi-x86-sse.rs index 837bf6134b0..90757e601af 100644 --- a/tests/codegen/abi-x86-sse.rs +++ b/tests/codegen/abi-x86-sse.rs @@ -27,8 +27,9 @@ trait Copy {} #[repr(simd)] pub struct Sse([f32; 4]); -// x86-64: <4 x float> @sse_id(<4 x float> {{[^,]*}}) -// x86-32: <4 x float> @sse_id(<4 x float> {{[^,]*}}) +// FIXME: due to #139029 we are passing them all indirectly. +// x86-64: void @sse_id(ptr{{( [^,]*)?}} sret([16 x i8]){{( .*)?}}, ptr{{( [^,]*)?}}) +// x86-32: void @sse_id(ptr{{( [^,]*)?}} sret([16 x i8]){{( .*)?}}, ptr{{( [^,]*)?}}) // x86-32-nosse: void @sse_id(ptr{{( [^,]*)?}} sret([16 x i8]){{( .*)?}}, ptr{{( [^,]*)?}}) #[no_mangle] pub fn sse_id(x: Sse) -> Sse { diff --git a/tests/codegen/align-byval-alignment-mismatch.rs b/tests/codegen/align-byval-alignment-mismatch.rs index 46cfb2972df..c69fc2de9d2 100644 --- a/tests/codegen/align-byval-alignment-mismatch.rs +++ b/tests/codegen/align-byval-alignment-mismatch.rs @@ -2,9 +2,10 @@ //@ add-core-stubs //@ revisions:i686-linux x86_64-linux -//@[i686-linux] compile-flags: --target i686-unknown-linux-gnu -C panic=abort +//@ compile-flags: -Cno-prepopulate-passes -Copt-level=1 -Cpanic=abort +//@[i686-linux] compile-flags: --target i686-unknown-linux-gnu //@[i686-linux] needs-llvm-components: x86 -//@[x86_64-linux] compile-flags: --target x86_64-unknown-linux-gnu -C panic=abort +//@[x86_64-linux] compile-flags: --target x86_64-unknown-linux-gnu //@[x86_64-linux] needs-llvm-components: x86 // Tests that we correctly copy arguments into allocas when the alignment of the byval argument @@ -54,8 +55,10 @@ extern "C" { pub unsafe fn rust_to_c_increases_alignment(x: Align1) { // i686-linux: start: // i686-linux-NEXT: [[ALLOCA:%[0-9a-z]+]] = alloca [48 x i8], align 4 + // i686-linux-NEXT: call void @llvm.lifetime.start.p0(i64 48, ptr {{.*}}[[ALLOCA]]) // i686-linux-NEXT: call void @llvm.memcpy.{{.+}}(ptr {{.*}}align 4 {{.*}}[[ALLOCA]], ptr {{.*}}align 1 {{.*}}%x // i686-linux-NEXT: call void @extern_c_align1({{.+}} [[ALLOCA]]) + // i686-linux-NEXT: call void @llvm.lifetime.end.p0(i64 48, ptr {{.*}}[[ALLOCA]]) // x86_64-linux: start: // x86_64-linux-NEXT: call void @extern_c_align1 diff --git a/tests/codegen/autodiff/batched.rs b/tests/codegen/autodiff/batched.rs index e0047116405..d27aed50e6c 100644 --- a/tests/codegen/autodiff/batched.rs +++ b/tests/codegen/autodiff/batched.rs @@ -11,11 +11,11 @@ #![feature(autodiff)] -use std::autodiff::autodiff; +use std::autodiff::autodiff_forward; -#[autodiff(d_square3, Forward, Dual, DualOnly)] -#[autodiff(d_square2, Forward, 4, Dual, DualOnly)] -#[autodiff(d_square1, Forward, 4, Dual, Dual)] +#[autodiff_forward(d_square3, Dual, DualOnly)] +#[autodiff_forward(d_square2, 4, Dual, DualOnly)] +#[autodiff_forward(d_square1, 4, Dual, Dual)] #[no_mangle] fn square(x: &f32) -> f32 { x * x diff --git a/tests/codegen/autodiff/generic.rs b/tests/codegen/autodiff/generic.rs index 15e7d8a4957..2f674079be0 100644 --- a/tests/codegen/autodiff/generic.rs +++ b/tests/codegen/autodiff/generic.rs @@ -3,9 +3,9 @@ //@ needs-enzyme #![feature(autodiff)] -use std::autodiff::autodiff; +use std::autodiff::autodiff_reverse; -#[autodiff(d_square, Reverse, Duplicated, Active)] +#[autodiff_reverse(d_square, Duplicated, Active)] fn square<T: std::ops::Mul<Output = T> + Copy>(x: &T) -> T { *x * *x } diff --git a/tests/codegen/autodiff/identical_fnc.rs b/tests/codegen/autodiff/identical_fnc.rs index 1c3277f52b4..1c25b3d09ab 100644 --- a/tests/codegen/autodiff/identical_fnc.rs +++ b/tests/codegen/autodiff/identical_fnc.rs @@ -11,14 +11,14 @@ // identical function calls in the LLVM-IR, while having two different calls in the Rust code. #![feature(autodiff)] -use std::autodiff::autodiff; +use std::autodiff::autodiff_reverse; -#[autodiff(d_square, Reverse, Duplicated, Active)] +#[autodiff_reverse(d_square, Duplicated, Active)] fn square(x: &f64) -> f64 { x * x } -#[autodiff(d_square2, Reverse, Duplicated, Active)] +#[autodiff_reverse(d_square2, Duplicated, Active)] fn square2(x: &f64) -> f64 { x * x } diff --git a/tests/codegen/autodiff/inline.rs b/tests/codegen/autodiff/inline.rs index e90faa4aa38..65bed170207 100644 --- a/tests/codegen/autodiff/inline.rs +++ b/tests/codegen/autodiff/inline.rs @@ -4,9 +4,9 @@ #![feature(autodiff)] -use std::autodiff::autodiff; +use std::autodiff::autodiff_reverse; -#[autodiff(d_square, Reverse, Duplicated, Active)] +#[autodiff_reverse(d_square, Duplicated, Active)] fn square(x: &f64) -> f64 { x * x } diff --git a/tests/codegen/autodiff/scalar.rs b/tests/codegen/autodiff/scalar.rs index 85358f5fcb6..096b4209e84 100644 --- a/tests/codegen/autodiff/scalar.rs +++ b/tests/codegen/autodiff/scalar.rs @@ -3,9 +3,9 @@ //@ needs-enzyme #![feature(autodiff)] -use std::autodiff::autodiff; +use std::autodiff::autodiff_reverse; -#[autodiff(d_square, Reverse, Duplicated, Active)] +#[autodiff_reverse(d_square, Duplicated, Active)] #[no_mangle] fn square(x: &f64) -> f64 { x * x diff --git a/tests/codegen/autodiff/sret.rs b/tests/codegen/autodiff/sret.rs index 5ead90041ed..d2fa85e3e37 100644 --- a/tests/codegen/autodiff/sret.rs +++ b/tests/codegen/autodiff/sret.rs @@ -9,10 +9,10 @@ #![feature(autodiff)] -use std::autodiff::autodiff; +use std::autodiff::autodiff_reverse; #[no_mangle] -#[autodiff(df, Reverse, Active, Active, Active)] +#[autodiff_reverse(df, Active, Active, Active)] fn primal(x: f32, y: f32) -> f64 { (x * x * y) as f64 } diff --git a/tests/codegen/call-tmps-lifetime.rs b/tests/codegen/call-tmps-lifetime.rs new file mode 100644 index 00000000000..7b7b6e17bdd --- /dev/null +++ b/tests/codegen/call-tmps-lifetime.rs @@ -0,0 +1,68 @@ +// Test that temporary allocas used for call arguments have their lifetimes described by +// intrinsics. +// +//@ add-core-stubs +//@ compile-flags: -Copt-level=1 -Cno-prepopulate-passes --crate-type=lib --target i686-unknown-linux-gnu +//@ needs-llvm-components: x86 +#![feature(no_core)] +#![no_std] +#![no_core] +extern crate minicore; +use minicore::*; + +// Const operand. Regression test for #98156. +// +// CHECK-LABEL: define void @const_indirect( +// CHECK-NEXT: start: +// CHECK-NEXT: [[B:%.*]] = alloca +// CHECK-NEXT: [[A:%.*]] = alloca +// CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 4096, ptr [[A]]) +// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[A]], ptr align 4 {{.*}}, i32 4096, i1 false) +// CHECK-NEXT: call void %h(ptr {{.*}} [[A]]) +// CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 4096, ptr [[A]]) +// CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 4096, ptr [[B]]) +// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[B]], ptr align 4 {{.*}}, i32 4096, i1 false) +// CHECK-NEXT: call void %h(ptr {{.*}} [[B]]) +// CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 4096, ptr [[B]]) +#[no_mangle] +pub fn const_indirect(h: extern "C" fn([u32; 1024])) { + const C: [u32; 1024] = [0; 1024]; + h(C); + h(C); +} + +#[repr(C)] +pub struct Str { + pub ptr: *const u8, + pub len: usize, +} + +// Pair of immediates. Regression test for #132014. +// +// CHECK-LABEL: define void @immediate_indirect(ptr {{.*}}%s.0, i32 {{.*}}%s.1, ptr {{.*}}%g) +// CHECK-NEXT: start: +// CHECK-NEXT: [[A:%.*]] = alloca +// CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 8, ptr [[A]]) +// CHECK-NEXT: store ptr %s.0, ptr [[A]] +// CHECK-NEXT: [[B:%.]] = getelementptr inbounds i8, ptr [[A]], i32 4 +// CHECK-NEXT: store i32 %s.1, ptr [[B]] +// CHECK-NEXT: call void %g(ptr {{.*}} [[A]]) +// CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 8, ptr [[A]]) +#[no_mangle] +pub fn immediate_indirect(s: Str, g: extern "C" fn(Str)) { + g(s); +} + +// Indirect argument with a higher alignment requirement than the type's. +// +// CHECK-LABEL: define void @align_indirect(ptr{{.*}} align 1{{.*}} %a, ptr{{.*}} %fun) +// CHECK-NEXT: start: +// CHECK-NEXT: [[A:%.*]] = alloca [1024 x i8], align 4 +// CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 1024, ptr [[A]]) +// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[A]], ptr align 1 %a, i32 1024, i1 false) +// CHECK-NEXT: call void %fun(ptr {{.*}} [[A]]) +// CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 1024, ptr [[A]]) +#[no_mangle] +pub fn align_indirect(a: [u8; 1024], fun: extern "C" fn([u8; 1024])) { + fun(a); +} diff --git a/tests/codegen/enum/enum-u128.rs b/tests/codegen/enum/enum-u128.rs index ecdff3c5ce3..2676669f3e3 100644 --- a/tests/codegen/enum/enum-u128.rs +++ b/tests/codegen/enum/enum-u128.rs @@ -13,9 +13,6 @@ // CHECK: {{.*}}DIEnumerator{{.*}}name: "Hi",{{.*}}value: 18446744073709551616,{{.*}} // CHECK: {{.*}}DIEnumerator{{.*}}name: "Bar",{{.*}}value: 18446745000000000123,{{.*}} -#![allow(incomplete_features)] -#![feature(repr128)] - #[repr(u128)] pub enum Foo { Lo, diff --git a/tests/codegen/frame-pointer.rs b/tests/codegen/frame-pointer.rs index 1f7c9a59c98..23989653fa8 100644 --- a/tests/codegen/frame-pointer.rs +++ b/tests/codegen/frame-pointer.rs @@ -26,8 +26,10 @@ pub fn peach(x: u32) -> u32 { // CHECK: attributes [[PEACH_ATTRS]] = { // x64-linux-NOT: {{.*}}"frame-pointer"{{.*}} -// aarch64-linux-NOT: {{.*}}"frame-pointer"{{.*}} // x64-apple-SAME: {{.*}}"frame-pointer"="all" // force-SAME: {{.*}}"frame-pointer"="all" +// +// AAPCS64 demands frame pointers: +// aarch64-linux-SAME: {{.*}}"frame-pointer"="non-leaf" // aarch64-apple-SAME: {{.*}}"frame-pointer"="non-leaf" // CHECK-SAME: } diff --git a/tests/codegen/issues/issue-98156-const-arg-temp-lifetime.rs b/tests/codegen/issues/issue-98156-const-arg-temp-lifetime.rs deleted file mode 100644 index aecb81caf22..00000000000 --- a/tests/codegen/issues/issue-98156-const-arg-temp-lifetime.rs +++ /dev/null @@ -1,27 +0,0 @@ -// This test checks that temporaries for indirectly-passed arguments get lifetime markers. - -//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes -Zmir-opt-level=0 - -#![crate_type = "lib"] - -extern "Rust" { - fn f(x: [u8; 1024]); -} - -const A: [u8; 1024] = [0; 1024]; - -// CHECK-LABEL: @const_arg_indirect -#[no_mangle] -pub unsafe fn const_arg_indirect() { - // Ensure that the live ranges for the two argument temporaries don't overlap. - - // CHECK: call void @llvm.lifetime.start - // CHECK: call void @f - // CHECK: call void @llvm.lifetime.end - // CHECK: call void @llvm.lifetime.start - // CHECK: call void @f - // CHECK: call void @llvm.lifetime.end - - f(A); - f(A); -} diff --git a/tests/codegen/option-niche-eq.rs b/tests/codegen/option-niche-eq.rs index 9c5ed9ce57a..3900cb79aa2 100644 --- a/tests/codegen/option-niche-eq.rs +++ b/tests/codegen/option-niche-eq.rs @@ -1,4 +1,7 @@ +//@ revisions: REGULAR LLVM21 +//@ min-llvm-version: 20 //@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled +//@ [LLVM21] min-llvm-version: 21 #![crate_type = "lib"] extern crate core; @@ -24,6 +27,18 @@ pub fn non_zero_signed_eq(l: Option<NonZero<i64>>, r: Option<NonZero<i64>>) -> b l == r } +// FIXME(#49892) +// This currently relies on a manual implementation of `PartialOrd`/`Ord` for `Option` +// Once LLVM is better able to optimize this pattern, we can return to using a derive. +// CHECK-LABEL: @non_zero_ord +#[no_mangle] +pub fn non_zero_ord(a: Option<NonZero<u32>>, b: Option<NonZero<u32>>) -> bool { + // CHECK: start: + // CHECK-NEXT: icmp ult i32 + // CHECK-NEXT: ret i1 + a < b +} + // CHECK-LABEL: @non_null_eq #[no_mangle] pub fn non_null_eq(l: Option<NonNull<u8>>, r: Option<NonNull<u8>>) -> bool { @@ -62,12 +77,11 @@ pub fn niche_eq(l: Option<EnumWithNiche>, r: Option<EnumWithNiche>) -> bool { l == r } -// FIXME: This should work too -// // FIXME-CHECK-LABEL: @bool_eq -// #[no_mangle] -// pub fn bool_eq(l: Option<bool>, r: Option<bool>) -> bool { -// // FIXME-CHECK: start: -// // FIXME-CHECK-NEXT: icmp eq i8 -// // FIXME-CHECK-NEXT: ret i1 -// l == r -// } +// LLVM21-LABEL: @bool_eq +#[no_mangle] +pub fn bool_eq(l: Option<bool>, r: Option<bool>) -> bool { + // LLVM21: start: + // LLVM21-NEXT: icmp eq i8 + // LLVM21-NEXT: ret i1 + l == r +} diff --git a/tests/codegen/option-niche-unfixed/option-nonzero-eq.rs b/tests/codegen/option-niche-unfixed/option-nonzero-eq.rs new file mode 100644 index 00000000000..308856cfb7e --- /dev/null +++ b/tests/codegen/option-niche-unfixed/option-nonzero-eq.rs @@ -0,0 +1,24 @@ +//@ should-fail +//@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled +//! FIXME(#49892) +//! Test that the derived implementation of `PartialEq` for `Option` is not fully +//! optimized by LLVM. If this starts passing, the test and manual impl should +//! be removed. +#![crate_type = "lib"] + +use std::num::NonZero; + +#[derive(Copy, Clone, PartialEq, Eq)] +pub enum Option<T> { + None, + Some(T), +} + +// CHECK-LABEL: @non_zero_eq +#[no_mangle] +pub fn non_zero_eq(l: Option<NonZero<u32>>, r: Option<NonZero<u32>>) -> bool { + // CHECK: start: + // CHECK-NEXT: icmp eq i32 + // CHECK-NEXT: ret i1 + l == r +} diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs index d3853361de9..977bf3379b7 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs @@ -1,14 +1,8 @@ // //@ compile-flags: -C no-prepopulate-passes -// LLVM IR isn't very portable and the one tested here depends on the ABI -// which is different between x86 (where we use SSE registers) and others. -// `x86-64` and `x86-32-sse2` are identical, but compiletest does not support -// taking the union of multiple `only` annotations. -//@ revisions: x86-64 x86-32-sse2 other -//@[x86-64] only-x86_64 -//@[x86-32-sse2] only-rustc_abi-x86-sse2 -//@[other] ignore-rustc_abi-x86-sse2 -//@[other] ignore-x86_64 +// 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"] #![allow(non_camel_case_types)] @@ -47,9 +41,7 @@ pub fn build_array_s(x: [f32; 4]) -> S<4> { #[no_mangle] pub fn build_array_transmute_s(x: [f32; 4]) -> S<4> { // CHECK: %[[VAL:.+]] = load <4 x float>, ptr %x, align [[ARRAY_ALIGN]] - // x86-32: ret <4 x float> %[[VAL:.+]] - // x86-64: ret <4 x float> %[[VAL:.+]] - // other: store <4 x float> %[[VAL:.+]], ptr %_0, align [[VECTOR_ALIGN]] + // CHECK: store <4 x float> %[[VAL:.+]], ptr %_0, align [[VECTOR_ALIGN]] unsafe { std::mem::transmute(x) } } @@ -64,8 +56,6 @@ pub fn build_array_t(x: [f32; 4]) -> T { #[no_mangle] pub fn build_array_transmute_t(x: [f32; 4]) -> T { // CHECK: %[[VAL:.+]] = load <4 x float>, ptr %x, align [[ARRAY_ALIGN]] - // x86-32: ret <4 x float> %[[VAL:.+]] - // x86-64: ret <4 x float> %[[VAL:.+]] - // other: store <4 x float> %[[VAL:.+]], ptr %_0, align [[VECTOR_ALIGN]] + // CHECK: store <4 x float> %[[VAL:.+]], ptr %_0, align [[VECTOR_ALIGN]] unsafe { std::mem::transmute(x) } } diff --git a/tests/codegen/simd/packed-simd.rs b/tests/codegen/simd/packed-simd.rs index a27d5e3af45..73e0d29d7d6 100644 --- a/tests/codegen/simd/packed-simd.rs +++ b/tests/codegen/simd/packed-simd.rs @@ -30,16 +30,18 @@ fn load<T, const N: usize>(v: PackedSimd<T, N>) -> FullSimd<T, N> { } } -// CHECK-LABEL: define <3 x float> @square_packed_full(ptr{{[a-z_ ]*}} align 4 {{[^,]*}}) +// CHECK-LABEL: square_packed_full +// CHECK-SAME: ptr{{[a-z_ ]*}} sret([[RET_TYPE:[^)]+]]) [[RET_ALIGN:align (8|16)]]{{[^%]*}} [[RET_VREG:%[_0-9]*]] +// CHECK-SAME: ptr{{[a-z_ ]*}} align 4 #[no_mangle] pub fn square_packed_full(x: PackedSimd<f32, 3>) -> FullSimd<f32, 3> { - // The unoptimized version of this is not very interesting to check - // since `load` does not get inlined. - // opt3-NEXT: start: - // opt3-NEXT: load <3 x float> + // CHECK-NEXT: start + // noopt: alloca [[RET_TYPE]], [[RET_ALIGN]] + // CHECK: load <3 x float> let x = load(x); - // opt3-NEXT: [[VREG:%[a-z0-9_]+]] = fmul <3 x float> - // opt3-NEXT: ret <3 x float> [[VREG:%[a-z0-9_]+]] + // CHECK: [[VREG:%[a-z0-9_]+]] = fmul <3 x float> + // CHECK-NEXT: store <3 x float> [[VREG]], ptr [[RET_VREG]], [[RET_ALIGN]] + // CHECK-NEXT: ret void unsafe { intrinsics::simd_mul(x, x) } } diff --git a/tests/codegen/thread-local.rs b/tests/codegen/thread-local.rs index 9ce34473b91..41df8c9be1b 100644 --- a/tests/codegen/thread-local.rs +++ b/tests/codegen/thread-local.rs @@ -14,13 +14,14 @@ use std::cell::Cell; thread_local!(static A: Cell<u32> = const { Cell::new(1) }); -// CHECK: [[TLS_AUX:@.+]] = external thread_local local_unnamed_addr global i64 -// CHECK: [[TLS:@.+]] = internal thread_local unnamed_addr global +// CHECK: [[TLS_AUX:@.+]] = external thread_local{{.*}} global i64 +// CHECK: [[TLS:@.+]] = internal thread_local{{.*}} global // CHECK-LABEL: @get #[no_mangle] fn get() -> u32 { - // CHECK: [[RET_0:%.+]] = load i32, {{.*}}[[TLS]]{{.*}} + // CHECK: [[PTR:%.+]] = tail call {{.*}} ptr @llvm.threadlocal.address.p0(ptr [[TLS]]) + // CHECK-NEXT: [[RET_0:%.+]] = load i32, ptr [[PTR]] // CHECK-NEXT: ret i32 [[RET_0]] A.with(|a| a.get()) } @@ -28,7 +29,8 @@ fn get() -> u32 { // CHECK-LABEL: @set #[no_mangle] fn set(v: u32) { - // CHECK: store i32 %0, {{.*}}[[TLS]]{{.*}} + // CHECK: [[PTR:%.+]] = tail call {{.*}} ptr @llvm.threadlocal.address.p0(ptr [[TLS]]) + // CHECK-NEXT: store i32 %0, ptr [[PTR]] // CHECK-NEXT: ret void A.with(|a| a.set(v)) } @@ -36,7 +38,8 @@ fn set(v: u32) { // CHECK-LABEL: @get_aux #[no_mangle] fn get_aux() -> u64 { - // CHECK: [[RET_1:%.+]] = load i64, {{.*}}[[TLS_AUX]] + // CHECK: [[PTR:%.+]] = tail call {{.*}} ptr @llvm.threadlocal.address.p0(ptr [[TLS_AUX]]) + // CHECK-NEXT: [[RET_1:%.+]] = load i64, ptr [[PTR]] // CHECK-NEXT: ret i64 [[RET_1]] aux::A.with(|a| a.get()) } @@ -44,7 +47,8 @@ fn get_aux() -> u64 { // CHECK-LABEL: @set_aux #[no_mangle] fn set_aux(v: u64) { - // CHECK: store i64 %0, {{.*}}[[TLS_AUX]] + // CHECK: [[PTR:%.+]] = tail call {{.*}} ptr @llvm.threadlocal.address.p0(ptr [[TLS_AUX]]) + // CHECK-NEXT: store i64 %0, ptr [[PTR]] // CHECK-NEXT: ret void aux::A.with(|a| a.set(v)) } diff --git a/tests/coverage/async_closure.cov-map b/tests/coverage/async_closure.cov-map index 53128dd7a48..9f8dc8d6cbb 100644 --- a/tests/coverage/async_closure.cov-map +++ b/tests/coverage/async_closure.cov-map @@ -37,29 +37,32 @@ Number of file 0 mappings: 8 Highest counter ID seen: c0 Function name: async_closure::main::{closure#0} -Raw bytes (9): 0x[01, 01, 00, 01, 01, 0b, 22, 00, 24] +Raw bytes (14): 0x[01, 01, 00, 02, 01, 0b, 22, 00, 23, 01, 00, 23, 00, 24] Number of files: 1 - file 0 => $DIR/async_closure.rs Number of expressions: 0 -Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 11, 34) to (start + 0, 36) +Number of file 0 mappings: 2 +- Code(Counter(0)) at (prev + 11, 34) to (start + 0, 35) +- Code(Counter(0)) at (prev + 0, 35) to (start + 0, 36) Highest counter ID seen: c0 Function name: async_closure::main::{closure#0} -Raw bytes (9): 0x[01, 01, 00, 01, 01, 0b, 22, 00, 24] +Raw bytes (14): 0x[01, 01, 00, 02, 01, 0b, 22, 00, 23, 01, 00, 23, 00, 24] Number of files: 1 - file 0 => $DIR/async_closure.rs Number of expressions: 0 -Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 11, 34) to (start + 0, 36) +Number of file 0 mappings: 2 +- Code(Counter(0)) at (prev + 11, 34) to (start + 0, 35) +- Code(Counter(0)) at (prev + 0, 35) to (start + 0, 36) Highest counter ID seen: c0 Function name: async_closure::main::{closure#0}::{closure#0}::<i16> -Raw bytes (9): 0x[01, 01, 00, 01, 01, 0b, 22, 00, 24] +Raw bytes (14): 0x[01, 01, 00, 02, 01, 0b, 22, 00, 23, 01, 00, 23, 00, 24] Number of files: 1 - file 0 => $DIR/async_closure.rs Number of expressions: 0 -Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 11, 34) to (start + 0, 36) +Number of file 0 mappings: 2 +- Code(Counter(0)) at (prev + 11, 34) to (start + 0, 35) +- Code(Counter(0)) at (prev + 0, 35) to (start + 0, 36) Highest counter ID seen: c0 diff --git a/tests/coverage/unused-local-file.coverage b/tests/coverage/unused-local-file.coverage deleted file mode 100644 index 8f5a32f6d70..00000000000 --- a/tests/coverage/unused-local-file.coverage +++ /dev/null @@ -1,7 +0,0 @@ - LL| |//@ edition: 2021 - LL| | - LL| |// Force this function to be generated in its home crate, so that it ends up - LL| |// with normal coverage metadata. - LL| |#[inline(never)] - LL| 1|pub fn external_function() {} - diff --git a/tests/coverage/unused-local-file.rs b/tests/coverage/unused-local-file.rs deleted file mode 100644 index cf43c62d703..00000000000 --- a/tests/coverage/unused-local-file.rs +++ /dev/null @@ -1,22 +0,0 @@ -//! If we give LLVM a local file table for a function, but some of the entries -//! in that table have no associated mapping regions, then an assertion failure -//! will occur in LLVM. We therefore need to detect and skip any function that -//! would trigger that assertion. -//! -//! To test that this case is handled, even before adding code that could allow -//! it to happen organically (for expansion region support), we use a special -//! testing-only flag to force it to occur. - -//@ edition: 2024 -//@ compile-flags: -Zcoverage-options=inject-unused-local-file - -// The `llvm-cov` tool will complain if the test binary ends up having no -// coverage metadata at all. To prevent that, we also link to instrumented -// code in an auxiliary crate that doesn't have the special flag set. - -//@ aux-build: discard_all_helper.rs -extern crate discard_all_helper; - -fn main() { - discard_all_helper::external_function(); -} diff --git a/tests/crashes/113379.rs b/tests/crashes/113379.rs deleted file mode 100644 index 7163cbc3934..00000000000 --- a/tests/crashes/113379.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ known-bug: #113379 - -async fn f999() -> Vec<usize> { - 'b: { - continue 'b; - } -} diff --git a/tests/crashes/121429.rs b/tests/crashes/121429.rs deleted file mode 100644 index e407754db5c..00000000000 --- a/tests/crashes/121429.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ known-bug: #121429 - -#![feature(generic_const_exprs)] - -struct FixedI8<const X: usize>; -const FRAC_LHS: usize = 0; -const FRAC_RHS: usize = 1; - -pub trait True {} - -impl<const N: usize = { const { 3 } }> PartialEq<FixedI8<FRAC_RHS>> for FixedI8<FRAC_LHS> where - If<{}>: True -{ -} diff --git a/tests/crashes/121623.rs b/tests/crashes/121623.rs deleted file mode 100644 index 3c01a7f452c..00000000000 --- a/tests/crashes/121623.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ known-bug: #121623 -fn main() { - match () { - _ => 'b: { - continue 'b; - } - } -} diff --git a/tests/crashes/122704.rs b/tests/crashes/122704.rs deleted file mode 100644 index d6c07be8318..00000000000 --- a/tests/crashes/122704.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ known-bug: #122704 -use std::any::Any; - -pub struct Foo { - bar: Box<dyn for<'a> Fn(&'a usize) -> Box<dyn Any + 'a>>, -} - -impl Foo { - pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I>) { - self.bar = Box::new(|baz| Box::new(f(baz))); - } -} - -fn main() {} diff --git a/tests/crashes/133199.rs b/tests/crashes/133199.rs deleted file mode 100644 index 76535fa83a6..00000000000 --- a/tests/crashes/133199.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ known-bug: #133199 -//@ aux-build: aux133199.rs - -extern crate aux133199; - -use aux133199::FixedBitSet; - -fn main() { - FixedBitSet::<7>::new(); - //~^ ERROR -} diff --git a/tests/crashes/135863.rs b/tests/crashes/135863.rs deleted file mode 100644 index a0ff5988a0d..00000000000 --- a/tests/crashes/135863.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ known-bug: #135863 -struct A; - -impl A { - fn len(self: &&B) {} -} - -fn main() { - A.len() -} diff --git a/tests/crashes/136894.rs b/tests/crashes/136894.rs deleted file mode 100644 index 26bbb78717e..00000000000 --- a/tests/crashes/136894.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ known-bug: #136894 -#![feature(generic_const_exprs)] -#![crate_type = "lib"] -#![allow(incomplete_features, dead_code)] - -struct X<T>([(); f::<T>()]) where [(); f::<T>()]:; - -const fn f<T>() -> usize { panic!() } diff --git a/tests/crashes/137813.rs b/tests/crashes/137813.rs deleted file mode 100644 index 5d205ee5331..00000000000 --- a/tests/crashes/137813.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ known-bug: #137813 -trait AssocConst { - const A: u8; -} - -impl<T> AssocConst for (T,) { - const A: u8 = 0; -} - -trait Trait {} - -impl<U> Trait for () where (U,): AssocConst<A = { 0 }> {} - -fn foo() -where - (): Trait, -{ -} diff --git a/tests/crashes/140255.rs b/tests/crashes/140255.rs deleted file mode 100644 index 6b0ec1718b0..00000000000 --- a/tests/crashes/140255.rs +++ /dev/null @@ -1,3 +0,0 @@ -//@ known-bug: #140255 -#[unsafe(macro_use::VAR2)] -fn dead_code() {} diff --git a/tests/crashes/140281.rs b/tests/crashes/140281.rs deleted file mode 100644 index 76858cfc74a..00000000000 --- a/tests/crashes/140281.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ known-bug: #140281 - -macro_rules! foo { - ($x:expr) => { $x } -} - -fn main() { - let t = vec![ - /// test RTL in doc in vec! - // ICE (Sadly) - 1 - ]; - - foo!( - /// test RTL in doc in macro - 1 - ); -} diff --git a/tests/crashes/140484.rs b/tests/crashes/140484.rs deleted file mode 100644 index 92ec1984398..00000000000 --- a/tests/crashes/140484.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ known-bug: #140484 -//@edition:2024 -#![feature(async_drop)] -use std::future::AsyncDrop; -struct a; -impl Drop for a { - fn b() {} -} -impl AsyncDrop for a { - type c; -} -async fn bar() { - a; -} diff --git a/tests/crashes/140500.rs b/tests/crashes/140500.rs deleted file mode 100644 index ee5b93ab821..00000000000 --- a/tests/crashes/140500.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ known-bug: #140500 - -#![feature(async_drop)] -use std::future::AsyncDrop; -struct a; -impl Drop for a { - fn b() {} -} -impl AsyncDrop for a { - fn c(d: impl Sized) {} -} -async fn bar() { - a; -} diff --git a/tests/crashes/140642.rs b/tests/crashes/140642.rs deleted file mode 100644 index ff75a6ec2f2..00000000000 --- a/tests/crashes/140642.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ known-bug: #140642 -#![feature(min_generic_const_args)] - -pub trait Tr<A> { - const SIZE: usize; -} - -fn mk_array(_x: T) -> [(); <T as Tr<bool>>::SIZE] {} diff --git a/tests/crashes/140683.rs b/tests/crashes/140683.rs deleted file mode 100644 index 74ea5c2533b..00000000000 --- a/tests/crashes/140683.rs +++ /dev/null @@ -1,5 +0,0 @@ -//@ known-bug: #140683 -impl T { -#[core::contracts::ensures] - fn b() { (loop) } -} diff --git a/tests/crashes/140823.rs b/tests/crashes/140823.rs deleted file mode 100644 index ca2d683beed..00000000000 --- a/tests/crashes/140823.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ known-bug: #140823 - -struct Container<T> { - data: T, -} - -fn ice(callback: Box<dyn Fn(Container<&u8>)>) { - let fails: Box<dyn Fn(&Container<&u8>)> = callback; -} diff --git a/tests/crashes/140884.rs b/tests/crashes/140884.rs deleted file mode 100644 index 6840760933a..00000000000 --- a/tests/crashes/140884.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ known-bug: #140884 -//@ needs-rustc-debug-assertions - -fn a() { - extern "" {} -} diff --git a/tests/debuginfo/by-value-non-immediate-argument.rs b/tests/debuginfo/by-value-non-immediate-argument.rs index 192f6efe7db..5233b95f1f4 100644 --- a/tests/debuginfo/by-value-non-immediate-argument.rs +++ b/tests/debuginfo/by-value-non-immediate-argument.rs @@ -2,6 +2,7 @@ //@ min-gdb-version: 13.0 //@ compile-flags:-g //@ ignore-windows-gnu: #128973 +//@ ignore-aarch64-unknown-linux-gnu (gdb tries to read from 0x0; FIXME: #128973) // === GDB TESTS =================================================================================== diff --git a/tests/debuginfo/msvc-pretty-enums.rs b/tests/debuginfo/msvc-pretty-enums.rs index 06bc25dc5d5..aa6629ef1e1 100644 --- a/tests/debuginfo/msvc-pretty-enums.rs +++ b/tests/debuginfo/msvc-pretty-enums.rs @@ -231,8 +231,6 @@ // cdb-command: dx c_style_i128_d // cdb-check: c_style_i128_d : D [Type: enum2$<msvc_pretty_enums::CStyleI128>] #![feature(rustc_attrs)] -#![feature(repr128)] -#![feature(arbitrary_enum_discriminant)] use std::num::NonZero; diff --git a/tests/debuginfo/multiline-calls.rs b/tests/debuginfo/multiline-calls.rs new file mode 100644 index 00000000000..724ad29729f --- /dev/null +++ b/tests/debuginfo/multiline-calls.rs @@ -0,0 +1,35 @@ +//@ compile-flags:-g +//@ min-gdb-version: 16.0 + +// === GDB TESTS =================================================================================== + +// gdb-command: run +// gdb-check:[...]#break[...] +// gdb-command: up +// gdb-check:[...]zzz[...] + +// === LLDB TESTS ================================================================================== + +// lldb-command:run +// lldb-check:[...]#break[...] +// lldb-command: up +// lldb-check:[...]zzz[...] + +struct Foo; + +impl Foo { + fn bar(self) -> Foo { + println!("bar"); + self + } + fn baz(self) -> Foo { + println!("baz"); // #break + self + } +} + +fn main() { + let f = Foo; + f.bar() // aaa + .baz(); // zzz +} diff --git a/tests/incremental/print-dep-node-cycle.rs b/tests/incremental/print-dep-node-cycle.rs new file mode 100644 index 00000000000..931d3da521e --- /dev/null +++ b/tests/incremental/print-dep-node-cycle.rs @@ -0,0 +1,25 @@ +//@ compile-flags: -Z query-dep-graph +//@ revisions: rpass1 + +// Exercises a debug-assertions-only query cycle that when printing a valtree const in +// a dep node's debug representation, we end up invoking a query that also has a valtree +// const in its dep node's debug representation, which leads to a cycle (and ICE, since +// deps are not tracked when printing dep nodes' debug representations). + +#![feature(adt_const_params)] + +use std::marker::ConstParamTy; + +#[derive(Debug, ConstParamTy, PartialEq, Eq)] +enum Foo { + A1, +} + +#[inline(never)] +fn hello<const F: Foo>() { + println!("{:#?}", F); +} + +fn main() { + hello::<{ Foo::A1 }>(); +} diff --git a/tests/mir-opt/address_of.address_of_reborrow.SimplifyCfg-initial.after.mir b/tests/mir-opt/address_of.address_of_reborrow.SimplifyCfg-initial.after.mir index 5fc77f95eaf..8afb6ad250e 100644 --- a/tests/mir-opt/address_of.address_of_reborrow.SimplifyCfg-initial.after.mir +++ b/tests/mir-opt/address_of.address_of_reborrow.SimplifyCfg-initial.after.mir @@ -1,34 +1,34 @@ // MIR for `address_of_reborrow` after SimplifyCfg-initial | User Type Annotations -| 0: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:8:10: 8:18, inferred_ty: *const [i32; 10] -| 1: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:10:10: 10:25, inferred_ty: *const dyn std::marker::Send -| 2: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:14:12: 14:20, inferred_ty: *const [i32; 10] -| 3: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:14:12: 14:20, inferred_ty: *const [i32; 10] +| 0: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [Ty(General(U0))] }, span: $DIR/address_of.rs:8:10: 8:18, inferred_ty: *const [i32; 10] +| 1: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [Region(U0)] }, span: $DIR/address_of.rs:10:10: 10:25, inferred_ty: *const dyn std::marker::Send +| 2: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [Ty(General(U0))] }, span: $DIR/address_of.rs:14:12: 14:20, inferred_ty: *const [i32; 10] +| 3: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [Ty(General(U0))] }, span: $DIR/address_of.rs:14:12: 14:20, inferred_ty: *const [i32; 10] | 4: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:15:12: 15:28, inferred_ty: *const [i32; 10] | 5: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:15:12: 15:28, inferred_ty: *const [i32; 10] -| 6: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:16:12: 16:27, inferred_ty: *const dyn std::marker::Send -| 7: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:16:12: 16:27, inferred_ty: *const dyn std::marker::Send +| 6: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [Region(U0)] }, span: $DIR/address_of.rs:16:12: 16:27, inferred_ty: *const dyn std::marker::Send +| 7: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [Region(U0)] }, span: $DIR/address_of.rs:16:12: 16:27, inferred_ty: *const dyn std::marker::Send | 8: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:17:12: 17:24, inferred_ty: *const [i32] | 9: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:17:12: 17:24, inferred_ty: *const [i32] -| 10: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:19:10: 19:18, inferred_ty: *const [i32; 10] -| 11: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:21:10: 21:25, inferred_ty: *const dyn std::marker::Send -| 12: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:24:12: 24:20, inferred_ty: *const [i32; 10] -| 13: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:24:12: 24:20, inferred_ty: *const [i32; 10] +| 10: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [Ty(General(U0))] }, span: $DIR/address_of.rs:19:10: 19:18, inferred_ty: *const [i32; 10] +| 11: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [Region(U0)] }, span: $DIR/address_of.rs:21:10: 21:25, inferred_ty: *const dyn std::marker::Send +| 12: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [Ty(General(U0))] }, span: $DIR/address_of.rs:24:12: 24:20, inferred_ty: *const [i32; 10] +| 13: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [Ty(General(U0))] }, span: $DIR/address_of.rs:24:12: 24:20, inferred_ty: *const [i32; 10] | 14: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:25:12: 25:28, inferred_ty: *const [i32; 10] | 15: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:25:12: 25:28, inferred_ty: *const [i32; 10] -| 16: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:26:12: 26:27, inferred_ty: *const dyn std::marker::Send -| 17: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:26:12: 26:27, inferred_ty: *const dyn std::marker::Send +| 16: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [Region(U0)] }, span: $DIR/address_of.rs:26:12: 26:27, inferred_ty: *const dyn std::marker::Send +| 17: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [Region(U0)] }, span: $DIR/address_of.rs:26:12: 26:27, inferred_ty: *const dyn std::marker::Send | 18: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:27:12: 27:24, inferred_ty: *const [i32] | 19: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:27:12: 27:24, inferred_ty: *const [i32] -| 20: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:29:10: 29:16, inferred_ty: *mut [i32; 10] -| 21: user_ty: Canonical { value: Ty(*mut dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:31:10: 31:23, inferred_ty: *mut dyn std::marker::Send -| 22: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:34:12: 34:18, inferred_ty: *mut [i32; 10] -| 23: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: $DIR/address_of.rs:34:12: 34:18, inferred_ty: *mut [i32; 10] +| 20: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [Ty(General(U0))] }, span: $DIR/address_of.rs:29:10: 29:16, inferred_ty: *mut [i32; 10] +| 21: user_ty: Canonical { value: Ty(*mut dyn std::marker::Send), max_universe: U0, variables: [Region(U0)] }, span: $DIR/address_of.rs:31:10: 31:23, inferred_ty: *mut dyn std::marker::Send +| 22: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [Ty(General(U0))] }, span: $DIR/address_of.rs:34:12: 34:18, inferred_ty: *mut [i32; 10] +| 23: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [Ty(General(U0))] }, span: $DIR/address_of.rs:34:12: 34:18, inferred_ty: *mut [i32; 10] | 24: user_ty: Canonical { value: Ty(*mut [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:35:12: 35:26, inferred_ty: *mut [i32; 10] | 25: user_ty: Canonical { value: Ty(*mut [i32; 10]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:35:12: 35:26, inferred_ty: *mut [i32; 10] -| 26: user_ty: Canonical { value: Ty(*mut dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:36:12: 36:25, inferred_ty: *mut dyn std::marker::Send -| 27: user_ty: Canonical { value: Ty(*mut dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/address_of.rs:36:12: 36:25, inferred_ty: *mut dyn std::marker::Send +| 26: user_ty: Canonical { value: Ty(*mut dyn std::marker::Send), max_universe: U0, variables: [Region(U0)] }, span: $DIR/address_of.rs:36:12: 36:25, inferred_ty: *mut dyn std::marker::Send +| 27: user_ty: Canonical { value: Ty(*mut dyn std::marker::Send), max_universe: U0, variables: [Region(U0)] }, span: $DIR/address_of.rs:36:12: 36:25, inferred_ty: *mut dyn std::marker::Send | 28: user_ty: Canonical { value: Ty(*mut [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:37:12: 37:22, inferred_ty: *mut [i32] | 29: user_ty: Canonical { value: Ty(*mut [i32]), max_universe: U0, variables: [] }, span: $DIR/address_of.rs:37:12: 37:22, inferred_ty: *mut [i32] | diff --git a/tests/mir-opt/building/receiver_ptr_mutability.main.built.after.mir b/tests/mir-opt/building/receiver_ptr_mutability.main.built.after.mir index 6e349a2a24f..744553c7cd2 100644 --- a/tests/mir-opt/building/receiver_ptr_mutability.main.built.after.mir +++ b/tests/mir-opt/building/receiver_ptr_mutability.main.built.after.mir @@ -3,8 +3,8 @@ | User Type Annotations | 0: user_ty: Canonical { value: Ty(*mut Test), max_universe: U0, variables: [] }, span: $DIR/receiver_ptr_mutability.rs:15:14: 15:23, inferred_ty: *mut Test | 1: user_ty: Canonical { value: Ty(*mut Test), max_universe: U0, variables: [] }, span: $DIR/receiver_ptr_mutability.rs:15:14: 15:23, inferred_ty: *mut Test -| 2: user_ty: Canonical { value: Ty(&&&&*mut Test), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/receiver_ptr_mutability.rs:19:18: 19:31, inferred_ty: &&&&*mut Test -| 3: user_ty: Canonical { value: Ty(&&&&*mut Test), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }] }, span: $DIR/receiver_ptr_mutability.rs:19:18: 19:31, inferred_ty: &&&&*mut Test +| 2: user_ty: Canonical { value: Ty(&&&&*mut Test), max_universe: U0, variables: [Region(U0), Region(U0), Region(U0), Region(U0)] }, span: $DIR/receiver_ptr_mutability.rs:19:18: 19:31, inferred_ty: &&&&*mut Test +| 3: user_ty: Canonical { value: Ty(&&&&*mut Test), max_universe: U0, variables: [Region(U0), Region(U0), Region(U0), Region(U0)] }, span: $DIR/receiver_ptr_mutability.rs:19:18: 19:31, inferred_ty: &&&&*mut Test | fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/coverage/branch_match_arms.main.InstrumentCoverage.diff b/tests/mir-opt/coverage/branch_match_arms.main.InstrumentCoverage.diff index fa88211383a..d465b8bded2 100644 --- a/tests/mir-opt/coverage/branch_match_arms.main.InstrumentCoverage.diff +++ b/tests/mir-opt/coverage/branch_match_arms.main.InstrumentCoverage.diff @@ -40,7 +40,7 @@ + coverage Code { bcb: bcb5 } => $DIR/branch_match_arms.rs:19:17: 19:18 (#0); + coverage Code { bcb: bcb5 } => $DIR/branch_match_arms.rs:19:23: 19:30 (#0); + coverage Code { bcb: bcb5 } => $DIR/branch_match_arms.rs:19:31: 19:32 (#0); -+ coverage Code { bcb: bcb2 } => $DIR/branch_match_arms.rs:21:1: 21:2 (#0); ++ coverage Code { bcb: bcb2 } => $DIR/branch_match_arms.rs:21:2: 21:2 (#0); + bb0: { + Coverage::VirtualCounter(bcb0); diff --git a/tests/mir-opt/coverage/instrument_coverage.bar.InstrumentCoverage.diff b/tests/mir-opt/coverage/instrument_coverage.bar.InstrumentCoverage.diff index 9b6d2b22087..cf6d85abd80 100644 --- a/tests/mir-opt/coverage/instrument_coverage.bar.InstrumentCoverage.diff +++ b/tests/mir-opt/coverage/instrument_coverage.bar.InstrumentCoverage.diff @@ -6,7 +6,7 @@ + coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:27:1: 27:17 (#0); + coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:28:5: 28:9 (#0); -+ coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:29:1: 29:2 (#0); ++ coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:29:2: 29:2 (#0); + bb0: { + Coverage::VirtualCounter(bcb0); diff --git a/tests/mir-opt/coverage/instrument_coverage.main.InstrumentCoverage.diff b/tests/mir-opt/coverage/instrument_coverage.main.InstrumentCoverage.diff index b2bb2375aee..980c5e202ff 100644 --- a/tests/mir-opt/coverage/instrument_coverage.main.InstrumentCoverage.diff +++ b/tests/mir-opt/coverage/instrument_coverage.main.InstrumentCoverage.diff @@ -10,8 +10,8 @@ + coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:13:1: 13:10 (#0); + coverage Code { bcb: bcb1 } => $DIR/instrument_coverage.rs:15:12: 15:15 (#0); + coverage Code { bcb: bcb2 } => $DIR/instrument_coverage.rs:16:13: 16:18 (#0); -+ coverage Code { bcb: bcb3 } => $DIR/instrument_coverage.rs:17:9: 17:10 (#0); -+ coverage Code { bcb: bcb2 } => $DIR/instrument_coverage.rs:19:1: 19:2 (#0); ++ coverage Code { bcb: bcb3 } => $DIR/instrument_coverage.rs:17:10: 17:10 (#0); ++ coverage Code { bcb: bcb2 } => $DIR/instrument_coverage.rs:19:2: 19:2 (#0); + bb0: { + Coverage::VirtualCounter(bcb0); diff --git a/tests/mir-opt/coverage/instrument_coverage_cleanup.main.CleanupPostBorrowck.diff b/tests/mir-opt/coverage/instrument_coverage_cleanup.main.CleanupPostBorrowck.diff index 2eb78c08ee8..b707cd41788 100644 --- a/tests/mir-opt/coverage/instrument_coverage_cleanup.main.CleanupPostBorrowck.diff +++ b/tests/mir-opt/coverage/instrument_coverage_cleanup.main.CleanupPostBorrowck.diff @@ -10,8 +10,8 @@ coverage Code { bcb: bcb0 } => $DIR/instrument_coverage_cleanup.rs:13:1: 13:10 (#0); coverage Code { bcb: bcb0 } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0); coverage Code { bcb: bcb3 } => $DIR/instrument_coverage_cleanup.rs:14:37: 14:39 (#0); - coverage Code { bcb: bcb1 } => $DIR/instrument_coverage_cleanup.rs:14:38: 14:39 (#0); - coverage Code { bcb: bcb2 } => $DIR/instrument_coverage_cleanup.rs:15:1: 15:2 (#0); + coverage Code { bcb: bcb1 } => $DIR/instrument_coverage_cleanup.rs:14:39: 14:39 (#0); + coverage Code { bcb: bcb2 } => $DIR/instrument_coverage_cleanup.rs:15:2: 15:2 (#0); coverage Branch { true_bcb: bcb3, false_bcb: bcb1 } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0); bb0: { diff --git a/tests/mir-opt/coverage/instrument_coverage_cleanup.main.InstrumentCoverage.diff b/tests/mir-opt/coverage/instrument_coverage_cleanup.main.InstrumentCoverage.diff index 0c1bc24b6dc..239b845c231 100644 --- a/tests/mir-opt/coverage/instrument_coverage_cleanup.main.InstrumentCoverage.diff +++ b/tests/mir-opt/coverage/instrument_coverage_cleanup.main.InstrumentCoverage.diff @@ -10,8 +10,8 @@ + coverage Code { bcb: bcb0 } => $DIR/instrument_coverage_cleanup.rs:13:1: 13:10 (#0); + coverage Code { bcb: bcb0 } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0); + coverage Code { bcb: bcb3 } => $DIR/instrument_coverage_cleanup.rs:14:37: 14:39 (#0); -+ coverage Code { bcb: bcb1 } => $DIR/instrument_coverage_cleanup.rs:14:38: 14:39 (#0); -+ coverage Code { bcb: bcb2 } => $DIR/instrument_coverage_cleanup.rs:15:1: 15:2 (#0); ++ coverage Code { bcb: bcb1 } => $DIR/instrument_coverage_cleanup.rs:14:39: 14:39 (#0); ++ coverage Code { bcb: bcb2 } => $DIR/instrument_coverage_cleanup.rs:15:2: 15:2 (#0); + coverage Branch { true_bcb: bcb3, false_bcb: bcb1 } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0); + bb0: { diff --git a/tests/mir-opt/dataflow.main.maybe_init.borrowck.dot b/tests/mir-opt/dataflow.main.maybe_init.borrowck.dot deleted file mode 100644 index 7c7d8921fb3..00000000000 --- a/tests/mir-opt/dataflow.main.maybe_init.borrowck.dot +++ /dev/null @@ -1,6 +0,0 @@ -digraph graph_for_def_id_0_3 { - graph[fontname="Courier, monospace"]; - node[fontname="Courier, monospace"]; - edge[fontname="Courier, monospace"]; - bb_0[label=<<table border="1" cellborder="1" cellspacing="0" cellpadding="3" sides="rb"><tr><td colspan="3" sides="tl">bb0</td></tr><tr><td colspan="2" bgcolor="#a0a0a0" sides="tl">MIR</td><td bgcolor="#a0a0a0" sides="tl">STATE</td></tr><tr><td valign="bottom" sides="tl" align="right"></td><td valign="bottom" sides="tl" align="left">(on start)</td><td colspan="1" valign="bottom" sides="tl" align="left">{}</td></tr><tr><td valign="top" sides="tl" bgcolor="#f0f0f0" align="right">0</td><td valign="top" sides="tl" bgcolor="#f0f0f0" align="left">_0 = const ()</td><td valign="top" sides="tl" bgcolor="#f0f0f0" align="left"><font color="darkgreen">+_0</font></td></tr><tr><td valign="top" sides="tl" align="right">T</td><td valign="top" sides="tl" align="left">return</td><td valign="top" sides="tl" align="left"></td></tr><tr><td valign="bottom" sides="tl" bgcolor="#f0f0f0" align="right"></td><td valign="bottom" sides="tl" bgcolor="#f0f0f0" align="left">(on end)</td><td colspan="1" valign="bottom" sides="tl" bgcolor="#f0f0f0" align="left">{_0}</td></tr></table>>][shape="none"]; -} diff --git a/tests/mir-opt/dataflow.main.maybe_uninit.borrowck.dot b/tests/mir-opt/dataflow.main.maybe_uninit.borrowck.dot new file mode 100644 index 00000000000..258404b8da7 --- /dev/null +++ b/tests/mir-opt/dataflow.main.maybe_uninit.borrowck.dot @@ -0,0 +1,6 @@ +digraph graph_for_def_id_0_3 { + graph[fontname="Courier, monospace"]; + node[fontname="Courier, monospace"]; + edge[fontname="Courier, monospace"]; + bb_0[label=<<table border="1" cellborder="1" cellspacing="0" cellpadding="3" sides="rb"><tr><td colspan="3" sides="tl">bb0</td></tr><tr><td colspan="2" bgcolor="#a0a0a0" sides="tl">MIR</td><td bgcolor="#a0a0a0" sides="tl">STATE</td></tr><tr><td valign="bottom" sides="tl" align="right"></td><td valign="bottom" sides="tl" align="left">(on start)</td><td colspan="1" valign="bottom" sides="tl" align="left">{_0}</td></tr><tr><td valign="top" sides="tl" bgcolor="#f0f0f0" align="right">0</td><td valign="top" sides="tl" bgcolor="#f0f0f0" align="left">_0 = const ()</td><td valign="top" sides="tl" bgcolor="#f0f0f0" align="left"><font color="red">-_0</font></td></tr><tr><td valign="top" sides="tl" align="right">T</td><td valign="top" sides="tl" align="left">return</td><td valign="top" sides="tl" align="left"></td></tr><tr><td valign="bottom" sides="tl" bgcolor="#f0f0f0" align="right"></td><td valign="bottom" sides="tl" bgcolor="#f0f0f0" align="left">(on end)</td><td colspan="1" valign="bottom" sides="tl" bgcolor="#f0f0f0" align="left">{}</td></tr></table>>][shape="none"]; +} diff --git a/tests/mir-opt/dataflow.rs b/tests/mir-opt/dataflow.rs index 3a28f5d47b9..5ed3da4c531 100644 --- a/tests/mir-opt/dataflow.rs +++ b/tests/mir-opt/dataflow.rs @@ -2,5 +2,5 @@ // Test graphviz dataflow output //@ compile-flags: -Z dump-mir=main -Z dump-mir-dataflow -// EMIT_MIR dataflow.main.maybe_init.borrowck.dot +// EMIT_MIR dataflow.main.maybe_uninit.borrowck.dot fn main() {} diff --git a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff index 35eb4fbd106..25ffff619e6 100644 --- a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff @@ -59,7 +59,7 @@ scope 10 (inlined <std::alloc::Global as Allocator>::allocate) { } } - scope 9 (inlined Layout::from_size_align_unchecked) { + scope 9 (inlined #[track_caller] Layout::from_size_align_unchecked) { let mut _19: bool; let _20: (); let mut _21: std::ptr::Alignment; diff --git a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff index 4427a5fcc7d..839b53e3b0b 100644 --- a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff @@ -59,7 +59,7 @@ scope 10 (inlined <std::alloc::Global as Allocator>::allocate) { } } - scope 9 (inlined Layout::from_size_align_unchecked) { + scope 9 (inlined #[track_caller] Layout::from_size_align_unchecked) { let mut _19: bool; let _20: (); let mut _21: std::ptr::Alignment; diff --git a/tests/mir-opt/enum_opt.rs b/tests/mir-opt/enum_opt.rs index e42be8ac06d..81390567c2b 100644 --- a/tests/mir-opt/enum_opt.rs +++ b/tests/mir-opt/enum_opt.rs @@ -3,8 +3,6 @@ // EMIT_MIR_FOR_EACH_BIT_WIDTH //@ compile-flags: -Zunsound-mir-opts -Zdump-mir-exclude-alloc-bytes -#![feature(arbitrary_enum_discriminant, repr128)] - // Tests that an enum with a variant with no data gets correctly transformed. pub enum NoData { Large([u8; 8196]), diff --git a/tests/mir-opt/gvn_repeat.repeat_local.GVN.diff b/tests/mir-opt/gvn_repeat.repeat_local.GVN.diff new file mode 100644 index 00000000000..fd047825281 --- /dev/null +++ b/tests/mir-opt/gvn_repeat.repeat_local.GVN.diff @@ -0,0 +1,18 @@ +- // MIR for `repeat_local` before GVN ++ // MIR for `repeat_local` after GVN + + fn repeat_local(_1: usize, _2: usize, _3: i32) -> i32 { + let mut _0: i32; + let mut _4: [i32; 5]; + let mut _5: &i32; + + bb0: { + _4 = [copy _3; 5]; + _5 = &_4[_1]; + _1 = copy _2; +- _0 = copy (*_5); ++ _0 = copy _3; + return; + } + } + diff --git a/tests/mir-opt/gvn_repeat.repeat_place.GVN.diff b/tests/mir-opt/gvn_repeat.repeat_place.GVN.diff new file mode 100644 index 00000000000..e490925bc11 --- /dev/null +++ b/tests/mir-opt/gvn_repeat.repeat_place.GVN.diff @@ -0,0 +1,17 @@ +- // MIR for `repeat_place` before GVN ++ // MIR for `repeat_place` after GVN + + fn repeat_place(_1: usize, _2: usize, _3: &i32) -> i32 { + let mut _0: i32; + let mut _4: [i32; 5]; + let mut _5: &i32; + + bb0: { + _4 = [copy (*_3); 5]; + _5 = &_4[_1]; + _1 = copy _2; + _0 = copy (*_5); + return; + } + } + diff --git a/tests/mir-opt/gvn_repeat.rs b/tests/mir-opt/gvn_repeat.rs new file mode 100644 index 00000000000..bbbb2a7ccba --- /dev/null +++ b/tests/mir-opt/gvn_repeat.rs @@ -0,0 +1,49 @@ +//@ test-mir-pass: GVN + +#![feature(custom_mir, core_intrinsics)] + +// Check that we do not introduce out-of-bounds access. + +use std::intrinsics::mir::*; + +// EMIT_MIR gvn_repeat.repeat_place.GVN.diff +#[custom_mir(dialect = "runtime")] +pub fn repeat_place(mut idx1: usize, idx2: usize, val: &i32) -> i32 { + // CHECK-LABEL: fn repeat_place( + // CHECK: let mut [[ELEM:.*]]: &i32; + // CHECK: _0 = copy (*[[ELEM]]) + mir! { + let array; + let elem; + { + array = [*val; 5]; + elem = &array[idx1]; + idx1 = idx2; + RET = *elem; + Return() + } + } +} + +// EMIT_MIR gvn_repeat.repeat_local.GVN.diff +#[custom_mir(dialect = "runtime")] +pub fn repeat_local(mut idx1: usize, idx2: usize, val: i32) -> i32 { + // CHECK-LABEL: fn repeat_local( + // CHECK: _0 = copy _3 + mir! { + let array; + let elem; + { + array = [val; 5]; + elem = &array[idx1]; + idx1 = idx2; + RET = *elem; + Return() + } + } +} + +fn main() { + assert_eq!(repeat_place(0, 5, &0), 0); + assert_eq!(repeat_local(0, 5, 0), 0); +} diff --git a/tests/mir-opt/inline/unchecked_shifts.rs b/tests/mir-opt/inline/unchecked_shifts.rs index 3c4e73bf7ea..122f099da4b 100644 --- a/tests/mir-opt/inline/unchecked_shifts.rs +++ b/tests/mir-opt/inline/unchecked_shifts.rs @@ -11,7 +11,7 @@ // EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir pub unsafe fn unchecked_shl_unsigned_smaller(a: u16, b: u32) -> u16 { // CHECK-LABEL: fn unchecked_shl_unsigned_smaller( - // CHECK: (inlined core::num::<impl u16>::unchecked_shl) + // CHECK: (inlined #[track_caller] core::num::<impl u16>::unchecked_shl) a.unchecked_shl(b) } @@ -19,6 +19,6 @@ pub unsafe fn unchecked_shl_unsigned_smaller(a: u16, b: u32) -> u16 { // EMIT_MIR unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.mir pub unsafe fn unchecked_shr_signed_bigger(a: i64, b: u32) -> i64 { // CHECK-LABEL: fn unchecked_shr_signed_bigger( - // CHECK: (inlined core::num::<impl i64>::unchecked_shr) + // CHECK: (inlined #[track_caller] core::num::<impl i64>::unchecked_shr) a.unchecked_shr(b) } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff index 39ba480d203..813796657b2 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff @@ -7,7 +7,7 @@ let mut _0: u16; let mut _3: u16; let mut _4: u32; -+ scope 1 (inlined core::num::<impl u16>::unchecked_shl) { ++ scope 1 (inlined #[track_caller] core::num::<impl u16>::unchecked_shl) { + let _5: (); + scope 2 (inlined core::ub_checks::check_language_ub) { + let mut _6: bool; diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff index 5a758d35740..61fdb69f74b 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff @@ -7,7 +7,7 @@ let mut _0: u16; let mut _3: u16; let mut _4: u32; -+ scope 1 (inlined core::num::<impl u16>::unchecked_shl) { ++ scope 1 (inlined #[track_caller] core::num::<impl u16>::unchecked_shl) { + let _5: (); + scope 2 (inlined core::ub_checks::check_language_ub) { + let mut _6: bool; diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir index 611273ab08d..0fc7c4b7947 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir @@ -4,7 +4,7 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { debug a => _1; debug b => _2; let mut _0: u16; - scope 1 (inlined core::num::<impl u16>::unchecked_shl) { + scope 1 (inlined #[track_caller] core::num::<impl u16>::unchecked_shl) { scope 2 (inlined core::ub_checks::check_language_ub) { scope 3 (inlined core::ub_checks::check_language_ub::runtime) { } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir index 611273ab08d..0fc7c4b7947 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir @@ -4,7 +4,7 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { debug a => _1; debug b => _2; let mut _0: u16; - scope 1 (inlined core::num::<impl u16>::unchecked_shl) { + scope 1 (inlined #[track_caller] core::num::<impl u16>::unchecked_shl) { scope 2 (inlined core::ub_checks::check_language_ub) { scope 3 (inlined core::ub_checks::check_language_ub::runtime) { } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff index a0caf141f2d..5ea99e8301b 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff @@ -7,7 +7,7 @@ let mut _0: i64; let mut _3: i64; let mut _4: u32; -+ scope 1 (inlined core::num::<impl i64>::unchecked_shr) { ++ scope 1 (inlined #[track_caller] core::num::<impl i64>::unchecked_shr) { + let _5: (); + scope 2 (inlined core::ub_checks::check_language_ub) { + let mut _6: bool; diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff index 633089e7b2a..b13531ab148 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff @@ -7,7 +7,7 @@ let mut _0: i64; let mut _3: i64; let mut _4: u32; -+ scope 1 (inlined core::num::<impl i64>::unchecked_shr) { ++ scope 1 (inlined #[track_caller] core::num::<impl i64>::unchecked_shr) { + let _5: (); + scope 2 (inlined core::ub_checks::check_language_ub) { + let mut _6: bool; diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-abort.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-abort.mir index f4ddd0bca04..bef7fa7b1df 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-abort.mir @@ -4,7 +4,7 @@ fn unchecked_shr_signed_bigger(_1: i64, _2: u32) -> i64 { debug a => _1; debug b => _2; let mut _0: i64; - scope 1 (inlined core::num::<impl i64>::unchecked_shr) { + scope 1 (inlined #[track_caller] core::num::<impl i64>::unchecked_shr) { scope 2 (inlined core::ub_checks::check_language_ub) { scope 3 (inlined core::ub_checks::check_language_ub::runtime) { } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-unwind.mir index f4ddd0bca04..bef7fa7b1df 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-unwind.mir @@ -4,7 +4,7 @@ fn unchecked_shr_signed_bigger(_1: i64, _2: u32) -> i64 { debug a => _1; debug b => _2; let mut _0: i64; - scope 1 (inlined core::num::<impl i64>::unchecked_shr) { + scope 1 (inlined #[track_caller] core::num::<impl i64>::unchecked_shr) { scope 2 (inlined core::ub_checks::check_language_ub) { scope 3 (inlined core::ub_checks::check_language_ub::runtime) { } diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff index a5986a4315a..0119dd79970 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff @@ -9,7 +9,7 @@ + let mut _3: isize; + scope 2 { + } -+ scope 3 (inlined unreachable_unchecked) { ++ scope 3 (inlined #[track_caller] unreachable_unchecked) { + let _4: (); + scope 4 (inlined core::ub_checks::check_language_ub) { + let mut _5: bool; diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff index 12b03a6b6d9..d6a5eab1d6e 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff @@ -9,7 +9,7 @@ + let mut _3: isize; + scope 2 { + } -+ scope 3 (inlined unreachable_unchecked) { ++ scope 3 (inlined #[track_caller] unreachable_unchecked) { + let _4: (); + scope 4 (inlined core::ub_checks::check_language_ub) { + let mut _5: bool; diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir index 66ab5e1b962..b7b892c177c 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir @@ -7,7 +7,7 @@ fn unwrap_unchecked(_1: Option<T>) -> T { let mut _2: isize; scope 2 { } - scope 3 (inlined unreachable_unchecked) { + scope 3 (inlined #[track_caller] unreachable_unchecked) { scope 4 (inlined core::ub_checks::check_language_ub) { scope 5 (inlined core::ub_checks::check_language_ub::runtime) { } diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir index 66ab5e1b962..b7b892c177c 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir @@ -7,7 +7,7 @@ fn unwrap_unchecked(_1: Option<T>) -> T { let mut _2: isize; scope 2 { } - scope 3 (inlined unreachable_unchecked) { + scope 3 (inlined #[track_caller] unreachable_unchecked) { scope 4 (inlined core::ub_checks::check_language_ub) { scope 5 (inlined core::ub_checks::check_language_ub::runtime) { } diff --git a/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify-after-simplifycfg.diff b/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify-after-simplifycfg.diff index 82353a2d540..2c9071e6e20 100644 --- a/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify-after-simplifycfg.diff +++ b/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify-after-simplifycfg.diff @@ -9,7 +9,7 @@ let mut _3: isize; scope 2 { } - scope 3 (inlined unreachable_unchecked) { + scope 3 (inlined #[track_caller] unreachable_unchecked) { let _4: (); scope 4 (inlined core::ub_checks::check_language_ub) { let mut _5: bool; diff --git a/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.panic-abort.diff b/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.panic-abort.diff index 7f325245bce..d73cc3d214e 100644 --- a/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.panic-abort.diff +++ b/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.panic-abort.diff @@ -45,7 +45,7 @@ _9 = copy _10; _8 = move _9 as *mut i32 (PtrToPtr); StorageDead(_9); -- _3 = copy_nonoverlapping::<i32>(move _4, move _8, const 0_usize) -> [return: bb1, unwind unreachable]; +- _3 = std::intrinsics::copy_nonoverlapping::<i32>(move _4, move _8, const 0_usize) -> [return: bb1, unwind unreachable]; + copy_nonoverlapping(dst = move _8, src = move _4, count = const 0_usize); + goto -> bb1; } diff --git a/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.panic-unwind.diff b/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.panic-unwind.diff index 7f325245bce..d73cc3d214e 100644 --- a/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.panic-unwind.diff +++ b/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.panic-unwind.diff @@ -45,7 +45,7 @@ _9 = copy _10; _8 = move _9 as *mut i32 (PtrToPtr); StorageDead(_9); -- _3 = copy_nonoverlapping::<i32>(move _4, move _8, const 0_usize) -> [return: bb1, unwind unreachable]; +- _3 = std::intrinsics::copy_nonoverlapping::<i32>(move _4, move _8, const 0_usize) -> [return: bb1, unwind unreachable]; + copy_nonoverlapping(dst = move _8, src = move _4, count = const 0_usize); + goto -> bb1; } diff --git a/tests/mir-opt/lower_intrinsics.rs b/tests/mir-opt/lower_intrinsics.rs index 5afddc5ff73..1e4f2024194 100644 --- a/tests/mir-opt/lower_intrinsics.rs +++ b/tests/mir-opt/lower_intrinsics.rs @@ -1,9 +1,11 @@ //@ test-mir-pass: LowerIntrinsics // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -#![feature(core_intrinsics, intrinsics, rustc_attrs)] +#![feature(core_intrinsics)] #![crate_type = "lib"] +use std::intrinsics::copy_nonoverlapping; + // EMIT_MIR lower_intrinsics.wrapping.LowerIntrinsics.diff pub fn wrapping(a: i32, b: i32) { // CHECK-LABEL: fn wrapping( @@ -153,11 +155,6 @@ pub fn discriminant<T>(t: T) { core::intrinsics::discriminant_value(&E::B); } -// Cannot use `std::intrinsics::copy_nonoverlapping` as that is a wrapper function -#[rustc_nounwind] -#[rustc_intrinsic] -unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize); - // EMIT_MIR lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.diff pub fn f_copy_nonoverlapping() { // CHECK-LABEL: fn f_copy_nonoverlapping( @@ -266,3 +263,24 @@ pub fn get_metadata(a: *const i32, b: *const [u8], c: *const dyn std::fmt::Debug let _usize = ptr_metadata(b); let _vtable = ptr_metadata(c); } + +// EMIT_MIR lower_intrinsics.slice_get.LowerIntrinsics.diff +pub unsafe fn slice_get<'a, 'b>( + r: &'a [i8], + rm: &'b mut [i16], + p: *const [i32], + pm: *mut [i64], + i: usize, +) -> (&'a i8, &'b mut i16, *const i32, *mut i64) { + use std::intrinsics::slice_get_unchecked; + // CHECK: = &(*_{{[0-9]+}})[_{{[0-9]+}}] + // CHECK: = &mut (*_{{[0-9]+}})[_{{[0-9]+}}] + // CHECK: = &raw const (*_{{[0-9]+}})[_{{[0-9]+}}] + // CHECK: = &raw mut (*_{{[0-9]+}})[_{{[0-9]+}}] + ( + slice_get_unchecked(r, i), + slice_get_unchecked(rm, i), + slice_get_unchecked(p, i), + slice_get_unchecked(pm, i), + ) +} diff --git a/tests/mir-opt/lower_intrinsics.slice_get.LowerIntrinsics.panic-abort.diff b/tests/mir-opt/lower_intrinsics.slice_get.LowerIntrinsics.panic-abort.diff new file mode 100644 index 00000000000..d18bdc43168 --- /dev/null +++ b/tests/mir-opt/lower_intrinsics.slice_get.LowerIntrinsics.panic-abort.diff @@ -0,0 +1,85 @@ +- // MIR for `slice_get` before LowerIntrinsics ++ // MIR for `slice_get` after LowerIntrinsics + + fn slice_get(_1: &[i8], _2: &mut [i16], _3: *const [i32], _4: *mut [i64], _5: usize) -> (&i8, &mut i16, *const i32, *mut i64) { + debug r => _1; + debug rm => _2; + debug p => _3; + debug pm => _4; + debug i => _5; + let mut _0: (&i8, &mut i16, *const i32, *mut i64); + let mut _6: &i8; + let mut _7: &[i8]; + let mut _8: usize; + let mut _9: &mut i16; + let mut _10: &mut [i16]; + let mut _11: usize; + let mut _12: *const i32; + let mut _13: *const [i32]; + let mut _14: usize; + let mut _15: *mut i64; + let mut _16: *mut [i64]; + let mut _17: usize; + + bb0: { + StorageLive(_6); + StorageLive(_7); + _7 = copy _1; + StorageLive(_8); + _8 = copy _5; +- _6 = slice_get_unchecked::<&i8, &[i8], i8>(move _7, move _8) -> [return: bb1, unwind unreachable]; ++ _6 = &(*_7)[_8]; ++ goto -> bb1; + } + + bb1: { + StorageDead(_8); + StorageDead(_7); + StorageLive(_9); + StorageLive(_10); + _10 = move _2; + StorageLive(_11); + _11 = copy _5; +- _9 = slice_get_unchecked::<&mut i16, &mut [i16], i16>(move _10, move _11) -> [return: bb2, unwind unreachable]; ++ _9 = &mut (*_10)[_11]; ++ goto -> bb2; + } + + bb2: { + StorageDead(_11); + StorageDead(_10); + StorageLive(_12); + StorageLive(_13); + _13 = copy _3; + StorageLive(_14); + _14 = copy _5; +- _12 = slice_get_unchecked::<*const i32, *const [i32], i32>(move _13, move _14) -> [return: bb3, unwind unreachable]; ++ _12 = &raw const (*_13)[_14]; ++ goto -> bb3; + } + + bb3: { + StorageDead(_14); + StorageDead(_13); + StorageLive(_15); + StorageLive(_16); + _16 = copy _4; + StorageLive(_17); + _17 = copy _5; +- _15 = slice_get_unchecked::<*mut i64, *mut [i64], i64>(move _16, move _17) -> [return: bb4, unwind unreachable]; ++ _15 = &raw mut (*_16)[_17]; ++ goto -> bb4; + } + + bb4: { + StorageDead(_17); + StorageDead(_16); + _0 = (move _6, move _9, move _12, move _15); + StorageDead(_15); + StorageDead(_12); + StorageDead(_9); + StorageDead(_6); + return; + } + } + diff --git a/tests/mir-opt/lower_intrinsics.slice_get.LowerIntrinsics.panic-unwind.diff b/tests/mir-opt/lower_intrinsics.slice_get.LowerIntrinsics.panic-unwind.diff new file mode 100644 index 00000000000..d18bdc43168 --- /dev/null +++ b/tests/mir-opt/lower_intrinsics.slice_get.LowerIntrinsics.panic-unwind.diff @@ -0,0 +1,85 @@ +- // MIR for `slice_get` before LowerIntrinsics ++ // MIR for `slice_get` after LowerIntrinsics + + fn slice_get(_1: &[i8], _2: &mut [i16], _3: *const [i32], _4: *mut [i64], _5: usize) -> (&i8, &mut i16, *const i32, *mut i64) { + debug r => _1; + debug rm => _2; + debug p => _3; + debug pm => _4; + debug i => _5; + let mut _0: (&i8, &mut i16, *const i32, *mut i64); + let mut _6: &i8; + let mut _7: &[i8]; + let mut _8: usize; + let mut _9: &mut i16; + let mut _10: &mut [i16]; + let mut _11: usize; + let mut _12: *const i32; + let mut _13: *const [i32]; + let mut _14: usize; + let mut _15: *mut i64; + let mut _16: *mut [i64]; + let mut _17: usize; + + bb0: { + StorageLive(_6); + StorageLive(_7); + _7 = copy _1; + StorageLive(_8); + _8 = copy _5; +- _6 = slice_get_unchecked::<&i8, &[i8], i8>(move _7, move _8) -> [return: bb1, unwind unreachable]; ++ _6 = &(*_7)[_8]; ++ goto -> bb1; + } + + bb1: { + StorageDead(_8); + StorageDead(_7); + StorageLive(_9); + StorageLive(_10); + _10 = move _2; + StorageLive(_11); + _11 = copy _5; +- _9 = slice_get_unchecked::<&mut i16, &mut [i16], i16>(move _10, move _11) -> [return: bb2, unwind unreachable]; ++ _9 = &mut (*_10)[_11]; ++ goto -> bb2; + } + + bb2: { + StorageDead(_11); + StorageDead(_10); + StorageLive(_12); + StorageLive(_13); + _13 = copy _3; + StorageLive(_14); + _14 = copy _5; +- _12 = slice_get_unchecked::<*const i32, *const [i32], i32>(move _13, move _14) -> [return: bb3, unwind unreachable]; ++ _12 = &raw const (*_13)[_14]; ++ goto -> bb3; + } + + bb3: { + StorageDead(_14); + StorageDead(_13); + StorageLive(_15); + StorageLive(_16); + _16 = copy _4; + StorageLive(_17); + _17 = copy _5; +- _15 = slice_get_unchecked::<*mut i64, *mut [i64], i64>(move _16, move _17) -> [return: bb4, unwind unreachable]; ++ _15 = &raw mut (*_16)[_17]; ++ goto -> bb4; + } + + bb4: { + StorageDead(_17); + StorageDead(_16); + _0 = (move _6, move _9, move _12, move _15); + StorageDead(_15); + StorageDead(_12); + StorageDead(_9); + StorageDead(_6); + return; + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.match_non_int_failed.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_non_int_failed.MatchBranchSimplification.diff new file mode 100644 index 00000000000..81e900a34c0 --- /dev/null +++ b/tests/mir-opt/matches_reduce_branches.match_non_int_failed.MatchBranchSimplification.diff @@ -0,0 +1,29 @@ +- // MIR for `match_non_int_failed` before MatchBranchSimplification ++ // MIR for `match_non_int_failed` after MatchBranchSimplification + + fn match_non_int_failed(_1: char) -> u8 { + let mut _0: u8; + + bb0: { + switchInt(copy _1) -> [97: bb1, 98: bb2, otherwise: bb3]; + } + + bb1: { + _0 = const 97_u8; + goto -> bb4; + } + + bb2: { + _0 = const 98_u8; + goto -> bb4; + } + + bb3: { + unreachable; + } + + bb4: { + return; + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.rs b/tests/mir-opt/matches_reduce_branches.rs index 3372ae2f2a6..89ef3bfb308 100644 --- a/tests/mir-opt/matches_reduce_branches.rs +++ b/tests/mir-opt/matches_reduce_branches.rs @@ -1,6 +1,5 @@ //@ test-mir-pass: MatchBranchSimplification -#![feature(repr128)] #![feature(core_intrinsics)] #![feature(custom_mir)] #![allow(non_camel_case_types)] @@ -628,6 +627,37 @@ fn match_i128_u128(i: EnumAi128) -> u128 { } } +// EMIT_MIR matches_reduce_branches.match_non_int_failed.MatchBranchSimplification.diff +#[custom_mir(dialect = "runtime")] +fn match_non_int_failed(i: char) -> u8 { + // CHECK-LABEL: fn match_non_int_failed( + // CHECK: switchInt + // CHECK: return + mir! { + { + match i { + 'a' => bb1, + 'b' => bb2, + _ => unreachable_bb, + } + } + bb1 = { + RET = 97; + Goto(ret) + } + bb2 = { + RET = 98; + Goto(ret) + } + unreachable_bb = { + Unreachable() + } + ret = { + Return() + } + } +} + fn main() { let _ = foo(None); let _ = foo(Some(())); @@ -665,4 +695,5 @@ fn main() { let _ = match_i128_u128(EnumAi128::A); let _ = my_is_some(None); + let _ = match_non_int_failed('a'); } diff --git a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-abort.mir index a9dd8886577..18eeb8e4d3b 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-abort.mir @@ -7,7 +7,7 @@ fn checked_shl(_1: u32, _2: u32) -> Option<u32> { scope 1 (inlined core::num::<impl u32>::checked_shl) { let mut _3: bool; let mut _4: u32; - scope 2 (inlined core::num::<impl u32>::unchecked_shl) { + scope 2 (inlined #[track_caller] core::num::<impl u32>::unchecked_shl) { scope 3 (inlined core::ub_checks::check_language_ub) { scope 4 (inlined core::ub_checks::check_language_ub::runtime) { } diff --git a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir index a9dd8886577..18eeb8e4d3b 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir @@ -7,7 +7,7 @@ fn checked_shl(_1: u32, _2: u32) -> Option<u32> { scope 1 (inlined core::num::<impl u32>::checked_shl) { let mut _3: bool; let mut _4: u32; - scope 2 (inlined core::num::<impl u32>::unchecked_shl) { + scope 2 (inlined #[track_caller] core::num::<impl u32>::unchecked_shl) { scope 3 (inlined core::ub_checks::check_language_ub) { scope 4 (inlined core::ub_checks::check_language_ub::runtime) { } diff --git a/tests/mir-opt/pre-codegen/duplicate_switch_targets.ub_if_b.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/duplicate_switch_targets.ub_if_b.PreCodegen.after.mir index 518fedffc16..8a6732d5f74 100644 --- a/tests/mir-opt/pre-codegen/duplicate_switch_targets.ub_if_b.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/duplicate_switch_targets.ub_if_b.PreCodegen.after.mir @@ -4,7 +4,7 @@ fn ub_if_b(_1: Thing) -> Thing { debug t => _1; let mut _0: Thing; let mut _2: isize; - scope 1 (inlined unreachable_unchecked) { + scope 1 (inlined #[track_caller] unreachable_unchecked) { scope 2 (inlined core::ub_checks::check_language_ub) { scope 3 (inlined core::ub_checks::check_language_ub::runtime) { } diff --git a/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir index 1f9c464d633..154cbd3791c 100644 --- a/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir @@ -29,7 +29,7 @@ fn int_range(_1: usize, _2: usize) -> () { scope 8 (inlined <usize as Step>::forward_unchecked) { debug start => _11; debug n => const 1_usize; - scope 9 (inlined core::num::<impl usize>::unchecked_add) { + scope 9 (inlined #[track_caller] core::num::<impl usize>::unchecked_add) { debug self => _11; debug rhs => const 1_usize; scope 10 (inlined core::ub_checks::check_language_ub) { diff --git a/tests/mir-opt/pre-codegen/ptr_offset.demo_byte_add_fat.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/ptr_offset.demo_byte_add_fat.PreCodegen.after.panic-abort.mir index 5faa1e210cf..a6dad00bbdb 100644 --- a/tests/mir-opt/pre-codegen/ptr_offset.demo_byte_add_fat.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/ptr_offset.demo_byte_add_fat.PreCodegen.after.panic-abort.mir @@ -4,12 +4,12 @@ fn demo_byte_add_fat(_1: *const [u32], _2: usize) -> *const [u32] { debug p => _1; debug n => _2; let mut _0: *const [u32]; - scope 1 (inlined std::ptr::const_ptr::<impl *const [u32]>::byte_add) { + scope 1 (inlined #[track_caller] std::ptr::const_ptr::<impl *const [u32]>::byte_add) { let mut _3: *const u8; let mut _4: *const u8; scope 2 (inlined std::ptr::const_ptr::<impl *const [u32]>::cast::<u8>) { } - scope 3 (inlined std::ptr::const_ptr::<impl *const u8>::add) { + scope 3 (inlined #[track_caller] std::ptr::const_ptr::<impl *const u8>::add) { } scope 4 (inlined std::ptr::const_ptr::<impl *const u8>::with_metadata_of::<[u32]>) { let mut _5: usize; diff --git a/tests/mir-opt/pre-codegen/ptr_offset.demo_byte_add_fat.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/ptr_offset.demo_byte_add_fat.PreCodegen.after.panic-unwind.mir index 5faa1e210cf..a6dad00bbdb 100644 --- a/tests/mir-opt/pre-codegen/ptr_offset.demo_byte_add_fat.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/ptr_offset.demo_byte_add_fat.PreCodegen.after.panic-unwind.mir @@ -4,12 +4,12 @@ fn demo_byte_add_fat(_1: *const [u32], _2: usize) -> *const [u32] { debug p => _1; debug n => _2; let mut _0: *const [u32]; - scope 1 (inlined std::ptr::const_ptr::<impl *const [u32]>::byte_add) { + scope 1 (inlined #[track_caller] std::ptr::const_ptr::<impl *const [u32]>::byte_add) { let mut _3: *const u8; let mut _4: *const u8; scope 2 (inlined std::ptr::const_ptr::<impl *const [u32]>::cast::<u8>) { } - scope 3 (inlined std::ptr::const_ptr::<impl *const u8>::add) { + scope 3 (inlined #[track_caller] std::ptr::const_ptr::<impl *const u8>::add) { } scope 4 (inlined std::ptr::const_ptr::<impl *const u8>::with_metadata_of::<[u32]>) { let mut _5: usize; diff --git a/tests/mir-opt/pre-codegen/ptr_offset.demo_byte_add_thin.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/ptr_offset.demo_byte_add_thin.PreCodegen.after.panic-abort.mir index 9429785045a..cb7f1565746 100644 --- a/tests/mir-opt/pre-codegen/ptr_offset.demo_byte_add_thin.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/ptr_offset.demo_byte_add_thin.PreCodegen.after.panic-abort.mir @@ -4,12 +4,12 @@ fn demo_byte_add_thin(_1: *const u32, _2: usize) -> *const u32 { debug p => _1; debug n => _2; let mut _0: *const u32; - scope 1 (inlined std::ptr::const_ptr::<impl *const u32>::byte_add) { + scope 1 (inlined #[track_caller] std::ptr::const_ptr::<impl *const u32>::byte_add) { let mut _3: *const u8; let mut _4: *const u8; scope 2 (inlined std::ptr::const_ptr::<impl *const u32>::cast::<u8>) { } - scope 3 (inlined std::ptr::const_ptr::<impl *const u8>::add) { + scope 3 (inlined #[track_caller] std::ptr::const_ptr::<impl *const u8>::add) { } scope 4 (inlined std::ptr::const_ptr::<impl *const u8>::with_metadata_of::<u32>) { scope 5 (inlined std::ptr::metadata::<u32>) { diff --git a/tests/mir-opt/pre-codegen/ptr_offset.demo_byte_add_thin.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/ptr_offset.demo_byte_add_thin.PreCodegen.after.panic-unwind.mir index 9429785045a..cb7f1565746 100644 --- a/tests/mir-opt/pre-codegen/ptr_offset.demo_byte_add_thin.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/ptr_offset.demo_byte_add_thin.PreCodegen.after.panic-unwind.mir @@ -4,12 +4,12 @@ fn demo_byte_add_thin(_1: *const u32, _2: usize) -> *const u32 { debug p => _1; debug n => _2; let mut _0: *const u32; - scope 1 (inlined std::ptr::const_ptr::<impl *const u32>::byte_add) { + scope 1 (inlined #[track_caller] std::ptr::const_ptr::<impl *const u32>::byte_add) { let mut _3: *const u8; let mut _4: *const u8; scope 2 (inlined std::ptr::const_ptr::<impl *const u32>::cast::<u8>) { } - scope 3 (inlined std::ptr::const_ptr::<impl *const u8>::add) { + scope 3 (inlined #[track_caller] std::ptr::const_ptr::<impl *const u8>::add) { } scope 4 (inlined std::ptr::const_ptr::<impl *const u8>::with_metadata_of::<u32>) { scope 5 (inlined std::ptr::metadata::<u32>) { diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir index 0aa37203c1b..dfe618612ab 100644 --- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir @@ -24,7 +24,7 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { let mut _8: u32; scope 6 { scope 8 (inlined <u32 as Step>::forward_unchecked) { - scope 9 (inlined core::num::<impl u32>::unchecked_add) { + scope 9 (inlined #[track_caller] core::num::<impl u32>::unchecked_add) { scope 10 (inlined core::ub_checks::check_language_ub) { scope 11 (inlined core::ub_checks::check_language_ub::runtime) { } diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir index 699d8bc8fea..e0fcfcaffc5 100644 --- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir @@ -24,7 +24,7 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { let mut _8: u32; scope 6 { scope 8 (inlined <u32 as Step>::forward_unchecked) { - scope 9 (inlined core::num::<impl u32>::unchecked_add) { + scope 9 (inlined #[track_caller] core::num::<impl u32>::unchecked_add) { scope 10 (inlined core::ub_checks::check_language_ub) { scope 11 (inlined core::ub_checks::check_language_ub::runtime) { } diff --git a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir index f3033d4a2fa..1f82fc59ac2 100644 --- a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir @@ -10,7 +10,7 @@ fn range_iter_next(_1: &mut std::ops::Range<u32>) -> Option<u32> { let mut _6: u32; scope 3 { scope 5 (inlined <u32 as Step>::forward_unchecked) { - scope 6 (inlined core::num::<impl u32>::unchecked_add) { + scope 6 (inlined #[track_caller] core::num::<impl u32>::unchecked_add) { scope 7 (inlined core::ub_checks::check_language_ub) { scope 8 (inlined core::ub_checks::check_language_ub::runtime) { } diff --git a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir index f3033d4a2fa..1f82fc59ac2 100644 --- a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir @@ -10,7 +10,7 @@ fn range_iter_next(_1: &mut std::ops::Range<u32>) -> Option<u32> { let mut _6: u32; scope 3 { scope 5 (inlined <u32 as Step>::forward_unchecked) { - scope 6 (inlined core::num::<impl u32>::unchecked_add) { + scope 6 (inlined #[track_caller] core::num::<impl u32>::unchecked_add) { scope 7 (inlined core::ub_checks::check_language_ub) { scope 8 (inlined core::ub_checks::check_language_ub::runtime) { } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir index ec67193bc79..d1b1e3d7dd7 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir @@ -8,19 +8,11 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { scope 2 (inlined <usize as SliceIndex<[u32]>>::get_mut) { let mut _3: usize; let mut _4: bool; - let mut _5: *mut [u32]; - let mut _7: *mut u32; - let mut _8: &mut u32; - scope 3 (inlined core::slice::index::get_mut_noubcheck::<u32>) { - let _6: *mut u32; - scope 4 { - } - } + let mut _5: &mut u32; } } bb0: { - StorageLive(_8); StorageLive(_4); StorageLive(_3); _3 = PtrMetadata(copy _1); @@ -36,23 +28,15 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { bb2: { StorageDead(_3); - StorageLive(_7); StorageLive(_5); - _5 = &raw mut (*_1); - StorageLive(_6); - _6 = copy _5 as *mut u32 (PtrToPtr); - _7 = Offset(copy _6, copy _2); - StorageDead(_6); + _5 = &mut (*_1)[_2]; + _0 = Option::<&mut u32>::Some(move _5); StorageDead(_5); - _8 = &mut (*_7); - _0 = Option::<&mut u32>::Some(copy _8); - StorageDead(_7); goto -> bb3; } bb3: { StorageDead(_4); - StorageDead(_8); return; } } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir index ec67193bc79..d1b1e3d7dd7 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir @@ -8,19 +8,11 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { scope 2 (inlined <usize as SliceIndex<[u32]>>::get_mut) { let mut _3: usize; let mut _4: bool; - let mut _5: *mut [u32]; - let mut _7: *mut u32; - let mut _8: &mut u32; - scope 3 (inlined core::slice::index::get_mut_noubcheck::<u32>) { - let _6: *mut u32; - scope 4 { - } - } + let mut _5: &mut u32; } } bb0: { - StorageLive(_8); StorageLive(_4); StorageLive(_3); _3 = PtrMetadata(copy _1); @@ -36,23 +28,15 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { bb2: { StorageDead(_3); - StorageLive(_7); StorageLive(_5); - _5 = &raw mut (*_1); - StorageLive(_6); - _6 = copy _5 as *mut u32 (PtrToPtr); - _7 = Offset(copy _6, copy _2); - StorageDead(_6); + _5 = &mut (*_1)[_2]; + _0 = Option::<&mut u32>::Some(move _5); StorageDead(_5); - _8 = &mut (*_7); - _0 = Option::<&mut u32>::Some(copy _8); - StorageDead(_7); goto -> bb3; } bb3: { StorageDead(_4); - StorageDead(_8); return; } } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir index 220e881f866..6fb1637a6e0 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir @@ -6,21 +6,19 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> let mut _0: &mut [u32]; let mut _3: usize; let mut _4: usize; - scope 1 (inlined core::slice::<impl [u32]>::get_unchecked_mut::<std::ops::Range<usize>>) { + scope 1 (inlined #[track_caller] core::slice::<impl [u32]>::get_unchecked_mut::<std::ops::Range<usize>>) { let mut _5: *mut [u32]; let mut _11: *mut [u32]; - scope 2 (inlined <std::ops::Range<usize> as SliceIndex<[u32]>>::get_unchecked_mut) { + scope 2 (inlined #[track_caller] <std::ops::Range<usize> as SliceIndex<[u32]>>::get_unchecked_mut) { let mut _6: usize; let _7: (); let _8: usize; scope 3 { scope 6 (inlined core::slice::index::get_offset_len_mut_noubcheck::<u32>) { - let _10: *mut u32; + let _9: *mut u32; scope 7 { - } - scope 8 (inlined core::slice::index::get_mut_noubcheck::<u32>) { - let _9: *mut u32; - scope 9 { + let _10: *mut u32; + scope 8 { } } } @@ -47,13 +45,13 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> bb1: { StorageDead(_6); _8 = SubUnchecked(copy _4, copy _3); - StorageLive(_10); StorageLive(_9); + StorageLive(_10); _9 = copy _5 as *mut u32 (PtrToPtr); _10 = Offset(copy _9, copy _3); - StorageDead(_9); _11 = *mut [u32] from (copy _10, copy _8); StorageDead(_10); + StorageDead(_9); StorageDead(_8); StorageDead(_5); _0 = &mut (*_11); diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir index 220e881f866..6fb1637a6e0 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir @@ -6,21 +6,19 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> let mut _0: &mut [u32]; let mut _3: usize; let mut _4: usize; - scope 1 (inlined core::slice::<impl [u32]>::get_unchecked_mut::<std::ops::Range<usize>>) { + scope 1 (inlined #[track_caller] core::slice::<impl [u32]>::get_unchecked_mut::<std::ops::Range<usize>>) { let mut _5: *mut [u32]; let mut _11: *mut [u32]; - scope 2 (inlined <std::ops::Range<usize> as SliceIndex<[u32]>>::get_unchecked_mut) { + scope 2 (inlined #[track_caller] <std::ops::Range<usize> as SliceIndex<[u32]>>::get_unchecked_mut) { let mut _6: usize; let _7: (); let _8: usize; scope 3 { scope 6 (inlined core::slice::index::get_offset_len_mut_noubcheck::<u32>) { - let _10: *mut u32; + let _9: *mut u32; scope 7 { - } - scope 8 (inlined core::slice::index::get_mut_noubcheck::<u32>) { - let _9: *mut u32; - scope 9 { + let _10: *mut u32; + scope 8 { } } } @@ -47,13 +45,13 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> bb1: { StorageDead(_6); _8 = SubUnchecked(copy _4, copy _3); - StorageLive(_10); StorageLive(_9); + StorageLive(_10); _9 = copy _5 as *mut u32 (PtrToPtr); _10 = Offset(copy _9, copy _3); - StorageDead(_9); _11 = *mut [u32] from (copy _10, copy _8); StorageDead(_10); + StorageDead(_9); StorageDead(_8); StorageDead(_5); _0 = &mut (*_11); diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-abort.mir index 1e0df94b67f..ad1ca5dff43 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-abort.mir @@ -7,18 +7,16 @@ fn slice_ptr_get_unchecked_range(_1: *const [u32], _2: std::ops::Range<usize>) - let mut _3: usize; let mut _4: usize; scope 1 (inlined std::ptr::const_ptr::<impl *const [u32]>::get_unchecked::<std::ops::Range<usize>>) { - scope 2 (inlined <std::ops::Range<usize> as SliceIndex<[u32]>>::get_unchecked) { + scope 2 (inlined #[track_caller] <std::ops::Range<usize> as SliceIndex<[u32]>>::get_unchecked) { let mut _5: usize; let _6: (); let _7: usize; scope 3 { scope 6 (inlined core::slice::index::get_offset_len_noubcheck::<u32>) { - let _9: *const u32; + let _8: *const u32; scope 7 { - } - scope 8 (inlined core::slice::index::get_noubcheck::<u32>) { - let _8: *const u32; - scope 9 { + let _9: *const u32; + scope 8 { } } } @@ -42,13 +40,13 @@ fn slice_ptr_get_unchecked_range(_1: *const [u32], _2: std::ops::Range<usize>) - bb1: { StorageDead(_5); _7 = SubUnchecked(copy _4, copy _3); - StorageLive(_9); StorageLive(_8); + StorageLive(_9); _8 = copy _1 as *const u32 (PtrToPtr); _9 = Offset(copy _8, copy _3); - StorageDead(_8); _0 = *const [u32] from (copy _9, copy _7); StorageDead(_9); + StorageDead(_8); StorageDead(_7); return; } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-unwind.mir index 1e0df94b67f..ad1ca5dff43 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_ptr_get_unchecked_range.PreCodegen.after.panic-unwind.mir @@ -7,18 +7,16 @@ fn slice_ptr_get_unchecked_range(_1: *const [u32], _2: std::ops::Range<usize>) - let mut _3: usize; let mut _4: usize; scope 1 (inlined std::ptr::const_ptr::<impl *const [u32]>::get_unchecked::<std::ops::Range<usize>>) { - scope 2 (inlined <std::ops::Range<usize> as SliceIndex<[u32]>>::get_unchecked) { + scope 2 (inlined #[track_caller] <std::ops::Range<usize> as SliceIndex<[u32]>>::get_unchecked) { let mut _5: usize; let _6: (); let _7: usize; scope 3 { scope 6 (inlined core::slice::index::get_offset_len_noubcheck::<u32>) { - let _9: *const u32; + let _8: *const u32; scope 7 { - } - scope 8 (inlined core::slice::index::get_noubcheck::<u32>) { - let _8: *const u32; - scope 9 { + let _9: *const u32; + scope 8 { } } } @@ -42,13 +40,13 @@ fn slice_ptr_get_unchecked_range(_1: *const [u32], _2: std::ops::Range<usize>) - bb1: { StorageDead(_5); _7 = SubUnchecked(copy _4, copy _3); - StorageLive(_9); StorageLive(_8); + StorageLive(_9); _8 = copy _1 as *const u32 (PtrToPtr); _9 = Offset(copy _8, copy _3); - StorageDead(_8); _0 = *const [u32] from (copy _9, copy _7); StorageDead(_9); + StorageDead(_8); StorageDead(_7); return; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir index c75edde711e..d389e4069d0 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir @@ -58,7 +58,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { scope 30 { let _23: usize; scope 31 { - scope 34 (inlined core::num::<impl usize>::unchecked_sub) { + scope 34 (inlined #[track_caller] core::num::<impl usize>::unchecked_sub) { scope 35 (inlined core::ub_checks::check_language_ub) { scope 36 (inlined core::ub_checks::check_language_ub::runtime) { } @@ -115,7 +115,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } scope 13 (inlined NonNull::<T>::as_ptr) { } - scope 14 (inlined std::ptr::mut_ptr::<impl *mut T>::add) { + scope 14 (inlined #[track_caller] std::ptr::mut_ptr::<impl *mut T>::add) { } } scope 8 (inlined NonNull::<[T]>::from_ref) { diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir index bc72181b77c..3b58f1d61f4 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir @@ -40,7 +40,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } scope 13 (inlined NonNull::<T>::as_ptr) { } - scope 14 (inlined std::ptr::mut_ptr::<impl *mut T>::add) { + scope 14 (inlined #[track_caller] std::ptr::mut_ptr::<impl *mut T>::add) { } } scope 8 (inlined NonNull::<[T]>::from_ref) { diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir index 38c509d0b53..216e05ec5b7 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir @@ -30,7 +30,7 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 18 { let _22: usize; scope 19 { - scope 22 (inlined core::num::<impl usize>::unchecked_sub) { + scope 22 (inlined #[track_caller] core::num::<impl usize>::unchecked_sub) { scope 23 (inlined core::ub_checks::check_language_ub) { scope 24 (inlined core::ub_checks::check_language_ub::runtime) { } @@ -86,7 +86,7 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } scope 13 (inlined NonNull::<T>::as_ptr) { } - scope 14 (inlined std::ptr::mut_ptr::<impl *mut T>::add) { + scope 14 (inlined #[track_caller] std::ptr::mut_ptr::<impl *mut T>::add) { } } scope 8 (inlined NonNull::<[T]>::from_ref) { diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir index 158cc284b1a..00102391980 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir @@ -30,7 +30,7 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 18 { let _22: usize; scope 19 { - scope 22 (inlined core::num::<impl usize>::unchecked_sub) { + scope 22 (inlined #[track_caller] core::num::<impl usize>::unchecked_sub) { scope 23 (inlined core::ub_checks::check_language_ub) { scope 24 (inlined core::ub_checks::check_language_ub::runtime) { } @@ -86,7 +86,7 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } scope 13 (inlined NonNull::<T>::as_ptr) { } - scope 14 (inlined std::ptr::mut_ptr::<impl *mut T>::add) { + scope 14 (inlined #[track_caller] std::ptr::mut_ptr::<impl *mut T>::add) { } } scope 8 (inlined NonNull::<[T]>::from_ref) { diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir index f8d11df5185..41e273151ec 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir @@ -29,7 +29,7 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let mut _8: usize; scope 7 { scope 9 (inlined <usize as Step>::forward_unchecked) { - scope 10 (inlined core::num::<impl usize>::unchecked_add) { + scope 10 (inlined #[track_caller] core::num::<impl usize>::unchecked_add) { scope 11 (inlined core::ub_checks::check_language_ub) { scope 12 (inlined core::ub_checks::check_language_ub::runtime) { } diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir index 2c249197894..ec781c1480c 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir @@ -29,7 +29,7 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let mut _8: usize; scope 7 { scope 9 (inlined <usize as Step>::forward_unchecked) { - scope 10 (inlined core::num::<impl usize>::unchecked_add) { + scope 10 (inlined #[track_caller] core::num::<impl usize>::unchecked_add) { scope 11 (inlined core::ub_checks::check_language_ub) { scope 12 (inlined core::ub_checks::check_language_ub::runtime) { } diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir index 00366762108..b09e3622344 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir @@ -40,7 +40,7 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } scope 13 (inlined NonNull::<T>::as_ptr) { } - scope 14 (inlined std::ptr::mut_ptr::<impl *mut T>::add) { + scope 14 (inlined #[track_caller] std::ptr::mut_ptr::<impl *mut T>::add) { } } scope 8 (inlined NonNull::<[T]>::from_ref) { diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir index e1d710fb689..12b54b57b84 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir @@ -40,7 +40,7 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } scope 13 (inlined NonNull::<T>::as_ptr) { } - scope 14 (inlined std::ptr::mut_ptr::<impl *mut T>::add) { + scope 14 (inlined #[track_caller] std::ptr::mut_ptr::<impl *mut T>::add) { } } scope 8 (inlined NonNull::<[T]>::from_ref) { diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir index b6df2300efb..c0ed0aea1e2 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir @@ -15,7 +15,7 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { scope 3 { let _11: usize; scope 4 { - scope 7 (inlined core::num::<impl usize>::unchecked_sub) { + scope 7 (inlined #[track_caller] core::num::<impl usize>::unchecked_sub) { scope 8 (inlined core::ub_checks::check_language_ub) { scope 9 (inlined core::ub_checks::check_language_ub::runtime) { } diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir index b6df2300efb..c0ed0aea1e2 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir @@ -15,7 +15,7 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { scope 3 { let _11: usize; scope 4 { - scope 7 (inlined core::num::<impl usize>::unchecked_sub) { + scope 7 (inlined #[track_caller] core::num::<impl usize>::unchecked_sub) { scope 8 (inlined core::ub_checks::check_language_ub) { scope 9 (inlined core::ub_checks::check_language_ub::runtime) { } diff --git a/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-abort.mir index 927deabd253..30eafe8594b 100644 --- a/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-abort.mir @@ -29,7 +29,7 @@ fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] { } } } - scope 12 (inlined std::slice::from_raw_parts::<'_, u8>) { + scope 12 (inlined #[track_caller] std::slice::from_raw_parts::<'_, u8>) { debug data => _3; debug len => _4; let _5: *const [u8]; diff --git a/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-unwind.mir index 927deabd253..30eafe8594b 100644 --- a/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-unwind.mir @@ -29,7 +29,7 @@ fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] { } } } - scope 12 (inlined std::slice::from_raw_parts::<'_, u8>) { + scope 12 (inlined #[track_caller] std::slice::from_raw_parts::<'_, u8>) { debug data => _3; debug len => _4; let _5: *const [u8]; diff --git a/tests/pretty/autodiff/autodiff_forward.pp b/tests/pretty/autodiff/autodiff_forward.pp index 8253603e807..a2525abc832 100644 --- a/tests/pretty/autodiff/autodiff_forward.pp +++ b/tests/pretty/autodiff/autodiff_forward.pp @@ -13,7 +13,7 @@ extern crate std; // Test that forward mode ad macros are expanded correctly. -use std::autodiff::autodiff; +use std::autodiff::{autodiff_forward, autodiff_reverse}; #[rustc_autodiff] #[inline(never)] diff --git a/tests/pretty/autodiff/autodiff_forward.rs b/tests/pretty/autodiff/autodiff_forward.rs index ae974f9b4db..e23a1b3e241 100644 --- a/tests/pretty/autodiff/autodiff_forward.rs +++ b/tests/pretty/autodiff/autodiff_forward.rs @@ -7,48 +7,48 @@ // Test that forward mode ad macros are expanded correctly. -use std::autodiff::autodiff; +use std::autodiff::{autodiff_forward, autodiff_reverse}; -#[autodiff(df1, Forward, Dual, Const, Dual)] +#[autodiff_forward(df1, Dual, Const, Dual)] pub fn f1(x: &[f64], y: f64) -> f64 { unimplemented!() } -#[autodiff(df2, Forward, Dual, Const, Const)] +#[autodiff_forward(df2, Dual, Const, Const)] pub fn f2(x: &[f64], y: f64) -> f64 { unimplemented!() } -#[autodiff(df3, Forward, Dual, Const, Const)] +#[autodiff_forward(df3, Dual, Const, Const)] pub fn f3(x: &[f64], y: f64) -> f64 { unimplemented!() } // Not the most interesting derivative, but who are we to judge -#[autodiff(df4, Forward)] +#[autodiff_forward(df4)] pub fn f4() {} // We want to be sure that the same function can be differentiated in different ways -#[autodiff(df5_rev, Reverse, Duplicated, Const, Active)] -#[autodiff(df5_x, Forward, Dual, Const, Const)] -#[autodiff(df5_y, Forward, Const, Dual, Const)] +#[autodiff_reverse(df5_rev, Duplicated, Const, Active)] +#[autodiff_forward(df5_x, Dual, Const, Const)] +#[autodiff_forward(df5_y, Const, Dual, Const)] pub fn f5(x: &[f64], y: f64) -> f64 { unimplemented!() } struct DoesNotImplDefault; -#[autodiff(df6, Forward, Const)] +#[autodiff_forward(df6, Const)] pub fn f6() -> DoesNotImplDefault { unimplemented!() } // Make sure, that we add the None for the default return. -#[autodiff(df7, Forward, Const)] +#[autodiff_forward(df7, Const)] pub fn f7(x: f32) -> () {} -#[autodiff(f8_1, Forward, Dual, DualOnly)] -#[autodiff(f8_2, Forward, 4, Dual, DualOnly)] -#[autodiff(f8_3, Forward, 4, Dual, Dual)] +#[autodiff_forward(f8_1, Dual, DualOnly)] +#[autodiff_forward(f8_2, 4, Dual, DualOnly)] +#[autodiff_forward(f8_3, 4, Dual, Dual)] #[no_mangle] fn f8(x: &f32) -> f32 { unimplemented!() @@ -56,15 +56,15 @@ fn f8(x: &f32) -> f32 { // We want to make sure that we can use the macro for functions defined inside of functions pub fn f9() { - #[autodiff(d_inner_1, Forward, Dual, DualOnly)] - #[autodiff(d_inner_2, Forward, Dual, Dual)] + #[autodiff_forward(d_inner_1, Dual, DualOnly)] + #[autodiff_forward(d_inner_2, Dual, Dual)] fn inner(x: f32) -> f32 { x * x } } // Make sure we can handle generics -#[autodiff(d_square, Reverse, Duplicated, Active)] +#[autodiff_reverse(d_square, Duplicated, Active)] pub fn f10<T: std::ops::Mul<Output = T> + Copy>(x: &T) -> T { *x * *x } diff --git a/tests/pretty/autodiff/autodiff_reverse.pp b/tests/pretty/autodiff/autodiff_reverse.pp index 31920694a3a..e67c3443dde 100644 --- a/tests/pretty/autodiff/autodiff_reverse.pp +++ b/tests/pretty/autodiff/autodiff_reverse.pp @@ -13,7 +13,7 @@ extern crate std; // Test that reverse mode ad macros are expanded correctly. -use std::autodiff::autodiff; +use std::autodiff::autodiff_reverse; #[rustc_autodiff] #[inline(never)] diff --git a/tests/pretty/autodiff/autodiff_reverse.rs b/tests/pretty/autodiff/autodiff_reverse.rs index 3c024272f40..d37e5e3eb4c 100644 --- a/tests/pretty/autodiff/autodiff_reverse.rs +++ b/tests/pretty/autodiff/autodiff_reverse.rs @@ -7,18 +7,18 @@ // Test that reverse mode ad macros are expanded correctly. -use std::autodiff::autodiff; +use std::autodiff::autodiff_reverse; -#[autodiff(df1, Reverse, Duplicated, Const, Active)] +#[autodiff_reverse(df1, Duplicated, Const, Active)] pub fn f1(x: &[f64], y: f64) -> f64 { unimplemented!() } // Not the most interesting derivative, but who are we to judge -#[autodiff(df2, Reverse)] +#[autodiff_reverse(df2)] pub fn f2() {} -#[autodiff(df3, Reverse, Duplicated, Const, Active)] +#[autodiff_reverse(df3, Duplicated, Const, Active)] pub fn f3(x: &[f64], y: f64) -> f64 { unimplemented!() } @@ -27,12 +27,12 @@ enum Foo { Reverse } use Foo::Reverse; // What happens if we already have Reverse in type (enum variant decl) and value (enum variant // constructor) namespace? > It's expected to work normally. -#[autodiff(df4, Reverse, Const)] +#[autodiff_reverse(df4, Const)] pub fn f4(x: f32) { unimplemented!() } -#[autodiff(df5, Reverse, DuplicatedOnly, Duplicated)] +#[autodiff_reverse(df5, DuplicatedOnly, Duplicated)] pub fn f5(x: *const f32, y: &f32) { unimplemented!() } diff --git a/tests/pretty/autodiff/inherent_impl.pp b/tests/pretty/autodiff/inherent_impl.pp index 97ac766b6b9..d18061b2dbd 100644 --- a/tests/pretty/autodiff/inherent_impl.pp +++ b/tests/pretty/autodiff/inherent_impl.pp @@ -11,7 +11,7 @@ extern crate std; //@ pretty-compare-only //@ pp-exact:inherent_impl.pp -use std::autodiff::autodiff; +use std::autodiff::autodiff_reverse; struct Foo { a: f64, diff --git a/tests/pretty/autodiff/inherent_impl.rs b/tests/pretty/autodiff/inherent_impl.rs index 59de93f7e0f..11ff209f9d8 100644 --- a/tests/pretty/autodiff/inherent_impl.rs +++ b/tests/pretty/autodiff/inherent_impl.rs @@ -5,7 +5,7 @@ //@ pretty-compare-only //@ pp-exact:inherent_impl.pp -use std::autodiff::autodiff; +use std::autodiff::autodiff_reverse; struct Foo { a: f64, @@ -17,7 +17,7 @@ trait MyTrait { } impl MyTrait for Foo { - #[autodiff(df, Reverse, Const, Active, Active)] + #[autodiff_reverse(df, Const, Active, Active)] fn f(&self, x: f64) -> f64 { self.a * 0.25 * (x * x - 1.0 - 2.0 * x.ln()) } diff --git a/tests/run-make/atomic-lock-free/atomic_lock_free.rs b/tests/run-make/atomic-lock-free/atomic_lock_free.rs index b49c5044f31..e8bbd420cc4 100644 --- a/tests/run-make/atomic-lock-free/atomic_lock_free.rs +++ b/tests/run-make/atomic-lock-free/atomic_lock_free.rs @@ -1,9 +1,20 @@ #![feature(no_core, intrinsics, lang_items)] +#![feature(adt_const_params)] #![crate_type = "rlib"] #![no_core] +pub enum AtomicOrdering { + // These values must match the compiler's `AtomicOrdering` defined in + // `rustc_middle/src/ty/consts/int.rs`! + Relaxed = 0, + Release = 1, + Acquire = 2, + AcqRel = 3, + SeqCst = 4, +} + #[rustc_intrinsic] -unsafe fn atomic_xadd_seqcst<T>(dst: *mut T, src: T) -> T; +unsafe fn atomic_xadd<T, const ORD: AtomicOrdering>(dst: *mut T, src: T) -> T; #[lang = "sized"] trait Sized {} @@ -11,55 +22,58 @@ trait Sized {} trait Copy {} #[lang = "freeze"] trait Freeze {} +#[lang = "const_param_ty"] +pub trait ConstParamTy {} impl<T: ?Sized> Copy for *mut T {} +impl ConstParamTy for AtomicOrdering {} #[cfg(target_has_atomic = "8")] pub unsafe fn atomic_u8(x: *mut u8) { - atomic_xadd_seqcst(x, 1); - atomic_xadd_seqcst(x, 1); + atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1); + atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1); } #[cfg(target_has_atomic = "8")] pub unsafe fn atomic_i8(x: *mut i8) { - atomic_xadd_seqcst(x, 1); + atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1); } #[cfg(target_has_atomic = "16")] pub unsafe fn atomic_u16(x: *mut u16) { - atomic_xadd_seqcst(x, 1); + atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1); } #[cfg(target_has_atomic = "16")] pub unsafe fn atomic_i16(x: *mut i16) { - atomic_xadd_seqcst(x, 1); + atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1); } #[cfg(target_has_atomic = "32")] pub unsafe fn atomic_u32(x: *mut u32) { - atomic_xadd_seqcst(x, 1); + atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1); } #[cfg(target_has_atomic = "32")] pub unsafe fn atomic_i32(x: *mut i32) { - atomic_xadd_seqcst(x, 1); + atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1); } #[cfg(target_has_atomic = "64")] pub unsafe fn atomic_u64(x: *mut u64) { - atomic_xadd_seqcst(x, 1); + atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1); } #[cfg(target_has_atomic = "64")] pub unsafe fn atomic_i64(x: *mut i64) { - atomic_xadd_seqcst(x, 1); + atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1); } #[cfg(target_has_atomic = "128")] pub unsafe fn atomic_u128(x: *mut u128) { - atomic_xadd_seqcst(x, 1); + atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1); } #[cfg(target_has_atomic = "128")] pub unsafe fn atomic_i128(x: *mut i128) { - atomic_xadd_seqcst(x, 1); + atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1); } #[cfg(target_has_atomic = "ptr")] pub unsafe fn atomic_usize(x: *mut usize) { - atomic_xadd_seqcst(x, 1); + atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1); } #[cfg(target_has_atomic = "ptr")] pub unsafe fn atomic_isize(x: *mut isize) { - atomic_xadd_seqcst(x, 1); + atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1); } diff --git a/tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs b/tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs index bcaef33344e..36c9db106ec 100644 --- a/tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs +++ b/tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs @@ -30,9 +30,9 @@ pub unsafe extern "C" fn check_list_0(mut ap: VaList) -> usize { #[no_mangle] pub unsafe extern "C" fn check_list_1(mut ap: VaList) -> usize { continue_if!(ap.arg::<c_int>() == -1); - continue_if!(ap.arg::<c_char>() == 'A' as c_char); - continue_if!(ap.arg::<c_char>() == '4' as c_char); - continue_if!(ap.arg::<c_char>() == ';' as c_char); + continue_if!(ap.arg::<c_int>() == 'A' as c_int); + continue_if!(ap.arg::<c_int>() == '4' as c_int); + continue_if!(ap.arg::<c_int>() == ';' as c_int); continue_if!(ap.arg::<c_int>() == 0x32); continue_if!(ap.arg::<c_int>() == 0x10000001); continue_if!(compare_c_str(ap.arg::<*const c_char>(), "Valid!")); @@ -43,7 +43,7 @@ pub unsafe extern "C" fn check_list_1(mut ap: VaList) -> usize { pub unsafe extern "C" fn check_list_2(mut ap: VaList) -> usize { continue_if!(ap.arg::<c_double>().floor() == 3.14f64.floor()); continue_if!(ap.arg::<c_long>() == 12); - continue_if!(ap.arg::<c_char>() == 'a' as c_char); + continue_if!(ap.arg::<c_int>() == 'a' as c_int); continue_if!(ap.arg::<c_double>().floor() == 6.18f64.floor()); continue_if!(compare_c_str(ap.arg::<*const c_char>(), "Hello")); continue_if!(ap.arg::<c_int>() == 42); @@ -55,7 +55,7 @@ pub unsafe extern "C" fn check_list_2(mut ap: VaList) -> usize { pub unsafe extern "C" fn check_list_copy_0(mut ap: VaList) -> usize { continue_if!(ap.arg::<c_double>().floor() == 6.28f64.floor()); continue_if!(ap.arg::<c_int>() == 16); - continue_if!(ap.arg::<c_char>() == 'A' as c_char); + continue_if!(ap.arg::<c_int>() == 'A' as c_int); continue_if!(compare_c_str(ap.arg::<*const c_char>(), "Skip Me!")); ap.with_copy( |mut ap| { @@ -75,7 +75,7 @@ pub unsafe extern "C" fn check_varargs_0(_: c_int, mut ap: ...) -> usize { pub unsafe extern "C" fn check_varargs_1(_: c_int, mut ap: ...) -> usize { continue_if!(ap.arg::<c_double>().floor() == 3.14f64.floor()); continue_if!(ap.arg::<c_long>() == 12); - continue_if!(ap.arg::<c_char>() == 'A' as c_char); + continue_if!(ap.arg::<c_int>() == 'A' as c_int); continue_if!(ap.arg::<c_longlong>() == 1); 0 } @@ -112,6 +112,9 @@ pub unsafe extern "C" fn check_varargs_4(_: c_double, mut ap: ...) -> usize { continue_if!(ap.arg::<c_double>() == 8.0); continue_if!(ap.arg::<c_double>() == 9.0); continue_if!(ap.arg::<c_double>() == 10.0); + continue_if!(ap.arg::<c_double>() == 11.0); + continue_if!(ap.arg::<c_double>() == 12.0); + continue_if!(ap.arg::<c_double>() == 13.0); 0 } @@ -137,5 +140,11 @@ pub unsafe extern "C" fn check_varargs_5(_: c_int, mut ap: ...) -> usize { continue_if!(ap.arg::<c_double>() == 9.0); continue_if!(ap.arg::<c_int>() == 10); continue_if!(ap.arg::<c_double>() == 10.0); + continue_if!(ap.arg::<c_int>() == 11); + continue_if!(ap.arg::<c_double>() == 11.0); + continue_if!(ap.arg::<c_int>() == 12); + continue_if!(ap.arg::<c_double>() == 12.0); + continue_if!(ap.arg::<c_int>() == 13); + continue_if!(ap.arg::<c_double>() == 13.0); 0 } diff --git a/tests/run-make/c-link-to-rust-va-list-fn/test.c b/tests/run-make/c-link-to-rust-va-list-fn/test.c index 5bdb51680a6..b47a9357880 100644 --- a/tests/run-make/c-link-to-rust-va-list-fn/test.c +++ b/tests/run-make/c-link-to-rust-va-list-fn/test.c @@ -41,10 +41,11 @@ int main(int argc, char* argv[]) { assert(check_varargs_3(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10) == 0); - assert(check_varargs_4(0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0) == 0); + assert(check_varargs_4(0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, + 13.0) == 0); assert(check_varargs_5(0, 1.0, 1, 2.0, 2, 3.0, 3, 4.0, 4, 5, 5.0, 6, 6.0, 7, 7.0, 8, 8.0, - 9, 9.0, 10, 10.0) == 0); + 9, 9.0, 10, 10.0, 11, 11.0, 12, 12.0, 13, 13.0) == 0); return 0; } diff --git a/tests/run-make/crate-loading/multiple-dep-versions.stderr b/tests/run-make/crate-loading/multiple-dep-versions.stderr index 6e1d6111b58..dea08bb96c9 100644 --- a/tests/run-make/crate-loading/multiple-dep-versions.stderr +++ b/tests/run-make/crate-loading/multiple-dep-versions.stderr @@ -39,7 +39,7 @@ error[E0599]: no method named `foo` found for struct `dep_2_reexport::Type` in t --> replaced | LL | Type.foo(); - | ^^^ method not found in `Type` + | ^^^ method not found in `dep_2_reexport::Type` | note: there are multiple different versions of crate `dependency` in the dependency graph --> replaced @@ -63,7 +63,7 @@ error[E0599]: no function or associated item named `bar` found for struct `dep_2 --> replaced | LL | Type::bar(); - | ^^^ function or associated item not found in `Type` + | ^^^ function or associated item not found in `dep_2_reexport::Type` | note: there are multiple different versions of crate `dependency` in the dependency graph --> replaced diff --git a/tests/run-make/doctests-keep-binaries-2024/rmake.rs b/tests/run-make/doctests-keep-binaries-2024/rmake.rs index 3e8ffcbf244..97324e1dcbc 100644 --- a/tests/run-make/doctests-keep-binaries-2024/rmake.rs +++ b/tests/run-make/doctests-keep-binaries-2024/rmake.rs @@ -16,7 +16,22 @@ fn setup_test_env<F: FnOnce(&Path, &Path)>(callback: F) { } fn check_generated_binaries() { - run("doctests/merged_doctest_2024/rust_out"); + let mut found_merged_doctest = false; + rfs::read_dir_entries("doctests/", |path| { + if path + .file_name() + .and_then(|name| name.to_str()) + .is_some_and(|name| name.starts_with("merged_doctest_2024")) + { + found_merged_doctest = true; + let rust_out = path.join("rust_out"); + let rust_out = rust_out.to_string_lossy(); + run(&*rust_out); + } + }); + if !found_merged_doctest { + panic!("no directory starting with `merged_doctest_2024` found under `doctests/`"); + } } fn main() { diff --git a/tests/run-make/mte-ffi/bar.h b/tests/run-make/mte-ffi/bar.h index a2292ae02a3..9b030c618d1 100644 --- a/tests/run-make/mte-ffi/bar.h +++ b/tests/run-make/mte-ffi/bar.h @@ -1,3 +1,5 @@ +// FIXME(#141600) the mte-ffi test doesn't fail in aarch64-gnu + #ifndef __BAR_H #define __BAR_H diff --git a/tests/run-make/mte-ffi/bar_float.c b/tests/run-make/mte-ffi/bar_float.c index a1590f62765..acc2f5d9266 100644 --- a/tests/run-make/mte-ffi/bar_float.c +++ b/tests/run-make/mte-ffi/bar_float.c @@ -3,9 +3,9 @@ #include <stdint.h> #include "bar.h" -extern void foo(char*); +extern void foo(float*); -void bar(char *ptr) { +void bar(float *ptr) { if (((uintptr_t)ptr >> 56) != 0x1f) { fprintf(stderr, "Top byte corrupted on Rust -> C FFI boundary!\n"); exit(1); diff --git a/tests/run-make/mte-ffi/bar_int.c b/tests/run-make/mte-ffi/bar_int.c index d1c79e95dc9..c92e765302c 100644 --- a/tests/run-make/mte-ffi/bar_int.c +++ b/tests/run-make/mte-ffi/bar_int.c @@ -5,7 +5,7 @@ extern void foo(unsigned int *); -void bar(char *ptr) { +void bar(unsigned int *ptr) { if (((uintptr_t)ptr >> 56) != 0x1f) { fprintf(stderr, "Top byte corrupted on Rust -> C FFI boundary!\n"); exit(1); diff --git a/tests/run-make/mte-ffi/bar_string.c b/tests/run-make/mte-ffi/bar_string.c index 5669ffd6695..8e1202f6fd1 100644 --- a/tests/run-make/mte-ffi/bar_string.c +++ b/tests/run-make/mte-ffi/bar_string.c @@ -1,6 +1,7 @@ #include <stdio.h> #include <stdlib.h> #include <stdint.h> +#include <string.h> #include "bar.h" extern void foo(char*); @@ -32,7 +33,7 @@ int main(void) // Store an arbitrary tag in bits 56-59 of the pointer (where an MTE tag may be), // and a different value in the ignored top 4 bits. - ptr = (unsigned int *)((uintptr_t)ptr | 0x1fl << 56); + ptr = (char *)((uintptr_t)ptr | 0x1fl << 56); if (mte_enabled()) { set_tag(ptr); diff --git a/tests/run-make/repr128-dwarf/main.rs b/tests/run-make/repr128-dwarf/main.rs index 9842ab4a342..a8a414fd72e 100644 --- a/tests/run-make/repr128-dwarf/main.rs +++ b/tests/run-make/repr128-dwarf/main.rs @@ -1,5 +1,3 @@ -#![feature(repr128)] - // Use .to_le() to ensure that the bytes are in the same order on both little- and big-endian // platforms. diff --git a/tests/run-make/version-check/rmake.rs b/tests/run-make/version-check/rmake.rs new file mode 100644 index 00000000000..e6a14d2e95c --- /dev/null +++ b/tests/run-make/version-check/rmake.rs @@ -0,0 +1,13 @@ +use run_make_support::bare_rustc; + +fn main() { + let signalled_version = "Ceci n'est pas une rustc"; + let rustc_out = bare_rustc() + .env("RUSTC_OVERRIDE_VERSION_STRING", signalled_version) + .arg("--version") + .run() + .stdout_utf8(); + + let version = rustc_out.strip_prefix("rustc ").unwrap().trim_end(); + assert_eq!(version, signalled_version); +} diff --git a/tests/rustdoc-gui/collapse-trait-impl.goml b/tests/rustdoc-gui/collapse-trait-impl.goml new file mode 100644 index 00000000000..4db02e5239b --- /dev/null +++ b/tests/rustdoc-gui/collapse-trait-impl.goml @@ -0,0 +1,26 @@ +// Checks that individual trait impls can only be collapsed via clicking directly on the summary element + +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" +assert-attribute: ("details:has(#trait-impl-link-in-summary)", {"open": ""}) + +// Collapse the trait impl doc. The actual clickable area is outside the element, hence offset. +click-with-offset: ("summary:has(#trait-impl-link-in-summary)", {"x": -15, "y": 5}) +assert-attribute-false: ("details:has(#trait-impl-link-in-summary)", {"open": ""}) +click-with-offset: ("summary:has(#trait-impl-link-in-summary)", {"x": -15, "y": 5}) +assert-attribute: ("details:has(#trait-impl-link-in-summary)", {"open": ""}) + +// Clicks on the text should be ignored +click: "summary:has(#trait-impl-link-in-summary) > .impl" +assert-attribute: ("details:has(#trait-impl-link-in-summary)", {"open": ""}) + +// But links should still work +click: "summary:has(#trait-impl-link-in-summary) a:has(#trait-impl-link-in-summary)" +assert-window-property-false: ({"pageYOffset": "0"}) +assert-attribute: ("details:has(#trait-impl-link-in-summary)", {"open": ""}) + +// As well as clicks on elements within links +go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" +assert-window-property: ({"pageYOffset": "0"}) +click: "#trait-impl-link-in-summary" +assert-window-property-false: ({"pageYOffset": "0"}) +assert-attribute: ("details:has(#trait-impl-link-in-summary)", {"open": ""}) diff --git a/tests/rustdoc-gui/notable-trait.goml b/tests/rustdoc-gui/notable-trait.goml index 4624fb80b37..7fc70e0675d 100644 --- a/tests/rustdoc-gui/notable-trait.goml +++ b/tests/rustdoc-gui/notable-trait.goml @@ -244,10 +244,6 @@ click: ".sidebar-menu-toggle" assert: "//*[@class='sidebar shown']" assert-count: ("//*[@class='tooltip popover']", 0) assert-false: "#method\.create_an_iterator_from_read .tooltip:focus" -// Clicking a notable trait tooltip popover should close the sidebar. -click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']" -assert-count: ("//*[@class='tooltip popover']", 1) -assert-false: "//*[@class='sidebar shown']" // Also check the focus handling for the settings button. set-window-size: (1100, 600) diff --git a/tests/rustdoc-gui/pocket-menu.goml b/tests/rustdoc-gui/pocket-menu.goml index 4a062fec751..073172dd8a7 100644 --- a/tests/rustdoc-gui/pocket-menu.goml +++ b/tests/rustdoc-gui/pocket-menu.goml @@ -68,16 +68,3 @@ assert-css: ("#settings-menu .popover", {"display": "block"}) click: ".sidebar-menu-toggle" assert: "//*[@class='sidebar shown']" assert-css: ("#settings-menu .popover", {"display": "none"}) -// Opening the settings popover should close the sidebar. -click: "#settings-menu a" -assert-css: ("#settings-menu .popover", {"display": "block"}) -assert-false: "//*[@class='sidebar shown']" - -// Opening the settings popover at start (which async loads stuff) should also close. -reload: -click: ".sidebar-menu-toggle" -assert: "//*[@class='sidebar shown']" -assert-false: "#settings-menu .popover" -click: "#settings-menu a" -assert-false: "//*[@class='sidebar shown']" -wait-for: "#settings-menu .popover" diff --git a/tests/rustdoc-gui/sidebar-mobile.goml b/tests/rustdoc-gui/sidebar-mobile.goml index 4ada4837a57..6ddc07c6481 100644 --- a/tests/rustdoc-gui/sidebar-mobile.goml +++ b/tests/rustdoc-gui/sidebar-mobile.goml @@ -32,8 +32,8 @@ assert-css: ( {"display": "block"} ) -// Click elsewhere. -click: "body" +// Click the toggle to close it +click: ".sidebar-menu-toggle" assert-css: (".sidebar", {"display": "block", "left": "-1000px"}) // Open the sidebar menu, and make sure pressing Escape closes it. @@ -57,6 +57,8 @@ scroll-to: ".block.keyword li:nth-child(1)" compare-elements-position-near: (".block.keyword li:nth-child(1)", ".mobile-topbar", {"y": 544}) // Now checking the background color of the sidebar. +// Close the sidebar menu. +press-key: "Escape" show-text: true define-function: ( @@ -72,6 +74,10 @@ define-function: ( "background-color": |background|, "color": |color|, }) + // Make sure the sidebar is full width + compare-elements-size: (".sidebar", "body", ["width"]) + // Close the sidebar menu. + press-key: "Escape" }, ) diff --git a/tests/rustdoc-gui/src/test_docs/lib.rs b/tests/rustdoc-gui/src/test_docs/lib.rs index bb0015b8f9c..e8afe8b5687 100644 --- a/tests/rustdoc-gui/src/test_docs/lib.rs +++ b/tests/rustdoc-gui/src/test_docs/lib.rs @@ -79,6 +79,7 @@ impl Foo { pub fn warning2() {} } +/// <a href="#implementations"><code id="trait-impl-link-in-summary">A collapsible trait impl with a link</code></a> impl AsRef<str> for Foo { fn as_ref(&self) -> &str { "hello" diff --git a/tests/rustdoc-js/auxiliary/interner.rs b/tests/rustdoc-js/auxiliary/interner.rs index e4e4ff6276d..8af3b732ef7 100644 --- a/tests/rustdoc-js/auxiliary/interner.rs +++ b/tests/rustdoc-js/auxiliary/interner.rs @@ -18,7 +18,7 @@ pub trait Interner: Sized { type Binder<T: TypeVisitable<Self>>: BoundVars<Self> + TypeSuperVisitable<Self>; type BoundVars: IntoIterator<Item = Self::BoundVar>; type BoundVar; - type CanonicalVars: Copy + Debug + Hash + Eq + IntoIterator<Item = CanonicalVarInfo<Self>>; + type CanonicalVarKinds: Copy + Debug + Hash + Eq + IntoIterator<Item = CanonicalVarKind<Self>>; type Ty: Copy + DebugWithInfcx<Self> + Hash @@ -77,7 +77,7 @@ pub trait Interner: Sized { type ClosureKind: Copy + Debug + Hash + Eq; // Required method - fn mk_canonical_var_infos(self, infos: &[CanonicalVarInfo<Self>]) -> Self::CanonicalVars; + fn mk_canonical_var_kinds(self, kinds: &[CanonicalVarKind<Self>]) -> Self::CanonicalVarKinds; } pub trait DebugWithInfcx<I: Interner>: Debug { @@ -104,10 +104,6 @@ pub trait TypeSuperVisitable<I: Interner>: TypeVisitable<I> { fn super_visit_with<V: TypeVisitor<I>>(&self, visitor: &mut V) -> V::Result; } -pub struct CanonicalVarInfo<I: Interner> { - pub kind: CanonicalVarKind<I>, -} - pub struct CanonicalVarKind<I>(std::marker::PhantomData<I>); pub struct TyKind<I>(std::marker::PhantomData<I>); diff --git a/tests/rustdoc-js/looks-like-rustc-interner.js b/tests/rustdoc-js/looks-like-rustc-interner.js index d6d2764c3ae..7d051194454 100644 --- a/tests/rustdoc-js/looks-like-rustc-interner.js +++ b/tests/rustdoc-js/looks-like-rustc-interner.js @@ -3,13 +3,13 @@ const EXPECTED = [ { - 'query': 'canonicalvarinfo, intoiterator -> intoiterator', + 'query': 'CanonicalVarKind, intoiterator -> intoiterator', 'others': [], }, { - 'query': '[canonicalvarinfo], interner<tys=intoiterator> -> intoiterator', + 'query': '[CanonicalVarKind], interner<tys=intoiterator> -> intoiterator', 'others': [ - { 'path': 'looks_like_rustc_interner::Interner', 'name': 'mk_canonical_var_infos' }, + { 'path': 'looks_like_rustc_interner::Interner', 'name': 'mk_canonical_var_kinds' }, ], }, ]; diff --git a/tests/rustdoc-json/attrs/inline.rs b/tests/rustdoc-json/attrs/inline.rs new file mode 100644 index 00000000000..74f5f36f03f --- /dev/null +++ b/tests/rustdoc-json/attrs/inline.rs @@ -0,0 +1,11 @@ +//@ is "$.index[?(@.name=='just_inline')].attrs" '["#[inline]"]' +#[inline] +pub fn just_inline() {} + +//@ is "$.index[?(@.name=='inline_always')].attrs" '["#[inline(always)]"]' +#[inline(always)] +pub fn inline_always() {} + +//@ is "$.index[?(@.name=='inline_never')].attrs" '["#[inline(never)]"]' +#[inline(never)] +pub fn inline_never() {} diff --git a/tests/rustdoc-json/attrs/repr_combination.rs b/tests/rustdoc-json/attrs/repr_combination.rs index 0e8e2ef0d83..6fe29c5eac0 100644 --- a/tests/rustdoc-json/attrs/repr_combination.rs +++ b/tests/rustdoc-json/attrs/repr_combination.rs @@ -77,3 +77,7 @@ pub enum AlignedExplicitRepr { pub enum ReorderedAlignedExplicitRepr { First, } + +//@ is "$.index[?(@.name=='Transparent')].attrs" '["#[repr(transparent)]"]' +#[repr(transparent)] +pub struct Transparent(i64); diff --git a/tests/rustdoc-json/attrs/repr_transparent.rs b/tests/rustdoc-json/attrs/repr_transparent.rs deleted file mode 100644 index 1e634ca901d..00000000000 --- a/tests/rustdoc-json/attrs/repr_transparent.rs +++ /dev/null @@ -1,37 +0,0 @@ -#![no_std] - -// Rustdoc JSON *only* includes `#[repr(transparent)]` -// if the transparency is public API: -// - if a non-1-ZST field exists, it has to be public -// - otherwise, all fields are 1-ZST and at least one of them is public -// -// More info: https://doc.rust-lang.org/nomicon/other-reprs.html#reprtransparent - -// Here, the non-1-ZST field is public. -// We expect `#[repr(transparent)]` in the attributes. -// -//@ is "$.index[?(@.name=='Transparent')].attrs" '["#[repr(transparent)]"]' -#[repr(transparent)] -pub struct Transparent(pub i64); - -// Here the non-1-ZST field isn't public, so the attribute isn't included. -// -//@ has "$.index[?(@.name=='TransparentNonPub')]" -//@ is "$.index[?(@.name=='TransparentNonPub')].attrs" '[]' -#[repr(transparent)] -pub struct TransparentNonPub(i64); - -// Only 1-ZST fields here, and one of them is public. -// We expect `#[repr(transparent)]` in the attributes. -// -//@ is "$.index[?(@.name=='AllZst')].attrs" '["#[repr(transparent)]"]' -#[repr(transparent)] -pub struct AllZst<'a>(pub core::marker::PhantomData<&'a ()>, ()); - -// Only 1-ZST fields here but none of them are public. -// The attribute isn't included. -// -//@ has "$.index[?(@.name=='AllZstNotPublic')]" -//@ is "$.index[?(@.name=='AllZstNotPublic')].attrs" '[]' -#[repr(transparent)] -pub struct AllZstNotPublic<'a>(core::marker::PhantomData<&'a ()>, ()); diff --git a/tests/rustdoc-json/enums/discriminant/limits.rs b/tests/rustdoc-json/enums/discriminant/limits.rs index c84181334e3..e98271b7c80 100644 --- a/tests/rustdoc-json/enums/discriminant/limits.rs +++ b/tests/rustdoc-json/enums/discriminant/limits.rs @@ -1,6 +1,3 @@ -#![feature(repr128)] -#![allow(incomplete_features)] - #[repr(u64)] pub enum U64 { //@ is "$.index[?(@.name=='U64Min')].inner.variant.discriminant.value" '"0"' diff --git a/tests/rustdoc-ui/const-evalutation-ice.rs b/tests/rustdoc-ui/const-evalutation-ice.rs index 0dd3bcaa289..72bcbeb4c51 100644 --- a/tests/rustdoc-ui/const-evalutation-ice.rs +++ b/tests/rustdoc-ui/const-evalutation-ice.rs @@ -4,8 +4,8 @@ use std::cell::Cell; use std::mem; pub struct S { - s: Cell<usize> + s: Cell<usize>, } pub const N: usize = 0 - (mem::size_of::<S>() != 400) as usize; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflow diff --git a/tests/rustdoc-ui/const-evalutation-ice.stderr b/tests/rustdoc-ui/const-evalutation-ice.stderr index e1cb3323856..51958319f5f 100644 --- a/tests/rustdoc-ui/const-evalutation-ice.stderr +++ b/tests/rustdoc-ui/const-evalutation-ice.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow --> $DIR/const-evalutation-ice.rs:10:22 | LL | pub const N: usize = 0 - (mem::size_of::<S>() != 400) as usize; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `N` failed here error: aborting due to 1 previous error diff --git a/tests/rustdoc-ui/doc-cfg-check-cfg.cfg_empty.stderr b/tests/rustdoc-ui/doc-cfg-check-cfg.cfg_empty.stderr new file mode 100644 index 00000000000..0878f7edbf4 --- /dev/null +++ b/tests/rustdoc-ui/doc-cfg-check-cfg.cfg_empty.stderr @@ -0,0 +1,30 @@ +warning: unexpected `cfg` condition name: `foo` + --> $DIR/doc-cfg-check-cfg.rs:12:12 + | +LL | #![doc(cfg(foo))] + | ^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(foo)` + = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: unexpected `cfg` condition name: `foo` + --> $DIR/doc-cfg-check-cfg.rs:19:11 + | +LL | #[doc(cfg(foo))] + | ^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(foo)` + = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration + +warning: unexpected `cfg` condition name: `foo` + --> $DIR/doc-cfg-check-cfg.rs:15:11 + | +LL | #[doc(cfg(foo))] + | ^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(foo)` + = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration + +warning: 3 warnings emitted + diff --git a/tests/rustdoc-ui/doc-cfg-check-cfg.rs b/tests/rustdoc-ui/doc-cfg-check-cfg.rs index e3420dc0789..7d37077a32d 100644 --- a/tests/rustdoc-ui/doc-cfg-check-cfg.rs +++ b/tests/rustdoc-ui/doc-cfg-check-cfg.rs @@ -1,16 +1,25 @@ // Ensure that `doc(cfg())` respects `check-cfg` // Currently not properly working -#![feature(doc_cfg)] -#![deny(unexpected_cfgs)] -//@revisions: no_check cfg_empty cfg_foo +//@ check-pass +//@ no-auto-check-cfg + +//@ revisions: no_check cfg_empty cfg_foo //@[cfg_empty] compile-flags: --check-cfg cfg() //@[cfg_foo] compile-flags: --check-cfg cfg(foo) -//@[no_check] check-pass -//@[cfg_empty] check-pass -//@[cfg_empty] known-bug: #138358 -//@[cfg_foo] check-pass +#![feature(doc_cfg)] +#![doc(cfg(foo))] +//[cfg_empty]~^ WARN unexpected `cfg` condition name: `foo` #[doc(cfg(foo))] +//[cfg_empty]~^ WARN unexpected `cfg` condition name: `foo` pub fn foo() {} + +#[doc(cfg(foo))] +//[cfg_empty]~^ WARN unexpected `cfg` condition name: `foo` +pub mod module { + #[allow(unexpected_cfgs)] + #[doc(cfg(bar))] + pub fn bar() {} +} diff --git a/tests/rustdoc-ui/doc-cfg.rs b/tests/rustdoc-ui/doc-cfg.rs index 354d76bc3c4..14943bbc341 100644 --- a/tests/rustdoc-ui/doc-cfg.rs +++ b/tests/rustdoc-ui/doc-cfg.rs @@ -3,7 +3,9 @@ #[doc(cfg(), cfg(foo, bar))] //~^ ERROR //~^^ ERROR -#[doc(cfg(foo), cfg(bar))] // ok! +#[doc(cfg(foo), cfg(bar))] +//~^ WARN unexpected `cfg` condition name: `foo` +//~^^ WARN unexpected `cfg` condition name: `bar` #[doc(cfg())] //~ ERROR #[doc(cfg(foo, bar))] //~ ERROR pub fn foo() {} diff --git a/tests/rustdoc-ui/doc-cfg.stderr b/tests/rustdoc-ui/doc-cfg.stderr index 14b7b17e04d..1233ee010de 100644 --- a/tests/rustdoc-ui/doc-cfg.stderr +++ b/tests/rustdoc-ui/doc-cfg.stderr @@ -11,16 +11,36 @@ LL | #[doc(cfg(), cfg(foo, bar))] | ^^^ error: `cfg` predicate is not specified - --> $DIR/doc-cfg.rs:7:7 + --> $DIR/doc-cfg.rs:9:7 | LL | #[doc(cfg())] | ^^^^^ help: expected syntax is: `cfg(/* predicate */)` error: multiple `cfg` predicates are specified - --> $DIR/doc-cfg.rs:8:16 + --> $DIR/doc-cfg.rs:10:16 | LL | #[doc(cfg(foo, bar))] | ^^^ -error: aborting due to 4 previous errors +warning: unexpected `cfg` condition name: `foo` + --> $DIR/doc-cfg.rs:6:11 + | +LL | #[doc(cfg(foo), cfg(bar))] + | ^^^ + | + = help: expected names are: `FALSE` and `test` and 31 more + = help: to expect this configuration use `--check-cfg=cfg(foo)` + = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: unexpected `cfg` condition name: `bar` + --> $DIR/doc-cfg.rs:6:21 + | +LL | #[doc(cfg(foo), cfg(bar))] + | ^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(bar)` + = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration + +error: aborting due to 4 previous errors; 2 warnings emitted diff --git a/tests/rustdoc-ui/doctest/dead-code-items.rs b/tests/rustdoc-ui/doctest/dead-code-items.rs new file mode 100644 index 00000000000..015504cbced --- /dev/null +++ b/tests/rustdoc-ui/doctest/dead-code-items.rs @@ -0,0 +1,116 @@ +// Same test as dead-code-module but with 2 doc(test(attr())) at different levels. + +//@ 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" +//@ failure-status: 101 + +#![doc(test(attr(deny(warnings))))] + +#[doc(test(attr(allow(dead_code))))] +/// Example +/// +/// ```rust,no_run +/// trait OnlyWarning { fn no_deny_warnings(); } +/// ``` +static S: u32 = 5; + +#[doc(test(attr(allow(dead_code))))] +/// Example +/// +/// ```rust,no_run +/// let unused_error = 5; +/// +/// fn dead_code_but_no_error() {} +/// ``` +const C: u32 = 5; + +#[doc(test(attr(allow(dead_code))))] +/// Example +/// +/// ```rust,no_run +/// trait OnlyWarningAtA { fn no_deny_warnings(); } +/// ``` +struct A { + #[doc(test(attr(deny(dead_code))))] + /// Example + /// + /// ```rust,no_run + /// trait DeadCodeInField {} + /// ``` + field: u32 +} + +#[doc(test(attr(allow(dead_code))))] +/// Example +/// +/// ```rust,no_run +/// trait OnlyWarningAtU { fn no_deny_warnings(); } +/// ``` +union U { + #[doc(test(attr(deny(dead_code))))] + /// Example + /// + /// ```rust,no_run + /// trait DeadCodeInUnionField {} + /// ``` + field: u32, + /// Example + /// + /// ```rust,no_run + /// trait NotDeadCodeInUnionField {} + /// ``` + field2: u64, +} + +#[doc(test(attr(deny(dead_code))))] +/// Example +/// +/// ```rust,no_run +/// let not_dead_code_but_unused = 5; +/// ``` +enum Enum { + #[doc(test(attr(allow(dead_code))))] + /// Example + /// + /// ```rust,no_run + /// trait NotDeadCodeInVariant {} + /// + /// fn main() { let unused_in_variant = 5; } + /// ``` + Variant1, +} + +#[doc(test(attr(allow(dead_code))))] +/// Example +/// +/// ```rust,no_run +/// trait OnlyWarningAtImplA { fn no_deny_warnings(); } +/// ``` +impl A { + /// Example + /// + /// ```rust,no_run + /// trait NotDeadCodeInImplMethod {} + /// ``` + fn method() {} +} + +#[doc(test(attr(deny(dead_code))))] +/// Example +/// +/// ```rust,no_run +/// trait StillDeadCodeAtMyTrait { } +/// ``` +trait MyTrait { + #[doc(test(attr(allow(dead_code))))] + /// Example + /// + /// ```rust,no_run + /// trait NotDeadCodeAtImplFn {} + /// + /// fn main() { let unused_in_impl = 5; } + /// ``` + fn my_trait_fn(); +} diff --git a/tests/rustdoc-ui/doctest/dead-code-items.stdout b/tests/rustdoc-ui/doctest/dead-code-items.stdout new file mode 100644 index 00000000000..4b9d8be94dd --- /dev/null +++ b/tests/rustdoc-ui/doctest/dead-code-items.stdout @@ -0,0 +1,146 @@ + +running 13 tests +test $DIR/dead-code-items.rs - A (line 32) - compile ... ok +test $DIR/dead-code-items.rs - A (line 88) - compile ... ok +test $DIR/dead-code-items.rs - A::field (line 39) - compile ... FAILED +test $DIR/dead-code-items.rs - A::method (line 94) - compile ... ok +test $DIR/dead-code-items.rs - C (line 22) - compile ... FAILED +test $DIR/dead-code-items.rs - Enum (line 70) - compile ... FAILED +test $DIR/dead-code-items.rs - Enum::Variant1 (line 77) - compile ... FAILED +test $DIR/dead-code-items.rs - MyTrait (line 103) - compile ... FAILED +test $DIR/dead-code-items.rs - MyTrait::my_trait_fn (line 110) - compile ... FAILED +test $DIR/dead-code-items.rs - S (line 14) - compile ... ok +test $DIR/dead-code-items.rs - U (line 48) - compile ... ok +test $DIR/dead-code-items.rs - U::field (line 55) - compile ... FAILED +test $DIR/dead-code-items.rs - U::field2 (line 61) - compile ... ok + +failures: + +---- $DIR/dead-code-items.rs - A::field (line 39) stdout ---- +error: trait `DeadCodeInField` is never used + --> $DIR/dead-code-items.rs:40:7 + | +LL | trait DeadCodeInField {} + | ^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/dead-code-items.rs:38:9 + | +LL | #![deny(dead_code)] + | ^^^^^^^^^ + +error: aborting due to 1 previous error + +Couldn't compile the test. +---- $DIR/dead-code-items.rs - C (line 22) stdout ---- +error: unused variable: `unused_error` + --> $DIR/dead-code-items.rs:23:5 + | +LL | let unused_error = 5; + | ^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused_error` + | +note: the lint level is defined here + --> $DIR/dead-code-items.rs:20:9 + | +LL | #![deny(warnings)] + | ^^^^^^^^ + = note: `#[deny(unused_variables)]` implied by `#[deny(warnings)]` + +error: aborting due to 1 previous error + +Couldn't compile the test. +---- $DIR/dead-code-items.rs - Enum (line 70) stdout ---- +error: unused variable: `not_dead_code_but_unused` + --> $DIR/dead-code-items.rs:71:5 + | +LL | let not_dead_code_but_unused = 5; + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_not_dead_code_but_unused` + | +note: the lint level is defined here + --> $DIR/dead-code-items.rs:68:9 + | +LL | #![deny(warnings)] + | ^^^^^^^^ + = note: `#[deny(unused_variables)]` implied by `#[deny(warnings)]` + +error: aborting due to 1 previous error + +Couldn't compile the test. +---- $DIR/dead-code-items.rs - Enum::Variant1 (line 77) stdout ---- +error: unused variable: `unused_in_variant` + --> $DIR/dead-code-items.rs:80:17 + | +LL | fn main() { let unused_in_variant = 5; } + | ^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused_in_variant` + | +note: the lint level is defined here + --> $DIR/dead-code-items.rs:75:9 + | +LL | #![deny(warnings)] + | ^^^^^^^^ + = note: `#[deny(unused_variables)]` implied by `#[deny(warnings)]` + +error: aborting due to 1 previous error + +Couldn't compile the test. +---- $DIR/dead-code-items.rs - MyTrait (line 103) stdout ---- +error: trait `StillDeadCodeAtMyTrait` is never used + --> $DIR/dead-code-items.rs:104:7 + | +LL | trait StillDeadCodeAtMyTrait { } + | ^^^^^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/dead-code-items.rs:102:9 + | +LL | #![deny(dead_code)] + | ^^^^^^^^^ + +error: aborting due to 1 previous error + +Couldn't compile the test. +---- $DIR/dead-code-items.rs - MyTrait::my_trait_fn (line 110) stdout ---- +error: unused variable: `unused_in_impl` + --> $DIR/dead-code-items.rs:113:17 + | +LL | fn main() { let unused_in_impl = 5; } + | ^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused_in_impl` + | +note: the lint level is defined here + --> $DIR/dead-code-items.rs:108:9 + | +LL | #![deny(warnings)] + | ^^^^^^^^ + = note: `#[deny(unused_variables)]` implied by `#[deny(warnings)]` + +error: aborting due to 1 previous error + +Couldn't compile the test. +---- $DIR/dead-code-items.rs - U::field (line 55) stdout ---- +error: trait `DeadCodeInUnionField` is never used + --> $DIR/dead-code-items.rs:56:7 + | +LL | trait DeadCodeInUnionField {} + | ^^^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/dead-code-items.rs:54:9 + | +LL | #![deny(dead_code)] + | ^^^^^^^^^ + +error: aborting due to 1 previous error + +Couldn't compile the test. + +failures: + $DIR/dead-code-items.rs - A::field (line 39) + $DIR/dead-code-items.rs - C (line 22) + $DIR/dead-code-items.rs - Enum (line 70) + $DIR/dead-code-items.rs - Enum::Variant1 (line 77) + $DIR/dead-code-items.rs - MyTrait (line 103) + $DIR/dead-code-items.rs - MyTrait::my_trait_fn (line 110) + $DIR/dead-code-items.rs - U::field (line 55) + +test result: FAILED. 6 passed; 7 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME + diff --git a/tests/rustdoc-ui/doctest/dead-code-module-2.rs b/tests/rustdoc-ui/doctest/dead-code-module-2.rs new file mode 100644 index 00000000000..de7b11b91ec --- /dev/null +++ b/tests/rustdoc-ui/doctest/dead-code-module-2.rs @@ -0,0 +1,27 @@ +// Same test as dead-code-module but with 2 doc(test(attr())) at different levels. + +//@ edition: 2024 +//@ compile-flags:--test +//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR" +//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" +//@ failure-status: 101 + +#![doc(test(attr(allow(unused_variables))))] + +mod my_mod { + #![doc(test(attr(deny(warnings))))] + + /// Example + /// + /// ```rust,no_run + /// trait T { fn f(); } + /// ``` + pub fn f() {} +} + +/// Example +/// +/// ```rust,no_run +/// trait OnlyWarning { fn no_deny_warnings(); } +/// ``` +pub fn g() {} diff --git a/tests/rustdoc-ui/doctest/dead-code-module-2.stdout b/tests/rustdoc-ui/doctest/dead-code-module-2.stdout new file mode 100644 index 00000000000..d44068dcbf5 --- /dev/null +++ b/tests/rustdoc-ui/doctest/dead-code-module-2.stdout @@ -0,0 +1,35 @@ + +running 1 test +test $DIR/dead-code-module-2.rs - g (line 24) - compile ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME + + +running 1 test +test $DIR/dead-code-module-2.rs - my_mod::f (line 16) - compile ... FAILED + +failures: + +---- $DIR/dead-code-module-2.rs - my_mod::f (line 16) stdout ---- +error: trait `T` is never used + --> $DIR/dead-code-module-2.rs:17:7 + | +LL | trait T { fn f(); } + | ^ + | +note: the lint level is defined here + --> $DIR/dead-code-module-2.rs:15:9 + | +LL | #![deny(warnings)] + | ^^^^^^^^ + = note: `#[deny(dead_code)]` implied by `#[deny(warnings)]` + +error: aborting due to 1 previous error + +Couldn't compile the test. + +failures: + $DIR/dead-code-module-2.rs - my_mod::f (line 16) + +test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME + diff --git a/tests/rustdoc-ui/doctest/dead-code-module.rs b/tests/rustdoc-ui/doctest/dead-code-module.rs new file mode 100644 index 00000000000..f825749a6a2 --- /dev/null +++ b/tests/rustdoc-ui/doctest/dead-code-module.rs @@ -0,0 +1,18 @@ +// Same test as dead-code but inside a module. + +//@ edition: 2024 +//@ compile-flags:--test +//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR" +//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" +//@ failure-status: 101 + +mod my_mod { + #![doc(test(attr(allow(unused_variables), deny(warnings))))] + + /// Example + /// + /// ```rust,no_run + /// trait T { fn f(); } + /// ``` + pub fn f() {} +} diff --git a/tests/rustdoc-ui/doctest/dead-code-module.stdout b/tests/rustdoc-ui/doctest/dead-code-module.stdout new file mode 100644 index 00000000000..b5ccf225d25 --- /dev/null +++ b/tests/rustdoc-ui/doctest/dead-code-module.stdout @@ -0,0 +1,29 @@ + +running 1 test +test $DIR/dead-code-module.rs - my_mod::f (line 14) - compile ... FAILED + +failures: + +---- $DIR/dead-code-module.rs - my_mod::f (line 14) stdout ---- +error: trait `T` is never used + --> $DIR/dead-code-module.rs:15:7 + | +LL | trait T { fn f(); } + | ^ + | +note: the lint level is defined here + --> $DIR/dead-code-module.rs:13:9 + | +LL | #![deny(warnings)] + | ^^^^^^^^ + = note: `#[deny(dead_code)]` implied by `#[deny(warnings)]` + +error: aborting due to 1 previous error + +Couldn't compile the test. + +failures: + $DIR/dead-code-module.rs - my_mod::f (line 14) + +test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME + diff --git a/tests/rustdoc-ui/doctest/doc-test-attr-pass-module.rs b/tests/rustdoc-ui/doctest/doc-test-attr-pass-module.rs new file mode 100644 index 00000000000..e916ca41ea0 --- /dev/null +++ b/tests/rustdoc-ui/doctest/doc-test-attr-pass-module.rs @@ -0,0 +1,11 @@ +//@ check-pass + +#![crate_type = "lib"] +#![deny(invalid_doc_attributes)] +#![doc(test(no_crate_inject))] + +mod my_mod { + #![doc(test(attr(deny(warnings))))] + + pub fn foo() {} +} diff --git a/tests/rustdoc-ui/doctest/failed-doctest-extra-semicolon-on-item.stderr b/tests/rustdoc-ui/doctest/failed-doctest-extra-semicolon-on-item.stderr new file mode 100644 index 00000000000..113fb7ccb60 --- /dev/null +++ b/tests/rustdoc-ui/doctest/failed-doctest-extra-semicolon-on-item.stderr @@ -0,0 +1,8 @@ +warning: the `main` function of this doctest won't be run as it contains expressions at the top level, meaning that the whole doctest code will be wrapped in a function + --> $DIR/failed-doctest-extra-semicolon-on-item.rs:11:1 + | +11 | /// ```rust + | ^^^^^^^^^^^ + +warning: 1 warning emitted + diff --git a/tests/rustdoc-ui/doctest/main-alongside-stmts.stderr b/tests/rustdoc-ui/doctest/main-alongside-stmts.stderr new file mode 100644 index 00000000000..d90a289ca69 --- /dev/null +++ b/tests/rustdoc-ui/doctest/main-alongside-stmts.stderr @@ -0,0 +1,14 @@ +warning: the `main` function of this doctest won't be run as it contains expressions at the top level, meaning that the whole doctest code will be wrapped in a function + --> $DIR/main-alongside-stmts.rs:17:1 + | +17 | //! ``` + | ^^^^^^^ + +warning: the `main` function of this doctest won't be run as it contains expressions at the top level, meaning that the whole doctest code will be wrapped in a function + --> $DIR/main-alongside-stmts.rs:26:1 + | +26 | //! ``` + | ^^^^^^^ + +warning: 2 warnings emitted + diff --git a/tests/rustdoc-ui/doctest/test-main-alongside-exprs.stderr b/tests/rustdoc-ui/doctest/test-main-alongside-exprs.stderr new file mode 100644 index 00000000000..0dc7c2a2eea --- /dev/null +++ b/tests/rustdoc-ui/doctest/test-main-alongside-exprs.stderr @@ -0,0 +1,8 @@ +warning: the `main` function of this doctest won't be run as it contains expressions at the top level, meaning that the whole doctest code will be wrapped in a function + --> $DIR/test-main-alongside-exprs.rs:15:1 + | +15 | //! ``` + | ^^^^^^^ + +warning: 1 warning emitted + diff --git a/tests/rustdoc-ui/doctest/warn-main-not-called.rs b/tests/rustdoc-ui/doctest/warn-main-not-called.rs new file mode 100644 index 00000000000..25d92e9cee9 --- /dev/null +++ b/tests/rustdoc-ui/doctest/warn-main-not-called.rs @@ -0,0 +1,22 @@ +//@ check-pass +//@ 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" + +// In case there is a `main` function in the doctest alongside expressions, +// the whole doctest will be wrapped into a function and the `main` function +// won't be called. + +//! ``` +//! macro_rules! bla { +//! ($($x:tt)*) => {} +//! } +//! +//! let x = 12; +//! bla!(fn main ()); +//! ``` +//! +//! ``` +//! let x = 12; +//! fn main() {} +//! ``` diff --git a/tests/rustdoc-ui/doctest/warn-main-not-called.stderr b/tests/rustdoc-ui/doctest/warn-main-not-called.stderr new file mode 100644 index 00000000000..3a079f47555 --- /dev/null +++ b/tests/rustdoc-ui/doctest/warn-main-not-called.stderr @@ -0,0 +1,14 @@ +warning: the `main` function of this doctest won't be run as it contains expressions at the top level, meaning that the whole doctest code will be wrapped in a function + --> $DIR/warn-main-not-called.rs:10:1 + | +10 | //! ``` + | ^^^^^^^ + +warning: the `main` function of this doctest won't be run as it contains expressions at the top level, meaning that the whole doctest code will be wrapped in a function + --> $DIR/warn-main-not-called.rs:19:1 + | +19 | //! ``` + | ^^^^^^^ + +warning: 2 warnings emitted + diff --git a/tests/rustdoc-ui/doctest/warn-main-not-called.stdout b/tests/rustdoc-ui/doctest/warn-main-not-called.stdout new file mode 100644 index 00000000000..07cdddc7b94 --- /dev/null +++ b/tests/rustdoc-ui/doctest/warn-main-not-called.stdout @@ -0,0 +1,7 @@ + +running 2 tests +test $DIR/warn-main-not-called.rs - (line 10) ... ok +test $DIR/warn-main-not-called.rs - (line 19) ... ok + +test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME + diff --git a/tests/rustdoc-ui/intra-doc/bad-link-to-proc-macro.rs b/tests/rustdoc-ui/intra-doc/bad-link-to-proc-macro.rs new file mode 100644 index 00000000000..b449465768e --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/bad-link-to-proc-macro.rs @@ -0,0 +1,21 @@ +//@ compile-flags: --crate-type=proc-macro --document-private-items +#![deny(rustdoc::broken_intra_doc_links)] + +//! Link to [`m`]. +//~^ ERROR `m` is both a module and a macro + +// test a further edge case related to https://github.com/rust-lang/rust/issues/91274 + +// we need to make sure that when there is actually an ambiguity +// in a proc-macro crate, we print out a sensible error. +// because proc macro crates can't normally export modules, +// this can only happen in --document-private-items mode. + +extern crate proc_macro; + +mod m {} + +#[proc_macro] +pub fn m(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + input +} diff --git a/tests/rustdoc-ui/intra-doc/bad-link-to-proc-macro.stderr b/tests/rustdoc-ui/intra-doc/bad-link-to-proc-macro.stderr new file mode 100644 index 00000000000..09a5d26eded --- /dev/null +++ b/tests/rustdoc-ui/intra-doc/bad-link-to-proc-macro.stderr @@ -0,0 +1,22 @@ +error: `m` is both a module and a macro + --> $DIR/bad-link-to-proc-macro.rs:4:15 + | +LL | //! Link to [`m`]. + | ^ ambiguous link + | +note: the lint level is defined here + --> $DIR/bad-link-to-proc-macro.rs:2:9 + | +LL | #![deny(rustdoc::broken_intra_doc_links)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: to link to the module, prefix with `mod@` + | +LL | //! Link to [`mod@m`]. + | ++++ +help: to link to the macro, add an exclamation mark + | +LL | //! Link to [`m!`]. + | + + +error: aborting due to 1 previous error + diff --git a/tests/rustdoc-ui/intra-doc/warning.stderr b/tests/rustdoc-ui/intra-doc/warning.stderr index 3a06f1787e0..9b3f6f822d7 100644 --- a/tests/rustdoc-ui/intra-doc/warning.stderr +++ b/tests/rustdoc-ui/intra-doc/warning.stderr @@ -69,29 +69,19 @@ LL | bar [BarC] bar = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` warning: unresolved link to `BarD` - --> $DIR/warning.rs:45:9 + --> $DIR/warning.rs:45:20 | LL | #[doc = "Foo\nbar [BarD] bar\nbaz"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^ no item named `BarD` in scope | - = note: the link appears in this line: - - bar [BarD] bar - ^^^^ - = note: no item named `BarD` in scope = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` warning: unresolved link to `BarF` - --> $DIR/warning.rs:54:4 + --> $DIR/warning.rs:54:15 | LL | f!("Foo\nbar [BarF] bar\nbaz"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^ no item named `BarF` in scope | - = note: the link appears in this line: - - bar [BarF] bar - ^^^^ - = note: no item named `BarF` in scope = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` = note: this warning originates in the macro `f` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -112,29 +102,19 @@ LL | * time to introduce a link [error] = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` warning: unresolved link to `error` - --> $DIR/warning.rs:68:9 + --> $DIR/warning.rs:68:23 | LL | #[doc = "single line [error]"] - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ no item named `error` in scope | - = note: the link appears in this line: - - single line [error] - ^^^^^ - = note: no item named `error` in scope = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` warning: unresolved link to `error` - --> $DIR/warning.rs:71:9 + --> $DIR/warning.rs:71:41 | LL | #[doc = "single line with \"escaping\" [error]"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ no item named `error` in scope | - = note: the link appears in this line: - - single line with "escaping" [error] - ^^^^^ - = note: no item named `error` in scope = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` warning: unresolved link to `error` diff --git a/tests/rustdoc-ui/issues/issue-91713.stdout b/tests/rustdoc-ui/issues/issue-91713.stdout index 790e58b0df9..30aadfe89f4 100644 --- a/tests/rustdoc-ui/issues/issue-91713.stdout +++ b/tests/rustdoc-ui/issues/issue-91713.stdout @@ -1,4 +1,5 @@ Available passes for running rustdoc: + check-doc-cfg - checks `#[doc(cfg(...))]` for stability feature and unexpected cfgs check_doc_test_visibility - run various visibility-related lints on doctests strip-aliased-non-local - strips all non-local private aliased items from the output strip-hidden - strips all `#[doc(hidden)]` items from the output @@ -14,6 +15,7 @@ calculate-doc-coverage - counts the number of items with and without documentati Default passes for rustdoc: collect-trait-impls check_doc_test_visibility + check-doc-cfg strip-aliased-non-local strip-hidden (when not --document-hidden-items) strip-private (when not --document-private-items) diff --git a/tests/rustdoc-ui/lints/bare-urls-limit.rs b/tests/rustdoc-ui/lints/bare-urls-limit.rs new file mode 100644 index 00000000000..f64154b0496 --- /dev/null +++ b/tests/rustdoc-ui/lints/bare-urls-limit.rs @@ -0,0 +1,12 @@ +//@ check-fail + +#![deny(rustdoc::bare_urls)] + +// examples of bare urls that are beyond our ability to generate suggestions for + +// this falls through every heuristic in `source_span_for_markdown_range`, +// and thus does not get any suggestion. +#[doc = "good: <https://example.com/> \n\n"] +//~^ ERROR this URL is not a hyperlink +#[doc = "bad: https://example.com/"] +pub fn duplicate_raw() {} diff --git a/tests/rustdoc-ui/lints/bare-urls-limit.stderr b/tests/rustdoc-ui/lints/bare-urls-limit.stderr new file mode 100644 index 00000000000..9573665cb13 --- /dev/null +++ b/tests/rustdoc-ui/lints/bare-urls-limit.stderr @@ -0,0 +1,18 @@ +error: this URL is not a hyperlink + --> $DIR/bare-urls-limit.rs:9:9 + | +LL | #[doc = "good: <https://example.com/> \n\n"] + | _________^ +LL | | +LL | | #[doc = "bad: https://example.com/"] + | |___________________________________^ + | + = note: bare URLs are not automatically turned into clickable links +note: the lint level is defined here + --> $DIR/bare-urls-limit.rs:3:9 + | +LL | #![deny(rustdoc::bare_urls)] + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/rustdoc-ui/lints/bare-urls.fixed b/tests/rustdoc-ui/lints/bare-urls.fixed index 7938d715199..a91573146b8 100644 --- a/tests/rustdoc-ui/lints/bare-urls.fixed +++ b/tests/rustdoc-ui/lints/bare-urls.fixed @@ -38,6 +38,16 @@ //~^ ERROR this URL is not a hyperlink pub fn c() {} +#[doc = "here's a thing: <https://example.com/>"] +//~^ ERROR this URL is not a hyperlink +pub fn f() {} + +/// <https://example.com/sugar> +//~^ ERROR this URL is not a hyperlink +#[doc = "<https://example.com/raw>"] +//~^ ERROR this URL is not a hyperlink +pub fn mixed() {} + /// <https://somewhere.com> /// [a](http://a.com) /// [b] diff --git a/tests/rustdoc-ui/lints/bare-urls.rs b/tests/rustdoc-ui/lints/bare-urls.rs index 75f42b78ffb..5b008cdafa2 100644 --- a/tests/rustdoc-ui/lints/bare-urls.rs +++ b/tests/rustdoc-ui/lints/bare-urls.rs @@ -38,6 +38,16 @@ //~^ ERROR this URL is not a hyperlink pub fn c() {} +#[doc = "here's a thing: https://example.com/"] +//~^ ERROR this URL is not a hyperlink +pub fn f() {} + +/// https://example.com/sugar +//~^ ERROR this URL is not a hyperlink +#[doc = "https://example.com/raw"] +//~^ ERROR this URL is not a hyperlink +pub fn mixed() {} + /// <https://somewhere.com> /// [a](http://a.com) /// [b] diff --git a/tests/rustdoc-ui/lints/bare-urls.stderr b/tests/rustdoc-ui/lints/bare-urls.stderr index ddfc387eaf6..e1108c7e7f8 100644 --- a/tests/rustdoc-ui/lints/bare-urls.stderr +++ b/tests/rustdoc-ui/lints/bare-urls.stderr @@ -207,5 +207,41 @@ help: use an automatic link instead LL | /// hey! <https://somewhere.com/a?hello=12&bye=11#xyz> | + + -error: aborting due to 17 previous errors +error: this URL is not a hyperlink + --> $DIR/bare-urls.rs:41:26 + | +LL | #[doc = "here's a thing: https://example.com/"] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: bare URLs are not automatically turned into clickable links +help: use an automatic link instead + | +LL | #[doc = "here's a thing: <https://example.com/>"] + | + + + +error: this URL is not a hyperlink + --> $DIR/bare-urls.rs:45:5 + | +LL | /// https://example.com/sugar + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: bare URLs are not automatically turned into clickable links +help: use an automatic link instead + | +LL | /// <https://example.com/sugar> + | + + + +error: this URL is not a hyperlink + --> $DIR/bare-urls.rs:47:10 + | +LL | #[doc = "https://example.com/raw"] + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: bare URLs are not automatically turned into clickable links +help: use an automatic link instead + | +LL | #[doc = "<https://example.com/raw>"] + | + + + +error: aborting due to 20 previous errors diff --git a/tests/rustdoc-ui/unescaped_backticks.stderr b/tests/rustdoc-ui/unescaped_backticks.stderr index d93aaf5f3ca..1bcb88e108f 100644 --- a/tests/rustdoc-ui/unescaped_backticks.stderr +++ b/tests/rustdoc-ui/unescaped_backticks.stderr @@ -628,10 +628,10 @@ LL | /// or even to add a number `n` to 42 (`add(42, n)\`)! | + error: unescaped backtick - --> $DIR/unescaped_backticks.rs:108:9 + --> $DIR/unescaped_backticks.rs:108:10 | LL | #[doc = "`"] - | ^^^ + | ^ | = help: the opening or closing backtick of an inline code may be missing = help: if you meant to use a literal backtick, escape it @@ -639,10 +639,10 @@ LL | #[doc = "`"] to this: \` error: unescaped backtick - --> $DIR/unescaped_backticks.rs:115:9 + --> $DIR/unescaped_backticks.rs:115:26 | LL | #[doc = concat!("\\", "`")] - | ^^^^^^^^^^^^^^^^^^^^ + | ^ | = help: the opening backtick of an inline code may be missing change: \` diff --git a/tests/rustdoc/cfg-bool.rs b/tests/rustdoc/cfg-bool.rs new file mode 100644 index 00000000000..34fdfbe930e --- /dev/null +++ b/tests/rustdoc/cfg-bool.rs @@ -0,0 +1,13 @@ +#![feature(doc_cfg)] +#![crate_name = "foo"] + +// regression test for https://github.com/rust-lang/rust/issues/138112 + +//@ has 'foo/fn.foo.html' '//div[@class="stab portability"]' 'Available nowhere' +#[doc(cfg(false))] +pub fn foo() {} + +// a cfg(true) will simply be ommited, as it is the same as no cfg. +//@ !has 'foo/fn.bar.html' '//div[@class="stab portability"]' '' +#[doc(cfg(true))] +pub fn bar() {} diff --git a/tests/rustdoc/doctest/ignore-sometimes.rs b/tests/rustdoc/doctest/ignore-sometimes.rs new file mode 100644 index 00000000000..0f8586d221c --- /dev/null +++ b/tests/rustdoc/doctest/ignore-sometimes.rs @@ -0,0 +1,23 @@ +#![crate_name = "foo"] + +// test for https://github.com/rust-lang/rust/issues/141092 + +//@ has 'foo/fn.f.html' '//a[@title="This example is not tested on wasm"]' 'ⓘ' +/// Example +/// +/// ```ignore-wasm +/// let x = 1; +/// ``` +pub fn f() {} + +//@ has 'foo/fn.g.html' '//a[@title="This example is not tested on wasm or windows"]' 'ⓘ' +/// ```ignore-wasm,ignore-windows +/// let x = 1; +/// ``` +pub fn g() {} + +//@ has 'foo/fn.h.html' '//a[@title="This example is not tested on wasm, windows, or unix"]' 'ⓘ' +/// ```ignore-wasm,ignore-windows,ignore-unix +/// let x = 1; +/// ``` +pub fn h() {} diff --git a/tests/rustdoc/inline_cross/assoc-const-equality.rs b/tests/rustdoc/inline_cross/assoc-const-equality.rs index ec5c2f748ef..36ab027ef71 100644 --- a/tests/rustdoc/inline_cross/assoc-const-equality.rs +++ b/tests/rustdoc/inline_cross/assoc-const-equality.rs @@ -1,6 +1,5 @@ //@ aux-crate:assoc_const_equality=assoc-const-equality.rs //@ edition:2021 -//@ ignore-test (FIXME: #125092) #![crate_name = "user"] diff --git a/tests/rustdoc/intra-doc/link-to-proc-macro.rs b/tests/rustdoc/intra-doc/link-to-proc-macro.rs new file mode 100644 index 00000000000..6c289078db8 --- /dev/null +++ b/tests/rustdoc/intra-doc/link-to-proc-macro.rs @@ -0,0 +1,13 @@ +//@ compile-flags: --crate-type=proc-macro +//@ has 'foo/index.html' '//a[@href="macro.my_macro.html"]' 'my_macro' +//! Link to [`my_macro`]. +#![crate_name = "foo"] + +// regression test for https://github.com/rust-lang/rust/issues/91274 + +extern crate proc_macro; + +#[proc_macro] +pub fn my_macro(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + input +} diff --git a/tests/rustdoc/type-alias/repr.rs b/tests/rustdoc/type-alias/repr.rs new file mode 100644 index 00000000000..cf907980360 --- /dev/null +++ b/tests/rustdoc/type-alias/repr.rs @@ -0,0 +1,42 @@ +// This test ensures that the `repr` attribute is displayed in type aliases. +// +// Regression test for <https://github.com/rust-lang/rust/issues/140739>. + +#![crate_name = "foo"] + +/// bla +#[repr(C)] +pub struct Foo1; + +//@ has 'foo/type.Bar1.html' +//@ has - '//*[@class="rust item-decl"]/code' '#[repr(C)]pub struct Bar1;' +// Ensures that we see the doc comment of the type alias and not of the aliased type. +//@ has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'bar' +/// bar +pub type Bar1 = Foo1; + +/// bla +#[repr(C)] +pub union Foo2 { + pub a: u8, +} + +//@ has 'foo/type.Bar2.html' +//@ matches - '//*[@class="rust item-decl"]' '#\[repr\(C\)\]\npub union Bar2 \{*' +// Ensures that we see the doc comment of the type alias and not of the aliased type. +//@ has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'bar' +/// bar +pub type Bar2 = Foo2; + +/// bla +#[repr(C)] +pub enum Foo3 { + A, +} + +//@ has 'foo/type.Bar3.html' +//@ matches - '//*[@class="rust item-decl"]' '#\[repr\(C\)\]pub enum Bar3 \{*' +// Ensures that we see the doc comment of the type alias and not of the aliased type. +//@ has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'bar' +/// bar +pub type Bar3 = Foo3; diff --git a/tests/rustdoc/type-layout.rs b/tests/rustdoc/type-layout.rs index 6de435dbcc1..482b8b597dd 100644 --- a/tests/rustdoc/type-layout.rs +++ b/tests/rustdoc/type-layout.rs @@ -61,7 +61,7 @@ pub type TypeAlias = X; pub type GenericTypeAlias = (Generic<(u32, ())>, Generic<u32>); // Regression test for the rustdoc equivalent of #85103. -//@ hasraw type_layout/type.Edges.html 'Encountered an error during type layout; the type failed to be normalized.' +//@ hasraw type_layout/type.Edges.html 'Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.' pub type Edges<'a, E> = std::borrow::Cow<'a, [E]>; //@ !hasraw type_layout/trait.MyTrait.html 'Size: ' diff --git a/tests/ui-fulldeps/pprust-expr-roundtrip.rs b/tests/ui-fulldeps/pprust-expr-roundtrip.rs index 4a866560e79..f5cfa9e0bcc 100644 --- a/tests/ui-fulldeps/pprust-expr-roundtrip.rs +++ b/tests/ui-fulldeps/pprust-expr-roundtrip.rs @@ -34,7 +34,7 @@ extern crate thin_vec; extern crate rustc_driver; use parser::parse_expr; -use rustc_ast::mut_visit::{visit_clobber, MutVisitor}; +use rustc_ast::mut_visit::MutVisitor; use rustc_ast::ptr::P; use rustc_ast::*; use rustc_ast_pretty::pprust; @@ -202,15 +202,9 @@ struct AddParens; impl MutVisitor for AddParens { fn visit_expr(&mut self, e: &mut P<Expr>) { mut_visit::walk_expr(self, e); - visit_clobber(e, |e| { - P(Expr { - id: DUMMY_NODE_ID, - kind: ExprKind::Paren(e), - span: DUMMY_SP, - attrs: AttrVec::new(), - tokens: None, - }) - }); + let expr = std::mem::replace(e, Expr::dummy()); + + e.kind = ExprKind::Paren(expr); } } diff --git a/tests/ui-fulldeps/pprust-parenthesis-insertion.rs b/tests/ui-fulldeps/pprust-parenthesis-insertion.rs index 2b41020d307..c566ac459e0 100644 --- a/tests/ui-fulldeps/pprust-parenthesis-insertion.rs +++ b/tests/ui-fulldeps/pprust-parenthesis-insertion.rs @@ -42,7 +42,7 @@ use std::process::ExitCode; use parser::parse_expr; use rustc_ast::ast::{Expr, ExprKind}; -use rustc_ast::mut_visit::{self, DummyAstNode as _, MutVisitor}; +use rustc_ast::mut_visit::{self, MutVisitor}; use rustc_ast::ptr::P; use rustc_ast_pretty::pprust; use rustc_session::parse::ParseSess; @@ -154,7 +154,7 @@ struct Unparenthesize; impl MutVisitor for Unparenthesize { fn visit_expr(&mut self, e: &mut P<Expr>) { while let ExprKind::Paren(paren) = &mut e.kind { - **e = mem::replace(&mut *paren, Expr::dummy()); + *e = mem::replace(paren, Expr::dummy()); } mut_visit::walk_expr(self, e); } diff --git a/tests/ui/abi/c-zst.aarch64-darwin.stderr b/tests/ui/abi/c-zst.aarch64-darwin.stderr index 48fa2bf29bc..5e09145a271 100644 --- a/tests/ui/abi/c-zst.aarch64-darwin.stderr +++ b/tests/ui/abi/c-zst.aarch64-darwin.stderr @@ -5,9 +5,8 @@ error: fn_abi_of(pass_zst) = FnAbi { ty: (), layout: Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -34,9 +33,8 @@ error: fn_abi_of(pass_zst) = FnAbi { ty: (), layout: Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, diff --git a/tests/ui/abi/c-zst.powerpc-linux.stderr b/tests/ui/abi/c-zst.powerpc-linux.stderr index bfdf94c9900..b8d6c632b97 100644 --- a/tests/ui/abi/c-zst.powerpc-linux.stderr +++ b/tests/ui/abi/c-zst.powerpc-linux.stderr @@ -5,9 +5,8 @@ error: fn_abi_of(pass_zst) = FnAbi { ty: (), layout: Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -45,9 +44,8 @@ error: fn_abi_of(pass_zst) = FnAbi { ty: (), layout: Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, diff --git a/tests/ui/abi/c-zst.s390x-linux.stderr b/tests/ui/abi/c-zst.s390x-linux.stderr index bfdf94c9900..b8d6c632b97 100644 --- a/tests/ui/abi/c-zst.s390x-linux.stderr +++ b/tests/ui/abi/c-zst.s390x-linux.stderr @@ -5,9 +5,8 @@ error: fn_abi_of(pass_zst) = FnAbi { ty: (), layout: Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -45,9 +44,8 @@ error: fn_abi_of(pass_zst) = FnAbi { ty: (), layout: Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, diff --git a/tests/ui/abi/c-zst.sparc64-linux.stderr b/tests/ui/abi/c-zst.sparc64-linux.stderr index bfdf94c9900..b8d6c632b97 100644 --- a/tests/ui/abi/c-zst.sparc64-linux.stderr +++ b/tests/ui/abi/c-zst.sparc64-linux.stderr @@ -5,9 +5,8 @@ error: fn_abi_of(pass_zst) = FnAbi { ty: (), layout: Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -45,9 +44,8 @@ error: fn_abi_of(pass_zst) = FnAbi { ty: (), layout: Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, diff --git a/tests/ui/abi/c-zst.x86_64-linux.stderr b/tests/ui/abi/c-zst.x86_64-linux.stderr index 48fa2bf29bc..5e09145a271 100644 --- a/tests/ui/abi/c-zst.x86_64-linux.stderr +++ b/tests/ui/abi/c-zst.x86_64-linux.stderr @@ -5,9 +5,8 @@ error: fn_abi_of(pass_zst) = FnAbi { ty: (), layout: Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -34,9 +33,8 @@ error: fn_abi_of(pass_zst) = FnAbi { ty: (), layout: Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, diff --git a/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr b/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr index bfdf94c9900..b8d6c632b97 100644 --- a/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr +++ b/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr @@ -5,9 +5,8 @@ error: fn_abi_of(pass_zst) = FnAbi { ty: (), layout: Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -45,9 +44,8 @@ error: fn_abi_of(pass_zst) = FnAbi { ty: (), layout: Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, diff --git a/tests/ui/abi/debug.stderr b/tests/ui/abi/debug.stderr index 480f3f04215..8ed6dedf4d5 100644 --- a/tests/ui/abi/debug.stderr +++ b/tests/ui/abi/debug.stderr @@ -5,9 +5,8 @@ error: fn_abi_of(test) = FnAbi { ty: u8, layout: Layout { size: Size(1 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -44,9 +43,8 @@ error: fn_abi_of(test) = FnAbi { ty: bool, layout: Layout { size: Size(1 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -103,9 +101,8 @@ error: fn_abi_of(TestFnPtr) = FnAbi { ty: bool, layout: Layout { size: Size(1 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -151,9 +148,8 @@ error: fn_abi_of(TestFnPtr) = FnAbi { ty: u8, layout: Layout { size: Size(1 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -201,9 +197,8 @@ error: fn_abi_of(test_generic) = FnAbi { ty: *const T, layout: Layout { size: $SOME_SIZE, - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -241,9 +236,8 @@ error: fn_abi_of(test_generic) = FnAbi { ty: (), layout: Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -288,9 +282,8 @@ error: ABIs are not compatible ty: u8, layout: Layout { size: Size(1 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -327,9 +320,8 @@ error: ABIs are not compatible ty: (), layout: Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -362,9 +354,8 @@ error: ABIs are not compatible ty: u32, layout: Layout { size: $SOME_SIZE, - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -401,9 +392,8 @@ error: ABIs are not compatible ty: (), layout: Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -442,9 +432,8 @@ error: ABIs are not compatible ty: [u8; 32], layout: Layout { size: Size(32 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -482,9 +471,8 @@ error: ABIs are not compatible ty: (), layout: Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -517,9 +505,8 @@ error: ABIs are not compatible ty: [u32; 32], layout: Layout { size: Size(128 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -557,9 +544,8 @@ error: ABIs are not compatible ty: (), layout: Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -598,9 +584,8 @@ error: ABIs are not compatible ty: f32, layout: Layout { size: $SOME_SIZE, - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -636,9 +621,8 @@ error: ABIs are not compatible ty: (), layout: Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -671,9 +655,8 @@ error: ABIs are not compatible ty: u32, layout: Layout { size: $SOME_SIZE, - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -710,9 +693,8 @@ error: ABIs are not compatible ty: (), layout: Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -751,9 +733,8 @@ error: ABIs are not compatible ty: i32, layout: Layout { size: $SOME_SIZE, - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -790,9 +771,8 @@ error: ABIs are not compatible ty: (), layout: Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -825,9 +805,8 @@ error: ABIs are not compatible ty: u32, layout: Layout { size: $SOME_SIZE, - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -864,9 +843,8 @@ error: ABIs are not compatible ty: (), layout: Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -925,9 +903,8 @@ error: fn_abi_of(assoc_test) = FnAbi { ty: &S, layout: Layout { size: $SOME_SIZE, - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -977,9 +954,8 @@ error: fn_abi_of(assoc_test) = FnAbi { ty: (), layout: Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, diff --git a/tests/ui/abi/sysv64-zst.stderr b/tests/ui/abi/sysv64-zst.stderr index 59d7b004417..2233e8e4f62 100644 --- a/tests/ui/abi/sysv64-zst.stderr +++ b/tests/ui/abi/sysv64-zst.stderr @@ -5,9 +5,8 @@ error: fn_abi_of(pass_zst) = FnAbi { ty: (), layout: Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -34,9 +33,8 @@ error: fn_abi_of(pass_zst) = FnAbi { ty: (), layout: Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: $SOME_ALIGN, - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -59,7 +57,9 @@ error: fn_abi_of(pass_zst) = FnAbi { }, c_variadic: false, fixed_count: 1, - conv: X86_64SysV, + conv: X86( + SysV64, + ), can_unwind: false, } --> $DIR/sysv64-zst.rs:8:1 diff --git a/tests/ui/abi/unsupported.aarch64.stderr b/tests/ui/abi/unsupported.aarch64.stderr index c11cc4e2d52..ea645780b0d 100644 --- a/tests/ui/abi/unsupported.aarch64.stderr +++ b/tests/ui/abi/unsupported.aarch64.stderr @@ -1,5 +1,5 @@ warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:35:15 + --> $DIR/unsupported.rs:38:15 | LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,13 +9,13 @@ LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:40:1 + --> $DIR/unsupported.rs:43:1 | LL | extern "ptx-kernel" {} | ^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:51:17 + --> $DIR/unsupported.rs:50:17 | LL | fn aapcs_ptr(f: extern "aapcs" fn()) { | ^^^^^^^^^^^^^^^^^^^ @@ -24,13 +24,13 @@ LL | fn aapcs_ptr(f: extern "aapcs" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:64:1 + --> $DIR/unsupported.rs:55:1 | LL | extern "aapcs" {} | ^^^^^^^^^^^^^^^^^ warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:73:18 + --> $DIR/unsupported.rs:60:18 | LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -39,13 +39,13 @@ LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:78:1 + --> $DIR/unsupported.rs:65:1 | LL | extern "msp430-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:83:15 + --> $DIR/unsupported.rs:70:15 | LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -54,13 +54,13 @@ LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:88:1 + --> $DIR/unsupported.rs:75:1 | LL | extern "avr-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/unsupported.rs:96:17 + --> $DIR/unsupported.rs:80:17 | LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -69,13 +69,13 @@ LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:107:1 + --> $DIR/unsupported.rs:85:1 | LL | extern "riscv-interrupt-m" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/unsupported.rs:118:15 + --> $DIR/unsupported.rs:90:15 | LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -84,13 +84,13 @@ LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:129:1 + --> $DIR/unsupported.rs:95:1 | LL | extern "x86-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:141:20 + --> $DIR/unsupported.rs:100:20 | LL | fn thiscall_ptr(f: extern "thiscall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^ @@ -99,13 +99,13 @@ LL | fn thiscall_ptr(f: extern "thiscall" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:154:1 + --> $DIR/unsupported.rs:105:1 | LL | extern "thiscall" {} | ^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "stdcall" is not supported on this target - --> $DIR/unsupported.rs:167:19 + --> $DIR/unsupported.rs:112:19 | LL | fn stdcall_ptr(f: extern "stdcall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^ @@ -114,13 +114,68 @@ LL | fn stdcall_ptr(f: extern "stdcall" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:180:1 + --> $DIR/unsupported.rs:117:1 | LL | extern "stdcall" {} | ^^^^^^^^^^^^^^^^^^^ + | + = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` + +error[E0570]: `"stdcall-unwind"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:121:1 + | +LL | extern "stdcall-unwind" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: if you need `extern "stdcall-unwind"` on win32 and `extern "C-unwind"` everywhere else, use `extern "system-unwind"` + +warning: the calling convention "cdecl" is not supported on this target + --> $DIR/unsupported.rs:129:17 + | +LL | fn cdecl_ptr(f: extern "cdecl" fn()) { + | ^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:134:1 + | +LL | extern "cdecl" {} + | ^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default + +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:137:1 + | +LL | extern "cdecl-unwind" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C-unwind"` instead + +warning: the calling convention "vectorcall" is not supported on this target + --> $DIR/unsupported.rs:143:22 + | +LL | fn vectorcall_ptr(f: extern "vectorcall" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + +error[E0570]: `"vectorcall"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:148:1 + | +LL | extern "vectorcall" {} + | ^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:187:21 + --> $DIR/unsupported.rs:151:21 | LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -129,7 +184,7 @@ LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:195:22 + --> $DIR/unsupported.rs:159:22 | LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -138,77 +193,95 @@ LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:200:1 + --> $DIR/unsupported.rs:164:1 | LL | extern "C-cmse-nonsecure-entry" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:33:1 + --> $DIR/unsupported.rs:36:1 | LL | extern "ptx-kernel" fn ptx() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:42:1 + --> $DIR/unsupported.rs:45:1 | LL | extern "gpu-kernel" fn gpu() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:45:1 + --> $DIR/unsupported.rs:48:1 | LL | extern "aapcs" fn aapcs() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:71:1 + --> $DIR/unsupported.rs:58:1 | LL | extern "msp430-interrupt" fn msp430() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:81:1 + --> $DIR/unsupported.rs:68:1 | LL | extern "avr-interrupt" fn avr() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:91:1 + --> $DIR/unsupported.rs:78:1 | LL | extern "riscv-interrupt-m" fn riscv() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:113:1 + --> $DIR/unsupported.rs:88:1 | LL | extern "x86-interrupt" fn x86() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:135:1 + --> $DIR/unsupported.rs:98:1 | LL | extern "thiscall" fn thiscall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:161:1 + --> $DIR/unsupported.rs:108:1 | LL | extern "stdcall" fn stdcall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` + +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:126:1 + | +LL | extern "cdecl" fn cdecl() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead + +error[E0570]: `"vectorcall"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:141:1 + | +LL | extern "vectorcall" fn vectorcall() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:193:1 + --> $DIR/unsupported.rs:157:1 | LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 19 previous errors; 10 warnings emitted +error: aborting due to 22 previous errors; 15 warnings emitted For more information about this error, try `rustc --explain E0570`. Future incompatibility report: Future breakage diagnostic: warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:35:15 + --> $DIR/unsupported.rs:38:15 | LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -219,7 +292,7 @@ LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { Future breakage diagnostic: warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:51:17 + --> $DIR/unsupported.rs:50:17 | LL | fn aapcs_ptr(f: extern "aapcs" fn()) { | ^^^^^^^^^^^^^^^^^^^ @@ -230,7 +303,7 @@ LL | fn aapcs_ptr(f: extern "aapcs" fn()) { Future breakage diagnostic: warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:73:18 + --> $DIR/unsupported.rs:60:18 | LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -241,7 +314,7 @@ LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { Future breakage diagnostic: warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:83:15 + --> $DIR/unsupported.rs:70:15 | LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -252,7 +325,7 @@ LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { Future breakage diagnostic: warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/unsupported.rs:96:17 + --> $DIR/unsupported.rs:80:17 | LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -263,7 +336,7 @@ LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { Future breakage diagnostic: warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/unsupported.rs:118:15 + --> $DIR/unsupported.rs:90:15 | LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -274,7 +347,7 @@ LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { Future breakage diagnostic: warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:141:20 + --> $DIR/unsupported.rs:100:20 | LL | fn thiscall_ptr(f: extern "thiscall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^ @@ -285,7 +358,7 @@ LL | fn thiscall_ptr(f: extern "thiscall" fn()) { Future breakage diagnostic: warning: the calling convention "stdcall" is not supported on this target - --> $DIR/unsupported.rs:167:19 + --> $DIR/unsupported.rs:112:19 | LL | fn stdcall_ptr(f: extern "stdcall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^ @@ -295,8 +368,54 @@ LL | fn stdcall_ptr(f: extern "stdcall" fn()) { = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default Future breakage diagnostic: +warning: the calling convention "cdecl" is not supported on this target + --> $DIR/unsupported.rs:129:17 + | +LL | fn cdecl_ptr(f: extern "cdecl" fn()) { + | ^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:134:1 + | +LL | extern "cdecl" {} + | ^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:137:1 + | +LL | extern "cdecl-unwind" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C-unwind"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: the calling convention "vectorcall" is not supported on this target + --> $DIR/unsupported.rs:143:22 + | +LL | fn vectorcall_ptr(f: extern "vectorcall" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + +Future breakage diagnostic: warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:187:21 + --> $DIR/unsupported.rs:151:21 | LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -307,7 +426,7 @@ LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { Future breakage diagnostic: warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:195:22 + --> $DIR/unsupported.rs:159:22 | LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -316,3 +435,15 @@ LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default +Future breakage diagnostic: +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:126:1 + | +LL | extern "cdecl" fn cdecl() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default + diff --git a/tests/ui/abi/unsupported.arm.stderr b/tests/ui/abi/unsupported.arm.stderr index b2f24381336..2c82e2951e2 100644 --- a/tests/ui/abi/unsupported.arm.stderr +++ b/tests/ui/abi/unsupported.arm.stderr @@ -1,5 +1,5 @@ warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:35:15 + --> $DIR/unsupported.rs:38:15 | LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,13 +9,13 @@ LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:40:1 + --> $DIR/unsupported.rs:43:1 | LL | extern "ptx-kernel" {} | ^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:73:18 + --> $DIR/unsupported.rs:60:18 | LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,13 +24,13 @@ LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:78:1 + --> $DIR/unsupported.rs:65:1 | LL | extern "msp430-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:83:15 + --> $DIR/unsupported.rs:70:15 | LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -39,13 +39,13 @@ LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:88:1 + --> $DIR/unsupported.rs:75:1 | LL | extern "avr-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/unsupported.rs:96:17 + --> $DIR/unsupported.rs:80:17 | LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -54,13 +54,13 @@ LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:107:1 + --> $DIR/unsupported.rs:85:1 | LL | extern "riscv-interrupt-m" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/unsupported.rs:118:15 + --> $DIR/unsupported.rs:90:15 | LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -69,13 +69,13 @@ LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:129:1 + --> $DIR/unsupported.rs:95:1 | LL | extern "x86-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:141:20 + --> $DIR/unsupported.rs:100:20 | LL | fn thiscall_ptr(f: extern "thiscall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^ @@ -84,13 +84,13 @@ LL | fn thiscall_ptr(f: extern "thiscall" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:154:1 + --> $DIR/unsupported.rs:105:1 | LL | extern "thiscall" {} | ^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "stdcall" is not supported on this target - --> $DIR/unsupported.rs:167:19 + --> $DIR/unsupported.rs:112:19 | LL | fn stdcall_ptr(f: extern "stdcall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^ @@ -99,13 +99,68 @@ LL | fn stdcall_ptr(f: extern "stdcall" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:180:1 + --> $DIR/unsupported.rs:117:1 | LL | extern "stdcall" {} | ^^^^^^^^^^^^^^^^^^^ + | + = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` + +error[E0570]: `"stdcall-unwind"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:121:1 + | +LL | extern "stdcall-unwind" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: if you need `extern "stdcall-unwind"` on win32 and `extern "C-unwind"` everywhere else, use `extern "system-unwind"` + +warning: the calling convention "cdecl" is not supported on this target + --> $DIR/unsupported.rs:129:17 + | +LL | fn cdecl_ptr(f: extern "cdecl" fn()) { + | ^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:134:1 + | +LL | extern "cdecl" {} + | ^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default + +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:137:1 + | +LL | extern "cdecl-unwind" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C-unwind"` instead + +warning: the calling convention "vectorcall" is not supported on this target + --> $DIR/unsupported.rs:143:22 + | +LL | fn vectorcall_ptr(f: extern "vectorcall" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + +error[E0570]: `"vectorcall"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:148:1 + | +LL | extern "vectorcall" {} + | ^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:187:21 + --> $DIR/unsupported.rs:151:21 | LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -114,7 +169,7 @@ LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:195:22 + --> $DIR/unsupported.rs:159:22 | LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -123,71 +178,89 @@ LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:200:1 + --> $DIR/unsupported.rs:164:1 | LL | extern "C-cmse-nonsecure-entry" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:33:1 + --> $DIR/unsupported.rs:36:1 | LL | extern "ptx-kernel" fn ptx() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:42:1 + --> $DIR/unsupported.rs:45:1 | LL | extern "gpu-kernel" fn gpu() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:71:1 + --> $DIR/unsupported.rs:58:1 | LL | extern "msp430-interrupt" fn msp430() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:81:1 + --> $DIR/unsupported.rs:68:1 | LL | extern "avr-interrupt" fn avr() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:91:1 + --> $DIR/unsupported.rs:78:1 | LL | extern "riscv-interrupt-m" fn riscv() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:113:1 + --> $DIR/unsupported.rs:88:1 | LL | extern "x86-interrupt" fn x86() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:135:1 + --> $DIR/unsupported.rs:98:1 | LL | extern "thiscall" fn thiscall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:161:1 + --> $DIR/unsupported.rs:108:1 | LL | extern "stdcall" fn stdcall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` + +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:126:1 + | +LL | extern "cdecl" fn cdecl() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead + +error[E0570]: `"vectorcall"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:141:1 + | +LL | extern "vectorcall" fn vectorcall() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:193:1 + --> $DIR/unsupported.rs:157:1 | LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 17 previous errors; 9 warnings emitted +error: aborting due to 20 previous errors; 14 warnings emitted For more information about this error, try `rustc --explain E0570`. Future incompatibility report: Future breakage diagnostic: warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:35:15 + --> $DIR/unsupported.rs:38:15 | LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -198,7 +271,7 @@ LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { Future breakage diagnostic: warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:73:18 + --> $DIR/unsupported.rs:60:18 | LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -209,7 +282,7 @@ LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { Future breakage diagnostic: warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:83:15 + --> $DIR/unsupported.rs:70:15 | LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -220,7 +293,7 @@ LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { Future breakage diagnostic: warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/unsupported.rs:96:17 + --> $DIR/unsupported.rs:80:17 | LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -231,7 +304,7 @@ LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { Future breakage diagnostic: warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/unsupported.rs:118:15 + --> $DIR/unsupported.rs:90:15 | LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -242,7 +315,7 @@ LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { Future breakage diagnostic: warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:141:20 + --> $DIR/unsupported.rs:100:20 | LL | fn thiscall_ptr(f: extern "thiscall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^ @@ -253,7 +326,7 @@ LL | fn thiscall_ptr(f: extern "thiscall" fn()) { Future breakage diagnostic: warning: the calling convention "stdcall" is not supported on this target - --> $DIR/unsupported.rs:167:19 + --> $DIR/unsupported.rs:112:19 | LL | fn stdcall_ptr(f: extern "stdcall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^ @@ -263,8 +336,54 @@ LL | fn stdcall_ptr(f: extern "stdcall" fn()) { = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default Future breakage diagnostic: +warning: the calling convention "cdecl" is not supported on this target + --> $DIR/unsupported.rs:129:17 + | +LL | fn cdecl_ptr(f: extern "cdecl" fn()) { + | ^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:134:1 + | +LL | extern "cdecl" {} + | ^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:137:1 + | +LL | extern "cdecl-unwind" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C-unwind"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: the calling convention "vectorcall" is not supported on this target + --> $DIR/unsupported.rs:143:22 + | +LL | fn vectorcall_ptr(f: extern "vectorcall" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + +Future breakage diagnostic: warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:187:21 + --> $DIR/unsupported.rs:151:21 | LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -275,7 +394,7 @@ LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { Future breakage diagnostic: warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:195:22 + --> $DIR/unsupported.rs:159:22 | LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -284,3 +403,15 @@ LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default +Future breakage diagnostic: +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:126:1 + | +LL | extern "cdecl" fn cdecl() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default + diff --git a/tests/ui/abi/unsupported.i686.stderr b/tests/ui/abi/unsupported.i686.stderr index 94bd9b8af90..d552f9a132c 100644 --- a/tests/ui/abi/unsupported.i686.stderr +++ b/tests/ui/abi/unsupported.i686.stderr @@ -1,5 +1,5 @@ warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:35:15 + --> $DIR/unsupported.rs:38:15 | LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,13 +9,13 @@ LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:40:1 + --> $DIR/unsupported.rs:43:1 | LL | extern "ptx-kernel" {} | ^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:51:17 + --> $DIR/unsupported.rs:50:17 | LL | fn aapcs_ptr(f: extern "aapcs" fn()) { | ^^^^^^^^^^^^^^^^^^^ @@ -24,13 +24,13 @@ LL | fn aapcs_ptr(f: extern "aapcs" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:64:1 + --> $DIR/unsupported.rs:55:1 | LL | extern "aapcs" {} | ^^^^^^^^^^^^^^^^^ warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:73:18 + --> $DIR/unsupported.rs:60:18 | LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -39,13 +39,13 @@ LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:78:1 + --> $DIR/unsupported.rs:65:1 | LL | extern "msp430-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:83:15 + --> $DIR/unsupported.rs:70:15 | LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -54,13 +54,13 @@ LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:88:1 + --> $DIR/unsupported.rs:75:1 | LL | extern "avr-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/unsupported.rs:96:17 + --> $DIR/unsupported.rs:80:17 | LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -69,13 +69,13 @@ LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:107:1 + --> $DIR/unsupported.rs:85:1 | LL | extern "riscv-interrupt-m" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:187:21 + --> $DIR/unsupported.rs:151:21 | LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -84,7 +84,7 @@ LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:195:22 + --> $DIR/unsupported.rs:159:22 | LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -93,49 +93,49 @@ LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:200:1 + --> $DIR/unsupported.rs:164:1 | LL | extern "C-cmse-nonsecure-entry" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:33:1 + --> $DIR/unsupported.rs:36:1 | LL | extern "ptx-kernel" fn ptx() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:42:1 + --> $DIR/unsupported.rs:45:1 | LL | extern "gpu-kernel" fn gpu() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:45:1 + --> $DIR/unsupported.rs:48:1 | LL | extern "aapcs" fn aapcs() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:71:1 + --> $DIR/unsupported.rs:58:1 | LL | extern "msp430-interrupt" fn msp430() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:81:1 + --> $DIR/unsupported.rs:68:1 | LL | extern "avr-interrupt" fn avr() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:91:1 + --> $DIR/unsupported.rs:78:1 | LL | extern "riscv-interrupt-m" fn riscv() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:193:1 + --> $DIR/unsupported.rs:157:1 | LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -145,7 +145,7 @@ error: aborting due to 13 previous errors; 7 warnings emitted For more information about this error, try `rustc --explain E0570`. Future incompatibility report: Future breakage diagnostic: warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:35:15 + --> $DIR/unsupported.rs:38:15 | LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -156,7 +156,7 @@ LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { Future breakage diagnostic: warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:51:17 + --> $DIR/unsupported.rs:50:17 | LL | fn aapcs_ptr(f: extern "aapcs" fn()) { | ^^^^^^^^^^^^^^^^^^^ @@ -167,7 +167,7 @@ LL | fn aapcs_ptr(f: extern "aapcs" fn()) { Future breakage diagnostic: warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:73:18 + --> $DIR/unsupported.rs:60:18 | LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -178,7 +178,7 @@ LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { Future breakage diagnostic: warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:83:15 + --> $DIR/unsupported.rs:70:15 | LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -189,7 +189,7 @@ LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { Future breakage diagnostic: warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/unsupported.rs:96:17 + --> $DIR/unsupported.rs:80:17 | LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -200,7 +200,7 @@ LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { Future breakage diagnostic: warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:187:21 + --> $DIR/unsupported.rs:151:21 | LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -211,7 +211,7 @@ LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { Future breakage diagnostic: warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:195:22 + --> $DIR/unsupported.rs:159:22 | LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/abi/unsupported.riscv32.stderr b/tests/ui/abi/unsupported.riscv32.stderr index c6ff47283c6..a0e2901c759 100644 --- a/tests/ui/abi/unsupported.riscv32.stderr +++ b/tests/ui/abi/unsupported.riscv32.stderr @@ -1,5 +1,5 @@ warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:35:15 + --> $DIR/unsupported.rs:38:15 | LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,13 +9,13 @@ LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:40:1 + --> $DIR/unsupported.rs:43:1 | LL | extern "ptx-kernel" {} | ^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:51:17 + --> $DIR/unsupported.rs:50:17 | LL | fn aapcs_ptr(f: extern "aapcs" fn()) { | ^^^^^^^^^^^^^^^^^^^ @@ -24,13 +24,13 @@ LL | fn aapcs_ptr(f: extern "aapcs" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:64:1 + --> $DIR/unsupported.rs:55:1 | LL | extern "aapcs" {} | ^^^^^^^^^^^^^^^^^ warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:73:18 + --> $DIR/unsupported.rs:60:18 | LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -39,13 +39,13 @@ LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:78:1 + --> $DIR/unsupported.rs:65:1 | LL | extern "msp430-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:83:15 + --> $DIR/unsupported.rs:70:15 | LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -54,13 +54,13 @@ LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:88:1 + --> $DIR/unsupported.rs:75:1 | LL | extern "avr-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/unsupported.rs:118:15 + --> $DIR/unsupported.rs:90:15 | LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -69,13 +69,13 @@ LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:129:1 + --> $DIR/unsupported.rs:95:1 | LL | extern "x86-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:141:20 + --> $DIR/unsupported.rs:100:20 | LL | fn thiscall_ptr(f: extern "thiscall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^ @@ -84,13 +84,13 @@ LL | fn thiscall_ptr(f: extern "thiscall" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:154:1 + --> $DIR/unsupported.rs:105:1 | LL | extern "thiscall" {} | ^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "stdcall" is not supported on this target - --> $DIR/unsupported.rs:167:19 + --> $DIR/unsupported.rs:112:19 | LL | fn stdcall_ptr(f: extern "stdcall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^ @@ -99,13 +99,68 @@ LL | fn stdcall_ptr(f: extern "stdcall" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:180:1 + --> $DIR/unsupported.rs:117:1 | LL | extern "stdcall" {} | ^^^^^^^^^^^^^^^^^^^ + | + = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` + +error[E0570]: `"stdcall-unwind"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:121:1 + | +LL | extern "stdcall-unwind" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: if you need `extern "stdcall-unwind"` on win32 and `extern "C-unwind"` everywhere else, use `extern "system-unwind"` + +warning: the calling convention "cdecl" is not supported on this target + --> $DIR/unsupported.rs:129:17 + | +LL | fn cdecl_ptr(f: extern "cdecl" fn()) { + | ^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:134:1 + | +LL | extern "cdecl" {} + | ^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default + +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:137:1 + | +LL | extern "cdecl-unwind" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C-unwind"` instead + +warning: the calling convention "vectorcall" is not supported on this target + --> $DIR/unsupported.rs:143:22 + | +LL | fn vectorcall_ptr(f: extern "vectorcall" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + +error[E0570]: `"vectorcall"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:148:1 + | +LL | extern "vectorcall" {} + | ^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:187:21 + --> $DIR/unsupported.rs:151:21 | LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -114,7 +169,7 @@ LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:195:22 + --> $DIR/unsupported.rs:159:22 | LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -123,71 +178,89 @@ LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:200:1 + --> $DIR/unsupported.rs:164:1 | LL | extern "C-cmse-nonsecure-entry" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:33:1 + --> $DIR/unsupported.rs:36:1 | LL | extern "ptx-kernel" fn ptx() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:42:1 + --> $DIR/unsupported.rs:45:1 | LL | extern "gpu-kernel" fn gpu() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:45:1 + --> $DIR/unsupported.rs:48:1 | LL | extern "aapcs" fn aapcs() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:71:1 + --> $DIR/unsupported.rs:58:1 | LL | extern "msp430-interrupt" fn msp430() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:81:1 + --> $DIR/unsupported.rs:68:1 | LL | extern "avr-interrupt" fn avr() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:113:1 + --> $DIR/unsupported.rs:88:1 | LL | extern "x86-interrupt" fn x86() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:135:1 + --> $DIR/unsupported.rs:98:1 | LL | extern "thiscall" fn thiscall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:161:1 + --> $DIR/unsupported.rs:108:1 | LL | extern "stdcall" fn stdcall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` + +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:126:1 + | +LL | extern "cdecl" fn cdecl() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead + +error[E0570]: `"vectorcall"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:141:1 + | +LL | extern "vectorcall" fn vectorcall() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:193:1 + --> $DIR/unsupported.rs:157:1 | LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 17 previous errors; 9 warnings emitted +error: aborting due to 20 previous errors; 14 warnings emitted For more information about this error, try `rustc --explain E0570`. Future incompatibility report: Future breakage diagnostic: warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:35:15 + --> $DIR/unsupported.rs:38:15 | LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -198,7 +271,7 @@ LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { Future breakage diagnostic: warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:51:17 + --> $DIR/unsupported.rs:50:17 | LL | fn aapcs_ptr(f: extern "aapcs" fn()) { | ^^^^^^^^^^^^^^^^^^^ @@ -209,7 +282,7 @@ LL | fn aapcs_ptr(f: extern "aapcs" fn()) { Future breakage diagnostic: warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:73:18 + --> $DIR/unsupported.rs:60:18 | LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -220,7 +293,7 @@ LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { Future breakage diagnostic: warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:83:15 + --> $DIR/unsupported.rs:70:15 | LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -231,7 +304,7 @@ LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { Future breakage diagnostic: warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/unsupported.rs:118:15 + --> $DIR/unsupported.rs:90:15 | LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -242,7 +315,7 @@ LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { Future breakage diagnostic: warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:141:20 + --> $DIR/unsupported.rs:100:20 | LL | fn thiscall_ptr(f: extern "thiscall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^ @@ -253,7 +326,7 @@ LL | fn thiscall_ptr(f: extern "thiscall" fn()) { Future breakage diagnostic: warning: the calling convention "stdcall" is not supported on this target - --> $DIR/unsupported.rs:167:19 + --> $DIR/unsupported.rs:112:19 | LL | fn stdcall_ptr(f: extern "stdcall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^ @@ -263,8 +336,54 @@ LL | fn stdcall_ptr(f: extern "stdcall" fn()) { = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default Future breakage diagnostic: +warning: the calling convention "cdecl" is not supported on this target + --> $DIR/unsupported.rs:129:17 + | +LL | fn cdecl_ptr(f: extern "cdecl" fn()) { + | ^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:134:1 + | +LL | extern "cdecl" {} + | ^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:137:1 + | +LL | extern "cdecl-unwind" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C-unwind"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: the calling convention "vectorcall" is not supported on this target + --> $DIR/unsupported.rs:143:22 + | +LL | fn vectorcall_ptr(f: extern "vectorcall" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + +Future breakage diagnostic: warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:187:21 + --> $DIR/unsupported.rs:151:21 | LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -275,7 +394,7 @@ LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { Future breakage diagnostic: warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:195:22 + --> $DIR/unsupported.rs:159:22 | LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -284,3 +403,15 @@ LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default +Future breakage diagnostic: +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:126:1 + | +LL | extern "cdecl" fn cdecl() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default + diff --git a/tests/ui/abi/unsupported.riscv64.stderr b/tests/ui/abi/unsupported.riscv64.stderr index c6ff47283c6..a0e2901c759 100644 --- a/tests/ui/abi/unsupported.riscv64.stderr +++ b/tests/ui/abi/unsupported.riscv64.stderr @@ -1,5 +1,5 @@ warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:35:15 + --> $DIR/unsupported.rs:38:15 | LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,13 +9,13 @@ LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:40:1 + --> $DIR/unsupported.rs:43:1 | LL | extern "ptx-kernel" {} | ^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:51:17 + --> $DIR/unsupported.rs:50:17 | LL | fn aapcs_ptr(f: extern "aapcs" fn()) { | ^^^^^^^^^^^^^^^^^^^ @@ -24,13 +24,13 @@ LL | fn aapcs_ptr(f: extern "aapcs" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:64:1 + --> $DIR/unsupported.rs:55:1 | LL | extern "aapcs" {} | ^^^^^^^^^^^^^^^^^ warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:73:18 + --> $DIR/unsupported.rs:60:18 | LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -39,13 +39,13 @@ LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:78:1 + --> $DIR/unsupported.rs:65:1 | LL | extern "msp430-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:83:15 + --> $DIR/unsupported.rs:70:15 | LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -54,13 +54,13 @@ LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:88:1 + --> $DIR/unsupported.rs:75:1 | LL | extern "avr-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/unsupported.rs:118:15 + --> $DIR/unsupported.rs:90:15 | LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -69,13 +69,13 @@ LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:129:1 + --> $DIR/unsupported.rs:95:1 | LL | extern "x86-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:141:20 + --> $DIR/unsupported.rs:100:20 | LL | fn thiscall_ptr(f: extern "thiscall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^ @@ -84,13 +84,13 @@ LL | fn thiscall_ptr(f: extern "thiscall" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:154:1 + --> $DIR/unsupported.rs:105:1 | LL | extern "thiscall" {} | ^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "stdcall" is not supported on this target - --> $DIR/unsupported.rs:167:19 + --> $DIR/unsupported.rs:112:19 | LL | fn stdcall_ptr(f: extern "stdcall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^ @@ -99,13 +99,68 @@ LL | fn stdcall_ptr(f: extern "stdcall" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:180:1 + --> $DIR/unsupported.rs:117:1 | LL | extern "stdcall" {} | ^^^^^^^^^^^^^^^^^^^ + | + = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` + +error[E0570]: `"stdcall-unwind"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:121:1 + | +LL | extern "stdcall-unwind" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: if you need `extern "stdcall-unwind"` on win32 and `extern "C-unwind"` everywhere else, use `extern "system-unwind"` + +warning: the calling convention "cdecl" is not supported on this target + --> $DIR/unsupported.rs:129:17 + | +LL | fn cdecl_ptr(f: extern "cdecl" fn()) { + | ^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:134:1 + | +LL | extern "cdecl" {} + | ^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default + +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:137:1 + | +LL | extern "cdecl-unwind" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C-unwind"` instead + +warning: the calling convention "vectorcall" is not supported on this target + --> $DIR/unsupported.rs:143:22 + | +LL | fn vectorcall_ptr(f: extern "vectorcall" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + +error[E0570]: `"vectorcall"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:148:1 + | +LL | extern "vectorcall" {} + | ^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:187:21 + --> $DIR/unsupported.rs:151:21 | LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -114,7 +169,7 @@ LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:195:22 + --> $DIR/unsupported.rs:159:22 | LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -123,71 +178,89 @@ LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:200:1 + --> $DIR/unsupported.rs:164:1 | LL | extern "C-cmse-nonsecure-entry" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:33:1 + --> $DIR/unsupported.rs:36:1 | LL | extern "ptx-kernel" fn ptx() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:42:1 + --> $DIR/unsupported.rs:45:1 | LL | extern "gpu-kernel" fn gpu() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:45:1 + --> $DIR/unsupported.rs:48:1 | LL | extern "aapcs" fn aapcs() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:71:1 + --> $DIR/unsupported.rs:58:1 | LL | extern "msp430-interrupt" fn msp430() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:81:1 + --> $DIR/unsupported.rs:68:1 | LL | extern "avr-interrupt" fn avr() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:113:1 + --> $DIR/unsupported.rs:88:1 | LL | extern "x86-interrupt" fn x86() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:135:1 + --> $DIR/unsupported.rs:98:1 | LL | extern "thiscall" fn thiscall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:161:1 + --> $DIR/unsupported.rs:108:1 | LL | extern "stdcall" fn stdcall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` + +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:126:1 + | +LL | extern "cdecl" fn cdecl() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead + +error[E0570]: `"vectorcall"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:141:1 + | +LL | extern "vectorcall" fn vectorcall() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:193:1 + --> $DIR/unsupported.rs:157:1 | LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 17 previous errors; 9 warnings emitted +error: aborting due to 20 previous errors; 14 warnings emitted For more information about this error, try `rustc --explain E0570`. Future incompatibility report: Future breakage diagnostic: warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:35:15 + --> $DIR/unsupported.rs:38:15 | LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -198,7 +271,7 @@ LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { Future breakage diagnostic: warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:51:17 + --> $DIR/unsupported.rs:50:17 | LL | fn aapcs_ptr(f: extern "aapcs" fn()) { | ^^^^^^^^^^^^^^^^^^^ @@ -209,7 +282,7 @@ LL | fn aapcs_ptr(f: extern "aapcs" fn()) { Future breakage diagnostic: warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:73:18 + --> $DIR/unsupported.rs:60:18 | LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -220,7 +293,7 @@ LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { Future breakage diagnostic: warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:83:15 + --> $DIR/unsupported.rs:70:15 | LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -231,7 +304,7 @@ LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { Future breakage diagnostic: warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/unsupported.rs:118:15 + --> $DIR/unsupported.rs:90:15 | LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -242,7 +315,7 @@ LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { Future breakage diagnostic: warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:141:20 + --> $DIR/unsupported.rs:100:20 | LL | fn thiscall_ptr(f: extern "thiscall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^ @@ -253,7 +326,7 @@ LL | fn thiscall_ptr(f: extern "thiscall" fn()) { Future breakage diagnostic: warning: the calling convention "stdcall" is not supported on this target - --> $DIR/unsupported.rs:167:19 + --> $DIR/unsupported.rs:112:19 | LL | fn stdcall_ptr(f: extern "stdcall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^ @@ -263,8 +336,54 @@ LL | fn stdcall_ptr(f: extern "stdcall" fn()) { = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default Future breakage diagnostic: +warning: the calling convention "cdecl" is not supported on this target + --> $DIR/unsupported.rs:129:17 + | +LL | fn cdecl_ptr(f: extern "cdecl" fn()) { + | ^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:134:1 + | +LL | extern "cdecl" {} + | ^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:137:1 + | +LL | extern "cdecl-unwind" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C-unwind"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: the calling convention "vectorcall" is not supported on this target + --> $DIR/unsupported.rs:143:22 + | +LL | fn vectorcall_ptr(f: extern "vectorcall" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + +Future breakage diagnostic: warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:187:21 + --> $DIR/unsupported.rs:151:21 | LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -275,7 +394,7 @@ LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { Future breakage diagnostic: warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:195:22 + --> $DIR/unsupported.rs:159:22 | LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -284,3 +403,15 @@ LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default +Future breakage diagnostic: +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:126:1 + | +LL | extern "cdecl" fn cdecl() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default + diff --git a/tests/ui/abi/unsupported.rs b/tests/ui/abi/unsupported.rs index 84646502f6f..9ea22ca516b 100644 --- a/tests/ui/abi/unsupported.rs +++ b/tests/ui/abi/unsupported.rs @@ -1,8 +1,10 @@ //@ add-core-stubs -//@ revisions: x64 i686 aarch64 arm riscv32 riscv64 +//@ revisions: x64 x64_win i686 aarch64 arm riscv32 riscv64 // //@ [x64] needs-llvm-components: x86 //@ [x64] compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=rlib +//@ [x64_win] needs-llvm-components: x86 +//@ [x64_win] compile-flags: --target=x86_64-pc-windows-msvc --crate-type=rlib //@ [i686] needs-llvm-components: x86 //@ [i686] compile-flags: --target=i686-unknown-linux-gnu --crate-type=rlib //@ [aarch64] needs-llvm-components: aarch64 @@ -24,6 +26,7 @@ abi_x86_interrupt, abi_riscv_interrupt, abi_c_cmse_nonsecure_call, + abi_vectorcall, cmse_nonsecure_entry )] @@ -43,30 +46,14 @@ extern "gpu-kernel" fn gpu() {} //~^ ERROR is not a supported ABI extern "aapcs" fn aapcs() {} -//[x64]~^ ERROR is not a supported ABI -//[i686]~^^ ERROR is not a supported ABI -//[aarch64]~^^^ ERROR is not a supported ABI -//[riscv32]~^^^^ ERROR is not a supported ABI -//[riscv64]~^^^^^ ERROR is not a supported ABI +//[x64,x64_win,i686,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI fn aapcs_ptr(f: extern "aapcs" fn()) { - //[x64]~^ WARN unsupported_fn_ptr_calling_conventions - //[x64]~^^ WARN this was previously accepted - //[i686]~^^^ WARN unsupported_fn_ptr_calling_conventions - //[i686]~^^^^ WARN this was previously accepted - //[aarch64]~^^^^^ WARN unsupported_fn_ptr_calling_conventions - //[aarch64]~^^^^^^ WARN this was previously accepted - //[riscv32]~^^^^^^^ WARN unsupported_fn_ptr_calling_conventions - //[riscv32]~^^^^^^^^ WARN this was previously accepted - //[riscv64]~^^^^^^^^^ WARN unsupported_fn_ptr_calling_conventions - //[riscv64]~^^^^^^^^^^ WARN this was previously accepted + //[x64,x64_win,i686,aarch64,riscv32,riscv64]~^ WARN unsupported_fn_ptr_calling_conventions + //[x64,x64_win,i686,aarch64,riscv32,riscv64]~^^ WARN this was previously accepted f() } extern "aapcs" {} -//[x64]~^ ERROR is not a supported ABI -//[i686]~^^ ERROR is not a supported ABI -//[aarch64]~^^^ ERROR is not a supported ABI -//[riscv32]~^^^^ ERROR is not a supported ABI -//[riscv64]~^^^^^ ERROR is not a supported ABI +//[x64,x64_win,i686,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI extern "msp430-interrupt" fn msp430() {} //~^ ERROR is not a supported ABI @@ -89,100 +76,77 @@ extern "avr-interrupt" {} //~^ ERROR is not a supported ABI extern "riscv-interrupt-m" fn riscv() {} -//[arm]~^ ERROR is not a supported ABI -//[x64]~^^ ERROR is not a supported ABI -//[i686]~^^^ ERROR is not a supported ABI -//[aarch64]~^^^^ ERROR is not a supported ABI +//[x64,x64_win,i686,arm,aarch64]~^ ERROR is not a supported ABI fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { - //[arm]~^ WARN unsupported_fn_ptr_calling_conventions - //[arm]~^^ WARN this was previously accepted - //[x64]~^^^ WARN unsupported_fn_ptr_calling_conventions - //[x64]~^^^^ WARN this was previously accepted - //[i686]~^^^^^ WARN unsupported_fn_ptr_calling_conventions - //[i686]~^^^^^^ WARN this was previously accepted - //[aarch64]~^^^^^^^ WARN unsupported_fn_ptr_calling_conventions - //[aarch64]~^^^^^^^^ WARN this was previously accepted + //[x64,x64_win,i686,arm,aarch64]~^ WARN unsupported_fn_ptr_calling_conventions + //[x64,x64_win,i686,arm,aarch64]~^^ WARN this was previously accepted f() } extern "riscv-interrupt-m" {} -//[arm]~^ ERROR is not a supported ABI -//[x64]~^^ ERROR is not a supported ABI -//[i686]~^^^ ERROR is not a supported ABI -//[aarch64]~^^^^ ERROR is not a supported ABI +//[x64,x64_win,i686,arm,aarch64]~^ ERROR is not a supported ABI extern "x86-interrupt" fn x86() {} -//[aarch64]~^ ERROR is not a supported ABI -//[arm]~^^ ERROR is not a supported ABI -//[riscv32]~^^^ ERROR is not a supported ABI -//[riscv64]~^^^^ ERROR is not a supported ABI +//[aarch64,arm,riscv32,riscv64]~^ ERROR is not a supported ABI fn x86_ptr(f: extern "x86-interrupt" fn()) { - //[aarch64]~^ WARN unsupported_fn_ptr_calling_conventions - //[aarch64]~^^ WARN this was previously accepted - //[arm]~^^^ WARN unsupported_fn_ptr_calling_conventions - //[arm]~^^^^ WARN this was previously accepted - //[riscv32]~^^^^^ WARN unsupported_fn_ptr_calling_conventions - //[riscv32]~^^^^^^ WARN this was previously accepted - //[riscv64]~^^^^^^^ WARN unsupported_fn_ptr_calling_conventions - //[riscv64]~^^^^^^^^ WARN this was previously accepted + //[aarch64,arm,riscv32,riscv64]~^ WARN unsupported_fn_ptr_calling_conventions + //[aarch64,arm,riscv32,riscv64]~^^ WARN this was previously accepted f() } extern "x86-interrupt" {} -//[aarch64]~^ ERROR is not a supported ABI -//[arm]~^^ ERROR is not a supported ABI -//[riscv32]~^^^ ERROR is not a supported ABI -//[riscv64]~^^^^ ERROR is not a supported ABI +//[aarch64,arm,riscv32,riscv64]~^ ERROR is not a supported ABI extern "thiscall" fn thiscall() {} -//[x64]~^ ERROR is not a supported ABI -//[arm]~^^ ERROR is not a supported ABI -//[aarch64]~^^^ ERROR is not a supported ABI -//[riscv32]~^^^^ ERROR is not a supported ABI -//[riscv64]~^^^^^ ERROR is not a supported ABI +//[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI fn thiscall_ptr(f: extern "thiscall" fn()) { - //[x64]~^ WARN unsupported_fn_ptr_calling_conventions - //[x64]~^^ WARN this was previously accepted - //[arm]~^^^ WARN unsupported_fn_ptr_calling_conventions - //[arm]~^^^^ WARN this was previously accepted - //[aarch64]~^^^^^ WARN unsupported_fn_ptr_calling_conventions - //[aarch64]~^^^^^^ WARN this was previously accepted - //[riscv32]~^^^^^^^ WARN unsupported_fn_ptr_calling_conventions - //[riscv32]~^^^^^^^^ WARN this was previously accepted - //[riscv64]~^^^^^^^^^ WARN unsupported_fn_ptr_calling_conventions - //[riscv64]~^^^^^^^^^^ WARN this was previously accepted + //[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ WARN unsupported_fn_ptr_calling_conventions + //[x64,x64_win,arm,aarch64,riscv32,riscv64]~^^ WARN this was previously accepted f() } extern "thiscall" {} -//[x64]~^ ERROR is not a supported ABI -//[arm]~^^ ERROR is not a supported ABI -//[aarch64]~^^^ ERROR is not a supported ABI -//[riscv32]~^^^^ ERROR is not a supported ABI -//[riscv64]~^^^^^ ERROR is not a supported ABI +//[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI extern "stdcall" fn stdcall() {} -//[x64]~^ ERROR is not a supported ABI -//[arm]~^^ ERROR is not a supported ABI -//[aarch64]~^^^ ERROR is not a supported ABI -//[riscv32]~^^^^ ERROR is not a supported ABI -//[riscv64]~^^^^^ ERROR is not a supported ABI +//[x64,arm,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI +//[x64_win]~^^ WARN unsupported_calling_conventions +//[x64_win]~^^^ WARN this was previously accepted fn stdcall_ptr(f: extern "stdcall" fn()) { - //[x64]~^ WARN unsupported_fn_ptr_calling_conventions - //[x64]~^^ WARN this was previously accepted - //[arm]~^^^ WARN unsupported_fn_ptr_calling_conventions - //[arm]~^^^^ WARN this was previously accepted - //[aarch64]~^^^^^ WARN unsupported_fn_ptr_calling_conventions - //[aarch64]~^^^^^^ WARN this was previously accepted - //[riscv32]~^^^^^^^ WARN unsupported_fn_ptr_calling_conventions - //[riscv32]~^^^^^^^^ WARN this was previously accepted - //[riscv64]~^^^^^^^^^ WARN unsupported_fn_ptr_calling_conventions - //[riscv64]~^^^^^^^^^^ WARN this was previously accepted + //[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ WARN unsupported_fn_ptr_calling_conventions + //[x64,x64_win,arm,aarch64,riscv32,riscv64]~^^ WARN this was previously accepted f() } extern "stdcall" {} -//[x64]~^ ERROR is not a supported ABI -//[arm]~^^ ERROR is not a supported ABI -//[aarch64]~^^^ ERROR is not a supported ABI -//[riscv32]~^^^^ ERROR is not a supported ABI -//[riscv64]~^^^^^ ERROR is not a supported ABI +//[x64,arm,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI +//[x64_win]~^^ WARN unsupported_calling_conventions +//[x64_win]~^^^ WARN this was previously accepted +extern "stdcall-unwind" {} +//[x64,arm,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI +//[x64_win]~^^ WARN unsupported_calling_conventions +//[x64_win]~^^^ WARN this was previously accepted + +extern "cdecl" fn cdecl() {} +//[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ WARN unsupported_calling_conventions +//[x64,x64_win,arm,aarch64,riscv32,riscv64]~^^ WARN this was previously accepted +fn cdecl_ptr(f: extern "cdecl" fn()) { + //[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ WARN unsupported_fn_ptr_calling_conventions + //[x64,x64_win,arm,aarch64,riscv32,riscv64]~^^ WARN this was previously accepted + f() +} +extern "cdecl" {} +//[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ WARN unsupported_calling_conventions +//[x64,x64_win,arm,aarch64,riscv32,riscv64]~^^ WARN this was previously accepted +extern "cdecl-unwind" {} +//[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ WARN unsupported_calling_conventions +//[x64,x64_win,arm,aarch64,riscv32,riscv64]~^^ WARN this was previously accepted + +extern "vectorcall" fn vectorcall() {} +//[arm,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI +fn vectorcall_ptr(f: extern "vectorcall" fn()) { + //[arm,aarch64,riscv32,riscv64]~^ WARN unsupported_fn_ptr_calling_conventions + //[arm,aarch64,riscv32,riscv64]~^^ WARN this was previously accepted + f() +} +extern "vectorcall" {} +//[arm,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { //~^ WARN unsupported_fn_ptr_calling_conventions @@ -199,3 +163,9 @@ fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { } extern "C-cmse-nonsecure-entry" {} //~^ ERROR is not a supported ABI + +#[cfg(windows)] +#[link(name = "foo", kind = "raw-dylib")] +extern "cdecl" {} +//[x64_win]~^ WARN use of calling convention not supported on this target +//[x64_win]~^^ WARN this was previously accepted diff --git a/tests/ui/abi/unsupported.x64.stderr b/tests/ui/abi/unsupported.x64.stderr index 0a9f9a69123..732a5f84f50 100644 --- a/tests/ui/abi/unsupported.x64.stderr +++ b/tests/ui/abi/unsupported.x64.stderr @@ -1,5 +1,5 @@ warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:35:15 + --> $DIR/unsupported.rs:38:15 | LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,13 +9,13 @@ LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:40:1 + --> $DIR/unsupported.rs:43:1 | LL | extern "ptx-kernel" {} | ^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:51:17 + --> $DIR/unsupported.rs:50:17 | LL | fn aapcs_ptr(f: extern "aapcs" fn()) { | ^^^^^^^^^^^^^^^^^^^ @@ -24,13 +24,13 @@ LL | fn aapcs_ptr(f: extern "aapcs" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:64:1 + --> $DIR/unsupported.rs:55:1 | LL | extern "aapcs" {} | ^^^^^^^^^^^^^^^^^ warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:73:18 + --> $DIR/unsupported.rs:60:18 | LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -39,13 +39,13 @@ LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:78:1 + --> $DIR/unsupported.rs:65:1 | LL | extern "msp430-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:83:15 + --> $DIR/unsupported.rs:70:15 | LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -54,13 +54,13 @@ LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:88:1 + --> $DIR/unsupported.rs:75:1 | LL | extern "avr-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/unsupported.rs:96:17 + --> $DIR/unsupported.rs:80:17 | LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -69,13 +69,13 @@ LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:107:1 + --> $DIR/unsupported.rs:85:1 | LL | extern "riscv-interrupt-m" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:141:20 + --> $DIR/unsupported.rs:100:20 | LL | fn thiscall_ptr(f: extern "thiscall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^ @@ -84,13 +84,13 @@ LL | fn thiscall_ptr(f: extern "thiscall" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:154:1 + --> $DIR/unsupported.rs:105:1 | LL | extern "thiscall" {} | ^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "stdcall" is not supported on this target - --> $DIR/unsupported.rs:167:19 + --> $DIR/unsupported.rs:112:19 | LL | fn stdcall_ptr(f: extern "stdcall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^ @@ -99,13 +99,53 @@ LL | fn stdcall_ptr(f: extern "stdcall" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:180:1 + --> $DIR/unsupported.rs:117:1 | LL | extern "stdcall" {} | ^^^^^^^^^^^^^^^^^^^ + | + = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` + +error[E0570]: `"stdcall-unwind"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:121:1 + | +LL | extern "stdcall-unwind" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: if you need `extern "stdcall-unwind"` on win32 and `extern "C-unwind"` everywhere else, use `extern "system-unwind"` + +warning: the calling convention "cdecl" is not supported on this target + --> $DIR/unsupported.rs:129:17 + | +LL | fn cdecl_ptr(f: extern "cdecl" fn()) { + | ^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:134:1 + | +LL | extern "cdecl" {} + | ^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default + +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:137:1 + | +LL | extern "cdecl-unwind" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C-unwind"` instead warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:187:21 + --> $DIR/unsupported.rs:151:21 | LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -114,7 +154,7 @@ LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:195:22 + --> $DIR/unsupported.rs:159:22 | LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -123,71 +163,83 @@ LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:200:1 + --> $DIR/unsupported.rs:164:1 | LL | extern "C-cmse-nonsecure-entry" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:33:1 + --> $DIR/unsupported.rs:36:1 | LL | extern "ptx-kernel" fn ptx() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:42:1 + --> $DIR/unsupported.rs:45:1 | LL | extern "gpu-kernel" fn gpu() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:45:1 + --> $DIR/unsupported.rs:48:1 | LL | extern "aapcs" fn aapcs() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:71:1 + --> $DIR/unsupported.rs:58:1 | LL | extern "msp430-interrupt" fn msp430() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:81:1 + --> $DIR/unsupported.rs:68:1 | LL | extern "avr-interrupt" fn avr() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:91:1 + --> $DIR/unsupported.rs:78:1 | LL | extern "riscv-interrupt-m" fn riscv() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:135:1 + --> $DIR/unsupported.rs:98:1 | LL | extern "thiscall" fn thiscall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:161:1 + --> $DIR/unsupported.rs:108:1 | LL | extern "stdcall" fn stdcall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` + +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:126:1 + | +LL | extern "cdecl" fn cdecl() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:193:1 + --> $DIR/unsupported.rs:157:1 | LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 17 previous errors; 9 warnings emitted +error: aborting due to 18 previous errors; 13 warnings emitted For more information about this error, try `rustc --explain E0570`. Future incompatibility report: Future breakage diagnostic: warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:35:15 + --> $DIR/unsupported.rs:38:15 | LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -198,7 +250,7 @@ LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { Future breakage diagnostic: warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:51:17 + --> $DIR/unsupported.rs:50:17 | LL | fn aapcs_ptr(f: extern "aapcs" fn()) { | ^^^^^^^^^^^^^^^^^^^ @@ -209,7 +261,7 @@ LL | fn aapcs_ptr(f: extern "aapcs" fn()) { Future breakage diagnostic: warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:73:18 + --> $DIR/unsupported.rs:60:18 | LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -220,7 +272,7 @@ LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { Future breakage diagnostic: warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:83:15 + --> $DIR/unsupported.rs:70:15 | LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -231,7 +283,7 @@ LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { Future breakage diagnostic: warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/unsupported.rs:96:17 + --> $DIR/unsupported.rs:80:17 | LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -242,7 +294,7 @@ LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { Future breakage diagnostic: warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:141:20 + --> $DIR/unsupported.rs:100:20 | LL | fn thiscall_ptr(f: extern "thiscall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^ @@ -253,7 +305,7 @@ LL | fn thiscall_ptr(f: extern "thiscall" fn()) { Future breakage diagnostic: warning: the calling convention "stdcall" is not supported on this target - --> $DIR/unsupported.rs:167:19 + --> $DIR/unsupported.rs:112:19 | LL | fn stdcall_ptr(f: extern "stdcall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^ @@ -263,8 +315,43 @@ LL | fn stdcall_ptr(f: extern "stdcall" fn()) { = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default Future breakage diagnostic: +warning: the calling convention "cdecl" is not supported on this target + --> $DIR/unsupported.rs:129:17 + | +LL | fn cdecl_ptr(f: extern "cdecl" fn()) { + | ^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:134:1 + | +LL | extern "cdecl" {} + | ^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:137:1 + | +LL | extern "cdecl-unwind" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C-unwind"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default + +Future breakage diagnostic: warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:187:21 + --> $DIR/unsupported.rs:151:21 | LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -275,7 +362,7 @@ LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { Future breakage diagnostic: warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:195:22 + --> $DIR/unsupported.rs:159:22 | LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -284,3 +371,15 @@ LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default +Future breakage diagnostic: +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:126:1 + | +LL | extern "cdecl" fn cdecl() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default + diff --git a/tests/ui/abi/unsupported.x64_win.stderr b/tests/ui/abi/unsupported.x64_win.stderr new file mode 100644 index 00000000000..5597440d5d9 --- /dev/null +++ b/tests/ui/abi/unsupported.x64_win.stderr @@ -0,0 +1,449 @@ +warning: the calling convention "ptx-kernel" is not supported on this target + --> $DIR/unsupported.rs:38:15 + | +LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + +error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:43:1 + | +LL | extern "ptx-kernel" {} + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: the calling convention "aapcs" is not supported on this target + --> $DIR/unsupported.rs:50:17 + | +LL | fn aapcs_ptr(f: extern "aapcs" fn()) { + | ^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + +error[E0570]: `"aapcs"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:55:1 + | +LL | extern "aapcs" {} + | ^^^^^^^^^^^^^^^^^ + +warning: the calling convention "msp430-interrupt" is not supported on this target + --> $DIR/unsupported.rs:60:18 + | +LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + +error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:65:1 + | +LL | extern "msp430-interrupt" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: the calling convention "avr-interrupt" is not supported on this target + --> $DIR/unsupported.rs:70:15 + | +LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + +error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:75:1 + | +LL | extern "avr-interrupt" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: the calling convention "riscv-interrupt-m" is not supported on this target + --> $DIR/unsupported.rs:80:17 + | +LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + +error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:85:1 + | +LL | extern "riscv-interrupt-m" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: the calling convention "thiscall" is not supported on this target + --> $DIR/unsupported.rs:100:20 + | +LL | fn thiscall_ptr(f: extern "thiscall" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + +error[E0570]: `"thiscall"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:105:1 + | +LL | extern "thiscall" {} + | ^^^^^^^^^^^^^^^^^^^^ + +warning: the calling convention "stdcall" is not supported on this target + --> $DIR/unsupported.rs:112:19 + | +LL | fn stdcall_ptr(f: extern "stdcall" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:117:1 + | +LL | extern "stdcall" {} + | ^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` + = note: `#[warn(unsupported_calling_conventions)]` on by default + +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:121:1 + | +LL | extern "stdcall-unwind" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: if you need `extern "stdcall-unwind"` on win32 and `extern "C-unwind"` everywhere else, use `extern "system-unwind"` + +warning: the calling convention "cdecl" is not supported on this target + --> $DIR/unsupported.rs:129:17 + | +LL | fn cdecl_ptr(f: extern "cdecl" fn()) { + | ^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:134:1 + | +LL | extern "cdecl" {} + | ^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead + +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:137:1 + | +LL | extern "cdecl-unwind" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C-unwind"` instead + +warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target + --> $DIR/unsupported.rs:151:21 + | +LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + +warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target + --> $DIR/unsupported.rs:159:22 + | +LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + +error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:164:1 + | +LL | extern "C-cmse-nonsecure-entry" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:169:1 + | +LL | extern "cdecl" {} + | ^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead + +error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:36:1 + | +LL | extern "ptx-kernel" fn ptx() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:45:1 + | +LL | extern "gpu-kernel" fn gpu() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: `"aapcs"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:48:1 + | +LL | extern "aapcs" fn aapcs() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:58:1 + | +LL | extern "msp430-interrupt" fn msp430() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:68:1 + | +LL | extern "avr-interrupt" fn avr() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:78:1 + | +LL | extern "riscv-interrupt-m" fn riscv() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: `"thiscall"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:98:1 + | +LL | extern "thiscall" fn thiscall() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:108:1 + | +LL | extern "stdcall" fn stdcall() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` + +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:126:1 + | +LL | extern "cdecl" fn cdecl() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead + +error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target + --> $DIR/unsupported.rs:157:1 + | +LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 15 previous errors; 17 warnings emitted + +For more information about this error, try `rustc --explain E0570`. +Future incompatibility report: Future breakage diagnostic: +warning: the calling convention "ptx-kernel" is not supported on this target + --> $DIR/unsupported.rs:38:15 + | +LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: the calling convention "aapcs" is not supported on this target + --> $DIR/unsupported.rs:50:17 + | +LL | fn aapcs_ptr(f: extern "aapcs" fn()) { + | ^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: the calling convention "msp430-interrupt" is not supported on this target + --> $DIR/unsupported.rs:60:18 + | +LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: the calling convention "avr-interrupt" is not supported on this target + --> $DIR/unsupported.rs:70:15 + | +LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: the calling convention "riscv-interrupt-m" is not supported on this target + --> $DIR/unsupported.rs:80:17 + | +LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: the calling convention "thiscall" is not supported on this target + --> $DIR/unsupported.rs:100:20 + | +LL | fn thiscall_ptr(f: extern "thiscall" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: the calling convention "stdcall" is not supported on this target + --> $DIR/unsupported.rs:112:19 + | +LL | fn stdcall_ptr(f: extern "stdcall" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:117:1 + | +LL | extern "stdcall" {} + | ^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` + = note: `#[warn(unsupported_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:121:1 + | +LL | extern "stdcall-unwind" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: if you need `extern "stdcall-unwind"` on win32 and `extern "C-unwind"` everywhere else, use `extern "system-unwind"` + = note: `#[warn(unsupported_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: the calling convention "cdecl" is not supported on this target + --> $DIR/unsupported.rs:129:17 + | +LL | fn cdecl_ptr(f: extern "cdecl" fn()) { + | ^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:134:1 + | +LL | extern "cdecl" {} + | ^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:137:1 + | +LL | extern "cdecl-unwind" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C-unwind"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target + --> $DIR/unsupported.rs:151:21 + | +LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target + --> $DIR/unsupported.rs:159:22 + | +LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #130260 <https://github.com/rust-lang/rust/issues/130260> + = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:169:1 + | +LL | extern "cdecl" {} + | ^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:108:1 + | +LL | extern "stdcall" fn stdcall() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` + = note: `#[warn(unsupported_calling_conventions)]` on by default + +Future breakage diagnostic: +warning: use of calling convention not supported on this target + --> $DIR/unsupported.rs:126:1 + | +LL | extern "cdecl" fn cdecl() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default + diff --git a/tests/ui/allocator/auxiliary/helper.rs b/tests/ui/allocator/auxiliary/helper.rs index c638546a947..4267b901ca0 100644 --- a/tests/ui/allocator/auxiliary/helper.rs +++ b/tests/ui/allocator/auxiliary/helper.rs @@ -6,6 +6,6 @@ extern crate alloc; use alloc::fmt; -pub fn work_with(p: &fmt::Debug) { +pub fn work_with(p: &dyn fmt::Debug) { drop(p); } diff --git a/tests/ui/array-slice-vec/array_const_index-0.rs b/tests/ui/array-slice-vec/array_const_index-0.rs index f4fe89a50c2..aef07d952fa 100644 --- a/tests/ui/array-slice-vec/array_const_index-0.rs +++ b/tests/ui/array-slice-vec/array_const_index-0.rs @@ -1,7 +1,6 @@ const A: &'static [i32] = &[]; const B: i32 = (&A)[1]; -//~^ NOTE index out of bounds: the length is 0 but the index is 1 -//~| ERROR evaluation of constant value failed +//~^ ERROR index out of bounds: the length is 0 but the index is 1 fn main() { let _ = B; diff --git a/tests/ui/array-slice-vec/array_const_index-0.stderr b/tests/ui/array-slice-vec/array_const_index-0.stderr index d16e8d50dfd..04cb6849663 100644 --- a/tests/ui/array-slice-vec/array_const_index-0.stderr +++ b/tests/ui/array-slice-vec/array_const_index-0.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: index out of bounds: the length is 0 but the index is 1 --> $DIR/array_const_index-0.rs:2:16 | LL | const B: i32 = (&A)[1]; - | ^^^^^^^ index out of bounds: the length is 0 but the index is 1 + | ^^^^^^^ evaluation of `B` failed here error: aborting due to 1 previous error diff --git a/tests/ui/array-slice-vec/array_const_index-1.rs b/tests/ui/array-slice-vec/array_const_index-1.rs index 0d4de137a6e..4adbd157ed0 100644 --- a/tests/ui/array-slice-vec/array_const_index-1.rs +++ b/tests/ui/array-slice-vec/array_const_index-1.rs @@ -1,7 +1,6 @@ const A: [i32; 0] = []; const B: i32 = A[1]; -//~^ NOTE index out of bounds: the length is 0 but the index is 1 -//~| ERROR evaluation of constant value failed +//~^ ERROR index out of bounds: the length is 0 but the index is 1 fn main() { let _ = B; diff --git a/tests/ui/array-slice-vec/array_const_index-1.stderr b/tests/ui/array-slice-vec/array_const_index-1.stderr index f9ba2f13911..68b02673b01 100644 --- a/tests/ui/array-slice-vec/array_const_index-1.stderr +++ b/tests/ui/array-slice-vec/array_const_index-1.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: index out of bounds: the length is 0 but the index is 1 --> $DIR/array_const_index-1.rs:2:16 | LL | const B: i32 = A[1]; - | ^^^^ index out of bounds: the length is 0 but the index is 1 + | ^^^^ evaluation of `B` failed here error: aborting due to 1 previous error diff --git a/tests/ui/asm/cfg-parse-error.rs b/tests/ui/asm/cfg-parse-error.rs new file mode 100644 index 00000000000..9b79d16a76d --- /dev/null +++ b/tests/ui/asm/cfg-parse-error.rs @@ -0,0 +1,57 @@ +//@ needs-asm-support +#![feature(asm_cfg)] + +use std::arch::asm; + +fn main() { + unsafe { + asm!( + "", + #[cfg(false)] + clobber_abi("C"), + #[cfg(false)] + options(att_syntax), + #[cfg(false)] + a = out(reg) x, + "", + //~^ ERROR expected one of `#`, `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `label`, `lateout`, `options`, `out`, or `sym`, found `""` + ); + asm!( + #[cfg(false)] + "", + #[cfg(false)] + const { + 5 + }, + "", + //~^ ERROR expected one of `#`, `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `label`, `lateout`, `options`, `out`, or `sym`, found `""` + ); + + asm!( + #[cfg_attr(true, cfg(false))] + const { + 5 + }, + "", + ); + + // This is not accepted because `a = out(reg) x` is not a valid expression. + asm!( + #[cfg(false)] + a = out(reg) x, //~ ERROR expected token: `,` + "", + ); + + // For now, any non-cfg attributes are rejected + asm!( + #[rustfmt::skip] //~ ERROR this attribute is not supported on assembly + "", + ); + + // For now, any non-cfg attributes are rejected + asm!( + #![rustfmt::skip] //~ ERROR an inner attribute is not permitted in this context + "", + ); + } +} diff --git a/tests/ui/asm/cfg-parse-error.stderr b/tests/ui/asm/cfg-parse-error.stderr new file mode 100644 index 00000000000..8a70d39a43d --- /dev/null +++ b/tests/ui/asm/cfg-parse-error.stderr @@ -0,0 +1,39 @@ +error: expected one of `#`, `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `label`, `lateout`, `options`, `out`, or `sym`, found `""` + --> $DIR/cfg-parse-error.rs:16:13 + | +LL | a = out(reg) x, + | - expected one of 11 possible tokens +LL | "", + | ^^ unexpected token + +error: expected one of `#`, `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `label`, `lateout`, `options`, `out`, or `sym`, found `""` + --> $DIR/cfg-parse-error.rs:26:13 + | +LL | }, + | - expected one of 11 possible tokens +LL | "", + | ^^ unexpected token + +error: expected token: `,` + --> $DIR/cfg-parse-error.rs:41:26 + | +LL | a = out(reg) x, + | ^ expected `,` + +error: this attribute is not supported on assembly + --> $DIR/cfg-parse-error.rs:47:13 + | +LL | #[rustfmt::skip] + | ^^^^^^^^^^^^^^^^ + +error: an inner attribute is not permitted in this context + --> $DIR/cfg-parse-error.rs:53:13 + | +LL | #![rustfmt::skip] + | ^^^^^^^^^^^^^^^^^ + | + = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files + = note: outer attributes, like `#[test]`, annotate the item following them + +error: aborting due to 5 previous errors + diff --git a/tests/ui/asm/cfg.rs b/tests/ui/asm/cfg.rs new file mode 100644 index 00000000000..bcf86340b9d --- /dev/null +++ b/tests/ui/asm/cfg.rs @@ -0,0 +1,125 @@ +// Check that `cfg` and `cfg_attr` work as expected. +// +//@ revisions: reva revb +//@ only-x86_64 +//@ run-pass +#![feature(asm_cfg, cfg_select)] + +use std::arch::{asm, naked_asm}; + +#[unsafe(naked)] +extern "C" fn ignore_const_operand() -> u64 { + naked_asm!( + "mov rax, 5", + #[cfg(revb)] + "mov rax, {a}", + "ret", + #[cfg(revb)] + a = const 10, + ) +} + +#[unsafe(naked)] +extern "C" fn ignore_const_operand_cfg_attr() -> u64 { + naked_asm!( + "mov rax, 5", + #[cfg_attr(true, cfg(revb))] + "mov rax, {a}", + "ret", + #[cfg_attr(true, cfg(revb))] + a = const 10, + ) +} + +#[unsafe(naked)] +extern "C" fn const_operand() -> u64 { + naked_asm!( + "mov rax, {a}", + "ret", + #[cfg(reva)] + a = const 5, + #[cfg(revb)] + a = const 10, + ) +} + +fn options() { + // Without the cfg, this throws an error that the `att_syntax` option is provided twice. + unsafe { + asm!( + "nop", + #[cfg(false)] + options(att_syntax), + options(att_syntax) + ) + } +} + +fn clobber_abi() { + // Without the cfg, this throws an error that the "C" abi is provided twice. + unsafe { + asm!( + "nop", + #[cfg(false)] + clobber_abi("C"), + clobber_abi("C"), + ); + } +} + +#[unsafe(naked)] +extern "C" fn first_template() -> u64 { + naked_asm!( + #[cfg(reva)] + "mov rax, 5", + #[cfg(revb)] + "mov rax, 10", + "ret", + ) +} + +#[unsafe(naked)] +extern "C" fn true_and_false() -> u64 { + naked_asm!( + "mov rax, 5", + #[cfg(true)] + #[cfg(false)] + "mov rax, 10", + "ret", + ) +} + +#[unsafe(naked)] +extern "C" fn false_and_true() -> u64 { + naked_asm!( + "mov rax, 5", + #[cfg(false)] + #[cfg(true)] + "mov rax, 10", + "ret", + ) +} + +pub fn main() { + std::cfg_select! { + reva => { + assert_eq!(const_operand(), 5); + assert_eq!(ignore_const_operand_cfg_attr(), 5); + assert_eq!(ignore_const_operand(), 5); + assert_eq!(first_template(), 5); + + } + revb => { + assert_eq!(const_operand(), 10); + assert_eq!(ignore_const_operand_cfg_attr(), 10); + assert_eq!(ignore_const_operand(), 10); + assert_eq!(first_template(), 10); + + } + } + options(); + clobber_abi(); + + assert_eq!(true_and_false(), 5); + assert_eq!(false_and_true(), 5); +} diff --git a/tests/ui/asm/fail-const-eval-issue-121099.stderr b/tests/ui/asm/fail-const-eval-issue-121099.stderr index eb662dadffb..7e2718c9eac 100644 --- a/tests/ui/asm/fail-const-eval-issue-121099.stderr +++ b/tests/ui/asm/fail-const-eval-issue-121099.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of `{global_asm#0}::{constant#0}` failed +error[E0080]: attempt to shift left by `500_i32`, which would overflow --> $DIR/fail-const-eval-issue-121099.rs:8:31 | LL | global_asm!("/* {} */", const 1 << 500); - | ^^^^^^^^ attempt to shift left by `500_i32`, which would overflow + | ^^^^^^^^ evaluation of `{global_asm#0}::{constant#0}` failed here -error[E0080]: evaluation of `{global_asm#1}::{constant#0}` failed +error[E0080]: attempt to divide `1_i32` by zero --> $DIR/fail-const-eval-issue-121099.rs:10:31 | LL | global_asm!("/* {} */", const 1 / 0); - | ^^^^^ attempt to divide `1_i32` by zero + | ^^^^^ evaluation of `{global_asm#1}::{constant#0}` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/asm/naked-functions-ffi.rs b/tests/ui/asm/naked-functions-ffi.rs index 565c440022d..4ba5ccc57f6 100644 --- a/tests/ui/asm/naked-functions-ffi.rs +++ b/tests/ui/asm/naked-functions-ffi.rs @@ -7,6 +7,5 @@ use std::arch::naked_asm; #[unsafe(naked)] pub extern "C" fn naked(p: char) -> u128 { //~^ WARN uses type `char` - //~| WARN uses type `u128` naked_asm!("") } diff --git a/tests/ui/asm/naked-functions-ffi.stderr b/tests/ui/asm/naked-functions-ffi.stderr index 9df6185498e..f7893a3b8de 100644 --- a/tests/ui/asm/naked-functions-ffi.stderr +++ b/tests/ui/asm/naked-functions-ffi.stderr @@ -8,13 +8,5 @@ LL | pub extern "C" fn naked(p: char) -> u128 { = note: the `char` type has no C equivalent = note: `#[warn(improper_ctypes_definitions)]` on by default -warning: `extern` fn uses type `u128`, which is not FFI-safe - --> $DIR/naked-functions-ffi.rs:8:37 - | -LL | pub extern "C" fn naked(p: char) -> u128 { - | ^^^^ not FFI-safe - | - = note: 128-bit integers don't currently have a known stable ABI - -warning: 2 warnings emitted +warning: 1 warning emitted diff --git a/tests/ui/asm/parse-error.stderr b/tests/ui/asm/parse-error.stderr index 0bba1fd8d9b..dff85a601b7 100644 --- a/tests/ui/asm/parse-error.stderr +++ b/tests/ui/asm/parse-error.stderr @@ -176,17 +176,17 @@ LL | asm!("{a}", a = const foo, a = const bar); | = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"` -error: expected one of `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `label`, `lateout`, `options`, `out`, or `sym`, found `""` +error: expected one of `#`, `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `label`, `lateout`, `options`, `out`, or `sym`, found `""` --> $DIR/parse-error.rs:80:29 | LL | asm!("", options(), ""); - | ^^ expected one of 10 possible tokens + | ^^ expected one of 11 possible tokens -error: expected one of `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `label`, `lateout`, `options`, `out`, or `sym`, found `"{}"` +error: expected one of `#`, `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `label`, `lateout`, `options`, `out`, or `sym`, found `"{}"` --> $DIR/parse-error.rs:82:33 | LL | asm!("{}", in(reg) foo, "{}", out(reg) foo); - | ^^^^ expected one of 10 possible tokens + | ^^^^ expected one of 11 possible tokens error: asm template must be a string literal --> $DIR/parse-error.rs:84:14 @@ -340,17 +340,17 @@ LL | global_asm!("{a}", a = const FOO, a = const BAR); | = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"` -error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `""` +error: expected one of `#`, `clobber_abi`, `const`, `options`, or `sym`, found `""` --> $DIR/parse-error.rs:137:28 | LL | global_asm!("", options(), ""); - | ^^ expected one of `clobber_abi`, `const`, `options`, or `sym` + | ^^ expected one of `#`, `clobber_abi`, `const`, `options`, or `sym` -error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `"{}"` +error: expected one of `#`, `clobber_abi`, `const`, `options`, or `sym`, found `"{}"` --> $DIR/parse-error.rs:139:30 | LL | global_asm!("{}", const FOO, "{}", const FOO); - | ^^^^ expected one of `clobber_abi`, `const`, `options`, or `sym` + | ^^^^ expected one of `#`, `clobber_abi`, `const`, `options`, or `sym` error: asm template must be a string literal --> $DIR/parse-error.rs:141:13 diff --git a/tests/ui/asm/x86_64/evex512-implicit-feature.rs b/tests/ui/asm/x86_64/evex512-implicit-feature.rs index ec5da7c7fa4..1f678b2387a 100644 --- a/tests/ui/asm/x86_64/evex512-implicit-feature.rs +++ b/tests/ui/asm/x86_64/evex512-implicit-feature.rs @@ -2,8 +2,6 @@ //@ only-x86_64 //@ compile-flags: --crate-type=lib -C target-cpu=skylake -#![feature(stdarch_x86_avx512)] - use std::arch::x86_64::*; #[target_feature(enable = "avx512f")] diff --git a/tests/ui/associated-consts/associated-const-type-parameter-pattern.stderr b/tests/ui/associated-consts/associated-const-type-parameter-pattern.stderr index a8256f775a6..19b63a041d6 100644 --- a/tests/ui/associated-consts/associated-const-type-parameter-pattern.stderr +++ b/tests/ui/associated-consts/associated-const-type-parameter-pattern.stderr @@ -27,7 +27,7 @@ LL | B::X => println!("B::X"), | ^^^^ `const` depends on a generic parameter error[E0158]: constant pattern cannot depend on generic parameters - --> $DIR/associated-const-type-parameter-pattern.rs:30:9 + --> $DIR/associated-const-type-parameter-pattern.rs:28:48 | LL | pub trait Foo { | ------------- @@ -35,13 +35,12 @@ LL | const X: EFoo; | ------------- constant defined here ... LL | pub fn test_let_pat<A: Foo, B: Foo>(arg: EFoo, A::X: EFoo) { - | - constant depends on this generic parameter -LL | -LL | let A::X = arg; - | ^^^^ `const` depends on a generic parameter + | - ^^^^ `const` depends on a generic parameter + | | + | constant depends on this generic parameter error[E0158]: constant pattern cannot depend on generic parameters - --> $DIR/associated-const-type-parameter-pattern.rs:28:48 + --> $DIR/associated-const-type-parameter-pattern.rs:30:9 | LL | pub trait Foo { | ------------- @@ -49,9 +48,10 @@ LL | const X: EFoo; | ------------- constant defined here ... LL | pub fn test_let_pat<A: Foo, B: Foo>(arg: EFoo, A::X: EFoo) { - | - ^^^^ `const` depends on a generic parameter - | | - | constant depends on this generic parameter + | - constant depends on this generic parameter +LL | +LL | let A::X = arg; + | ^^^^ `const` depends on a generic parameter error: aborting due to 4 previous errors diff --git a/tests/ui/associated-consts/defaults-not-assumed-fail.rs b/tests/ui/associated-consts/defaults-not-assumed-fail.rs index 830fd4ab0e9..e63424e13e3 100644 --- a/tests/ui/associated-consts/defaults-not-assumed-fail.rs +++ b/tests/ui/associated-consts/defaults-not-assumed-fail.rs @@ -7,7 +7,7 @@ trait Tr { // This should not be a constant evaluation error (overflow). The value of // `Self::A` must not be assumed to hold inside the trait. const B: u8 = Self::A + 1; - //~^ ERROR evaluation of `<() as Tr>::B` failed + //~^ ERROR overflow } // An impl that doesn't override any constant will NOT cause a const eval error diff --git a/tests/ui/associated-consts/defaults-not-assumed-fail.stderr b/tests/ui/associated-consts/defaults-not-assumed-fail.stderr index 3386e81dc98..40f5f889f36 100644 --- a/tests/ui/associated-consts/defaults-not-assumed-fail.stderr +++ b/tests/ui/associated-consts/defaults-not-assumed-fail.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `<() as Tr>::B` failed +error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow --> $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 + | ^^^^^^^^^^^ evaluation of `<() as Tr>::B` failed here note: erroneous constant encountered --> $DIR/defaults-not-assumed-fail.rs:34:16 diff --git a/tests/ui/associated-inherent-types/issue-109299-1.stderr b/tests/ui/associated-inherent-types/issue-109299-1.stderr index 940ccd7e400..6bc7a539680 100644 --- a/tests/ui/associated-inherent-types/issue-109299-1.stderr +++ b/tests/ui/associated-inherent-types/issue-109299-1.stderr @@ -1,3 +1,11 @@ +error: unconstrained opaque type + --> $DIR/issue-109299-1.rs:10:10 + | +LL | type X = impl for<T> Fn() -> Lexer<T>::Cursor; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `X` must be used in combination with a concrete type within the same crate + error[E0220]: associated type `Cursor` not found for `Lexer<T>` in the current scope --> $DIR/issue-109299-1.rs:10:40 | @@ -23,14 +31,6 @@ LL | type X = impl for<T> Fn() -> Lexer<T>::Cursor; - `Lexer<i32>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: unconstrained opaque type - --> $DIR/issue-109299-1.rs:10:10 - | -LL | type X = impl for<T> Fn() -> Lexer<T>::Cursor; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `X` must be used in combination with a concrete type within the same crate - error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0220`. diff --git a/tests/ui/associated-inherent-types/not-found-self-type-differs-shadowing-trait-item.uncovered.stderr b/tests/ui/associated-inherent-types/not-found-self-type-differs-shadowing-trait-item.uncovered.stderr index 978305c2ce3..3e914e0538d 100644 --- a/tests/ui/associated-inherent-types/not-found-self-type-differs-shadowing-trait-item.uncovered.stderr +++ b/tests/ui/associated-inherent-types/not-found-self-type-differs-shadowing-trait-item.uncovered.stderr @@ -2,7 +2,13 @@ error[E0223]: ambiguous associated type --> $DIR/not-found-self-type-differs-shadowing-trait-item.rs:28:12 | LL | let _: S::<bool>::Pr = (); - | ^^^^^^^^^^^^^ help: use fully-qualified syntax: `<S<bool> as Tr>::Pr` + | ^^^^^^^^^^^^^ + | +help: use fully-qualified syntax + | +LL - let _: S::<bool>::Pr = (); +LL + let _: <S<bool> as Tr>::Pr = (); + | error: aborting due to 1 previous error diff --git a/tests/ui/associated-item/ambiguous-associated-type-with-generics.stderr b/tests/ui/associated-item/ambiguous-associated-type-with-generics.stderr index 9e1dd739807..fcf6b4c3e73 100644 --- a/tests/ui/associated-item/ambiguous-associated-type-with-generics.stderr +++ b/tests/ui/associated-item/ambiguous-associated-type-with-generics.stderr @@ -2,7 +2,12 @@ error[E0223]: ambiguous associated type --> $DIR/ambiguous-associated-type-with-generics.rs:13:13 | LL | let _x: <dyn Trait<i32>>::Ty; - | ^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<dyn Trait<i32> as Assoc>::Ty` + | ^^^^^^^^^^^^^^^^^^^^ + | +help: use fully-qualified syntax + | +LL | let _x: <dyn Trait<i32> as Assoc>::Ty; + | ++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/associated-item/associated-item-duplicate-names-3.stderr b/tests/ui/associated-item/associated-item-duplicate-names-3.stderr index a2346e292ac..84a9da09988 100644 --- a/tests/ui/associated-item/associated-item-duplicate-names-3.stderr +++ b/tests/ui/associated-item/associated-item-duplicate-names-3.stderr @@ -13,7 +13,13 @@ error[E0223]: ambiguous associated type --> $DIR/associated-item-duplicate-names-3.rs:18:12 | LL | let x: Baz::Bar = 5; - | ^^^^^^^^ help: use fully-qualified syntax: `<Baz as Foo>::Bar` + | ^^^^^^^^ + | +help: use fully-qualified syntax + | +LL - let x: Baz::Bar = 5; +LL + let x: <Baz as Foo>::Bar = 5; + | error: aborting due to 2 previous errors diff --git a/tests/ui/associated-type-bounds/duplicate.stderr b/tests/ui/associated-type-bounds/duplicate.stderr index 1ce212a9ff3..68fbb345f6f 100644 --- a/tests/ui/associated-type-bounds/duplicate.stderr +++ b/tests/ui/associated-type-bounds/duplicate.stderr @@ -199,16 +199,6 @@ LL | fn FRPIT1() -> impl Iterator<Item: Copy, Item: Send> { | `Item` bound here first error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified - --> $DIR/duplicate.rs:133:42 - | -LL | fn FRPIT1() -> impl Iterator<Item: Copy, Item: Send> { - | ---------- ^^^^^^^^^^ re-bound here - | | - | `Item` bound here first - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:139:42 | LL | fn FRPIT2() -> impl Iterator<Item: Copy, Item: Copy> { @@ -217,32 +207,12 @@ LL | fn FRPIT2() -> impl Iterator<Item: Copy, Item: Copy> { | `Item` bound here first error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified - --> $DIR/duplicate.rs:139:42 - | -LL | fn FRPIT2() -> impl Iterator<Item: Copy, Item: Copy> { - | ---------- ^^^^^^^^^^ re-bound here - | | - | `Item` bound here first - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified - --> $DIR/duplicate.rs:145:45 - | -LL | fn FRPIT3() -> impl Iterator<Item: 'static, Item: 'static> { - | ------------- ^^^^^^^^^^^^^ re-bound here - | | - | `Item` bound here first - -error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:145:45 | LL | fn FRPIT3() -> impl Iterator<Item: 'static, Item: 'static> { | ------------- ^^^^^^^^^^^^^ re-bound here | | | `Item` bound here first - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:151:40 @@ -341,60 +311,6 @@ LL | type ETAI3<T: Iterator<Item: 'static, Item: 'static>> = impl Copy; | `Item` bound here first error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified - --> $DIR/duplicate.rs:189:40 - | -LL | type ETAI4 = impl Iterator<Item: Copy, Item: Send>; - | ---------- ^^^^^^^^^^ re-bound here - | | - | `Item` bound here first - -error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified - --> $DIR/duplicate.rs:189:40 - | -LL | type ETAI4 = impl Iterator<Item: Copy, Item: Send>; - | ---------- ^^^^^^^^^^ re-bound here - | | - | `Item` bound here first - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified - --> $DIR/duplicate.rs:193:40 - | -LL | type ETAI5 = impl Iterator<Item: Copy, Item: Copy>; - | ---------- ^^^^^^^^^^ re-bound here - | | - | `Item` bound here first - -error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified - --> $DIR/duplicate.rs:193:40 - | -LL | type ETAI5 = impl Iterator<Item: Copy, Item: Copy>; - | ---------- ^^^^^^^^^^ re-bound here - | | - | `Item` bound here first - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified - --> $DIR/duplicate.rs:197:43 - | -LL | type ETAI6 = impl Iterator<Item: 'static, Item: 'static>; - | ------------- ^^^^^^^^^^^^^ re-bound here - | | - | `Item` bound here first - -error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified - --> $DIR/duplicate.rs:197:43 - | -LL | type ETAI6 = impl Iterator<Item: 'static, Item: 'static>; - | ------------- ^^^^^^^^^^^^^ re-bound here - | | - | `Item` bound here first - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:202:36 | LL | trait TRI1<T: Iterator<Item: Copy, Item: Send>> {} @@ -664,6 +580,16 @@ LL | type A: Iterator<Item: 'static, Item: 'static>; | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified + --> $DIR/duplicate.rs:133:42 + | +LL | fn FRPIT1() -> impl Iterator<Item: Copy, Item: Send> { + | ---------- ^^^^^^^^^^ re-bound here + | | + | `Item` bound here first + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0282]: type annotations needed --> $DIR/duplicate.rs:136:5 | @@ -675,6 +601,16 @@ help: consider specifying the generic argument LL | iter::empty::<T>() | +++++ +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified + --> $DIR/duplicate.rs:139:42 + | +LL | fn FRPIT2() -> impl Iterator<Item: Copy, Item: Copy> { + | ---------- ^^^^^^^^^^ re-bound here + | | + | `Item` bound here first + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0282]: type annotations needed --> $DIR/duplicate.rs:142:5 | @@ -686,6 +622,16 @@ help: consider specifying the generic argument LL | iter::empty::<T>() | +++++ +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified + --> $DIR/duplicate.rs:145:45 + | +LL | fn FRPIT3() -> impl Iterator<Item: 'static, Item: 'static> { + | ------------- ^^^^^^^^^^^^^ re-bound here + | | + | `Item` bound here first + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0282]: type annotations needed --> $DIR/duplicate.rs:148:5 | @@ -729,6 +675,24 @@ LL | type ETAI4 = impl Iterator<Item: Copy, Item: Send>; | = note: `ETAI4` must be used in combination with a concrete type within the same crate +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified + --> $DIR/duplicate.rs:189:40 + | +LL | type ETAI4 = impl Iterator<Item: Copy, Item: Send>; + | ---------- ^^^^^^^^^^ re-bound here + | | + | `Item` bound here first + +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified + --> $DIR/duplicate.rs:189:40 + | +LL | type ETAI4 = impl Iterator<Item: Copy, Item: Send>; + | ---------- ^^^^^^^^^^ re-bound here + | | + | `Item` bound here first + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error: unconstrained opaque type --> $DIR/duplicate.rs:193:14 | @@ -737,6 +701,24 @@ LL | type ETAI5 = impl Iterator<Item: Copy, Item: Copy>; | = note: `ETAI5` must be used in combination with a concrete type within the same crate +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified + --> $DIR/duplicate.rs:193:40 + | +LL | type ETAI5 = impl Iterator<Item: Copy, Item: Copy>; + | ---------- ^^^^^^^^^^ re-bound here + | | + | `Item` bound here first + +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified + --> $DIR/duplicate.rs:193:40 + | +LL | type ETAI5 = impl Iterator<Item: Copy, Item: Copy>; + | ---------- ^^^^^^^^^^ re-bound here + | | + | `Item` bound here first + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error: unconstrained opaque type --> $DIR/duplicate.rs:197:14 | @@ -745,6 +727,24 @@ LL | type ETAI6 = impl Iterator<Item: 'static, Item: 'static>; | = note: `ETAI6` must be used in combination with a concrete type within the same crate +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified + --> $DIR/duplicate.rs:197:43 + | +LL | type ETAI6 = impl Iterator<Item: 'static, Item: 'static>; + | ------------- ^^^^^^^^^^^^^ re-bound here + | | + | `Item` bound here first + +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified + --> $DIR/duplicate.rs:197:43 + | +LL | type ETAI6 = impl Iterator<Item: 'static, Item: 'static>; + | ------------- ^^^^^^^^^^^^^ re-bound here + | | + | `Item` bound here first + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error: aborting due to 87 previous errors Some errors have detailed explanations: E0282, E0719. diff --git a/tests/ui/associated-type-bounds/return-type-notation/path-missing.stderr b/tests/ui/associated-type-bounds/return-type-notation/path-missing.stderr index edac09db89d..677fc0e10bb 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/path-missing.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/path-missing.stderr @@ -8,9 +8,7 @@ error[E0575]: expected method or associated constant, found associated type `A:: --> $DIR/path-missing.rs:12:5 | LL | <T as A>::bad(..): Send, - | ^^^^^^^^^^^^^^^^^ - | - = note: can't use a type alias as a constructor + | ^^^^^^^^^^^^^^^^^ not a method or associated constant error[E0220]: associated function `method` not found for `T` --> $DIR/path-missing.rs:19:8 diff --git a/tests/ui/associated-type-bounds/return-type-notation/path-no-qself.stderr b/tests/ui/associated-type-bounds/return-type-notation/path-no-qself.stderr index aad6dfc496b..a13fdbda1bf 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/path-no-qself.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/path-no-qself.stderr @@ -7,7 +7,7 @@ LL | Trait::method(..): Send, help: if there were a type named `Example` that implemented `Trait`, you could use the fully-qualified path | LL - Trait::method(..): Send, -LL + <Example as Trait>::method: Send, +LL + <Example as Trait>::method(..): Send, | error: aborting due to 1 previous error diff --git a/tests/ui/associated-type-bounds/return-type-notation/path-non-param-qself.stderr b/tests/ui/associated-type-bounds/return-type-notation/path-non-param-qself.stderr index 38202bdbf07..4c4c2c24079 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/path-non-param-qself.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/path-non-param-qself.stderr @@ -3,18 +3,35 @@ error[E0223]: ambiguous associated function | LL | <()>::method(..): Send, | ^^^^^^^^^^^^^^^^ + | +help: if there were a trait named `Example` with associated function `method` implemented for `()`, you could use the fully-qualified path + | +LL | <() as Example>::method(..): Send, + | ++++++++++ error[E0223]: ambiguous associated function --> $DIR/path-non-param-qself.rs:13:5 | LL | i32::method(..): Send, | ^^^^^^^^^^^^^^^ + | +help: if there were a trait named `Example` with associated function `method` implemented for `i32`, you could use the fully-qualified path + | +LL - i32::method(..): Send, +LL + <i32 as Example>::method(..): Send, + | error[E0223]: ambiguous associated function --> $DIR/path-non-param-qself.rs:15:5 | LL | Adt::method(..): Send, | ^^^^^^^^^^^^^^^ + | +help: if there were a trait named `Example` with associated function `method` implemented for `Adt`, you could use the fully-qualified path + | +LL - Adt::method(..): Send, +LL + <Adt as Example>::method(..): Send, + | error: aborting due to 3 previous errors diff --git a/tests/ui/associated-types/associated-type-tuple-struct-construction.rs b/tests/ui/associated-types/associated-type-tuple-struct-construction.rs deleted file mode 100644 index d5809ecd55d..00000000000 --- a/tests/ui/associated-types/associated-type-tuple-struct-construction.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Users cannot yet construct structs through associated types -// in both expressions and patterns - -#![feature(more_qualified_paths)] - -fn main() { - let <Foo as A>::Assoc(n) = <Foo as A>::Assoc(2); - //~^ ERROR expected method or associated constant, found associated type - //~| ERROR expected method or associated constant, found associated type - assert!(n == 2); -} - -struct TupleStruct(i8); - -struct Foo; - - -trait A { - type Assoc; -} - -impl A for Foo { - type Assoc = TupleStruct; -} diff --git a/tests/ui/associated-types/associated-type-tuple-struct-construction.stderr b/tests/ui/associated-types/associated-type-tuple-struct-construction.stderr deleted file mode 100644 index bca7deeb512..00000000000 --- a/tests/ui/associated-types/associated-type-tuple-struct-construction.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0575]: expected method or associated constant, found associated type `A::Assoc` - --> $DIR/associated-type-tuple-struct-construction.rs:7:32 - | -LL | let <Foo as A>::Assoc(n) = <Foo as A>::Assoc(2); - | ^^^^^^^^^^^^^^^^^ - | - = note: can't use a type alias as a constructor - -error[E0575]: expected method or associated constant, found associated type `A::Assoc` - --> $DIR/associated-type-tuple-struct-construction.rs:7:9 - | -LL | let <Foo as A>::Assoc(n) = <Foo as A>::Assoc(2); - | ^^^^^^^^^^^^^^^^^ - | - = note: can't use a type alias as a constructor - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0575`. diff --git a/tests/ui/associated-types/associated-types-impl-redirect.rs b/tests/ui/associated-types/associated-types-impl-redirect.rs index 65e6a094b77..2cbe0d72540 100644 --- a/tests/ui/associated-types/associated-types-impl-redirect.rs +++ b/tests/ui/associated-types/associated-types-impl-redirect.rs @@ -21,7 +21,7 @@ trait Iterator { } trait IteratorExt: Iterator + Sized { - fn by_ref(&mut self) -> ByRef<Self> { + fn by_ref(&mut self) -> ByRef<'_, Self> { ByRef(self) } } diff --git a/tests/ui/associated-types/associated-types-in-ambiguous-context.stderr b/tests/ui/associated-types/associated-types-in-ambiguous-context.stderr index 1be8db5ddf4..a7647cf26aa 100644 --- a/tests/ui/associated-types/associated-types-in-ambiguous-context.stderr +++ b/tests/ui/associated-types/associated-types-in-ambiguous-context.stderr @@ -14,7 +14,13 @@ error[E0223]: ambiguous associated type --> $DIR/associated-types-in-ambiguous-context.rs:22:17 | LL | trait Foo where Foo::Assoc: Bar { - | ^^^^^^^^^^ help: use fully-qualified syntax: `<Self as Foo>::Assoc` + | ^^^^^^^^^^ + | +help: use fully-qualified syntax + | +LL - trait Foo where Foo::Assoc: Bar { +LL + trait Foo where <Self as Foo>::Assoc: Bar { + | error[E0223]: ambiguous associated type --> $DIR/associated-types-in-ambiguous-context.rs:27:10 @@ -42,7 +48,13 @@ error[E0223]: ambiguous associated type --> $DIR/associated-types-in-ambiguous-context.rs:13:23 | LL | fn grab(&self) -> Grab::Value; - | ^^^^^^^^^^^ help: use fully-qualified syntax: `<Self as Grab>::Value` + | ^^^^^^^^^^^ + | +help: use fully-qualified syntax + | +LL - fn grab(&self) -> Grab::Value; +LL + fn grab(&self) -> <Self as Grab>::Value; + | error[E0223]: ambiguous associated type --> $DIR/associated-types-in-ambiguous-context.rs:16:22 diff --git a/tests/ui/associated-types/associated-types-normalize-in-bounds-ufcs.rs b/tests/ui/associated-types/associated-types-normalize-in-bounds-ufcs.rs index f15de0d9a28..b32323181b5 100644 --- a/tests/ui/associated-types/associated-types-normalize-in-bounds-ufcs.rs +++ b/tests/ui/associated-types/associated-types-normalize-in-bounds-ufcs.rs @@ -21,11 +21,11 @@ trait SliceExt2 { impl<T> SliceExt2 for [T] { type Item = T; - fn split2<P>(&self, pred: P) -> Splits<T, P> where P: FnMut(&T) -> bool { + fn split2<P>(&self, pred: P) -> Splits<'_, T, P> where P: FnMut(&T) -> bool { loop {} } - fn splitn2<P>(&self, n: u32, pred: P) -> SplitsN<Splits<T, P>> where P: FnMut(&T) -> bool { + fn splitn2<P>(&self, n: u32, pred: P) -> SplitsN<Splits<'_, T, P>> where P: FnMut(&T) -> bool { SliceExt2::split2(self, pred); loop {} } diff --git a/tests/ui/associated-types/associated-types-normalize-in-bounds.rs b/tests/ui/associated-types/associated-types-normalize-in-bounds.rs index 7e94d3a011f..6844c5f9adb 100644 --- a/tests/ui/associated-types/associated-types-normalize-in-bounds.rs +++ b/tests/ui/associated-types/associated-types-normalize-in-bounds.rs @@ -3,32 +3,40 @@ // Test that we normalize associated types that appear in bounds; if // we didn't, the call to `self.split2()` fails to type check. - use std::marker::PhantomData; -struct Splits<'a, T, P>(PhantomData<(&'a(),T,P)>); +struct Splits<'a, T, P>(PhantomData<(&'a (), T, P)>); struct SplitsN<I>(PhantomData<I>); trait SliceExt2 { type Item; fn split2<'a, P>(&'a self, pred: P) -> Splits<'a, Self::Item, P> - where P: FnMut(&Self::Item) -> bool; + where + P: FnMut(&Self::Item) -> bool; + fn splitn2<'a, P>(&'a self, n: usize, pred: P) -> SplitsN<Splits<'a, Self::Item, P>> - where P: FnMut(&Self::Item) -> bool; + where + P: FnMut(&Self::Item) -> bool; } impl<T> SliceExt2 for [T] { type Item = T; - fn split2<P>(&self, pred: P) -> Splits<T, P> where P: FnMut(&T) -> bool { + fn split2<P>(&self, pred: P) -> Splits<'_, T, P> + where + P: FnMut(&T) -> bool, + { loop {} } - fn splitn2<P>(&self, n: usize, pred: P) -> SplitsN<Splits<T, P>> where P: FnMut(&T) -> bool { + fn splitn2<P>(&self, n: usize, pred: P) -> SplitsN<Splits<'_, T, P>> + where + P: FnMut(&T) -> bool, + { self.split2(pred); loop {} } } -fn main() { } +fn main() {} diff --git a/tests/ui/associated-types/associated-types-where-clause-impl-ambiguity.rs b/tests/ui/associated-types/associated-types-where-clause-impl-ambiguity.rs index dcfa3532cdf..34c269d4d90 100644 --- a/tests/ui/associated-types/associated-types-where-clause-impl-ambiguity.rs +++ b/tests/ui/associated-types/associated-types-where-clause-impl-ambiguity.rs @@ -20,7 +20,7 @@ trait Iterator { } trait IteratorExt: Iterator + Sized { - fn by_ref(&mut self) -> ByRef<Self> { + fn by_ref(&mut self) -> ByRef<'_, Self> { ByRef(self) } } diff --git a/tests/ui/associated-types/cache/elision.rs b/tests/ui/associated-types/cache/elision.rs index 12765fc5811..7ddb32ea874 100644 --- a/tests/ui/associated-types/cache/elision.rs +++ b/tests/ui/associated-types/cache/elision.rs @@ -14,7 +14,7 @@ pub trait UnicodeStr { impl UnicodeStr for str { #[inline] - fn split_whitespace(&self) -> SplitWhitespace { + fn split_whitespace(&self) -> SplitWhitespace<'_> { unimplemented!() } } diff --git a/tests/ui/associated-types/issue-43924.stderr b/tests/ui/associated-types/issue-43924.stderr index ab1a9511ec6..526f425b21e 100644 --- a/tests/ui/associated-types/issue-43924.stderr +++ b/tests/ui/associated-types/issue-43924.stderr @@ -14,7 +14,7 @@ error[E0599]: no function or associated item named `default` found for trait obj --> $DIR/issue-43924.rs:14:39 | LL | assert_eq!(<() as Foo<u32>>::Out::default().to_string(), "false"); - | ^^^^^^^ function or associated item not found in `dyn ToString` + | ^^^^^^^ function or associated item not found in `(dyn ToString + 'static)` error: aborting due to 2 previous errors diff --git a/tests/ui/associated-types/project-defer-unification.rs b/tests/ui/associated-types/project-defer-unification.rs index b51228ef411..a949171db12 100644 --- a/tests/ui/associated-types/project-defer-unification.rs +++ b/tests/ui/associated-types/project-defer-unification.rs @@ -50,7 +50,7 @@ where P: Pixel + 'static, loop { } } - pub fn pixels_mut(&mut self) -> PixelsMut<P> { + pub fn pixels_mut(&mut self) -> PixelsMut<'_, P> { loop { } } } diff --git a/tests/ui/associated-types/tuple-struct-expr-pat.fixed b/tests/ui/associated-types/tuple-struct-expr-pat.fixed new file mode 100644 index 00000000000..d6e2385f821 --- /dev/null +++ b/tests/ui/associated-types/tuple-struct-expr-pat.fixed @@ -0,0 +1,48 @@ +// Check that fully qualified syntax can **not** be used in tuple struct expressions (calls) and +// patterns. Both tuple struct expressions and patterns are resolved in value namespace and thus +// can't be resolved through associated *types*. +// +//@ run-rustfix + +#![feature(more_qualified_paths)] + +fn main() { + let <T<0> as Trait>::Assoc {} = <T<0> as Trait>::Assoc {}; + //~^ error: expected method or associated constant, found associated type + //~| error: expected tuple struct or tuple variant, found associated type + let <T<1> as Trait>::Assoc { 0: _a } = <T<1> as Trait>::Assoc { 0: 0 }; + //~^ error: expected method or associated constant, found associated type + //~| error: expected tuple struct or tuple variant, found associated type + let <T<2> as Trait>::Assoc { 0: _a, 1: _b } = <T<2> as Trait>::Assoc { 0: 0, 1: 1 }; + //~^ error: expected method or associated constant, found associated type + //~| error: expected tuple struct or tuple variant, found associated type + let <T<3> as Trait>::Assoc { 0: ref _a, 1: ref mut _b, 2: mut _c } = <T<3> as Trait>::Assoc { 0: 0, 1: 1, 2: 2 }; + //~^ error: expected method or associated constant, found associated type + //~| error: expected tuple struct or tuple variant, found associated type +} + + +struct T<const N: usize>; + +struct T0(); +struct T1(u8); +struct T2(u8, u8); +struct T3(u8, u8, u8); + +trait Trait { + type Assoc; +} + +impl Trait for T<0> { + type Assoc = T0; +} + +impl Trait for T<1> { + type Assoc = T1; +} +impl Trait for T<2> { + type Assoc = T2; +} +impl Trait for T<3> { + type Assoc = T3; +} diff --git a/tests/ui/associated-types/tuple-struct-expr-pat.rs b/tests/ui/associated-types/tuple-struct-expr-pat.rs new file mode 100644 index 00000000000..f27a5fe1753 --- /dev/null +++ b/tests/ui/associated-types/tuple-struct-expr-pat.rs @@ -0,0 +1,48 @@ +// Check that fully qualified syntax can **not** be used in tuple struct expressions (calls) and +// patterns. Both tuple struct expressions and patterns are resolved in value namespace and thus +// can't be resolved through associated *types*. +// +//@ run-rustfix + +#![feature(more_qualified_paths)] + +fn main() { + let <T<0> as Trait>::Assoc() = <T<0> as Trait>::Assoc(); + //~^ error: expected method or associated constant, found associated type + //~| error: expected tuple struct or tuple variant, found associated type + let <T<1> as Trait>::Assoc(_a) = <T<1> as Trait>::Assoc(0); + //~^ error: expected method or associated constant, found associated type + //~| error: expected tuple struct or tuple variant, found associated type + let <T<2> as Trait>::Assoc(_a, _b) = <T<2> as Trait>::Assoc(0, 1); + //~^ error: expected method or associated constant, found associated type + //~| error: expected tuple struct or tuple variant, found associated type + let <T<3> as Trait>::Assoc(ref _a, ref mut _b, mut _c) = <T<3> as Trait>::Assoc(0, 1, 2); + //~^ error: expected method or associated constant, found associated type + //~| error: expected tuple struct or tuple variant, found associated type +} + + +struct T<const N: usize>; + +struct T0(); +struct T1(u8); +struct T2(u8, u8); +struct T3(u8, u8, u8); + +trait Trait { + type Assoc; +} + +impl Trait for T<0> { + type Assoc = T0; +} + +impl Trait for T<1> { + type Assoc = T1; +} +impl Trait for T<2> { + type Assoc = T2; +} +impl Trait for T<3> { + type Assoc = T3; +} diff --git a/tests/ui/associated-types/tuple-struct-expr-pat.stderr b/tests/ui/associated-types/tuple-struct-expr-pat.stderr new file mode 100644 index 00000000000..135dfcb3447 --- /dev/null +++ b/tests/ui/associated-types/tuple-struct-expr-pat.stderr @@ -0,0 +1,97 @@ +error[E0575]: expected method or associated constant, found associated type `Trait::Assoc` + --> $DIR/tuple-struct-expr-pat.rs:10:36 + | +LL | let <T<0> as Trait>::Assoc() = <T<0> as Trait>::Assoc(); + | ^^^^^^^^^^^^^^^^^^^^^^-- help: use struct expression instead: `{}` + | + = note: can't use a type alias as a constructor + +error[E0575]: expected tuple struct or tuple variant, found associated type `Trait::Assoc` + --> $DIR/tuple-struct-expr-pat.rs:10:9 + | +LL | let <T<0> as Trait>::Assoc() = <T<0> as Trait>::Assoc(); + | ^^^^^^^^^^^^^^^^^^^^^^-- help: use struct pattern instead: `{}` + | + = note: can't use a type alias as tuple pattern + +error[E0575]: expected method or associated constant, found associated type `Trait::Assoc` + --> $DIR/tuple-struct-expr-pat.rs:13:38 + | +LL | let <T<1> as Trait>::Assoc(_a) = <T<1> as Trait>::Assoc(0); + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: can't use a type alias as a constructor +help: use struct expression instead + | +LL - let <T<1> as Trait>::Assoc(_a) = <T<1> as Trait>::Assoc(0); +LL + let <T<1> as Trait>::Assoc(_a) = <T<1> as Trait>::Assoc { 0: 0 }; + | + +error[E0575]: expected tuple struct or tuple variant, found associated type `Trait::Assoc` + --> $DIR/tuple-struct-expr-pat.rs:13:9 + | +LL | let <T<1> as Trait>::Assoc(_a) = <T<1> as Trait>::Assoc(0); + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: can't use a type alias as tuple pattern +help: use struct pattern instead + | +LL - let <T<1> as Trait>::Assoc(_a) = <T<1> as Trait>::Assoc(0); +LL + let <T<1> as Trait>::Assoc { 0: _a } = <T<1> as Trait>::Assoc(0); + | + +error[E0575]: expected method or associated constant, found associated type `Trait::Assoc` + --> $DIR/tuple-struct-expr-pat.rs:16:42 + | +LL | let <T<2> as Trait>::Assoc(_a, _b) = <T<2> as Trait>::Assoc(0, 1); + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: can't use a type alias as a constructor +help: use struct expression instead + | +LL - let <T<2> as Trait>::Assoc(_a, _b) = <T<2> as Trait>::Assoc(0, 1); +LL + let <T<2> as Trait>::Assoc(_a, _b) = <T<2> as Trait>::Assoc { 0: 0, 1: 1 }; + | + +error[E0575]: expected tuple struct or tuple variant, found associated type `Trait::Assoc` + --> $DIR/tuple-struct-expr-pat.rs:16:9 + | +LL | let <T<2> as Trait>::Assoc(_a, _b) = <T<2> as Trait>::Assoc(0, 1); + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: can't use a type alias as tuple pattern +help: use struct pattern instead + | +LL - let <T<2> as Trait>::Assoc(_a, _b) = <T<2> as Trait>::Assoc(0, 1); +LL + let <T<2> as Trait>::Assoc { 0: _a, 1: _b } = <T<2> as Trait>::Assoc(0, 1); + | + +error[E0575]: expected method or associated constant, found associated type `Trait::Assoc` + --> $DIR/tuple-struct-expr-pat.rs:19:62 + | +LL | let <T<3> as Trait>::Assoc(ref _a, ref mut _b, mut _c) = <T<3> as Trait>::Assoc(0, 1, 2); + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: can't use a type alias as a constructor +help: use struct expression instead + | +LL - let <T<3> as Trait>::Assoc(ref _a, ref mut _b, mut _c) = <T<3> as Trait>::Assoc(0, 1, 2); +LL + let <T<3> as Trait>::Assoc(ref _a, ref mut _b, mut _c) = <T<3> as Trait>::Assoc { 0: 0, 1: 1, 2: 2 }; + | + +error[E0575]: expected tuple struct or tuple variant, found associated type `Trait::Assoc` + --> $DIR/tuple-struct-expr-pat.rs:19:9 + | +LL | let <T<3> as Trait>::Assoc(ref _a, ref mut _b, mut _c) = <T<3> as Trait>::Assoc(0, 1, 2); + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: can't use a type alias as tuple pattern +help: use struct pattern instead + | +LL - let <T<3> as Trait>::Assoc(ref _a, ref mut _b, mut _c) = <T<3> as Trait>::Assoc(0, 1, 2); +LL + let <T<3> as Trait>::Assoc { 0: ref _a, 1: ref mut _b, 2: mut _c } = <T<3> as Trait>::Assoc(0, 1, 2); + | + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0575`. diff --git a/tests/ui/async-await/async-closures/async-fn-mut-impl-fn-once.rs b/tests/ui/async-await/async-closures/async-fn-mut-impl-fn-once.rs new file mode 100644 index 00000000000..59d034953d7 --- /dev/null +++ b/tests/ui/async-await/async-closures/async-fn-mut-impl-fn-once.rs @@ -0,0 +1,15 @@ +//@ edition:2021 +//@ check-pass +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver + +fn call_once<F>(_: impl FnOnce() -> F) {} + +fn main() { + let mut i = 0; + let c = async || { + i += 1; + }; + call_once(c); +} diff --git a/tests/ui/async-await/async-closures/promote-in-body.rs b/tests/ui/async-await/async-closures/promote-in-body.rs new file mode 100644 index 00000000000..ea95d680987 --- /dev/null +++ b/tests/ui/async-await/async-closures/promote-in-body.rs @@ -0,0 +1,13 @@ +//@ build-pass +//@ compile-flags: --crate-type=lib +//@ edition: 2024 + +union U { + f: i32, +} + +fn foo() { + async || { + &U { f: 1 } + }; +} diff --git a/tests/crashes/140530.rs b/tests/ui/async-await/async-drop/assign-incompatible-types.rs index 7e0372a4bd8..359939ff9ac 100644 --- a/tests/crashes/140530.rs +++ b/tests/ui/async-await/async-drop/assign-incompatible-types.rs @@ -1,7 +1,8 @@ -//@ known-bug: #140530 +// ex-ice: #140530 //@ edition: 2024 - +//@ build-pass #![feature(async_drop, gen_blocks)] +#![allow(incomplete_features)] async gen fn a() { _ = async {} } diff --git a/tests/ui/async-await/async-drop/dependency-dropped.rs b/tests/ui/async-await/async-drop/dependency-dropped.rs index c8670be4e8b..d7f415e19aa 100644 --- a/tests/ui/async-await/async-drop/dependency-dropped.rs +++ b/tests/ui/async-await/async-drop/dependency-dropped.rs @@ -5,7 +5,7 @@ //@ edition:2021 #![cfg_attr(with_feature, feature(async_drop))] -//[without_feature]~^ WARN found async drop types in dependecy `async_drop_dep`, but async_drop feature is disabled for `dependency_dropped` +//[without_feature]~^ WARN found async drop types in dependency `async_drop_dep`, but async_drop feature is disabled for `dependency_dropped` #![allow(incomplete_features)] diff --git a/tests/ui/async-await/async-drop/dependency-dropped.without_feature.stderr b/tests/ui/async-await/async-drop/dependency-dropped.without_feature.stderr index 56e49568e10..96a4572055c 100644 --- a/tests/ui/async-await/async-drop/dependency-dropped.without_feature.stderr +++ b/tests/ui/async-await/async-drop/dependency-dropped.without_feature.stderr @@ -1,4 +1,4 @@ -warning: found async drop types in dependecy `async_drop_dep`, but async_drop feature is disabled for `dependency_dropped` +warning: found async drop types in dependency `async_drop_dep`, but async_drop feature is disabled for `dependency_dropped` --> $DIR/dependency-dropped.rs:7:1 | LL | #![cfg_attr(with_feature, feature(async_drop))] diff --git a/tests/crashes/140975.rs b/tests/ui/async-await/async-drop/deref-later-projection.rs index e11dd40612c..baf81daf766 100644 --- a/tests/crashes/140975.rs +++ b/tests/ui/async-await/async-drop/deref-later-projection.rs @@ -1,7 +1,11 @@ -//@ known-bug: #140975 -//@ compile-flags: --crate-type lib -Zvalidate-mir -//@ edition: 2021 +// Ex-ICE: #140975 +//@ compile-flags: -Zvalidate-mir +//@ build-pass +//@ edition:2021 +#![crate_type = "lib"] #![feature(async_drop)] +#![allow(incomplete_features)] + use std::{future::AsyncDrop, pin::Pin}; struct HasAsyncDrop ; diff --git a/tests/crashes/140974.rs b/tests/ui/async-await/async-drop/elaborate-index-out-of-bounds.rs index ac1051a64fd..bd0a95eb1e4 100644 --- a/tests/crashes/140974.rs +++ b/tests/ui/async-await/async-drop/elaborate-index-out-of-bounds.rs @@ -1,5 +1,7 @@ -//@ known-bug: #140974 -//@edition:2021 +//@ edition: 2024 +// Ex-ICE: #140974 +#![crate_type = "lib"] +#![allow(incomplete_features)] #![feature(async_drop)] use core::future::AsyncDrop; @@ -10,5 +12,6 @@ impl Drop for HasIncompleteAsyncDrop { fn drop(&mut self) {} } impl AsyncDrop for HasIncompleteAsyncDrop { + //~^ ERROR: not all trait items implemented, missing: `drop` [E0046] // not implemented yet.. } diff --git a/tests/ui/async-await/async-drop/elaborate-index-out-of-bounds.stderr b/tests/ui/async-await/async-drop/elaborate-index-out-of-bounds.stderr new file mode 100644 index 00000000000..d8582398c79 --- /dev/null +++ b/tests/ui/async-await/async-drop/elaborate-index-out-of-bounds.stderr @@ -0,0 +1,11 @@ +error[E0046]: not all trait items implemented, missing: `drop` + --> $DIR/elaborate-index-out-of-bounds.rs:14:1 + | +LL | impl AsyncDrop for HasIncompleteAsyncDrop { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `drop` in implementation + | + = help: implement the missing item: `async fn drop(self: Pin<&mut Self>) { todo!() }` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/async-await/async-drop/open-drop-error2.rs b/tests/ui/async-await/async-drop/open-drop-error2.rs new file mode 100644 index 00000000000..b2a7b68190e --- /dev/null +++ b/tests/ui/async-await/async-drop/open-drop-error2.rs @@ -0,0 +1,21 @@ +//@compile-flags: -Zvalidate-mir -Zinline-mir=yes --crate-type=lib + +#![feature(async_drop)] +#![allow(incomplete_features)] + +use std::{ + future::{Future, async_drop_in_place}, + pin::pin, + task::Context, +}; + +fn wrong() -> impl Sized { + //~^ ERROR: the size for values of type `str` cannot be known at compilation time + *"abc" // Doesn't implement Sized +} +fn weird(context: &mut Context<'_>) { + let mut e = wrong(); + let h = unsafe { async_drop_in_place(&raw mut e) }; + let i = pin!(h); + i.poll(context); +} diff --git a/tests/ui/async-await/async-drop/open-drop-error2.stderr b/tests/ui/async-await/async-drop/open-drop-error2.stderr new file mode 100644 index 00000000000..e849829b1c7 --- /dev/null +++ b/tests/ui/async-await/async-drop/open-drop-error2.stderr @@ -0,0 +1,19 @@ +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/open-drop-error2.rs:12:15 + | +LL | fn wrong() -> impl Sized { + | ^^^^^^^^^^ doesn't have a size known at compile-time +LL | +LL | *"abc" // Doesn't implement Sized + | ------ return type was inferred to be `str` here + | + = help: the trait `Sized` is not implemented for `str` +help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression + | +LL - *"abc" // Doesn't implement Sized +LL + "abc" // Doesn't implement Sized + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/async-drop/type-parameter.rs b/tests/ui/async-await/async-drop/type-parameter.rs new file mode 100644 index 00000000000..dde5f9f8e64 --- /dev/null +++ b/tests/ui/async-await/async-drop/type-parameter.rs @@ -0,0 +1,16 @@ +//@ edition: 2024 +// ex-ice: #140500 +#![crate_type = "lib"] +#![feature(async_drop)] +#![expect(incomplete_features)] +use std::future::AsyncDrop; +struct A; +impl Drop for A { + fn drop(&mut self) {} +} +impl AsyncDrop for A { + fn drop(_wrong: impl Sized) {} //~ ERROR: method `drop` has a `self: Pin<&mut Self>` declaration in the trait, but not in the impl +} +async fn bar() { + A; +} diff --git a/tests/ui/async-await/async-drop/type-parameter.stderr b/tests/ui/async-await/async-drop/type-parameter.stderr new file mode 100644 index 00000000000..841576b839e --- /dev/null +++ b/tests/ui/async-await/async-drop/type-parameter.stderr @@ -0,0 +1,11 @@ +error[E0186]: method `drop` has a `self: Pin<&mut Self>` declaration in the trait, but not in the impl + --> $DIR/type-parameter.rs:12:5 + | +LL | fn drop(_wrong: impl Sized) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `self: Pin<&mut Self>` in impl + | + = note: `drop` from trait: `fn(Pin<&mut Self>) -> impl Future<Output = ()>` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0186`. diff --git a/tests/ui/async-await/async-drop/unexpected-sort.rs b/tests/ui/async-await/async-drop/unexpected-sort.rs new file mode 100644 index 00000000000..659e21eb241 --- /dev/null +++ b/tests/ui/async-await/async-drop/unexpected-sort.rs @@ -0,0 +1,18 @@ +// Ex-ice: #140484 +//@ edition: 2024 +#![crate_type = "lib"] +#![allow(incomplete_features)] +#![allow(non_camel_case_types)] +#![feature(async_drop)] +use std::future::AsyncDrop; +struct a; +impl Drop for a { //~ ERROR: not all trait items implemented, missing: `drop` + fn b() {} //~ ERROR: method `b` is not a member of trait `Drop` +} +impl AsyncDrop for a { //~ ERROR: not all trait items implemented, missing: `drop` + type c = (); + //~^ ERROR: type `c` is not a member of trait `AsyncDrop` +} +async fn bar() { + a; +} diff --git a/tests/ui/async-await/async-drop/unexpected-sort.stderr b/tests/ui/async-await/async-drop/unexpected-sort.stderr new file mode 100644 index 00000000000..a6e4f9fd573 --- /dev/null +++ b/tests/ui/async-await/async-drop/unexpected-sort.stderr @@ -0,0 +1,32 @@ +error[E0407]: method `b` is not a member of trait `Drop` + --> $DIR/unexpected-sort.rs:10:5 + | +LL | fn b() {} + | ^^^^^^^^^ not a member of trait `Drop` + +error[E0437]: type `c` is not a member of trait `AsyncDrop` + --> $DIR/unexpected-sort.rs:13:5 + | +LL | type c = (); + | ^^^^^^^^^^^^ not a member of trait `AsyncDrop` + +error[E0046]: not all trait items implemented, missing: `drop` + --> $DIR/unexpected-sort.rs:9:1 + | +LL | impl Drop for a { + | ^^^^^^^^^^^^^^^ missing `drop` in implementation + | + = help: implement the missing item: `fn drop(&mut self) { todo!() }` + +error[E0046]: not all trait items implemented, missing: `drop` + --> $DIR/unexpected-sort.rs:12:1 + | +LL | impl AsyncDrop for a { + | ^^^^^^^^^^^^^^^^^^^^ missing `drop` in implementation + | + = help: implement the missing item: `async fn drop(self: Pin<&mut Self>) { todo!() }` + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0046, E0407, E0437. +For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/async-await/async-fn/edition-2015-not-async-bound.rs b/tests/ui/async-await/async-fn/edition-2015-not-async-bound.rs index d222ddc081e..60a7dff7d49 100644 --- a/tests/ui/async-await/async-fn/edition-2015-not-async-bound.rs +++ b/tests/ui/async-await/async-fn/edition-2015-not-async-bound.rs @@ -1,3 +1,4 @@ +//@ edition:2015 //@ check-pass // Make sure that we don't eagerly recover `async ::Bound` in edition 2015. diff --git a/tests/ui/async-await/async-fn/edition-2015.rs b/tests/ui/async-await/async-fn/edition-2015.rs index 341b9b10e67..5a81df3a4e4 100644 --- a/tests/ui/async-await/async-fn/edition-2015.rs +++ b/tests/ui/async-await/async-fn/edition-2015.rs @@ -1,3 +1,4 @@ +//@ edition:2015 fn foo(x: impl async Fn()) -> impl async Fn() { x } //~^ ERROR `async` trait bounds are only allowed in Rust 2018 or later //~| ERROR `async` trait bounds are only allowed in Rust 2018 or later diff --git a/tests/ui/async-await/async-fn/edition-2015.stderr b/tests/ui/async-await/async-fn/edition-2015.stderr index ca9e64cd1bb..0bec00c162c 100644 --- a/tests/ui/async-await/async-fn/edition-2015.stderr +++ b/tests/ui/async-await/async-fn/edition-2015.stderr @@ -1,5 +1,5 @@ error: `async` trait bounds are only allowed in Rust 2018 or later - --> $DIR/edition-2015.rs:1:16 + --> $DIR/edition-2015.rs:2:16 | LL | fn foo(x: impl async Fn()) -> impl async Fn() { x } | ^^^^^ @@ -8,7 +8,7 @@ LL | fn foo(x: impl async Fn()) -> impl async Fn() { x } = note: for more on editions, read https://doc.rust-lang.org/edition-guide error: `async` trait bounds are only allowed in Rust 2018 or later - --> $DIR/edition-2015.rs:1:36 + --> $DIR/edition-2015.rs:2:36 | LL | fn foo(x: impl async Fn()) -> impl async Fn() { x } | ^^^^^ @@ -17,7 +17,7 @@ LL | fn foo(x: impl async Fn()) -> impl async Fn() { x } = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0658]: `async` trait bounds are unstable - --> $DIR/edition-2015.rs:1:16 + --> $DIR/edition-2015.rs:2:16 | LL | fn foo(x: impl async Fn()) -> impl async Fn() { x } | ^^^^^ @@ -28,7 +28,7 @@ LL | fn foo(x: impl async Fn()) -> impl async Fn() { x } = help: use the desugared name of the async trait, such as `AsyncFn` error[E0658]: `async` trait bounds are unstable - --> $DIR/edition-2015.rs:1:36 + --> $DIR/edition-2015.rs:2:36 | LL | fn foo(x: impl async Fn()) -> impl async Fn() { x } | ^^^^^ diff --git a/tests/ui/async-await/await-keyword/2015-edition-error-various-positions.rs b/tests/ui/async-await/await-keyword/2015-edition-error-various-positions.rs index 50c1639996e..714a3328ecf 100644 --- a/tests/ui/async-await/await-keyword/2015-edition-error-various-positions.rs +++ b/tests/ui/async-await/await-keyword/2015-edition-error-various-positions.rs @@ -1,3 +1,4 @@ +//@ edition:2015 #![allow(non_camel_case_types)] #![deny(keyword_idents)] diff --git a/tests/ui/async-await/await-keyword/2015-edition-error-various-positions.stderr b/tests/ui/async-await/await-keyword/2015-edition-error-various-positions.stderr index 8cea73f8651..70900e612f4 100644 --- a/tests/ui/async-await/await-keyword/2015-edition-error-various-positions.stderr +++ b/tests/ui/async-await/await-keyword/2015-edition-error-various-positions.stderr @@ -1,5 +1,5 @@ error: `await` is a keyword in the 2018 edition - --> $DIR/2015-edition-error-various-positions.rs:5:13 + --> $DIR/2015-edition-error-various-positions.rs:6:13 | LL | pub mod await { | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` @@ -7,14 +7,14 @@ LL | pub mod await { = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> note: the lint level is defined here - --> $DIR/2015-edition-error-various-positions.rs:2:9 + --> $DIR/2015-edition-error-various-positions.rs:3:9 | LL | #![deny(keyword_idents)] | ^^^^^^^^^^^^^^ = note: `#[deny(keyword_idents_2018)]` implied by `#[deny(keyword_idents)]` error: `await` is a keyword in the 2018 edition - --> $DIR/2015-edition-error-various-positions.rs:7:20 + --> $DIR/2015-edition-error-various-positions.rs:8:20 | LL | pub struct await; | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` @@ -23,7 +23,7 @@ LL | pub struct await; = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> error: `await` is a keyword in the 2018 edition - --> $DIR/2015-edition-error-various-positions.rs:11:16 + --> $DIR/2015-edition-error-various-positions.rs:12:16 | LL | use outer_mod::await::await; | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` @@ -32,7 +32,7 @@ LL | use outer_mod::await::await; = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> error: `await` is a keyword in the 2018 edition - --> $DIR/2015-edition-error-various-positions.rs:11:23 + --> $DIR/2015-edition-error-various-positions.rs:12:23 | LL | use outer_mod::await::await; | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` @@ -41,7 +41,7 @@ LL | use outer_mod::await::await; = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> error: `await` is a keyword in the 2018 edition - --> $DIR/2015-edition-error-various-positions.rs:16:14 + --> $DIR/2015-edition-error-various-positions.rs:17:14 | LL | struct Foo { await: () } | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` @@ -50,7 +50,7 @@ LL | struct Foo { await: () } = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> error: `await` is a keyword in the 2018 edition - --> $DIR/2015-edition-error-various-positions.rs:20:15 + --> $DIR/2015-edition-error-various-positions.rs:21:15 | LL | impl Foo { fn await() {} } | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` @@ -59,7 +59,7 @@ LL | impl Foo { fn await() {} } = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> error: `await` is a keyword in the 2018 edition - --> $DIR/2015-edition-error-various-positions.rs:24:14 + --> $DIR/2015-edition-error-various-positions.rs:25:14 | LL | macro_rules! await { | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` @@ -68,7 +68,7 @@ LL | macro_rules! await { = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> error: `await` is a keyword in the 2018 edition - --> $DIR/2015-edition-error-various-positions.rs:31:5 + --> $DIR/2015-edition-error-various-positions.rs:32:5 | LL | await!(); | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` @@ -77,7 +77,7 @@ LL | await!(); = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> error: `await` is a keyword in the 2018 edition - --> $DIR/2015-edition-error-various-positions.rs:34:11 + --> $DIR/2015-edition-error-various-positions.rs:35:11 | LL | match await { await => {} } | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` @@ -86,7 +86,7 @@ LL | match await { await => {} } = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> error: `await` is a keyword in the 2018 edition - --> $DIR/2015-edition-error-various-positions.rs:34:19 + --> $DIR/2015-edition-error-various-positions.rs:35:19 | LL | match await { await => {} } | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` diff --git a/tests/ui/async-await/await-keyword/2015-edition-warning.fixed b/tests/ui/async-await/await-keyword/2015-edition-warning.fixed index 4cb8017c7ee..45758cb1039 100644 --- a/tests/ui/async-await/await-keyword/2015-edition-warning.fixed +++ b/tests/ui/async-await/await-keyword/2015-edition-warning.fixed @@ -1,3 +1,4 @@ +//@ edition:2015 //@ run-rustfix #![allow(non_camel_case_types)] diff --git a/tests/ui/async-await/await-keyword/2015-edition-warning.rs b/tests/ui/async-await/await-keyword/2015-edition-warning.rs index d591a5af821..ea26abe072b 100644 --- a/tests/ui/async-await/await-keyword/2015-edition-warning.rs +++ b/tests/ui/async-await/await-keyword/2015-edition-warning.rs @@ -1,3 +1,4 @@ +//@ edition:2015 //@ run-rustfix #![allow(non_camel_case_types)] diff --git a/tests/ui/async-await/await-keyword/2015-edition-warning.stderr b/tests/ui/async-await/await-keyword/2015-edition-warning.stderr index 70b7fa52a19..9d19a09092b 100644 --- a/tests/ui/async-await/await-keyword/2015-edition-warning.stderr +++ b/tests/ui/async-await/await-keyword/2015-edition-warning.stderr @@ -1,5 +1,5 @@ error: `await` is a keyword in the 2018 edition - --> $DIR/2015-edition-warning.rs:7:13 + --> $DIR/2015-edition-warning.rs:8:13 | LL | pub mod await { | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` @@ -7,14 +7,14 @@ LL | pub mod await { = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> note: the lint level is defined here - --> $DIR/2015-edition-warning.rs:4:9 + --> $DIR/2015-edition-warning.rs:5:9 | LL | #![deny(keyword_idents)] | ^^^^^^^^^^^^^^ = note: `#[deny(keyword_idents_2018)]` implied by `#[deny(keyword_idents)]` error: `await` is a keyword in the 2018 edition - --> $DIR/2015-edition-warning.rs:10:20 + --> $DIR/2015-edition-warning.rs:11:20 | LL | pub struct await; | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` @@ -23,7 +23,7 @@ LL | pub struct await; = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> error: `await` is a keyword in the 2018 edition - --> $DIR/2015-edition-warning.rs:15:16 + --> $DIR/2015-edition-warning.rs:16:16 | LL | use outer_mod::await::await; | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` @@ -32,7 +32,7 @@ LL | use outer_mod::await::await; = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> error: `await` is a keyword in the 2018 edition - --> $DIR/2015-edition-warning.rs:15:23 + --> $DIR/2015-edition-warning.rs:16:23 | LL | use outer_mod::await::await; | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` @@ -41,7 +41,7 @@ LL | use outer_mod::await::await; = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> error: `await` is a keyword in the 2018 edition - --> $DIR/2015-edition-warning.rs:22:11 + --> $DIR/2015-edition-warning.rs:23:11 | LL | match await { await => {} } | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` @@ -50,7 +50,7 @@ LL | match await { await => {} } = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716> error: `await` is a keyword in the 2018 edition - --> $DIR/2015-edition-warning.rs:22:19 + --> $DIR/2015-edition-warning.rs:23:19 | LL | match await { await => {} } | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` diff --git a/tests/ui/async-await/debug-ice-attempted-to-add-with-overflow.stderr b/tests/ui/async-await/debug-ice-attempted-to-add-with-overflow.stderr index 8c9d06c79ca..40d44db205f 100644 --- a/tests/ui/async-await/debug-ice-attempted-to-add-with-overflow.stderr +++ b/tests/ui/async-await/debug-ice-attempted-to-add-with-overflow.stderr @@ -2,14 +2,16 @@ error[E0277]: `[usize; usize::MAX]` is not a future --> $DIR/debug-ice-attempted-to-add-with-overflow.rs:8:37 | LL | [0usize; 0xffff_ffff_ffff_ffff].await; - | -^^^^^ - | || - | |`[usize; usize::MAX]` is not a future - | help: remove the `.await` + | ^^^^^ `[usize; usize::MAX]` is not a future | = help: the trait `Future` is not implemented for `[usize; usize::MAX]` = note: [usize; usize::MAX] must be a future or must implement `IntoFuture` to be awaited = note: required for `[usize; usize::MAX]` to implement `IntoFuture` +help: remove the `.await` + | +LL - [0usize; 0xffff_ffff_ffff_ffff].await; +LL + [0usize; 0xffff_ffff_ffff_ffff]; + | error[E0752]: `main` function is not allowed to be `async` --> $DIR/debug-ice-attempted-to-add-with-overflow.rs:6:1 diff --git a/tests/ui/async-await/drop-track-bad-field-in-fru.stderr b/tests/ui/async-await/drop-track-bad-field-in-fru.stderr index 721e0106293..644a7c7717c 100644 --- a/tests/ui/async-await/drop-track-bad-field-in-fru.stderr +++ b/tests/ui/async-await/drop-track-bad-field-in-fru.stderr @@ -10,14 +10,16 @@ error[E0277]: `Option<_>` is not a future --> $DIR/drop-track-bad-field-in-fru.rs:6:46 | LL | None { value: (), ..Default::default() }.await; - | -^^^^^ - | || - | |`Option<_>` is not a future - | help: remove the `.await` + | ^^^^^ `Option<_>` is not a future | = help: the trait `Future` is not implemented for `Option<_>` = note: Option<_> must be a future or must implement `IntoFuture` to be awaited = note: required for `Option<_>` to implement `IntoFuture` +help: remove the `.await` + | +LL - None { value: (), ..Default::default() }.await; +LL + None { value: (), ..Default::default() }; + | error: aborting due to 2 previous errors diff --git a/tests/ui/async-await/dyn/mut-is-pointer-like.stderr b/tests/ui/async-await/dyn/mut-is-pointer-like.stderr index bf20473924b..6689539ff45 100644 --- a/tests/ui/async-await/dyn/mut-is-pointer-like.stderr +++ b/tests/ui/async-await/dyn/mut-is-pointer-like.stderr @@ -8,10 +8,10 @@ LL | #![feature(async_fn_in_dyn_trait)] = note: `#[warn(incomplete_features)]` on by default error[E0038]: the trait `AsyncTrait` is not dyn compatible - --> $DIR/mut-is-pointer-like.rs:35:16 + --> $DIR/mut-is-pointer-like.rs:35:29 | LL | let x: Pin<&mut dyn AsyncTrait<Output = ()>> = f; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `AsyncTrait` is not dyn compatible + | ^^^^^^^^^^^^^^^^^^^^^^^ `AsyncTrait` 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> @@ -24,48 +24,6 @@ LL | async fn async_dispatch(self: Pin<&mut Self>) -> Self::Output; | ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async` = help: consider moving `async_dispatch` to another trait -error[E0038]: the trait `AsyncTrait` is not dyn compatible - --> $DIR/mut-is-pointer-like.rs:35:56 - | -LL | let x: Pin<&mut dyn AsyncTrait<Output = ()>> = f; - | ^ `AsyncTrait` 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/mut-is-pointer-like.rs:16:14 - | -LL | trait AsyncTrait { - | ---------- this trait is not dyn compatible... -... -LL | async fn async_dispatch(self: Pin<&mut Self>) -> Self::Output; - | ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async` - = help: consider moving `async_dispatch` to another trait - = note: required for the cast from `Pin<&mut {async block@$DIR/mut-is-pointer-like.rs:32:32: 32:37}>` to `Pin<&mut dyn AsyncTrait<Output = ()>>` - -error[E0277]: the trait bound `dyn AsyncTrait<Output = ()>: AsyncTrait` is not satisfied - --> $DIR/mut-is-pointer-like.rs:36:11 - | -LL | x.async_dispatch().await; - | ^^^^^^^^^^^^^^ the trait `AsyncTrait` is not implemented for `dyn AsyncTrait<Output = ()>` - -error[E0038]: the trait `AsyncTrait` is not dyn compatible - --> $DIR/mut-is-pointer-like.rs:36:9 - | -LL | x.async_dispatch().await; - | ^^^^^^^^^^^^^^^^^^ `AsyncTrait` 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/mut-is-pointer-like.rs:16:14 - | -LL | trait AsyncTrait { - | ---------- this trait is not dyn compatible... -... -LL | async fn async_dispatch(self: Pin<&mut Self>) -> Self::Output; - | ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async` - = help: consider moving `async_dispatch` to another trait - -error: aborting due to 4 previous errors; 1 warning emitted +error: aborting due to 1 previous error; 1 warning emitted -Some errors have detailed explanations: E0038, E0277. -For more information about an error, try `rustc --explain E0038`. +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/async-await/dyn/works.stderr b/tests/ui/async-await/dyn/works.stderr index 47abeab5aac..338479d8b70 100644 --- a/tests/ui/async-await/dyn/works.stderr +++ b/tests/ui/async-await/dyn/works.stderr @@ -8,10 +8,10 @@ LL | #![feature(async_fn_in_dyn_trait)] = note: `#[warn(incomplete_features)]` on by default error[E0038]: the trait `AsyncTrait` is not dyn compatible - --> $DIR/works.rs:27:34 + --> $DIR/works.rs:27:21 | LL | let x: &dyn AsyncTrait = &"hello, world!"; - | ^^^^^^^^^^^^^^^^ `AsyncTrait` is not dyn compatible + | ^^^^^^^^^^ `AsyncTrait` 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> @@ -23,59 +23,7 @@ LL | async fn async_dispatch(&self); | ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async` = help: consider moving `async_dispatch` to another trait = help: only type `&'static str` implements `AsyncTrait`; consider using it directly instead. - = note: required for the cast from `&&'static str` to `&dyn AsyncTrait` -error[E0038]: the trait `AsyncTrait` is not dyn compatible - --> $DIR/works.rs:27:16 - | -LL | let x: &dyn AsyncTrait = &"hello, world!"; - | ^^^^^^^^^^^^^^^ `AsyncTrait` 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/works.rs:14:14 - | -LL | trait AsyncTrait { - | ---------- this trait is not dyn compatible... -LL | async fn async_dispatch(&self); - | ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async` - = help: consider moving `async_dispatch` to another trait - = help: only type `&'static str` implements `AsyncTrait`; consider using it directly instead. - -error[E0038]: the trait `AsyncTrait` is not dyn compatible - --> $DIR/works.rs:28:11 - | -LL | x.async_dispatch().await; - | ^^^^^^^^^^^^^^ `AsyncTrait` 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/works.rs:14:14 - | -LL | trait AsyncTrait { - | ---------- this trait is not dyn compatible... -LL | async fn async_dispatch(&self); - | ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async` - = help: consider moving `async_dispatch` to another trait - = help: only type `&'static str` implements `AsyncTrait`; consider using it directly instead. - -error[E0038]: the trait `AsyncTrait` is not dyn compatible - --> $DIR/works.rs:28:9 - | -LL | x.async_dispatch().await; - | ^^^^^^^^^^^^^^^^^^ `AsyncTrait` 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/works.rs:14:14 - | -LL | trait AsyncTrait { - | ---------- this trait is not dyn compatible... -LL | async fn async_dispatch(&self); - | ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async` - = help: consider moving `async_dispatch` to another trait - = help: only type `&'static str` implements `AsyncTrait`; consider using it directly instead. - -error: aborting due to 4 previous errors; 1 warning emitted +error: aborting due to 1 previous error; 1 warning emitted For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/async-await/dyn/wrong-size.stderr b/tests/ui/async-await/dyn/wrong-size.stderr index b4684f4fc17..a465f91f62a 100644 --- a/tests/ui/async-await/dyn/wrong-size.stderr +++ b/tests/ui/async-await/dyn/wrong-size.stderr @@ -8,10 +8,10 @@ LL | #![feature(async_fn_in_dyn_trait)] = note: `#[warn(incomplete_features)]` on by default error[E0038]: the trait `AsyncTrait` is not dyn compatible - --> $DIR/wrong-size.rs:21:30 + --> $DIR/wrong-size.rs:21:17 | LL | let x: &dyn AsyncTrait = &"hello, world!"; - | ^^^^^^^^^^^^^^^^ `AsyncTrait` is not dyn compatible + | ^^^^^^^^^^ `AsyncTrait` 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> @@ -23,25 +23,7 @@ LL | async fn async_dispatch(&self); | ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async` = help: consider moving `async_dispatch` to another trait = help: only type `&'static str` implements `AsyncTrait`; consider using it directly instead. - = note: required for the cast from `&&'static str` to `&dyn AsyncTrait` -error[E0038]: the trait `AsyncTrait` is not dyn compatible - --> $DIR/wrong-size.rs:21:12 - | -LL | let x: &dyn AsyncTrait = &"hello, world!"; - | ^^^^^^^^^^^^^^^ `AsyncTrait` 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/wrong-size.rs:9:14 - | -LL | trait AsyncTrait { - | ---------- this trait is not dyn compatible... -LL | async fn async_dispatch(&self); - | ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async` - = help: consider moving `async_dispatch` to another trait - = help: only type `&'static str` implements `AsyncTrait`; consider using it directly instead. - -error: aborting due to 2 previous errors; 1 warning emitted +error: aborting due to 1 previous error; 1 warning emitted For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/async-await/for-await-2015.rs b/tests/ui/async-await/for-await-2015.rs index 89ff256da1d..c2bd39c8446 100644 --- a/tests/ui/async-await/for-await-2015.rs +++ b/tests/ui/async-await/for-await-2015.rs @@ -1,3 +1,4 @@ +//@ edition:2015 //@ check-pass #![feature(async_for_loop)] diff --git a/tests/ui/async-await/in-trait/dyn-compatibility.stderr b/tests/ui/async-await/in-trait/dyn-compatibility.stderr index 553bcbf89d5..f0c5dc53478 100644 --- a/tests/ui/async-await/in-trait/dyn-compatibility.stderr +++ b/tests/ui/async-await/in-trait/dyn-compatibility.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/dyn-compatibility.rs:9:12 + --> $DIR/dyn-compatibility.rs:9:17 | LL | let x: &dyn Foo = todo!(); - | ^^^^^^^^ `Foo` is not dyn compatible + | ^^^ `Foo` 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> diff --git a/tests/ui/async-await/issue-101715.stderr b/tests/ui/async-await/issue-101715.stderr index f6af15c00d6..87302dce130 100644 --- a/tests/ui/async-await/issue-101715.stderr +++ b/tests/ui/async-await/issue-101715.stderr @@ -2,14 +2,15 @@ error[E0277]: `()` is not a future --> $DIR/issue-101715.rs:11:10 | LL | .await - | -^^^^^ - | || - | |`()` is not a future - | help: remove the `.await` + | ^^^^^ `()` is not a future | = help: the trait `Future` is not implemented for `()` = note: () must be a future or must implement `IntoFuture` to be awaited = note: required for `()` to implement `IntoFuture` +help: remove the `.await` + | +LL - .await + | error: aborting due to 1 previous error diff --git a/tests/ui/async-await/issue-65634-raw-ident-suggestion.edition2015.stderr b/tests/ui/async-await/issue-65634-raw-ident-suggestion.edition2015.stderr index 2bdc1347c81..8ce4d4ea06a 100644 --- a/tests/ui/async-await/issue-65634-raw-ident-suggestion.edition2015.stderr +++ b/tests/ui/async-await/issue-65634-raw-ident-suggestion.edition2015.stderr @@ -1,16 +1,16 @@ error[E0034]: multiple applicable items in scope - --> $DIR/issue-65634-raw-ident-suggestion.rs:24:13 + --> $DIR/issue-65634-raw-ident-suggestion.rs:25:13 | LL | r#fn {}.r#struct(); | ^^^^^^^^ multiple `r#struct` found | note: candidate #1 is defined in an impl of the trait `async` for the type `r#fn` - --> $DIR/issue-65634-raw-ident-suggestion.rs:7:5 + --> $DIR/issue-65634-raw-ident-suggestion.rs:8:5 | LL | fn r#struct(&self) { | ^^^^^^^^^^^^^^^^^^ note: candidate #2 is defined in an impl of the trait `await` for the type `r#fn` - --> $DIR/issue-65634-raw-ident-suggestion.rs:13:5 + --> $DIR/issue-65634-raw-ident-suggestion.rs:14:5 | LL | fn r#struct(&self) { | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/async-await/issue-65634-raw-ident-suggestion.edition2018.stderr b/tests/ui/async-await/issue-65634-raw-ident-suggestion.edition2018.stderr index ab10ab749fe..d910ef9872c 100644 --- a/tests/ui/async-await/issue-65634-raw-ident-suggestion.edition2018.stderr +++ b/tests/ui/async-await/issue-65634-raw-ident-suggestion.edition2018.stderr @@ -1,16 +1,16 @@ error[E0034]: multiple applicable items in scope - --> $DIR/issue-65634-raw-ident-suggestion.rs:24:13 + --> $DIR/issue-65634-raw-ident-suggestion.rs:25:13 | LL | r#fn {}.r#struct(); | ^^^^^^^^ multiple `r#struct` found | note: candidate #1 is defined in an impl of the trait `r#async` for the type `r#fn` - --> $DIR/issue-65634-raw-ident-suggestion.rs:7:5 + --> $DIR/issue-65634-raw-ident-suggestion.rs:8:5 | LL | fn r#struct(&self) { | ^^^^^^^^^^^^^^^^^^ note: candidate #2 is defined in an impl of the trait `r#await` for the type `r#fn` - --> $DIR/issue-65634-raw-ident-suggestion.rs:13:5 + --> $DIR/issue-65634-raw-ident-suggestion.rs:14:5 | LL | fn r#struct(&self) { | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/async-await/issue-65634-raw-ident-suggestion.rs b/tests/ui/async-await/issue-65634-raw-ident-suggestion.rs index ef5760f4846..98f5b6dd9f9 100644 --- a/tests/ui/async-await/issue-65634-raw-ident-suggestion.rs +++ b/tests/ui/async-await/issue-65634-raw-ident-suggestion.rs @@ -1,4 +1,5 @@ //@ revisions: edition2015 edition2018 +//@[edition2015]edition:2015 //@[edition2018]edition:2018 #![allow(non_camel_case_types)] diff --git a/tests/ui/async-await/issues/issue-63388-1.rs b/tests/ui/async-await/issues/issue-63388-1.rs index acfc64baff9..3a89f3ebfd2 100644 --- a/tests/ui/async-await/issues/issue-63388-1.rs +++ b/tests/ui/async-await/issues/issue-63388-1.rs @@ -9,7 +9,7 @@ trait Foo {} impl Xyz { async fn do_sth<'a>( &'a self, foo: &dyn Foo - ) -> &dyn Foo //~ WARNING elided lifetime has a name + ) -> &dyn Foo { foo //~^ ERROR explicit lifetime required in the type of `foo` [E0621] diff --git a/tests/ui/async-await/issues/issue-63388-1.stderr b/tests/ui/async-await/issues/issue-63388-1.stderr index 579caa45bc9..277f7fa6f63 100644 --- a/tests/ui/async-await/issues/issue-63388-1.stderr +++ b/tests/ui/async-await/issues/issue-63388-1.stderr @@ -1,14 +1,3 @@ -warning: elided lifetime has a name - --> $DIR/issue-63388-1.rs:12:10 - | -LL | async fn do_sth<'a>( - | -- lifetime `'a` declared here -LL | &'a self, foo: &dyn Foo -LL | ) -> &dyn Foo - | ^ this elided lifetime gets resolved as `'a` - | - = note: `#[warn(elided_named_lifetimes)]` on by default - error[E0621]: explicit lifetime required in the type of `foo` --> $DIR/issue-63388-1.rs:14:9 | @@ -18,6 +7,6 @@ LL | &'a self, foo: &dyn Foo LL | foo | ^^^ lifetime `'a` required -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0621`. diff --git a/tests/ui/async-await/suggest-switching-edition-on-await-cargo.rs b/tests/ui/async-await/suggest-switching-edition-on-await-cargo.rs index bcb5cb94b77..555b0110521 100644 --- a/tests/ui/async-await/suggest-switching-edition-on-await-cargo.rs +++ b/tests/ui/async-await/suggest-switching-edition-on-await-cargo.rs @@ -1,3 +1,4 @@ +//@ edition:2015 //@ rustc-env:CARGO_CRATE_NAME=foo use std::pin::Pin; diff --git a/tests/ui/async-await/suggest-switching-edition-on-await-cargo.stderr b/tests/ui/async-await/suggest-switching-edition-on-await-cargo.stderr index 11f5825c232..c5f1793731e 100644 --- a/tests/ui/async-await/suggest-switching-edition-on-await-cargo.stderr +++ b/tests/ui/async-await/suggest-switching-edition-on-await-cargo.stderr @@ -1,5 +1,5 @@ error[E0609]: no field `await` on type `await_on_struct_missing::S` - --> $DIR/suggest-switching-edition-on-await-cargo.rs:11:7 + --> $DIR/suggest-switching-edition-on-await-cargo.rs:12:7 | LL | x.await; | ^^^^^ unknown field @@ -9,7 +9,7 @@ LL | x.await; = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0609]: no field `await` on type `await_on_struct_similar::S` - --> $DIR/suggest-switching-edition-on-await-cargo.rs:24:7 + --> $DIR/suggest-switching-edition-on-await-cargo.rs:25:7 | LL | x.await; | ^^^^^ unknown field @@ -24,7 +24,7 @@ LL + x.awai; | error[E0609]: no field `await` on type `Pin<&mut dyn Future<Output = ()>>` - --> $DIR/suggest-switching-edition-on-await-cargo.rs:34:7 + --> $DIR/suggest-switching-edition-on-await-cargo.rs:35:7 | LL | x.await; | ^^^^^ unknown field @@ -34,7 +34,7 @@ LL | x.await; = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0609]: no field `await` on type `impl Future<Output = ()>` - --> $DIR/suggest-switching-edition-on-await-cargo.rs:43:7 + --> $DIR/suggest-switching-edition-on-await-cargo.rs:44:7 | LL | x.await; | ^^^^^ unknown field diff --git a/tests/ui/async-await/suggest-switching-edition-on-await.rs b/tests/ui/async-await/suggest-switching-edition-on-await.rs index 0907a87e02c..6b639fa0b4e 100644 --- a/tests/ui/async-await/suggest-switching-edition-on-await.rs +++ b/tests/ui/async-await/suggest-switching-edition-on-await.rs @@ -1,3 +1,4 @@ +//@ edition:2015 use std::pin::Pin; use std::future::Future; diff --git a/tests/ui/async-await/suggest-switching-edition-on-await.stderr b/tests/ui/async-await/suggest-switching-edition-on-await.stderr index 2ede8d5b7f4..bf03016222e 100644 --- a/tests/ui/async-await/suggest-switching-edition-on-await.stderr +++ b/tests/ui/async-await/suggest-switching-edition-on-await.stderr @@ -1,5 +1,5 @@ error[E0609]: no field `await` on type `await_on_struct_missing::S` - --> $DIR/suggest-switching-edition-on-await.rs:9:7 + --> $DIR/suggest-switching-edition-on-await.rs:10:7 | LL | x.await; | ^^^^^ unknown field @@ -9,7 +9,7 @@ LL | x.await; = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0609]: no field `await` on type `await_on_struct_similar::S` - --> $DIR/suggest-switching-edition-on-await.rs:22:7 + --> $DIR/suggest-switching-edition-on-await.rs:23:7 | LL | x.await; | ^^^^^ unknown field @@ -24,7 +24,7 @@ LL + x.awai; | error[E0609]: no field `await` on type `Pin<&mut dyn Future<Output = ()>>` - --> $DIR/suggest-switching-edition-on-await.rs:32:7 + --> $DIR/suggest-switching-edition-on-await.rs:33:7 | LL | x.await; | ^^^^^ unknown field @@ -34,7 +34,7 @@ LL | x.await; = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0609]: no field `await` on type `impl Future<Output = ()>` - --> $DIR/suggest-switching-edition-on-await.rs:41:7 + --> $DIR/suggest-switching-edition-on-await.rs:42:7 | LL | x.await; | ^^^^^ unknown field diff --git a/tests/ui/async-await/unnecessary-await.stderr b/tests/ui/async-await/unnecessary-await.stderr index 620370a6113..f60b4ecb990 100644 --- a/tests/ui/async-await/unnecessary-await.stderr +++ b/tests/ui/async-await/unnecessary-await.stderr @@ -23,14 +23,16 @@ error[E0277]: `()` is not a future --> $DIR/unnecessary-await.rs:28:10 | LL | e!().await; - | -^^^^^ - | || - | |`()` is not a future - | help: remove the `.await` + | ^^^^^ `()` is not a future | = help: the trait `Future` is not implemented for `()` = note: () must be a future or must implement `IntoFuture` to be awaited = note: required for `()` to implement `IntoFuture` +help: remove the `.await` + | +LL - e!().await; +LL + e!(); + | error[E0277]: `()` is not a future --> $DIR/unnecessary-await.rs:22:15 @@ -53,14 +55,16 @@ error[E0277]: `()` is not a future --> $DIR/unnecessary-await.rs:36:20 | LL | for x in [] {}.await - | -^^^^^ - | || - | |`()` is not a future - | help: remove the `.await` + | ^^^^^ `()` is not a future | = help: the trait `Future` is not implemented for `()` = note: () must be a future or must implement `IntoFuture` to be awaited = note: required for `()` to implement `IntoFuture` +help: remove the `.await` + | +LL - for x in [] {}.await +LL + for x in [] {} + | error: aborting due to 4 previous errors diff --git a/tests/ui/custom_attribute.rs b/tests/ui/attributes/attr_unknown_custom_attr.rs index 4957184229d..cdbe48a636f 100644 --- a/tests/ui/custom_attribute.rs +++ b/tests/ui/attributes/attr_unknown_custom_attr.rs @@ -1,3 +1,5 @@ +//! Checks error handling for undefined custom attributes. + #![feature(stmt_expr_attributes)] #[foo] //~ ERROR cannot find attribute `foo` in this scope diff --git a/tests/ui/custom_attribute.stderr b/tests/ui/attributes/attr_unknown_custom_attr.stderr index 4023892d294..76c3b884a5d 100644 --- a/tests/ui/custom_attribute.stderr +++ b/tests/ui/attributes/attr_unknown_custom_attr.stderr @@ -1,17 +1,17 @@ error: cannot find attribute `foo` in this scope - --> $DIR/custom_attribute.rs:3:3 + --> $DIR/attr_unknown_custom_attr.rs:5:3 | LL | #[foo] | ^^^ error: cannot find attribute `foo` in this scope - --> $DIR/custom_attribute.rs:5:7 + --> $DIR/attr_unknown_custom_attr.rs:7:7 | LL | #[foo] | ^^^ error: cannot find attribute `foo` in this scope - --> $DIR/custom_attribute.rs:7:7 + --> $DIR/attr_unknown_custom_attr.rs:9:7 | LL | #[foo] | ^^^ diff --git a/tests/ui/attributes/auxiliary/external-macro-use.rs b/tests/ui/attributes/auxiliary/external-macro-use.rs new file mode 100644 index 00000000000..beeb7fe689c --- /dev/null +++ b/tests/ui/attributes/auxiliary/external-macro-use.rs @@ -0,0 +1,7 @@ +extern crate proc_macro; +use proc_macro::*; + +#[proc_macro_attribute] +pub fn a(_: TokenStream, input: TokenStream) -> TokenStream { + input +} diff --git a/tests/ui/attributes/auxiliary/use-doc-alias-name-extern.rs b/tests/ui/attributes/auxiliary/use-doc-alias-name-extern.rs new file mode 100644 index 00000000000..4c06d0fdfe3 --- /dev/null +++ b/tests/ui/attributes/auxiliary/use-doc-alias-name-extern.rs @@ -0,0 +1,24 @@ +#[doc(alias="DocAliasS1")] +pub struct S1; + +#[doc(alias="DocAliasS2")] +#[doc(alias("DocAliasS3", "DocAliasS4"))] +pub struct S2; + +#[doc(alias("doc_alias_f1", "doc_alias_f2"))] +pub fn f() {} + +pub mod m { + #[doc(alias="DocAliasS5")] + pub struct S5; + + pub mod n { + #[doc(alias("DocAliasX"))] + pub mod x { + pub mod y { + #[doc(alias="DocAliasS6")] + pub struct S6; + } + } + } +} diff --git a/tests/ui/crate-name-attr-used.rs b/tests/ui/attributes/crate-name-attr-validation.rs index 5d5a58c32c7..e27893c3d25 100644 --- a/tests/ui/crate-name-attr-used.rs +++ b/tests/ui/attributes/crate-name-attr-validation.rs @@ -1,3 +1,5 @@ +//! Checks proper validation of the `#![crate_name]` attribute. + //@ run-pass //@ compile-flags:--crate-name crate_name_attr_used -F unused-attributes diff --git a/tests/ui/crate-name-mismatch.rs b/tests/ui/attributes/crate-name-mismatch.rs index 7651e0f97eb..0c343d70b9c 100644 --- a/tests/ui/crate-name-mismatch.rs +++ b/tests/ui/attributes/crate-name-mismatch.rs @@ -1,3 +1,5 @@ +//! Checks error handling for mismatched `--crate-name` and `#![crate_name]` values. + //@ compile-flags: --crate-name foo #![crate_name = "bar"] diff --git a/tests/ui/crate-name-mismatch.stderr b/tests/ui/attributes/crate-name-mismatch.stderr index 511562618d5..4021fbe7c18 100644 --- a/tests/ui/crate-name-mismatch.stderr +++ b/tests/ui/attributes/crate-name-mismatch.stderr @@ -1,5 +1,5 @@ error: `--crate-name` and `#[crate_name]` are required to match, but `foo` != `bar` - --> $DIR/crate-name-mismatch.rs:3:1 + --> $DIR/crate-name-mismatch.rs:5:1 | LL | #![crate_name = "bar"] | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/custom-attribute-multisegment.rs b/tests/ui/attributes/custom_attr_multisegment_error.rs index 24349213902..1045282c3a3 100644 --- a/tests/ui/custom-attribute-multisegment.rs +++ b/tests/ui/attributes/custom_attr_multisegment_error.rs @@ -1,4 +1,4 @@ -// Unresolved multi-segment attributes are not treated as custom. +//! Unresolved multi-segment attributes are not treated as custom. mod existent {} diff --git a/tests/ui/custom-attribute-multisegment.stderr b/tests/ui/attributes/custom_attr_multisegment_error.stderr index 90ebe277939..02bed225d53 100644 --- a/tests/ui/custom-attribute-multisegment.stderr +++ b/tests/ui/attributes/custom_attr_multisegment_error.stderr @@ -1,5 +1,5 @@ error[E0433]: failed to resolve: could not find `nonexistent` in `existent` - --> $DIR/custom-attribute-multisegment.rs:5:13 + --> $DIR/custom_attr_multisegment_error.rs:5:13 | LL | #[existent::nonexistent] | ^^^^^^^^^^^ could not find `nonexistent` in `existent` diff --git a/tests/ui/attributes/illegal-macro-use.rs b/tests/ui/attributes/illegal-macro-use.rs new file mode 100644 index 00000000000..5a567107a6e --- /dev/null +++ b/tests/ui/attributes/illegal-macro-use.rs @@ -0,0 +1,15 @@ +// issue#140255 + +#[macro_use::a] //~ ERROR failed to resolve: use of unresolved module or unlinked crate `macro_use` +fn f0() {} + +#[macro_use::a::b] //~ ERROR failed to resolve: use of unresolved module or unlinked crate `macro_use` +fn f1() {} + +#[macro_escape::a] //~ ERROR failed to resolve: use of unresolved module or unlinked crate `macro_escape` +fn f2() {} + +#[macro_escape::a::b] //~ ERROR failed to resolve: use of unresolved module or unlinked crate `macro_escape` +fn f3() {} + +fn main() {} diff --git a/tests/ui/attributes/illegal-macro-use.stderr b/tests/ui/attributes/illegal-macro-use.stderr new file mode 100644 index 00000000000..fa6bb83d588 --- /dev/null +++ b/tests/ui/attributes/illegal-macro-use.stderr @@ -0,0 +1,27 @@ +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `macro_escape` + --> $DIR/illegal-macro-use.rs:12:3 + | +LL | #[macro_escape::a::b] + | ^^^^^^^^^^^^ use of unresolved module or unlinked crate `macro_escape` + +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `macro_escape` + --> $DIR/illegal-macro-use.rs:9:3 + | +LL | #[macro_escape::a] + | ^^^^^^^^^^^^ use of unresolved module or unlinked crate `macro_escape` + +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `macro_use` + --> $DIR/illegal-macro-use.rs:6:3 + | +LL | #[macro_use::a::b] + | ^^^^^^^^^ use of unresolved module or unlinked crate `macro_use` + +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `macro_use` + --> $DIR/illegal-macro-use.rs:3:3 + | +LL | #[macro_use::a] + | ^^^^^^^^^ use of unresolved module or unlinked crate `macro_use` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/attributes/rustc_confusables.stderr b/tests/ui/attributes/rustc_confusables.stderr index 55c9219a08a..aba384ff8ac 100644 --- a/tests/ui/attributes/rustc_confusables.stderr +++ b/tests/ui/attributes/rustc_confusables.stderr @@ -42,13 +42,13 @@ error[E0599]: no method named `foo` found for struct `rustc_confusables_across_c --> $DIR/rustc_confusables.rs:15:7 | LL | x.foo(); - | ^^^ method not found in `BTreeSet` + | ^^^ method not found in `rustc_confusables_across_crate::BTreeSet` error[E0599]: no method named `push` found for struct `rustc_confusables_across_crate::BTreeSet` in the current scope --> $DIR/rustc_confusables.rs:17:7 | LL | x.push(); - | ^^^^ method not found in `BTreeSet` + | ^^^^ method not found in `rustc_confusables_across_crate::BTreeSet` | help: you might have meant to use `insert` | @@ -60,7 +60,7 @@ error[E0599]: no method named `test` found for struct `rustc_confusables_across_ --> $DIR/rustc_confusables.rs:20:7 | LL | x.test(); - | ^^^^ method not found in `BTreeSet` + | ^^^^ method not found in `rustc_confusables_across_crate::BTreeSet` error[E0599]: no method named `pulled` found for struct `rustc_confusables_across_crate::BTreeSet` in the current scope --> $DIR/rustc_confusables.rs:22:7 diff --git a/tests/ui/attributes/use-doc-alias-name.rs b/tests/ui/attributes/use-doc-alias-name.rs new file mode 100644 index 00000000000..1fc9199b6e3 --- /dev/null +++ b/tests/ui/attributes/use-doc-alias-name.rs @@ -0,0 +1,67 @@ +//@ aux-build: use-doc-alias-name-extern.rs + +// issue#124273 + +extern crate use_doc_alias_name_extern; + +use use_doc_alias_name_extern::*; + +#[doc(alias="LocalDocAliasS")] +struct S; + +fn main() { + LocalDocAliasS; // don't show help in local crate + //~^ ERROR: cannot find value `LocalDocAliasS` in this scope + + DocAliasS1; + //~^ ERROR: cannot find value `DocAliasS1` in this scope + //~| HELP: `S1` has a name defined in the doc alias attribute as `DocAliasS1` + + DocAliasS2; + //~^ ERROR: cannot find value `DocAliasS2` in this scope + //~| HELP: `S2` has a name defined in the doc alias attribute as `DocAliasS2` + + DocAliasS3; + //~^ ERROR: cannot find value `DocAliasS3` in this scope + //~| HELP: `S2` has a name defined in the doc alias attribute as `DocAliasS3` + + DocAliasS4; + //~^ ERROR: cannot find value `DocAliasS4` in this scope + //~| HELP: `S2` has a name defined in the doc alias attribute as `DocAliasS4` + + doc_alias_f1(); + //~^ ERROR: cannot find function `doc_alias_f1` in this scope + //~| HELP: `f` has a name defined in the doc alias attribute as `doc_alias_f1` + + doc_alias_f2(); + //~^ ERROR: cannot find function `doc_alias_f2` in this scope + //~| HELP: `f` has a name defined in the doc alias attribute as `doc_alias_f2` + + m::DocAliasS5; + //~^ ERROR: cannot find value `DocAliasS5` in module `m` + //~| HELP: `S5` has a name defined in the doc alias attribute as `DocAliasS5` + + not_exist_module::DocAliasS1; + //~^ ERROR: use of unresolved module or unlinked crate `not_exist_module` + //~| HELP: you might be missing a crate named `not_exist_module` + + use_doc_alias_name_extern::DocAliasS1; + //~^ ERROR: cannot find value `DocAliasS1` in crate `use_doc_alias_name_extern + //~| HELP: `S1` has a name defined in the doc alias attribute as `DocAliasS1` + + m::n::DocAliasX::y::S6; + //~^ ERROR: could not find `DocAliasX` in `n` + //~| HELP: `x` has a name defined in the doc alias attribute as `DocAliasX` + + m::n::x::y::DocAliasS6; + //~^ ERROR: cannot find value `DocAliasS6` in module `m::n::x::y` + //~| HELP: `S6` has a name defined in the doc alias attribute as `DocAliasS6` +} + +trait T { + fn f() { + DocAliasS1; + //~^ ERROR: cannot find value `DocAliasS1` in this scope + //~| HELP: `S1` has a name defined in the doc alias attribute as `DocAliasS1` + } +} diff --git a/tests/ui/attributes/use-doc-alias-name.stderr b/tests/ui/attributes/use-doc-alias-name.stderr new file mode 100644 index 00000000000..07f4865e415 --- /dev/null +++ b/tests/ui/attributes/use-doc-alias-name.stderr @@ -0,0 +1,150 @@ +error[E0433]: failed to resolve: could not find `DocAliasX` in `n` + --> $DIR/use-doc-alias-name.rs:52:11 + | +LL | m::n::DocAliasX::y::S6; + | ^^^^^^^^^ could not find `DocAliasX` in `n` + | +help: `x` has a name defined in the doc alias attribute as `DocAliasX` + | +LL - m::n::DocAliasX::y::S6; +LL + m::n::x::y::S6; + | + +error[E0425]: cannot find value `LocalDocAliasS` in this scope + --> $DIR/use-doc-alias-name.rs:13:5 + | +LL | LocalDocAliasS; // don't show help in local crate + | ^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find value `DocAliasS1` in this scope + --> $DIR/use-doc-alias-name.rs:16:5 + | +LL | DocAliasS1; + | ^^^^^^^^^^ + | +help: `S1` has a name defined in the doc alias attribute as `DocAliasS1` + | +LL - DocAliasS1; +LL + S1; + | + +error[E0425]: cannot find value `DocAliasS2` in this scope + --> $DIR/use-doc-alias-name.rs:20:5 + | +LL | DocAliasS2; + | ^^^^^^^^^^ + | +help: `S2` has a name defined in the doc alias attribute as `DocAliasS2` + | +LL - DocAliasS2; +LL + S2; + | + +error[E0425]: cannot find value `DocAliasS3` in this scope + --> $DIR/use-doc-alias-name.rs:24:5 + | +LL | DocAliasS3; + | ^^^^^^^^^^ + | +help: `S2` has a name defined in the doc alias attribute as `DocAliasS3` + | +LL - DocAliasS3; +LL + S2; + | + +error[E0425]: cannot find value `DocAliasS4` in this scope + --> $DIR/use-doc-alias-name.rs:28:5 + | +LL | DocAliasS4; + | ^^^^^^^^^^ + | +help: `S2` has a name defined in the doc alias attribute as `DocAliasS4` + | +LL - DocAliasS4; +LL + S2; + | + +error[E0425]: cannot find value `DocAliasS5` in module `m` + --> $DIR/use-doc-alias-name.rs:40:8 + | +LL | m::DocAliasS5; + | ^^^^^^^^^^ + | +help: `S5` has a name defined in the doc alias attribute as `DocAliasS5` + | +LL - m::DocAliasS5; +LL + m::S5; + | + +error[E0425]: cannot find value `DocAliasS1` in crate `use_doc_alias_name_extern` + --> $DIR/use-doc-alias-name.rs:48:32 + | +LL | use_doc_alias_name_extern::DocAliasS1; + | ^^^^^^^^^^ + | +help: `S1` has a name defined in the doc alias attribute as `DocAliasS1` + | +LL - use_doc_alias_name_extern::DocAliasS1; +LL + use_doc_alias_name_extern::S1; + | + +error[E0425]: cannot find value `DocAliasS6` in module `m::n::x::y` + --> $DIR/use-doc-alias-name.rs:56:17 + | +LL | m::n::x::y::DocAliasS6; + | ^^^^^^^^^^ + | +help: `S6` has a name defined in the doc alias attribute as `DocAliasS6` + | +LL - m::n::x::y::DocAliasS6; +LL + m::n::x::y::S6; + | + +error[E0425]: cannot find value `DocAliasS1` in this scope + --> $DIR/use-doc-alias-name.rs:63:9 + | +LL | DocAliasS1; + | ^^^^^^^^^^ + | +help: `S1` has a name defined in the doc alias attribute as `DocAliasS1` + | +LL - DocAliasS1; +LL + S1; + | + +error[E0425]: cannot find function `doc_alias_f1` in this scope + --> $DIR/use-doc-alias-name.rs:32:5 + | +LL | doc_alias_f1(); + | ^^^^^^^^^^^^ + | +help: `f` has a name defined in the doc alias attribute as `doc_alias_f1` + | +LL - doc_alias_f1(); +LL + f(); + | + +error[E0425]: cannot find function `doc_alias_f2` in this scope + --> $DIR/use-doc-alias-name.rs:36:5 + | +LL | doc_alias_f2(); + | ^^^^^^^^^^^^ + | +help: `f` has a name defined in the doc alias attribute as `doc_alias_f2` + | +LL - doc_alias_f2(); +LL + f(); + | + +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `not_exist_module` + --> $DIR/use-doc-alias-name.rs:44:5 + | +LL | not_exist_module::DocAliasS1; + | ^^^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `not_exist_module` + | + = help: you might be missing a crate named `not_exist_module` + +error: aborting due to 13 previous errors + +Some errors have detailed explanations: E0425, E0433. +For more information about an error, try `rustc --explain E0425`. diff --git a/tests/ui/attributes/use-extern-crate-named-macro-use.rs b/tests/ui/attributes/use-extern-crate-named-macro-use.rs new file mode 100644 index 00000000000..5b322ccfaf7 --- /dev/null +++ b/tests/ui/attributes/use-extern-crate-named-macro-use.rs @@ -0,0 +1,11 @@ +//@ check-pass +//@ proc-macro: external-macro-use.rs + +// issue#140255 + +extern crate external_macro_use as macro_use; + +#[macro_use::a] +fn f() {} + +fn main() {} diff --git a/tests/ui/autoderef-full-lval.rs b/tests/ui/autoderef-full-lval.rs deleted file mode 100644 index 0fadc5c9827..00000000000 --- a/tests/ui/autoderef-full-lval.rs +++ /dev/null @@ -1,25 +0,0 @@ -struct Clam { - x: Box<isize>, - y: Box<isize>, -} - - - -struct Fish { - a: Box<isize>, -} - -fn main() { - let a: Clam = Clam{ x: Box::new(1), y: Box::new(2) }; - let b: Clam = Clam{ x: Box::new(10), y: Box::new(20) }; - let z: isize = a.x + b.y; - //~^ ERROR cannot add `Box<isize>` to `Box<isize>` - println!("{}", z); - assert_eq!(z, 21); - let forty: Fish = Fish{ a: Box::new(40) }; - let two: Fish = Fish{ a: Box::new(2) }; - let answer: isize = forty.a + two.a; - //~^ ERROR cannot add `Box<isize>` to `Box<isize>` - println!("{}", answer); - assert_eq!(answer, 42); -} diff --git a/tests/ui/autodiff/autodiff_illegal.rs b/tests/ui/autodiff/autodiff_illegal.rs index a916bd8b857..a53b6d5e589 100644 --- a/tests/ui/autodiff/autodiff_illegal.rs +++ b/tests/ui/autodiff/autodiff_illegal.rs @@ -7,38 +7,38 @@ // Test that invalid ad macros give nice errors and don't ICE. -use std::autodiff::autodiff; +use std::autodiff::{autodiff_forward, autodiff_reverse}; // We can't use Duplicated on scalars -#[autodiff(df1, Reverse, Duplicated)] +#[autodiff_reverse(df1, Duplicated)] pub fn f1(x: f64) { //~^ ERROR Duplicated can not be used for this type unimplemented!() } // Too many activities -#[autodiff(df3, Reverse, Duplicated, Const)] +#[autodiff_reverse(df3, Duplicated, Const)] pub fn f3(x: f64) { //~^^ ERROR expected 1 activities, but found 2 unimplemented!() } // To few activities -#[autodiff(df4, Reverse)] +#[autodiff_reverse(df4)] pub fn f4(x: f64) { //~^^ ERROR expected 1 activities, but found 0 unimplemented!() } // We can't use Dual in Reverse mode -#[autodiff(df5, Reverse, Dual)] +#[autodiff_reverse(df5, Dual)] pub fn f5(x: f64) { //~^^ ERROR Dual can not be used in Reverse Mode unimplemented!() } // We can't use Duplicated in Forward mode -#[autodiff(df6, Forward, Duplicated)] +#[autodiff_forward(df6, Duplicated)] pub fn f6(x: f64) { //~^^ ERROR Duplicated can not be used in Forward Mode //~^^ ERROR Duplicated can not be used for this type @@ -46,36 +46,36 @@ pub fn f6(x: f64) { } fn dummy() { - #[autodiff(df7, Forward, Dual)] + #[autodiff_forward(df7, Dual)] let mut x = 5; //~^ ERROR autodiff must be applied to function - #[autodiff(df7, Forward, Dual)] + #[autodiff_forward(df7, Dual)] x = x + 3; //~^^ ERROR attributes on expressions are experimental [E0658] //~^^ ERROR autodiff must be applied to function - #[autodiff(df7, Forward, Dual)] + #[autodiff_forward(df7, Dual)] let add_one_v2 = |x: u32| -> u32 { x + 1 }; //~^ ERROR autodiff must be applied to function } // Malformed, where args? -#[autodiff] +#[autodiff_forward] pub fn f7(x: f64) { //~^ ERROR autodiff requires at least a name and mode unimplemented!() } // Malformed, where args? -#[autodiff()] +#[autodiff_forward()] pub fn f8(x: f64) { //~^ ERROR autodiff requires at least a name and mode unimplemented!() } // Invalid attribute syntax -#[autodiff = ""] +#[autodiff_forward = ""] pub fn f9(x: f64) { //~^ ERROR autodiff requires at least a name and mode unimplemented!() @@ -84,29 +84,15 @@ pub fn f9(x: f64) { fn fn_exists() {} // We colide with an already existing function -#[autodiff(fn_exists, Reverse, Active)] +#[autodiff_reverse(fn_exists, Active)] pub fn f10(x: f64) { //~^^ ERROR the name `fn_exists` is defined multiple times [E0428] unimplemented!() } -// Malformed, missing a mode -#[autodiff(df11)] -pub fn f11() { - //~^ ERROR autodiff requires at least a name and mode - unimplemented!() -} - -// Invalid Mode -#[autodiff(df12, Debug)] -pub fn f12() { - //~^^ ERROR unknown Mode: `Debug`. Use `Forward` or `Reverse` - unimplemented!() -} - // Invalid, please pick one Mode // or use two autodiff macros. -#[autodiff(df13, Forward, Reverse)] +#[autodiff_reverse(df13, Reverse)] pub fn f13() { //~^^ ERROR did not recognize Activity: `Reverse` unimplemented!() @@ -117,7 +103,7 @@ struct Foo {} // We can't handle Active structs, because that would mean (in the general case), that we would // need to allocate and initialize arbitrary user types. We have Duplicated/Dual input args for // that. FIXME: Give a nicer error and suggest to the user to have a `&mut Foo` input instead. -#[autodiff(df14, Reverse, Active, Active)] +#[autodiff_reverse(df14, Active, Active)] fn f14(x: f32) -> Foo { unimplemented!() } @@ -127,14 +113,14 @@ type MyFloat = f32; // We would like to support type alias to f32/f64 in argument type in the future, // but that requires us to implement our checks at a later stage // like THIR which has type information available. -#[autodiff(df15, Reverse, Active, Active)] +#[autodiff_reverse(df15, Active, Active)] fn f15(x: MyFloat) -> f32 { //~^^ ERROR failed to resolve: use of undeclared type `MyFloat` [E0433] unimplemented!() } // We would like to support type alias to f32/f64 in return type in the future -#[autodiff(df16, Reverse, Active, Active)] +#[autodiff_reverse(df16, Active, Active)] fn f16(x: f32) -> MyFloat { unimplemented!() } @@ -145,40 +131,40 @@ struct F64Trans { } // We would like to support `#[repr(transparent)]` f32/f64 wrapper in return type in the future -#[autodiff(df17, Reverse, Active, Active)] +#[autodiff_reverse(df17, Active, Active)] fn f17(x: f64) -> F64Trans { unimplemented!() } // We would like to support `#[repr(transparent)]` f32/f64 wrapper in argument type in the future -#[autodiff(df18, Reverse, Active, Active)] +#[autodiff_reverse(df18, Active, Active)] fn f18(x: F64Trans) -> f64 { //~^^ ERROR failed to resolve: use of undeclared type `F64Trans` [E0433] unimplemented!() } // Invalid return activity -#[autodiff(df19, Forward, Dual, Active)] +#[autodiff_forward(df19, Dual, Active)] fn f19(x: f32) -> f32 { //~^^ ERROR invalid return activity Active in Forward Mode unimplemented!() } -#[autodiff(df20, Reverse, Active, Dual)] +#[autodiff_reverse(df20, Active, Dual)] fn f20(x: f32) -> f32 { //~^^ ERROR invalid return activity Dual in Reverse Mode unimplemented!() } // Duplicated cannot be used as return activity -#[autodiff(df21, Reverse, Active, Duplicated)] +#[autodiff_reverse(df21, Active, Duplicated)] fn f21(x: f32) -> f32 { //~^^ ERROR invalid return activity Duplicated in Reverse Mode unimplemented!() } struct DoesNotImplDefault; -#[autodiff(df22, Forward, Dual)] +#[autodiff_forward(df22, Dual)] pub fn f22() -> DoesNotImplDefault { //~^^ ERROR the function or associated item `default` exists for tuple `(DoesNotImplDefault, DoesNotImplDefault)`, but its trait bounds were not satisfied unimplemented!() diff --git a/tests/ui/autodiff/autodiff_illegal.stderr b/tests/ui/autodiff/autodiff_illegal.stderr index b119f61b8ae..ad6f10af467 100644 --- a/tests/ui/autodiff/autodiff_illegal.stderr +++ b/tests/ui/autodiff/autodiff_illegal.stderr @@ -1,8 +1,8 @@ error[E0658]: attributes on expressions are experimental --> $DIR/autodiff_illegal.rs:53:5 | -LL | #[autodiff(df7, Forward, Dual)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[autodiff_forward(df7, Dual)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable @@ -17,26 +17,26 @@ LL | pub fn f1(x: f64) { error: expected 1 activities, but found 2 --> $DIR/autodiff_illegal.rs:20:1 | -LL | #[autodiff(df3, Reverse, Duplicated, Const)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[autodiff_reverse(df3, Duplicated, Const)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected 1 activities, but found 0 --> $DIR/autodiff_illegal.rs:27:1 | -LL | #[autodiff(df4, Reverse)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[autodiff_reverse(df4)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ error: Dual can not be used in Reverse Mode --> $DIR/autodiff_illegal.rs:34:1 | -LL | #[autodiff(df5, Reverse, Dual)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[autodiff_reverse(df5, Dual)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Duplicated can not be used in Forward Mode --> $DIR/autodiff_illegal.rs:41:1 | -LL | #[autodiff(df6, Forward, Duplicated)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[autodiff_forward(df6, Duplicated)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Duplicated can not be used for this type --> $DIR/autodiff_illegal.rs:42:14 @@ -95,69 +95,54 @@ error[E0428]: the name `fn_exists` is defined multiple times LL | fn fn_exists() {} | -------------- previous definition of the value `fn_exists` here ... -LL | #[autodiff(fn_exists, Reverse, Active)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `fn_exists` redefined here +LL | #[autodiff_reverse(fn_exists, Active)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `fn_exists` redefined here | = note: `fn_exists` must be defined only once in the value namespace of this module -error: autodiff requires at least a name and mode - --> $DIR/autodiff_illegal.rs:95:1 - | -LL | / pub fn f11() { -LL | | -LL | | unimplemented!() -LL | | } - | |_^ - -error: unknown Mode: `Debug`. Use `Forward` or `Reverse` - --> $DIR/autodiff_illegal.rs:101:18 - | -LL | #[autodiff(df12, Debug)] - | ^^^^^ - error: did not recognize Activity: `Reverse` - --> $DIR/autodiff_illegal.rs:109:27 + --> $DIR/autodiff_illegal.rs:95:26 | -LL | #[autodiff(df13, Forward, Reverse)] - | ^^^^^^^ +LL | #[autodiff_reverse(df13, Reverse)] + | ^^^^^^^ error: invalid return activity Active in Forward Mode - --> $DIR/autodiff_illegal.rs:161:1 + --> $DIR/autodiff_illegal.rs:147:1 | -LL | #[autodiff(df19, Forward, Dual, Active)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[autodiff_forward(df19, Dual, Active)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: invalid return activity Dual in Reverse Mode - --> $DIR/autodiff_illegal.rs:167:1 + --> $DIR/autodiff_illegal.rs:153:1 | -LL | #[autodiff(df20, Reverse, Active, Dual)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[autodiff_reverse(df20, Active, Dual)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: invalid return activity Duplicated in Reverse Mode - --> $DIR/autodiff_illegal.rs:174:1 + --> $DIR/autodiff_illegal.rs:160:1 | -LL | #[autodiff(df21, Reverse, Active, Duplicated)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[autodiff_reverse(df21, Active, Duplicated)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0433]: failed to resolve: use of undeclared type `MyFloat` - --> $DIR/autodiff_illegal.rs:130:1 + --> $DIR/autodiff_illegal.rs:116:1 | -LL | #[autodiff(df15, Reverse, Active, Active)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of undeclared type `MyFloat` +LL | #[autodiff_reverse(df15, Active, Active)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of undeclared type `MyFloat` error[E0433]: failed to resolve: use of undeclared type `F64Trans` - --> $DIR/autodiff_illegal.rs:154:1 + --> $DIR/autodiff_illegal.rs:140:1 | -LL | #[autodiff(df18, Reverse, Active, Active)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of undeclared type `F64Trans` +LL | #[autodiff_reverse(df18, Active, Active)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of undeclared type `F64Trans` error[E0599]: the function or associated item `default` exists for tuple `(DoesNotImplDefault, DoesNotImplDefault)`, but its trait bounds were not satisfied - --> $DIR/autodiff_illegal.rs:181:1 + --> $DIR/autodiff_illegal.rs:167:1 | LL | struct DoesNotImplDefault; | ------------------------- doesn't satisfy `DoesNotImplDefault: Default` -LL | #[autodiff(df22, Forward, Dual)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function or associated item cannot be called on `(DoesNotImplDefault, DoesNotImplDefault)` due to unsatisfied trait bounds +LL | #[autodiff_forward(df22, Dual)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function or associated item cannot be called on `(DoesNotImplDefault, DoesNotImplDefault)` due to unsatisfied trait bounds | = note: the following trait bounds were not satisfied: `DoesNotImplDefault: Default` @@ -168,7 +153,7 @@ LL + #[derive(Default)] LL | struct DoesNotImplDefault; | -error: aborting due to 23 previous errors +error: aborting due to 21 previous errors Some errors have detailed explanations: E0428, E0433, E0599, E0658. For more information about an error, try `rustc --explain E0428`. diff --git a/tests/ui/autodiff/auxiliary/my_macro.rs b/tests/ui/autodiff/auxiliary/my_macro.rs index 217631a33c9..1d5a6de1454 100644 --- a/tests/ui/autodiff/auxiliary/my_macro.rs +++ b/tests/ui/autodiff/auxiliary/my_macro.rs @@ -3,6 +3,6 @@ use proc_macro::TokenStream; #[proc_macro_attribute] #[macro_use] -pub fn autodiff(_attr: TokenStream, item: TokenStream) -> TokenStream { +pub fn autodiff_forward(_attr: TokenStream, item: TokenStream) -> TokenStream { item // identity proc-macro } diff --git a/tests/ui/autodiff/visibility.rs b/tests/ui/autodiff/visibility.rs index dfaec03aef0..a84df75e799 100644 --- a/tests/ui/autodiff/visibility.rs +++ b/tests/ui/autodiff/visibility.rs @@ -6,12 +6,11 @@ #![feature(autodiff)] #[cfg(std_autodiff)] -use std::autodiff::autodiff; - +use std::autodiff::autodiff_forward; extern crate my_macro; -use my_macro::autodiff; // bring `autodiff` in scope +use my_macro::autodiff_forward; // bring `autodiff_forward` in scope -#[autodiff] -//[std_autodiff]~^^^ ERROR the name `autodiff` is defined multiple times +#[autodiff_forward(dfoo)] +//[std_autodiff]~^^^ ERROR the name `autodiff_forward` is defined multiple times //[std_autodiff]~^^ ERROR this rustc version does not support autodiff fn foo() {} diff --git a/tests/ui/autodiff/visibility.std_autodiff.stderr b/tests/ui/autodiff/visibility.std_autodiff.stderr index 720c9a00170..e45f1139012 100644 --- a/tests/ui/autodiff/visibility.std_autodiff.stderr +++ b/tests/ui/autodiff/visibility.std_autodiff.stderr @@ -1,23 +1,23 @@ -error[E0252]: the name `autodiff` is defined multiple times - --> $DIR/visibility.rs:12:5 +error[E0252]: the name `autodiff_forward` is defined multiple times + --> $DIR/visibility.rs:11:5 | -LL | use std::autodiff::autodiff; - | ----------------------- previous import of the macro `autodiff` here -... -LL | use my_macro::autodiff; // bring `autodiff` in scope - | ^^^^^^^^^^^^^^^^^^ `autodiff` reimported here +LL | use std::autodiff::autodiff_forward; + | ------------------------------- previous import of the macro `autodiff_forward` here +LL | extern crate my_macro; +LL | use my_macro::autodiff_forward; // bring `autodiff_forward` in scope + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `autodiff_forward` reimported here | - = note: `autodiff` must be defined only once in the macro namespace of this module + = note: `autodiff_forward` must be defined only once in the macro namespace of this module help: you can use `as` to change the binding name of the import | -LL | use my_macro::autodiff as other_autodiff; // bring `autodiff` in scope - | +++++++++++++++++ +LL | use my_macro::autodiff_forward as other_autodiff_forward; // bring `autodiff_forward` in scope + | +++++++++++++++++++++++++ error: this rustc version does not support autodiff - --> $DIR/visibility.rs:14:1 + --> $DIR/visibility.rs:13:1 | -LL | #[autodiff] - | ^^^^^^^^^^^ +LL | #[autodiff_forward(dfoo)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/autoref-autoderef/autoderef-box-no-add.rs b/tests/ui/autoref-autoderef/autoderef-box-no-add.rs new file mode 100644 index 00000000000..f8085c1ae96 --- /dev/null +++ b/tests/ui/autoref-autoderef/autoderef-box-no-add.rs @@ -0,0 +1,35 @@ +//! Tests that auto-dereferencing does not allow addition of `Box<isize>` values. +//! +//! This test ensures that `Box<isize>` fields in structs (`Clam` and `Fish`) are not +//! automatically dereferenced to `isize` during addition operations, as `Box<isize>` +//! does not implement the `Add` trait. + +struct Clam { + x: Box<isize>, + y: Box<isize>, +} + +struct Fish { + a: Box<isize>, +} + +fn main() { + let a: Clam = Clam { + x: Box::new(1), + y: Box::new(2), + }; + let b: Clam = Clam { + x: Box::new(10), + y: Box::new(20), + }; + let z: isize = a.x + b.y; + //~^ ERROR cannot add `Box<isize>` to `Box<isize>` + println!("{}", z); + assert_eq!(z, 21); + let forty: Fish = Fish { a: Box::new(40) }; + let two: Fish = Fish { a: Box::new(2) }; + let answer: isize = forty.a + two.a; + //~^ ERROR cannot add `Box<isize>` to `Box<isize>` + println!("{}", answer); + assert_eq!(answer, 42); +} diff --git a/tests/ui/autoderef-full-lval.stderr b/tests/ui/autoref-autoderef/autoderef-box-no-add.stderr index d90238a7fb2..20ef3352831 100644 --- a/tests/ui/autoderef-full-lval.stderr +++ b/tests/ui/autoref-autoderef/autoderef-box-no-add.stderr @@ -1,5 +1,5 @@ error[E0369]: cannot add `Box<isize>` to `Box<isize>` - --> $DIR/autoderef-full-lval.rs:15:24 + --> $DIR/autoderef-box-no-add.rs:25:24 | LL | let z: isize = a.x + b.y; | --- ^ --- Box<isize> @@ -13,7 +13,7 @@ note: the foreign item type `Box<isize>` doesn't implement `Add` = note: not implement `Add` error[E0369]: cannot add `Box<isize>` to `Box<isize>` - --> $DIR/autoderef-full-lval.rs:21:33 + --> $DIR/autoderef-box-no-add.rs:31:33 | LL | let answer: isize = forty.a + two.a; | ------- ^ ----- Box<isize> diff --git a/tests/ui/autoref-autoderef/autoderef-privacy.rs b/tests/ui/autoref-autoderef/autoderef-privacy.rs index d2a217257e5..5fa28750f73 100644 --- a/tests/ui/autoref-autoderef/autoderef-privacy.rs +++ b/tests/ui/autoref-autoderef/autoderef-privacy.rs @@ -14,28 +14,28 @@ impl Bar2 { mod foo { #[derive(Default)] - pub struct Bar { i: ::Bar2 } + pub struct Bar { i: crate::Bar2 } #[derive(Default)] - pub struct Baz(::Baz2); + pub struct Baz(crate::Baz2); impl Bar { fn f(&self) -> bool { false } } impl ::std::ops::Deref for Bar { - type Target = ::Bar2; - fn deref(&self) -> &::Bar2 { &self.i } + type Target = crate::Bar2; + fn deref(&self) -> &crate::Bar2 { &self.i } } impl ::std::ops::Deref for Baz { - type Target = ::Baz2; - fn deref(&self) -> &::Baz2 { &self.0 } + type Target = crate::Baz2; + fn deref(&self) -> &crate::Baz2 { &self.0 } } pub fn f(bar: &Bar, baz: &Baz) { // Since the private fields and methods are visible here, there should be no autoderefs. - let _: &::Bar2 = &bar.i; - let _: &::Baz2 = &baz.0; + let _: &crate::Bar2 = &bar.i; + let _: &crate::Baz2 = &baz.0; assert!(!bar.f()); } } diff --git a/tests/ui/autoref-autoderef/autoderef-vec-to-slice-by-value.rs b/tests/ui/autoref-autoderef/autoderef-vec-to-slice-by-value.rs new file mode 100644 index 00000000000..4d67c3a6733 --- /dev/null +++ b/tests/ui/autoref-autoderef/autoderef-vec-to-slice-by-value.rs @@ -0,0 +1,18 @@ +//! Tests that a `Vec<isize>` can call a method defined in a trait (`Foo`) +//! implemented for `&[isize]` with a by-value receiver (`self`), relying on auto-dereferencing +//! from `Vec` to `&[isize]` during method resolution. + +//@ run-pass + +trait Foo { + fn foo(self); +} + +impl<'a> Foo for &'a [isize] { + fn foo(self) {} +} + +pub fn main() { + let items = vec![ 3, 5, 1, 2, 4 ]; + items.foo(); +} diff --git a/tests/ui/auxiliary/delegate_macro.rs b/tests/ui/auxiliary/delegate_macro.rs new file mode 100644 index 00000000000..0d752e12039 --- /dev/null +++ b/tests/ui/auxiliary/delegate_macro.rs @@ -0,0 +1,6 @@ +#[macro_export] +macro_rules! delegate { + ($method:ident) => { + <Self>::$method(8) + }; +} diff --git a/tests/ui/auxiliary/pub-and-stability.rs b/tests/ui/auxiliary/pub-and-stability.rs index d2d07f99398..8866233b61e 100644 --- a/tests/ui/auxiliary/pub-and-stability.rs +++ b/tests/ui/auxiliary/pub-and-stability.rs @@ -44,7 +44,7 @@ mod m { #[unstable(feature = "unstable_undeclared", issue = "38412")] // SILLY pub(crate) b_crate: i32, #[unstable(feature = "unstable_declared", issue = "38412")] // SILLY - pub(in m) c_mod: i32, + pub(in crate::m) c_mod: i32, #[stable(feature = "unit_test", since = "1.0.0")] // SILLY d_priv: i32 } @@ -60,7 +60,7 @@ mod m { pub i32, pub(crate) i32, - pub(in m) i32, + pub(in crate::m) i32, i32); impl Record { @@ -113,7 +113,7 @@ mod m { #[unstable(feature = "unstable_undeclared", issue = "38412")] // SILLY pub(crate) fn pub_crate(&self) -> i32 { self.d_priv } #[unstable(feature = "unstable_declared", issue = "38412")] // SILLY - pub(in m) fn pub_mod(&self) -> i32 { self.d_priv } + pub(in crate::m) fn pub_mod(&self) -> i32 { self.d_priv } #[stable(feature = "unit_test", since = "1.0.0")] // SILLY fn private(&self) -> i32 { self.d_priv } } @@ -127,7 +127,7 @@ mod m { pub fn stable(&self) -> i32 { self.0 } pub(crate) fn pub_crate(&self) -> i32 { self.0 } - pub(in m) fn pub_mod(&self) -> i32 { self.0 } + pub(in crate::m) fn pub_mod(&self) -> i32 { self.0 } fn private(&self) -> i32 { self.0 } } } diff --git a/tests/ui/bogus-tag.rs b/tests/ui/bogus-tag.rs deleted file mode 100644 index c594385eec2..00000000000 --- a/tests/ui/bogus-tag.rs +++ /dev/null @@ -1,10 +0,0 @@ -enum Color { Rgb(isize, isize, isize), Rgba(isize, isize, isize, isize), } - -fn main() { - let red: Color = Color::Rgb(255, 0, 0); - match red { - Color::Rgb(r, g, b) => { println!("rgb"); } - Color::Hsl(h, s, l) => { println!("hsl"); } - //~^ ERROR no variant - } -} diff --git a/tests/ui/borrow-by-val-method-receiver.rs b/tests/ui/borrow-by-val-method-receiver.rs deleted file mode 100644 index aee1108d96d..00000000000 --- a/tests/ui/borrow-by-val-method-receiver.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ run-pass - -trait Foo { - fn foo(self); -} - -impl<'a> Foo for &'a [isize] { - fn foo(self) {} -} - -pub fn main() { - let items = vec![ 3, 5, 1, 2, 4 ]; - items.foo(); -} diff --git a/tests/ui/borrowck/copy-suggestion-region-vid.fixed b/tests/ui/borrowck/copy-suggestion-region-vid.fixed index 7fe18615408..2bc8a74086e 100644 --- a/tests/ui/borrowck/copy-suggestion-region-vid.fixed +++ b/tests/ui/borrowck/copy-suggestion-region-vid.fixed @@ -7,7 +7,7 @@ pub struct HelperStruct<'n> { } impl DataStruct { - pub fn f(&self) -> HelperStruct { + pub fn f(&self) -> HelperStruct<'_> { let helpers = [vec![], vec![]]; HelperStruct { helpers: helpers.clone(), is_empty: helpers[0].is_empty() } diff --git a/tests/ui/borrowck/copy-suggestion-region-vid.rs b/tests/ui/borrowck/copy-suggestion-region-vid.rs index daafba71ece..248ce80d22b 100644 --- a/tests/ui/borrowck/copy-suggestion-region-vid.rs +++ b/tests/ui/borrowck/copy-suggestion-region-vid.rs @@ -7,7 +7,7 @@ pub struct HelperStruct<'n> { } impl DataStruct { - pub fn f(&self) -> HelperStruct { + pub fn f(&self) -> HelperStruct<'_> { let helpers = [vec![], vec![]]; HelperStruct { helpers, is_empty: helpers[0].is_empty() } diff --git a/tests/ui/borrowck/issue-81899.rs b/tests/ui/borrowck/issue-81899.rs index 11755620d86..03d9b8cb6c6 100644 --- a/tests/ui/borrowck/issue-81899.rs +++ b/tests/ui/borrowck/issue-81899.rs @@ -3,7 +3,7 @@ //@ dont-require-annotations: NOTE -const _CONST: &[u8] = &f(&[], |_| {}); //~ ERROR evaluation of constant value failed +const _CONST: &[u8] = &f(&[], |_| {}); //~ ERROR explicit panic //~^ NOTE constant const fn f<F>(_: &[u8], _: F) -> &[u8] diff --git a/tests/ui/borrowck/issue-81899.stderr b/tests/ui/borrowck/issue-81899.stderr index 97d463cb6a7..96fe2ad709a 100644 --- a/tests/ui/borrowck/issue-81899.stderr +++ b/tests/ui/borrowck/issue-81899.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/issue-81899.rs:6:24 | LL | const _CONST: &[u8] = &f(&[], |_| {}); - | ^^^^^^^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^^^^^^^ evaluation of `_CONST` failed inside this call | note: inside `f::<{closure@$DIR/issue-81899.rs:6:31: 6:34}>` --> $DIR/issue-81899.rs:13:5 diff --git a/tests/ui/borrowck/issue-88434-minimal-example.rs b/tests/ui/borrowck/issue-88434-minimal-example.rs index 7482b3fd612..901e0142c36 100644 --- a/tests/ui/borrowck/issue-88434-minimal-example.rs +++ b/tests/ui/borrowck/issue-88434-minimal-example.rs @@ -2,7 +2,7 @@ //@ dont-require-annotations: NOTE -const _CONST: &() = &f(&|_| {}); //~ ERROR evaluation of constant value failed +const _CONST: &() = &f(&|_| {}); //~ ERROR explicit panic //~^ NOTE constant const fn f<F>(_: &F) @@ -12,4 +12,4 @@ where panic!() //~ NOTE inside `f } -fn main() { } +fn main() {} diff --git a/tests/ui/borrowck/issue-88434-minimal-example.stderr b/tests/ui/borrowck/issue-88434-minimal-example.stderr index 4c525b9ea2c..3921c47640e 100644 --- a/tests/ui/borrowck/issue-88434-minimal-example.stderr +++ b/tests/ui/borrowck/issue-88434-minimal-example.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/issue-88434-minimal-example.rs:5:22 | LL | const _CONST: &() = &f(&|_| {}); - | ^^^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^^^ evaluation of `_CONST` failed inside this call | note: inside `f::<{closure@$DIR/issue-88434-minimal-example.rs:5:25: 5:28}>` --> $DIR/issue-88434-minimal-example.rs:12:5 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 09b1f59c449..cce59124ade 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 @@ -2,7 +2,7 @@ //@ dont-require-annotations: NOTE -const _CONST: &[u8] = &f(&[], |_| {}); //~ ERROR evaluation of constant value failed +const _CONST: &[u8] = &f(&[], |_| {}); //~ ERROR explicit panic //~^ NOTE constant const fn f<F>(_: &[u8], _: F) -> &[u8] @@ -12,4 +12,4 @@ where panic!() //~ NOTE inside `f } -fn main() { } +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 a22621c9c1b..c7f945dc6ef 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,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/issue-88434-removal-index-should-be-less.rs:5:24 | LL | const _CONST: &[u8] = &f(&[], |_| {}); - | ^^^^^^^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^^^^^^^ evaluation of `_CONST` failed inside this call | 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 diff --git a/tests/ui/cleanup-rvalue-scopes-cf.rs b/tests/ui/borrowck/rvalue-borrow-scope-error.rs index e3cecb1bffe..5bf96e800d3 100644 --- a/tests/ui/cleanup-rvalue-scopes-cf.rs +++ b/tests/ui/borrowck/rvalue-borrow-scope-error.rs @@ -1,15 +1,19 @@ -// Test that the borrow checker prevents pointers to temporaries -// with statement lifetimes from escaping. +//! Test that the borrow checker prevents pointers to temporaries +//! with statement lifetimes from escaping. use std::ops::Drop; static mut FLAGS: u64 = 0; -struct StackBox<T> { f: T } -struct AddFlags { bits: u64 } +struct StackBox<T> { + f: T, +} +struct AddFlags { + bits: u64, +} fn AddFlags(bits: u64) -> AddFlags { - AddFlags { bits: bits } + AddFlags { bits } } fn arg(x: &AddFlags) -> &AddFlags { diff --git a/tests/ui/cleanup-rvalue-scopes-cf.stderr b/tests/ui/borrowck/rvalue-borrow-scope-error.stderr index 425cd75141c..bedcfce4541 100644 --- a/tests/ui/cleanup-rvalue-scopes-cf.stderr +++ b/tests/ui/borrowck/rvalue-borrow-scope-error.stderr @@ -1,5 +1,5 @@ error[E0716]: temporary value dropped while borrowed - --> $DIR/cleanup-rvalue-scopes-cf.rs:26:19 + --> $DIR/rvalue-borrow-scope-error.rs:30:19 | LL | let x1 = arg(&AddFlags(1)); | ^^^^^^^^^^^ - temporary value is freed at the end of this statement @@ -16,7 +16,7 @@ LL ~ let x1 = arg(&binding); | error[E0716]: temporary value dropped while borrowed - --> $DIR/cleanup-rvalue-scopes-cf.rs:27:14 + --> $DIR/rvalue-borrow-scope-error.rs:31:14 | LL | let x2 = AddFlags(1).get(); | ^^^^^^^^^^^ - temporary value is freed at the end of this statement @@ -33,7 +33,7 @@ LL ~ let x2 = binding.get(); | error[E0716]: temporary value dropped while borrowed - --> $DIR/cleanup-rvalue-scopes-cf.rs:28:21 + --> $DIR/rvalue-borrow-scope-error.rs:32:21 | LL | let x3 = &*arg(&AddFlags(1)); | ^^^^^^^^^^^ - temporary value is freed at the end of this statement @@ -50,7 +50,7 @@ LL ~ let x3 = &*arg(&binding); | error[E0716]: temporary value dropped while borrowed - --> $DIR/cleanup-rvalue-scopes-cf.rs:29:24 + --> $DIR/rvalue-borrow-scope-error.rs:33:24 | LL | let ref x4 = *arg(&AddFlags(1)); | ^^^^^^^^^^^ - temporary value is freed at the end of this statement @@ -67,7 +67,7 @@ LL ~ let ref x4 = *arg(&binding); | error[E0716]: temporary value dropped while borrowed - --> $DIR/cleanup-rvalue-scopes-cf.rs:30:24 + --> $DIR/rvalue-borrow-scope-error.rs:34:24 | LL | let &ref x5 = arg(&AddFlags(1)); | ^^^^^^^^^^^ - temporary value is freed at the end of this statement @@ -84,7 +84,7 @@ LL ~ let &ref x5 = arg(&binding); | error[E0716]: temporary value dropped while borrowed - --> $DIR/cleanup-rvalue-scopes-cf.rs:31:14 + --> $DIR/rvalue-borrow-scope-error.rs:35:14 | LL | let x6 = AddFlags(1).get(); | ^^^^^^^^^^^ - temporary value is freed at the end of this statement @@ -101,7 +101,7 @@ LL ~ let x6 = binding.get(); | error[E0716]: temporary value dropped while borrowed - --> $DIR/cleanup-rvalue-scopes-cf.rs:32:44 + --> $DIR/rvalue-borrow-scope-error.rs:36:44 | LL | let StackBox { f: x7 } = StackBox { f: AddFlags(1).get() }; | ^^^^^^^^^^^ - temporary value is freed at the end of this statement diff --git a/tests/ui/borrowck/unconstrained-closure-lifetime-generic.rs b/tests/ui/borrowck/unconstrained-closure-lifetime-generic.rs new file mode 100644 index 00000000000..4fdf5470fea --- /dev/null +++ b/tests/ui/borrowck/unconstrained-closure-lifetime-generic.rs @@ -0,0 +1,22 @@ +// Regression test for #122704 +use std::any::Any; + +pub struct Foo { + bar: Box<dyn for<'a> Fn(&'a usize) -> Box<dyn Any + 'a>>, +} + +impl Foo { + pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I>) { + self.bar = Box::new(|baz| Box::new(f(baz))); + //~^ ERROR the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` may not live long enough + //~| ERROR the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` may not live long enough + //~| ERROR the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` may not live long enough + //~| ERROR the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` may not live long enough + //~| ERROR the parameter type `I` may not live long enough + //~| ERROR the parameter type `I` may not live long enough + //~| ERROR the parameter type `I` may not live long enough + //~| ERROR `f` does not live long enough + } +} + +fn main() {} diff --git a/tests/ui/borrowck/unconstrained-closure-lifetime-generic.stderr b/tests/ui/borrowck/unconstrained-closure-lifetime-generic.stderr new file mode 100644 index 00000000000..df86ce79f09 --- /dev/null +++ b/tests/ui/borrowck/unconstrained-closure-lifetime-generic.stderr @@ -0,0 +1,119 @@ +error[E0310]: the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` may not live long enough + --> $DIR/unconstrained-closure-lifetime-generic.rs:10:9 + | +LL | self.bar = Box::new(|baz| Box::new(f(baz))); + | ^^^^^^^^ + | | + | the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` must be valid for the static lifetime... + | ...so that the type `impl for<'a> Fn(&'a usize) -> Box<I>` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound + | +LL | pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I> + 'static) { + | +++++++++ + +error[E0310]: the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` may not live long enough + --> $DIR/unconstrained-closure-lifetime-generic.rs:10:9 + | +LL | self.bar = Box::new(|baz| Box::new(f(baz))); + | ^^^^^^^^ + | | + | the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` must be valid for the static lifetime... + | ...so that the type `impl for<'a> Fn(&'a usize) -> Box<I>` will meet its required lifetime bounds + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: consider adding an explicit lifetime bound + | +LL | pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I> + 'static) { + | +++++++++ + +error[E0310]: the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` may not live long enough + --> $DIR/unconstrained-closure-lifetime-generic.rs:10:20 + | +LL | self.bar = Box::new(|baz| Box::new(f(baz))); + | ^^^^^^^^ + | | + | the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` must be valid for the static lifetime... + | ...so that the type `impl for<'a> Fn(&'a usize) -> Box<I>` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound + | +LL | pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I> + 'static) { + | +++++++++ + +error[E0310]: the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` may not live long enough + --> $DIR/unconstrained-closure-lifetime-generic.rs:10:20 + | +LL | self.bar = Box::new(|baz| Box::new(f(baz))); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | the parameter type `impl for<'a> Fn(&'a usize) -> Box<I>` must be valid for the static lifetime... + | ...so that the type `impl for<'a> Fn(&'a usize) -> Box<I>` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound + | +LL | pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I> + 'static) { + | +++++++++ + +error[E0310]: the parameter type `I` may not live long enough + --> $DIR/unconstrained-closure-lifetime-generic.rs:10:35 + | +LL | self.bar = Box::new(|baz| Box::new(f(baz))); + | ^^^^^^^^^^^^^^^^ + | | + | the parameter type `I` must be valid for the static lifetime... + | ...so that the type `I` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound + | +LL | pub fn ack<I: 'static>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I>) { + | +++++++++ + +error[E0310]: the parameter type `I` may not live long enough + --> $DIR/unconstrained-closure-lifetime-generic.rs:10:35 + | +LL | self.bar = Box::new(|baz| Box::new(f(baz))); + | ^^^^^^^^^^^^^^^^ + | | + | the parameter type `I` must be valid for the static lifetime... + | ...so that the type `I` will meet its required lifetime bounds + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: consider adding an explicit lifetime bound + | +LL | pub fn ack<I: 'static>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I>) { + | +++++++++ + +error[E0311]: the parameter type `I` may not live long enough + --> $DIR/unconstrained-closure-lifetime-generic.rs:10:35 + | +LL | pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I>) { + | --------- the parameter type `I` must be valid for the anonymous lifetime defined here... +LL | self.bar = Box::new(|baz| Box::new(f(baz))); + | ^^^^^^^^^^^^^^^^ ...so that the type `I` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound + | +LL | pub fn ack<'a, I: 'a>(&'a mut self, f: impl for<'a> Fn(&'a usize) -> Box<I>) { + | +++ ++++ ++ + +error[E0597]: `f` does not live long enough + --> $DIR/unconstrained-closure-lifetime-generic.rs:10:44 + | +LL | pub fn ack<I>(&mut self, f: impl for<'a> Fn(&'a usize) -> Box<I>) { + | - binding `f` declared here +LL | self.bar = Box::new(|baz| Box::new(f(baz))); + | -------- ----- ^ borrowed value does not live long enough + | | | + | | value captured here + | coercion requires that `f` is borrowed for `'static` +... +LL | } + | - `f` dropped here while still borrowed + | + = note: due to object lifetime defaults, `Box<dyn for<'a> Fn(&'a usize) -> Box<(dyn Any + 'a)>>` actually means `Box<(dyn for<'a> Fn(&'a usize) -> Box<(dyn Any + 'a)> + 'static)>` + +error: aborting due to 8 previous errors + +Some errors have detailed explanations: E0310, E0311, E0597. +For more information about an error, try `rustc --explain E0310`. diff --git a/tests/ui/borrowck/unconstrained-closure-lifetime-trait-object.rs b/tests/ui/borrowck/unconstrained-closure-lifetime-trait-object.rs new file mode 100644 index 00000000000..3eee98d9bdb --- /dev/null +++ b/tests/ui/borrowck/unconstrained-closure-lifetime-trait-object.rs @@ -0,0 +1,11 @@ +// Regression test for #139004 +use std::any::Any; + +type B = Box<dyn for<'a> Fn(&(dyn Any + 'a)) -> Box<dyn Any + 'a>>; + +fn foo<E>() -> B { + Box::new(|e| Box::new(e.is::<E>())) + //~^ ERROR the parameter type `E` may not live long enough +} + +fn main() {} diff --git a/tests/ui/borrowck/unconstrained-closure-lifetime-trait-object.stderr b/tests/ui/borrowck/unconstrained-closure-lifetime-trait-object.stderr new file mode 100644 index 00000000000..c9d5f78828d --- /dev/null +++ b/tests/ui/borrowck/unconstrained-closure-lifetime-trait-object.stderr @@ -0,0 +1,17 @@ +error[E0310]: the parameter type `E` may not live long enough + --> $DIR/unconstrained-closure-lifetime-trait-object.rs:7:29 + | +LL | Box::new(|e| Box::new(e.is::<E>())) + | ^^ + | | + | the parameter type `E` must be valid for the static lifetime... + | ...so that the type `E` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound + | +LL | fn foo<E: 'static>() -> B { + | +++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0310`. diff --git a/tests/ui/break-diverging-value.rs b/tests/ui/break-diverging-value.rs deleted file mode 100644 index d070fddaffc..00000000000 --- a/tests/ui/break-diverging-value.rs +++ /dev/null @@ -1,37 +0,0 @@ -#![feature(never_type)] - -fn loop_break_return() -> i32 { - let loop_value = loop { break return 0 }; // ok -} - -fn loop_break_loop() -> i32 { - let loop_value = loop { break loop {} }; // ok -} - -fn loop_break_break() -> i32 { //~ ERROR mismatched types - let loop_value = loop { break break }; -} - -fn loop_break_return_2() -> i32 { - let loop_value = loop { break { return 0; () } }; // ok -} - -enum Void {} - -fn get_void() -> Void { - panic!() -} - -fn loop_break_void() -> i32 { //~ ERROR mismatched types - let loop_value = loop { break get_void() }; -} - -fn get_never() -> ! { - panic!() -} - -fn loop_break_never() -> i32 { - let loop_value = loop { break get_never() }; // ok -} - -fn main() {} diff --git a/tests/ui/cancel-clean-via-immediate-rvalue-ref.rs b/tests/ui/cancel-clean-via-immediate-rvalue-ref.rs deleted file mode 100644 index 12d143bd989..00000000000 --- a/tests/ui/cancel-clean-via-immediate-rvalue-ref.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ run-pass - -fn foo(x: &mut Box<u8>) { - *x = Box::new(5); -} - -pub fn main() { - foo(&mut Box::new(4)); -} diff --git a/tests/ui/cannot-mutate-captured-non-mut-var.rs b/tests/ui/cannot-mutate-captured-non-mut-var.rs deleted file mode 100644 index 952dab25bf9..00000000000 --- a/tests/ui/cannot-mutate-captured-non-mut-var.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![feature(unboxed_closures, tuple_trait)] - -use std::io::Read; - -fn to_fn_once<A:std::marker::Tuple,F:FnOnce<A>>(f: F) -> F { f } - -fn main() { - let x = 1; - to_fn_once(move|| { x = 2; }); - //~^ ERROR: cannot assign to `x`, as it is not declared as mutable - - let s = std::io::stdin(); - to_fn_once(move|| { s.read_to_end(&mut Vec::new()); }); - //~^ ERROR: cannot borrow `s` as mutable, as it is not declared as mutable -} diff --git a/tests/ui/cast/cast-to-slice.stderr b/tests/ui/cast/cast-to-slice.stderr index 8f862c00014..382ccc3d10c 100644 --- a/tests/ui/cast/cast-to-slice.stderr +++ b/tests/ui/cast/cast-to-slice.stderr @@ -2,17 +2,23 @@ error[E0620]: cast to unsized type: `&[u8]` as `[char]` --> $DIR/cast-to-slice.rs:2:5 | LL | "example".as_bytes() as [char]; - | ^^^^^^^^^^^^^^^^^^^^^^^^------ - | | - | help: try casting to a reference instead: `&[char]` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: consider casting to a reference instead + | +LL | "example".as_bytes() as &[char]; + | + error[E0620]: cast to unsized type: `&[u8]` as `[char]` --> $DIR/cast-to-slice.rs:6:5 | LL | arr as [char]; - | ^^^^^^^------ - | | - | help: try casting to a reference instead: `&[char]` + | ^^^^^^^^^^^^^ + | +help: consider casting to a reference instead + | +LL | arr as &[char]; + | + error: aborting due to 2 previous errors diff --git a/tests/ui/cast/cast-to-unsized-trait-object-suggestion.stderr b/tests/ui/cast/cast-to-unsized-trait-object-suggestion.stderr index 3b5b8ea69c1..2803c3380d7 100644 --- a/tests/ui/cast/cast-to-unsized-trait-object-suggestion.stderr +++ b/tests/ui/cast/cast-to-unsized-trait-object-suggestion.stderr @@ -2,17 +2,23 @@ error[E0620]: cast to unsized type: `&{integer}` as `dyn Send` --> $DIR/cast-to-unsized-trait-object-suggestion.rs:2:5 | LL | &1 as dyn Send; - | ^^^^^^-------- - | | - | help: try casting to a reference instead: `&dyn Send` + | ^^^^^^^^^^^^^^ + | +help: consider casting to a reference instead + | +LL | &1 as &dyn Send; + | + error[E0620]: cast to unsized type: `Box<{integer}>` as `dyn Send` --> $DIR/cast-to-unsized-trait-object-suggestion.rs:3:5 | LL | Box::new(1) as dyn Send; - | ^^^^^^^^^^^^^^^-------- - | | - | help: you can cast to a `Box` instead: `Box<dyn Send>` + | ^^^^^^^^^^^^^^^^^^^^^^^ + | +help: you can cast to a `Box` instead + | +LL | Box::new(1) as Box<dyn Send>; + | ++++ + error: aborting due to 2 previous errors diff --git a/tests/ui/cast/func-pointer-issue-140491.rs b/tests/ui/cast/func-pointer-issue-140491.rs new file mode 100644 index 00000000000..d5d86a66f5a --- /dev/null +++ b/tests/ui/cast/func-pointer-issue-140491.rs @@ -0,0 +1,7 @@ +fn my_fn(event: &Event<'_>) {} + +struct Event<'a>(&'a ()); + +fn main() { + const ptr: &fn(&Event<'_>) = &my_fn as _; //~ ERROR non-primitive cast: `&for<'a, 'b> fn(&'a Event<'b>) {my_fn}` as `&for<'a, 'b> fn(&'a Event<'b>)` [E0605] +} diff --git a/tests/ui/cast/func-pointer-issue-140491.stderr b/tests/ui/cast/func-pointer-issue-140491.stderr new file mode 100644 index 00000000000..e1c07010e69 --- /dev/null +++ b/tests/ui/cast/func-pointer-issue-140491.stderr @@ -0,0 +1,11 @@ +error[E0605]: non-primitive cast: `&for<'a, 'b> fn(&'a Event<'b>) {my_fn}` as `&for<'a, 'b> fn(&'a Event<'b>)` + --> $DIR/func-pointer-issue-140491.rs:6:34 + | +LL | ..._>) = &my_fn as _; + | ^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object + | + = note: casting reference expression `&my_fn` because `&` binds tighter than `as` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0605`. diff --git a/tests/ui/cfg/cfg-version/cfg-version-expand.rs b/tests/ui/cfg/cfg-version/cfg-version-expand.rs new file mode 100644 index 00000000000..8c426b4a41f --- /dev/null +++ b/tests/ui/cfg/cfg-version/cfg-version-expand.rs @@ -0,0 +1,30 @@ +//@ run-pass +//@ rustc-env:RUSTC_OVERRIDE_VERSION_STRING=1.50.3 + +#![feature(cfg_version)] + +#[cfg(version("1.49.0"))] +const ON_1_49_0: bool = true; +#[cfg(version("1.50"))] +const ON_1_50_0: bool = true; +#[cfg(not(version("1.51")))] +const ON_1_51_0: bool = false; + +// This one uses the wrong syntax, so doesn't eval to true +#[warn(unexpected_cfgs)] +#[cfg(not(version = "1.48.0"))] //~ WARN unexpected `cfg` condition name: `version` +const ON_1_48_0: bool = false; + +fn main() { + assert!(!ON_1_48_0); + assert!(ON_1_49_0); + assert!(ON_1_50_0); + assert!(!ON_1_51_0); + assert!(cfg!(version("1.1"))); + assert!(cfg!(version("1.49"))); + assert!(cfg!(version("1.50.0"))); + assert!(cfg!(version("1.50.3"))); + assert!(!cfg!(version("1.50.4"))); + assert!(!cfg!(version("1.51"))); + assert!(!cfg!(version("1.100"))); +} diff --git a/tests/ui/cfg/cfg-version/cfg-version-expand.stderr b/tests/ui/cfg/cfg-version/cfg-version-expand.stderr new file mode 100644 index 00000000000..a9a8d86c0fa --- /dev/null +++ b/tests/ui/cfg/cfg-version/cfg-version-expand.stderr @@ -0,0 +1,17 @@ +warning: unexpected `cfg` condition name: `version` + --> $DIR/cfg-version-expand.rs:15:11 + | +LL | #[cfg(not(version = "1.48.0"))] + | ^^^^^^^^^^^^^^^^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(version, values("1.48.0"))` + = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration + = note: `#[warn(unexpected_cfgs)]` on by default +help: there is a similar config predicate: `version("..")` + | +LL - #[cfg(not(version = "1.48.0"))] +LL + #[cfg(not(version("1.48.0")))] + | + +warning: 1 warning emitted + diff --git a/tests/ui/cfg/cfg-version/syntax.rs b/tests/ui/cfg/cfg-version/syntax.rs new file mode 100644 index 00000000000..22aab47e1ec --- /dev/null +++ b/tests/ui/cfg/cfg-version/syntax.rs @@ -0,0 +1,152 @@ +//! Check `#[cfg(version(..))]` parsing. + +#![feature(cfg_version)] + +// Overall grammar +// =============== +// +// `#[cfg(version(..))]` accepts only the `version(VERSION_STRING_LITERAL)` predicate form, where +// only a single string literal is permitted. + +#[cfg(version(42))] +//~^ ERROR expected a version literal +fn not_a_string_literal_simple() {} + +#[cfg(version(1.20))] +//~^ ERROR expected a version literal +fn not_a_string_literal_semver_like() {} + +#[cfg(version(false))] +//~^ ERROR expected a version literal +fn not_a_string_literal_other() {} + +#[cfg(version("1.43", "1.44", "1.45"))] +//~^ ERROR expected single version literal +fn multiple_version_literals() {} + +// The key-value form `cfg(version = "..")` is not considered a valid `cfg(version(..))` usage, but +// it will only trigger the `unexpected_cfgs` lint and not a hard error. + +#[cfg(version = "1.43")] +//~^ WARN unexpected `cfg` condition name: `version` +fn key_value_form() {} + +// Additional version string literal constraints +// ============================================= +// +// The `VERSION_STRING_LITERAL` ("version literal") has additional constraints on its syntactical +// well-formedness. + +// 1. A valid version literal can only constitute of numbers and periods (a "simple" semver version +// string). Non-semver strings or "complex" semver strings (such as build metadata) are not +// considered valid version literals, and will emit a non-lint warning "unknown version literal +// format". + +#[cfg(version("1.43.0"))] +fn valid_major_minor_patch() {} + +#[cfg(version("0.0.0"))] +fn valid_zero_zero_zero_major_minor_patch() {} + +#[cfg(version("foo"))] +//~^ WARN unknown version literal format, assuming it refers to a future version +fn not_numbers_or_periods() {} + +#[cfg(version("1.20.0-stable"))] +//~^ WARN unknown version literal format, assuming it refers to a future version +fn complex_semver_with_metadata() {} + +// 2. "Shortened" version strings are permitted but *only* for the omission of the patch number. + +#[cfg(version("1.0"))] +fn valid_major_minor_1() {} + +#[cfg(version("1.43"))] +fn valid_major_minor_2() {} + +#[cfg(not(version("1.44")))] +fn valid_major_minor_negated_smoke_test() {} + +#[cfg(version("0.0"))] +fn valid_zero_zero_major_minor() {} + +#[cfg(version("0.7"))] +fn valid_zero_major_minor() {} + +// 3. Major-only, or other non-Semver-like strings are not permitted. + +#[cfg(version("1"))] +//~^ WARN unknown version literal format, assuming it refers to a future version +fn invalid_major_only() {} + +#[cfg(version("0"))] +//~^ WARN unknown version literal format, assuming it refers to a future version +fn invalid_major_only_zero() {} + +#[cfg(version(".7"))] +//~^ WARN unknown version literal format, assuming it refers to a future version +fn invalid_decimal_like() {} + +// Misc parsing overflow/underflow edge cases +// ========================================== +// +// Check that we report "unknown version literal format" user-facing warnings and not ICEs. + +#[cfg(version("-1"))] +//~^ WARN unknown version literal format, assuming it refers to a future version +fn invalid_major_only_negative() {} + +// Implementation detail: we store rustc version as `{ major: u16, minor: u16, patch: u16 }`. + +#[cfg(version("65536"))] +//~^ WARN unknown version literal format, assuming it refers to a future version +fn exceed_u16_major() {} + +#[cfg(version("1.65536.0"))] +//~^ WARN unknown version literal format, assuming it refers to a future version +fn exceed_u16_minor() {} + +#[cfg(version("1.0.65536"))] +//~^ WARN unknown version literal format, assuming it refers to a future version +fn exceed_u16_patch() {} + +#[cfg(version("65536.0.65536"))] +//~^ WARN unknown version literal format, assuming it refers to a future version +fn exceed_u16_mixed() {} + +// Usage as `cfg!()` +// ================= + +fn cfg_usage() { + assert!(cfg!(version("1.0"))); + assert!(cfg!(version("1.43"))); + assert!(cfg!(version("1.43.0"))); + + assert!(cfg!(version("foo"))); + //~^ WARN unknown version literal format, assuming it refers to a future version + assert!(cfg!(version("1.20.0-stable"))); + //~^ WARN unknown version literal format, assuming it refers to a future version + + assert!(cfg!(version = "1.43")); + //~^ WARN unexpected `cfg` condition name: `version` +} + +fn main() { + cfg_usage(); + + // `cfg(version = "..")` is not a valid `cfg_version` form, but it only triggers + // `unexpected_cfgs` lint, and `cfg(version = "..")` eval to `false`. + key_value_form(); //~ ERROR cannot find function + + // Invalid version literal formats within valid `cfg(version(..))` form should also cause + // `cfg(version(..))` eval to `false`. + not_numbers_or_periods(); //~ ERROR cannot find function + complex_semver_with_metadata(); //~ ERROR cannot find function + invalid_major_only(); //~ ERROR cannot find function + invalid_major_only_zero(); //~ ERROR cannot find function + invalid_major_only_negative(); //~ ERROR cannot find function + exceed_u16_major(); //~ ERROR cannot find function + exceed_u16_minor(); //~ ERROR cannot find function + exceed_u16_patch(); //~ ERROR cannot find function + exceed_u16_mixed(); //~ ERROR cannot find function +} diff --git a/tests/ui/cfg/cfg-version/syntax.stderr b/tests/ui/cfg/cfg-version/syntax.stderr new file mode 100644 index 00000000000..2facd960763 --- /dev/null +++ b/tests/ui/cfg/cfg-version/syntax.stderr @@ -0,0 +1,188 @@ +error: expected a version literal + --> $DIR/syntax.rs:11:15 + | +LL | #[cfg(version(42))] + | ^^ + +error: expected a version literal + --> $DIR/syntax.rs:15:15 + | +LL | #[cfg(version(1.20))] + | ^^^^ + +error: expected a version literal + --> $DIR/syntax.rs:19:15 + | +LL | #[cfg(version(false))] + | ^^^^^ + +error: expected single version literal + --> $DIR/syntax.rs:23:7 + | +LL | #[cfg(version("1.43", "1.44", "1.45"))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: unknown version literal format, assuming it refers to a future version + --> $DIR/syntax.rs:51:15 + | +LL | #[cfg(version("foo"))] + | ^^^^^ + +warning: unknown version literal format, assuming it refers to a future version + --> $DIR/syntax.rs:55:15 + | +LL | #[cfg(version("1.20.0-stable"))] + | ^^^^^^^^^^^^^^^ + +warning: unknown version literal format, assuming it refers to a future version + --> $DIR/syntax.rs:78:15 + | +LL | #[cfg(version("1"))] + | ^^^ + +warning: unknown version literal format, assuming it refers to a future version + --> $DIR/syntax.rs:82:15 + | +LL | #[cfg(version("0"))] + | ^^^ + +warning: unknown version literal format, assuming it refers to a future version + --> $DIR/syntax.rs:86:15 + | +LL | #[cfg(version(".7"))] + | ^^^^ + +warning: unknown version literal format, assuming it refers to a future version + --> $DIR/syntax.rs:95:15 + | +LL | #[cfg(version("-1"))] + | ^^^^ + +warning: unknown version literal format, assuming it refers to a future version + --> $DIR/syntax.rs:101:15 + | +LL | #[cfg(version("65536"))] + | ^^^^^^^ + +warning: unknown version literal format, assuming it refers to a future version + --> $DIR/syntax.rs:105:15 + | +LL | #[cfg(version("1.65536.0"))] + | ^^^^^^^^^^^ + +warning: unknown version literal format, assuming it refers to a future version + --> $DIR/syntax.rs:109:15 + | +LL | #[cfg(version("1.0.65536"))] + | ^^^^^^^^^^^ + +warning: unknown version literal format, assuming it refers to a future version + --> $DIR/syntax.rs:113:15 + | +LL | #[cfg(version("65536.0.65536"))] + | ^^^^^^^^^^^^^^^ + +warning: unknown version literal format, assuming it refers to a future version + --> $DIR/syntax.rs:125:26 + | +LL | assert!(cfg!(version("foo"))); + | ^^^^^ + +warning: unknown version literal format, assuming it refers to a future version + --> $DIR/syntax.rs:127:26 + | +LL | assert!(cfg!(version("1.20.0-stable"))); + | ^^^^^^^^^^^^^^^ + +warning: unexpected `cfg` condition name: `version` + --> $DIR/syntax.rs:30:7 + | +LL | #[cfg(version = "1.43")] + | ^^^^^^^^^^^^^^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(version, values("1.43"))` + = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration + = note: `#[warn(unexpected_cfgs)]` on by default +help: there is a similar config predicate: `version("..")` + | +LL - #[cfg(version = "1.43")] +LL + #[cfg(version("1.43"))] + | + +warning: unexpected `cfg` condition name: `version` + --> $DIR/syntax.rs:130:18 + | +LL | assert!(cfg!(version = "1.43")); + | ^^^^^^^^^^^^^^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(version, values("1.43"))` + = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration +help: there is a similar config predicate: `version("..")` + | +LL - assert!(cfg!(version = "1.43")); +LL + assert!(cfg!(version("1.43"))); + | + +error[E0425]: cannot find function `key_value_form` in this scope + --> $DIR/syntax.rs:139:5 + | +LL | key_value_form(); + | ^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find function `not_numbers_or_periods` in this scope + --> $DIR/syntax.rs:143:5 + | +LL | not_numbers_or_periods(); + | ^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find function `complex_semver_with_metadata` in this scope + --> $DIR/syntax.rs:144:5 + | +LL | complex_semver_with_metadata(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find function `invalid_major_only` in this scope + --> $DIR/syntax.rs:145:5 + | +LL | invalid_major_only(); + | ^^^^^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find function `invalid_major_only_zero` in this scope + --> $DIR/syntax.rs:146:5 + | +LL | invalid_major_only_zero(); + | ^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find function `invalid_major_only_negative` in this scope + --> $DIR/syntax.rs:147:5 + | +LL | invalid_major_only_negative(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find function `exceed_u16_major` in this scope + --> $DIR/syntax.rs:148:5 + | +LL | exceed_u16_major(); + | ^^^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find function `exceed_u16_minor` in this scope + --> $DIR/syntax.rs:149:5 + | +LL | exceed_u16_minor(); + | ^^^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find function `exceed_u16_patch` in this scope + --> $DIR/syntax.rs:150:5 + | +LL | exceed_u16_patch(); + | ^^^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find function `exceed_u16_mixed` in this scope + --> $DIR/syntax.rs:151:5 + | +LL | exceed_u16_mixed(); + | ^^^^^^^^^^^^^^^^ not found in this scope + +error: aborting due to 14 previous errors; 14 warnings emitted + +For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/cfg/diagnostics-reexport-2.rs b/tests/ui/cfg/diagnostics-reexport-2.rs new file mode 100644 index 00000000000..f66b9ed99ee --- /dev/null +++ b/tests/ui/cfg/diagnostics-reexport-2.rs @@ -0,0 +1,61 @@ +// issue#141256 + +mod original { + #[cfg(false)] + //~^ NOTE the item is gated here + //~| NOTE the item is gated here + //~| NOTE the item is gated here + //~| NOTE the item is gated here + //~| NOTE the item is gated here + pub mod gated { + //~^ NOTE found an item that was configured out + //~| NOTE found an item that was configured out + //~| NOTE found an item that was configured out + //~| NOTE found an item that was configured out + //~| NOTE found an item that was configured out + pub fn foo() {} + } +} + +mod reexport { + pub use super::original::*; +} + +mod reexport2 { + pub use super::reexport::*; +} + +mod reexport30 { + pub use super::original::*; + pub use super::reexport31::*; +} + +mod reexport31 { + pub use super::reexport30::*; +} + +mod reexport32 { + pub use super::reexport30::*; +} + +fn main() { + reexport::gated::foo(); + //~^ ERROR failed to resolve: could not find `gated` in `reexport` + //~| NOTE could not find `gated` in `reexport` + + reexport2::gated::foo(); + //~^ ERROR failed to resolve: could not find `gated` in `reexport2` + //~| NOTE could not find `gated` in `reexport2` + + reexport30::gated::foo(); + //~^ ERROR failed to resolve: could not find `gated` in `reexport30` + //~| NOTE could not find `gated` in `reexport30` + + reexport31::gated::foo(); + //~^ ERROR failed to resolve: could not find `gated` in `reexport31` + //~| NOTE could not find `gated` in `reexport31` + + reexport32::gated::foo(); + //~^ ERROR failed to resolve: could not find `gated` in `reexport32` + //~| NOTE could not find `gated` in `reexport32` +} diff --git a/tests/ui/cfg/diagnostics-reexport-2.stderr b/tests/ui/cfg/diagnostics-reexport-2.stderr new file mode 100644 index 00000000000..95ac5a19b0b --- /dev/null +++ b/tests/ui/cfg/diagnostics-reexport-2.stderr @@ -0,0 +1,88 @@ +error[E0433]: failed to resolve: could not find `gated` in `reexport` + --> $DIR/diagnostics-reexport-2.rs:42:15 + | +LL | reexport::gated::foo(); + | ^^^^^ could not find `gated` in `reexport` + | +note: found an item that was configured out + --> $DIR/diagnostics-reexport-2.rs:10:13 + | +LL | pub mod gated { + | ^^^^^ +note: the item is gated here + --> $DIR/diagnostics-reexport-2.rs:4:5 + | +LL | #[cfg(false)] + | ^^^^^^^^^^^^^ + +error[E0433]: failed to resolve: could not find `gated` in `reexport2` + --> $DIR/diagnostics-reexport-2.rs:46:16 + | +LL | reexport2::gated::foo(); + | ^^^^^ could not find `gated` in `reexport2` + | +note: found an item that was configured out + --> $DIR/diagnostics-reexport-2.rs:10:13 + | +LL | pub mod gated { + | ^^^^^ +note: the item is gated here + --> $DIR/diagnostics-reexport-2.rs:4:5 + | +LL | #[cfg(false)] + | ^^^^^^^^^^^^^ + +error[E0433]: failed to resolve: could not find `gated` in `reexport30` + --> $DIR/diagnostics-reexport-2.rs:50:17 + | +LL | reexport30::gated::foo(); + | ^^^^^ could not find `gated` in `reexport30` + | +note: found an item that was configured out + --> $DIR/diagnostics-reexport-2.rs:10:13 + | +LL | pub mod gated { + | ^^^^^ +note: the item is gated here + --> $DIR/diagnostics-reexport-2.rs:4:5 + | +LL | #[cfg(false)] + | ^^^^^^^^^^^^^ + +error[E0433]: failed to resolve: could not find `gated` in `reexport31` + --> $DIR/diagnostics-reexport-2.rs:54:17 + | +LL | reexport31::gated::foo(); + | ^^^^^ could not find `gated` in `reexport31` + | +note: found an item that was configured out + --> $DIR/diagnostics-reexport-2.rs:10:13 + | +LL | pub mod gated { + | ^^^^^ +note: the item is gated here + --> $DIR/diagnostics-reexport-2.rs:4:5 + | +LL | #[cfg(false)] + | ^^^^^^^^^^^^^ + +error[E0433]: failed to resolve: could not find `gated` in `reexport32` + --> $DIR/diagnostics-reexport-2.rs:58:17 + | +LL | reexport32::gated::foo(); + | ^^^^^ could not find `gated` in `reexport32` + | +note: found an item that was configured out + --> $DIR/diagnostics-reexport-2.rs:10:13 + | +LL | pub mod gated { + | ^^^^^ +note: the item is gated here + --> $DIR/diagnostics-reexport-2.rs:4:5 + | +LL | #[cfg(false)] + | ^^^^^^^^^^^^^ + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/char.rs b/tests/ui/char.rs deleted file mode 100644 index a7842f16fa7..00000000000 --- a/tests/ui/char.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ run-pass - -pub fn main() { - let c: char = 'x'; - let d: char = 'x'; - assert_eq!(c, 'x'); - assert_eq!('x', c); - assert_eq!(c, c); - assert_eq!(c, d); - assert_eq!(d, c); - assert_eq!(d, 'x'); - assert_eq!('x', d); -} diff --git a/tests/ui/check-cfg/target_feature.stderr b/tests/ui/check-cfg/target_feature.stderr index eb66633f9dd..ec81ba2e3d8 100644 --- a/tests/ui/check-cfg/target_feature.stderr +++ b/tests/ui/check-cfg/target_feature.stderr @@ -62,6 +62,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `c` `cache` `cmpxchg16b` +`concurrent-functions` `crc` `crt-static` `cssc` @@ -159,6 +160,15 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `lzcnt` `m` `mclass` +`message-security-assist-extension12` +`message-security-assist-extension3` +`message-security-assist-extension4` +`message-security-assist-extension5` +`message-security-assist-extension8` +`message-security-assist-extension9` +`miscellaneous-extensions-2` +`miscellaneous-extensions-3` +`miscellaneous-extensions-4` `mops` `movbe` `movrs` @@ -287,9 +297,11 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `vector` `vector-enhancements-1` `vector-enhancements-2` +`vector-enhancements-3` `vector-packed-decimal` `vector-packed-decimal-enhancement` `vector-packed-decimal-enhancement-2` +`vector-packed-decimal-enhancement-3` `vfp2` `vfp3` `vfp4` diff --git a/tests/ui/check-cfg/well-known-values.stderr b/tests/ui/check-cfg/well-known-values.stderr index 7cda6c2eaa5..532c1ab13d1 100644 --- a/tests/ui/check-cfg/well-known-values.stderr +++ b/tests/ui/check-cfg/well-known-values.stderr @@ -138,7 +138,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` LL | target_arch = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_arch` are: `aarch64`, `amdgpu`, `arm`, `arm64ec`, `avr`, `bpf`, `csky`, `hexagon`, `loongarch64`, `m68k`, `mips`, `mips32r6`, `mips64`, `mips64r6`, `msp430`, `nvptx64`, `powerpc`, `powerpc64`, `riscv32`, `riscv64`, `s390x`, `sparc`, `sparc64`, `wasm32`, `wasm64`, `x86`, `x86_64`, and `xtensa` + = note: expected values for `target_arch` are: `aarch64`, `amdgpu`, `arm`, `arm64ec`, `avr`, `bpf`, `csky`, `hexagon`, `loongarch32`, `loongarch64`, `m68k`, `mips`, `mips32r6`, `mips64`, `mips64r6`, `msp430`, `nvptx64`, `powerpc`, `powerpc64`, `riscv32`, `riscv64`, `s390x`, `sparc`, `sparc64`, `wasm32`, `wasm64`, `x86`, `x86_64`, and `xtensa` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` diff --git a/tests/ui/check-cfg/wrong-version-syntax.fixed b/tests/ui/check-cfg/wrong-version-syntax.fixed new file mode 100644 index 00000000000..efbe2ed1bd8 --- /dev/null +++ b/tests/ui/check-cfg/wrong-version-syntax.fixed @@ -0,0 +1,14 @@ +// Check warning for wrong `cfg(version("1.27"))` syntax +// +//@ check-pass +//@ no-auto-check-cfg +//@ compile-flags: --check-cfg=cfg() +//@ run-rustfix + +#![feature(cfg_version)] + +#[cfg(not(version("1.48.0")))] +//~^ WARNING unexpected `cfg` condition name: `version` +pub fn g() {} + +pub fn main() {} diff --git a/tests/ui/check-cfg/wrong-version-syntax.rs b/tests/ui/check-cfg/wrong-version-syntax.rs new file mode 100644 index 00000000000..221ecf4cae8 --- /dev/null +++ b/tests/ui/check-cfg/wrong-version-syntax.rs @@ -0,0 +1,14 @@ +// Check warning for wrong `cfg(version("1.27"))` syntax +// +//@ check-pass +//@ no-auto-check-cfg +//@ compile-flags: --check-cfg=cfg() +//@ run-rustfix + +#![feature(cfg_version)] + +#[cfg(not(version = "1.48.0"))] +//~^ WARNING unexpected `cfg` condition name: `version` +pub fn g() {} + +pub fn main() {} diff --git a/tests/ui/check-cfg/wrong-version-syntax.stderr b/tests/ui/check-cfg/wrong-version-syntax.stderr new file mode 100644 index 00000000000..97157a0c02b --- /dev/null +++ b/tests/ui/check-cfg/wrong-version-syntax.stderr @@ -0,0 +1,17 @@ +warning: unexpected `cfg` condition name: `version` + --> $DIR/wrong-version-syntax.rs:10:11 + | +LL | #[cfg(not(version = "1.48.0"))] + | ^^^^^^^^^^^^^^^^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(version, values("1.48.0"))` + = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration + = note: `#[warn(unexpected_cfgs)]` on by default +help: there is a similar config predicate: `version("..")` + | +LL - #[cfg(not(version = "1.48.0"))] +LL + #[cfg(not(version("1.48.0")))] + | + +warning: 1 warning emitted + diff --git a/tests/ui/class-cast-to-trait.rs b/tests/ui/class-cast-to-trait.rs deleted file mode 100644 index ca98e4c9003..00000000000 --- a/tests/ui/class-cast-to-trait.rs +++ /dev/null @@ -1,54 +0,0 @@ -trait Noisy { - fn speak(&mut self); -} - -struct Cat { - meows : usize, - - how_hungry : isize, - name : String, -} - -impl Cat { - pub fn eat(&mut self) -> bool { - if self.how_hungry > 0 { - println!("OM NOM NOM"); - self.how_hungry -= 2; - return true; - } - else { - println!("Not hungry!"); - return false; - } - } -} - -impl Noisy for Cat { - fn speak(&mut self) { self.meow(); } - -} - -impl Cat { - fn meow(&mut self) { - println!("Meow"); - self.meows += 1; - if self.meows % 5 == 0 { - self.how_hungry += 1; - } - } -} - -fn cat(in_x : usize, in_y : isize, in_name: String) -> Cat { - Cat { - meows: in_x, - how_hungry: in_y, - name: in_name - } -} - - - -fn main() { - let nyan: Box<dyn Noisy> = Box::new(cat(0, 2, "nyan".to_string())) as Box<dyn Noisy>; - nyan.eat(); //~ ERROR no method named `eat` found -} diff --git a/tests/ui/class-cast-to-trait.stderr b/tests/ui/class-cast-to-trait.stderr deleted file mode 100644 index 4ea0f41c3ed..00000000000 --- a/tests/ui/class-cast-to-trait.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0599]: no method named `eat` found for struct `Box<dyn Noisy>` in the current scope - --> $DIR/class-cast-to-trait.rs:53:8 - | -LL | nyan.eat(); - | ^^^ method not found in `Box<dyn Noisy>` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/class-method-missing.rs b/tests/ui/class-method-missing.rs deleted file mode 100644 index 5dc18328f31..00000000000 --- a/tests/ui/class-method-missing.rs +++ /dev/null @@ -1,21 +0,0 @@ -trait Animal { - fn eat(&self); -} - -struct Cat { - meows: usize, -} - -impl Animal for Cat { - //~^ ERROR not all trait items implemented, missing: `eat` -} - -fn cat(in_x : usize) -> Cat { - Cat { - meows: in_x - } -} - -fn main() { - let nyan = cat(0); -} diff --git a/tests/ui/class-method-missing.stderr b/tests/ui/class-method-missing.stderr deleted file mode 100644 index 42bd22e18a1..00000000000 --- a/tests/ui/class-method-missing.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0046]: not all trait items implemented, missing: `eat` - --> $DIR/class-method-missing.rs:9:1 - | -LL | fn eat(&self); - | -------------- `eat` from trait -... -LL | impl Animal for Cat { - | ^^^^^^^^^^^^^^^^^^^ missing `eat` in implementation - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/cleanup-rvalue-for-scope.rs b/tests/ui/cleanup-rvalue-for-scope.rs deleted file mode 100644 index 8f5ee8723fd..00000000000 --- a/tests/ui/cleanup-rvalue-for-scope.rs +++ /dev/null @@ -1,60 +0,0 @@ -//@ run-pass - -#![allow(non_snake_case)] -#![allow(dead_code)] -#![allow(unused_variables)] -// Test that the lifetime of rvalues in for loops is extended -// to the for loop itself. -static mut FLAGS: u64 = 0; - -struct Box<T> { f: T } -struct AddFlags { bits: u64 } - -fn AddFlags(bits: u64) -> AddFlags { - AddFlags { bits: bits } -} - -fn arg(exp: u64, _x: &AddFlags) { - check_flags(exp); -} - -fn pass<T>(v: T) -> T { - v -} - -fn check_flags(exp: u64) { - unsafe { - let x = FLAGS; - FLAGS = 0; - println!("flags {}, expected {}", x, exp); - assert_eq!(x, exp); - } -} - -impl AddFlags { - fn check_flags(&self, exp: u64) -> &AddFlags { - check_flags(exp); - self - } - - fn bits(&self) -> u64 { - self.bits - } -} - -impl Drop for AddFlags { - fn drop(&mut self) { - unsafe { - FLAGS = FLAGS + self.bits; - } - } -} - -pub fn main() { - // The array containing [AddFlags] should not be dropped until - // after the for loop: - for x in &[AddFlags(1)] { - check_flags(0); - } - check_flags(1); -} diff --git a/tests/ui/cleanup-rvalue-scopes.rs b/tests/ui/cleanup-rvalue-scopes.rs deleted file mode 100644 index 09ceda065b9..00000000000 --- a/tests/ui/cleanup-rvalue-scopes.rs +++ /dev/null @@ -1,128 +0,0 @@ -//@ run-pass -#![allow(unused_braces)] -#![allow(non_snake_case)] -#![allow(unused_variables)] -// Test that destructors for rvalue temporaries run either at end of -// statement or end of block, as appropriate given the temporary -// lifetime rules. - -#![feature(box_patterns)] - -static mut FLAGS: u64 = 0; - -struct Box<T> { f: T } -struct AddFlags { bits: u64 } - -fn AddFlags(bits: u64) -> AddFlags { - AddFlags { bits: bits } -} - -fn arg(exp: u64, _x: &AddFlags) { - check_flags(exp); -} - -fn pass<T>(v: T) -> T { - v -} - -fn check_flags(exp: u64) { - unsafe { - let x = FLAGS; - FLAGS = 0; - println!("flags {}, expected {}", x, exp); - assert_eq!(x, exp); - } -} - -impl AddFlags { - fn check_flags<'a>(&'a self, exp: u64) -> &'a AddFlags { - check_flags(exp); - self - } - - fn bits(&self) -> u64 { - self.bits - } -} - -impl Drop for AddFlags { - fn drop(&mut self) { - unsafe { - FLAGS = FLAGS + self.bits; - } - } -} - -macro_rules! end_of_block { - ($pat:pat, $expr:expr) => ( - { - println!("end_of_block({})", stringify!({let $pat = $expr;})); - - { - // Destructor here does not run until exit from the block. - let $pat = $expr; - check_flags(0); - } - check_flags(1); - } - ) -} - -macro_rules! end_of_stmt { - ($pat:pat, $expr:expr) => ( - { - println!("end_of_stmt({})", stringify!($expr)); - - { - // Destructor here run after `let` statement - // terminates. - let $pat = $expr; - check_flags(1); - } - - check_flags(0); - } - ) -} - -pub fn main() { - - // In all these cases, we trip over the rules designed to cover - // the case where we are taking addr of rvalue and storing that - // addr into a stack slot, either via `let ref` or via a `&` in - // the initializer. - - end_of_block!(_x, AddFlags(1)); - end_of_block!(_x, &AddFlags(1)); - end_of_block!(_x, & &AddFlags(1)); - end_of_block!(_x, Box { f: AddFlags(1) }); - end_of_block!(_x, Box { f: &AddFlags(1) }); - end_of_block!(_x, Box { f: &AddFlags(1) }); - end_of_block!(_x, pass(AddFlags(1))); - end_of_block!(ref _x, AddFlags(1)); - end_of_block!(AddFlags { bits: ref _x }, AddFlags(1)); - end_of_block!(&AddFlags { bits }, &AddFlags(1)); - end_of_block!((_, ref _y), (AddFlags(1), 22)); - end_of_block!(box ref _x, std::boxed::Box::new(AddFlags(1))); - end_of_block!(box _x, std::boxed::Box::new(AddFlags(1))); - end_of_block!(_, { { check_flags(0); &AddFlags(1) } }); - end_of_block!(_, &((Box { f: AddFlags(1) }).f)); - end_of_block!(_, &(([AddFlags(1)])[0])); - - // LHS does not create a ref binding, so temporary lives as long - // as statement, and we do not move the AddFlags out: - end_of_stmt!(_, AddFlags(1)); - end_of_stmt!((_, _), (AddFlags(1), 22)); - - // `&` operator appears inside an arg to a function, - // so it is not prolonged: - end_of_stmt!(ref _x, arg(0, &AddFlags(1))); - - // autoref occurs inside receiver, so temp lifetime is not - // prolonged: - end_of_stmt!(ref _x, AddFlags(1).check_flags(0).bits()); - - // No reference is created on LHS, thus RHS is moved into - // a temporary that lives just as long as the statement. - end_of_stmt!(AddFlags { bits }, AddFlags(1)); -} diff --git a/tests/ui/close-over-big-then-small-data.rs b/tests/ui/close-over-big-then-small-data.rs deleted file mode 100644 index d3cb1db8886..00000000000 --- a/tests/ui/close-over-big-then-small-data.rs +++ /dev/null @@ -1,39 +0,0 @@ -//@ run-pass - -#![allow(dead_code)] -// If we use GEPi rather than GEP_tup_like when -// storing closure data (as we used to do), the u64 would -// overwrite the u16. - -struct Pair<A,B> { - a: A, b: B -} - -struct Invoker<A> { - a: A, - b: u16, -} - -trait Invokable<A> { - fn f(&self) -> (A, u16); -} - -impl<A:Clone> Invokable<A> for Invoker<A> { - fn f(&self) -> (A, u16) { - (self.a.clone(), self.b) - } -} - -fn f<A:Clone + 'static>(a: A, b: u16) -> Box<dyn Invokable<A>+'static> { - Box::new(Invoker { - a: a, - b: b, - }) as Box<dyn Invokable<A>+'static> -} - -pub fn main() { - let (a, b) = f(22_u64, 44u16).f(); - println!("a={} b={}", a, b); - assert_eq!(a, 22u64); - assert_eq!(b, 44u16); -} diff --git a/tests/ui/closures/2229_closure_analysis/run_pass/lit-pattern-matching-with-methods.rs b/tests/ui/closures/2229_closure_analysis/run_pass/lit-pattern-matching-with-methods.rs index 7a4d7d9a81e..afb16cf58e8 100644 --- a/tests/ui/closures/2229_closure_analysis/run_pass/lit-pattern-matching-with-methods.rs +++ b/tests/ui/closures/2229_closure_analysis/run_pass/lit-pattern-matching-with-methods.rs @@ -14,14 +14,14 @@ fn main() { map.insert("c", ()); { - let mut it = map.extract_if(|_, _| true); + let mut it = map.extract_if(.., |_, _| true); catch_unwind(AssertUnwindSafe(|| while it.next().is_some() {})).unwrap_err(); let result = catch_unwind(AssertUnwindSafe(|| it.next())); assert!(matches!(result, Ok(None))); } { - let mut it = map.extract_if(|_, _| true); + let mut it = map.extract_if(.., |_, _| true); catch_unwind(AssertUnwindSafe(|| while let Some(_) = it.next() {})).unwrap_err(); let result = catch_unwind(AssertUnwindSafe(|| it.next())); assert!(matches!(result, Ok(None))); diff --git a/tests/ui/closures/closure-immut-capture-error.rs b/tests/ui/closures/closure-immut-capture-error.rs new file mode 100644 index 00000000000..19fe599f241 --- /dev/null +++ b/tests/ui/closures/closure-immut-capture-error.rs @@ -0,0 +1,23 @@ +//! Tests that mutation of captured immutable variables in closures are not permitted. + +#![feature(unboxed_closures, tuple_trait)] + +use std::io::Read; + +fn to_fn_once<A: std::marker::Tuple, F: FnOnce<A>>(f: F) -> F { + f +} + +fn main() { + let x = 1; + to_fn_once(move || { + x = 2; + //~^ ERROR: cannot assign to `x`, as it is not declared as mutable + }); + + let s = std::io::stdin(); + to_fn_once(move || { + s.read_to_end(&mut Vec::new()); + //~^ ERROR: cannot borrow `s` as mutable, as it is not declared as mutable + }); +} diff --git a/tests/ui/cannot-mutate-captured-non-mut-var.stderr b/tests/ui/closures/closure-immut-capture-error.stderr index 8d794f8251f..516cf7c074e 100644 --- a/tests/ui/cannot-mutate-captured-non-mut-var.stderr +++ b/tests/ui/closures/closure-immut-capture-error.stderr @@ -1,8 +1,8 @@ error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/cannot-mutate-captured-non-mut-var.rs:9:25 + --> $DIR/closure-immut-capture-error.rs:14:9 | -LL | to_fn_once(move|| { x = 2; }); - | ^^^^^ cannot assign +LL | x = 2; + | ^^^^^ cannot assign | help: consider changing this to be mutable | @@ -10,10 +10,10 @@ LL | let mut x = 1; | +++ error[E0596]: cannot borrow `s` as mutable, as it is not declared as mutable - --> $DIR/cannot-mutate-captured-non-mut-var.rs:13:25 + --> $DIR/closure-immut-capture-error.rs:20:9 | -LL | to_fn_once(move|| { s.read_to_end(&mut Vec::new()); }); - | ^ cannot borrow as mutable +LL | s.read_to_end(&mut Vec::new()); + | ^ cannot borrow as mutable | help: consider changing this to be mutable | diff --git a/tests/ui/codegen/rvalue-mut-ref-box-drop.rs b/tests/ui/codegen/rvalue-mut-ref-box-drop.rs new file mode 100644 index 00000000000..441820ad64e --- /dev/null +++ b/tests/ui/codegen/rvalue-mut-ref-box-drop.rs @@ -0,0 +1,13 @@ +//! Tests cleanup of a temporary `Box` rvalue passed as a mutable reference. +//! +//! - Issue: <https://github.com/rust-lang/rust/issues/7972>. + +//@ run-pass + +fn foo(x: &mut Box<u8>) { + *x = Box::new(5); +} + +pub fn main() { + foo(&mut Box::new(4)); +} diff --git a/tests/ui/coercion/issue-73886.stderr b/tests/ui/coercion/issue-73886.stderr index 0d4c90017cf..891931d0bf8 100644 --- a/tests/ui/coercion/issue-73886.stderr +++ b/tests/ui/coercion/issue-73886.stderr @@ -3,14 +3,15 @@ error[E0605]: non-primitive cast: `&&[i32; 1]` as `&[_]` | LL | let _ = &&[0] as &[_]; | ^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object + | + = note: casting reference expression `&&[0]` because `&` binds tighter than `as` error[E0605]: non-primitive cast: `u32` as `Option<_>` --> $DIR/issue-73886.rs:4:13 | LL | let _ = 7u32 as Option<_>; - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object | - = 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<_>; diff --git a/tests/ui/coercion/non-primitive-cast-135412.stderr b/tests/ui/coercion/non-primitive-cast-135412.stderr index 7e5861f83e9..e5e9ee13459 100644 --- a/tests/ui/coercion/non-primitive-cast-135412.stderr +++ b/tests/ui/coercion/non-primitive-cast-135412.stderr @@ -2,9 +2,8 @@ error[E0605]: non-primitive cast: `u32` as `Option<_>` --> $DIR/non-primitive-cast-135412.rs:6:13 | LL | let _ = 7u32 as Option<_>; - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object | - = 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<_>; @@ -15,9 +14,8 @@ error[E0605]: non-primitive cast: `&'static str` as `Arc<str>` --> $DIR/non-primitive-cast-135412.rs:8:13 | LL | let _ = "String" as Arc<str>; - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object | - = 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>; diff --git a/tests/ui/coercion/retslot-cast.rs b/tests/ui/coercion/retslot-cast.rs index ae500cb15df..a87ac35a8e1 100644 --- a/tests/ui/coercion/retslot-cast.rs +++ b/tests/ui/coercion/retslot-cast.rs @@ -1,7 +1,7 @@ #![allow(warnings)] -pub fn fail(x: Option<&(Iterator<Item=()>+Send)>) - -> Option<&Iterator<Item=()>> { +pub fn fail(x: Option<&(dyn Iterator<Item=()>+Send)>) + -> Option<&dyn Iterator<Item=()>> { // This call used to trigger an LLVM assertion because the return // slot had type "Option<&Iterator>"* instead of // "Option<&(Iterator+Send)>"* -- but this now yields a @@ -13,8 +13,8 @@ pub fn fail(x: Option<&(Iterator<Item=()>+Send)>) inner(x) //~ ERROR mismatched types } -pub fn inner(x: Option<&(Iterator<Item=()>+Send)>) - -> Option<&(Iterator<Item=()>+Send)> { +pub fn inner(x: Option<&(dyn Iterator<Item=()>+Send)>) + -> Option<&(dyn Iterator<Item=()>+Send)> { x } diff --git a/tests/ui/coercion/retslot-cast.stderr b/tests/ui/coercion/retslot-cast.stderr index dac21a7f25b..a5242c13edd 100644 --- a/tests/ui/coercion/retslot-cast.stderr +++ b/tests/ui/coercion/retslot-cast.stderr @@ -1,8 +1,8 @@ error[E0308]: mismatched types --> $DIR/retslot-cast.rs:13:5 | -LL | -> Option<&Iterator<Item=()>> { - | -------------------------- expected `Option<&dyn Iterator<Item = ()>>` because of return type +LL | -> Option<&dyn Iterator<Item=()>> { + | ------------------------------ expected `Option<&dyn Iterator<Item = ()>>` because of return type ... LL | inner(x) | ^^^^^^^^ expected trait `Iterator<Item = ()>`, found trait `Iterator<Item = ()> + Send` diff --git a/tests/ui/coherence/coherence_inherent.rs b/tests/ui/coherence/coherence_inherent.rs index f3ebf000386..b2007e3437d 100644 --- a/tests/ui/coherence/coherence_inherent.rs +++ b/tests/ui/coherence/coherence_inherent.rs @@ -15,8 +15,8 @@ mod Lib { mod Import { // Trait is in scope here: - use Lib::TheStruct; - use Lib::TheTrait; + use crate::Lib::TheStruct; + use crate::Lib::TheTrait; fn call_the_fn(s: &TheStruct) { s.the_fn(); @@ -25,7 +25,7 @@ mod Import { mod NoImport { // Trait is not in scope here: - use Lib::TheStruct; + use crate::Lib::TheStruct; fn call_the_fn(s: &TheStruct) { s.the_fn(); diff --git a/tests/ui/coherence/const-errs-dont-conflict-103369.stderr b/tests/ui/coherence/const-errs-dont-conflict-103369.stderr index b2104299f65..c8ed75abf72 100644 --- a/tests/ui/coherence/const-errs-dont-conflict-103369.stderr +++ b/tests/ui/coherence/const-errs-dont-conflict-103369.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: Some error occurred --> $DIR/const-errs-dont-conflict-103369.rs:5:25 | LL | impl ConstGenericTrait<{my_fn(1)}> for () {} - | ^^^^^^^^ evaluation panicked: Some error occurred + | ^^^^^^^^ evaluation of `<() as ConstGenericTrait<{my_fn(1)}>>::{constant#0}` failed inside this call | note: inside `my_fn` --> $DIR/const-errs-dont-conflict-103369.rs:10:5 @@ -10,11 +10,11 @@ note: inside `my_fn` LL | panic!("Some error occurred"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: Some error occurred --> $DIR/const-errs-dont-conflict-103369.rs:7:25 | LL | impl ConstGenericTrait<{my_fn(2)}> for () {} - | ^^^^^^^^ evaluation panicked: Some error occurred + | ^^^^^^^^ evaluation of `<() as ConstGenericTrait<{my_fn(2)}>>::{constant#0}` failed inside this call | note: inside `my_fn` --> $DIR/const-errs-dont-conflict-103369.rs:10:5 diff --git a/tests/ui/complex.rs b/tests/ui/complex.rs deleted file mode 100644 index d1da9d189ca..00000000000 --- a/tests/ui/complex.rs +++ /dev/null @@ -1,38 +0,0 @@ -//@ run-pass - -#![allow(unconditional_recursion)] -#![allow(non_camel_case_types)] -#![allow(dead_code)] -#![allow(unused_mut)] - - - -type t = isize; - -fn nothing() { } - -fn putstr(_s: String) { } - -fn putint(_i: isize) { - let mut i: isize = 33; - while i < 36 { putstr("hi".to_string()); i = i + 1; } -} - -fn zerg(i: isize) -> isize { return i; } - -fn foo(x: isize) -> isize { - let mut y: t = x + 2; - putstr("hello".to_string()); - while y < 10 { putint(y); if y * 3 == 4 { y = y + 2; nothing(); } } - let mut z: t; - z = 0x55; - foo(z); - return 0; -} - -pub fn main() { - let x: isize = 2 + 2; - println!("{}", x); - println!("hello, world"); - println!("{}", 10); -} diff --git a/tests/ui/const-generics/associated_const_equality/equality_bound_with_infer.rs b/tests/ui/const-generics/associated_const_equality/equality_bound_with_infer.rs new file mode 100644 index 00000000000..f45b7c3268b --- /dev/null +++ b/tests/ui/const-generics/associated_const_equality/equality_bound_with_infer.rs @@ -0,0 +1,24 @@ +#![feature(generic_arg_infer, associated_const_equality, generic_const_items)] +#![expect(incomplete_features)] + +// Regression test for #133066 where we would try to evaluate `<() as Foo>::ASSOC<_>` even +// though it contained inference variables, which would cause ICEs. + +trait Foo { + const ASSOC<const N: u32>: u32; +} + +impl Foo for () { + const ASSOC<const N: u32>: u32 = N; +} + +fn bar<const N: u32, T: Foo<ASSOC<N> = 10>>() {} + +fn main() { + bar::<_, ()>(); + //~^ ERROR: type mismatch resolving `<() as Foo>::ASSOC<_> == 10` + + // FIXME(mgca): + // FIXME(associated_const_equality): + // This ought to start compiling once const items are aliases rather than bodies +} diff --git a/tests/ui/const-generics/associated_const_equality/equality_bound_with_infer.stderr b/tests/ui/const-generics/associated_const_equality/equality_bound_with_infer.stderr new file mode 100644 index 00000000000..00741c901e4 --- /dev/null +++ b/tests/ui/const-generics/associated_const_equality/equality_bound_with_infer.stderr @@ -0,0 +1,17 @@ +error[E0271]: type mismatch resolving `<() as Foo>::ASSOC<_> == 10` + --> $DIR/equality_bound_with_infer.rs:18:14 + | +LL | bar::<_, ()>(); + | ^^ expected `10`, found `<() as Foo>::ASSOC::<_>` + | + = note: expected constant `10` + found constant `<() as Foo>::ASSOC::<_>` +note: required by a bound in `bar` + --> $DIR/equality_bound_with_infer.rs:15:29 + | +LL | fn bar<const N: u32, T: Foo<ASSOC<N> = 10>>() {} + | ^^^^^^^^^^^^^ required by this bound in `bar` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/const-generics/associated_const_equality/unconstrained_impl_param.rs b/tests/ui/const-generics/associated_const_equality/unconstrained_impl_param.rs new file mode 100644 index 00000000000..99318ef7598 --- /dev/null +++ b/tests/ui/const-generics/associated_const_equality/unconstrained_impl_param.rs @@ -0,0 +1,26 @@ +// regression test for #137813 where we would assume all constants in the type system +// cannot contain inference variables, even though associated const equality syntax +// was still lowered without the feature gate enabled. + +trait AssocConst { + const A: u8; +} + +impl<T> AssocConst for (T,) { + const A: u8 = 0; +} + +trait Trait {} + +impl<U> Trait for () where (U,): AssocConst<A = { 0 }> {} +//~^ ERROR associated const equality is incomplete +//~| ERROR the type parameter `U` is not constrained by the impl trait + +fn foo() +where + (): Trait, + //~^ ERROR type mismatch resolving +{ +} + +fn main() {} diff --git a/tests/ui/const-generics/associated_const_equality/unconstrained_impl_param.stderr b/tests/ui/const-generics/associated_const_equality/unconstrained_impl_param.stderr new file mode 100644 index 00000000000..e6799ec5c3a --- /dev/null +++ b/tests/ui/const-generics/associated_const_equality/unconstrained_impl_param.stderr @@ -0,0 +1,39 @@ +error[E0658]: associated const equality is incomplete + --> $DIR/unconstrained_impl_param.rs:15:45 + | +LL | impl<U> Trait for () where (U,): AssocConst<A = { 0 }> {} + | ^^^^^^^^^ + | + = note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information + = help: add `#![feature(associated_const_equality)]` 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[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates + --> $DIR/unconstrained_impl_param.rs:15:6 + | +LL | impl<U> Trait for () where (U,): AssocConst<A = { 0 }> {} + | ^ unconstrained type parameter + +error[E0271]: type mismatch resolving `<(_,) as AssocConst>::A == 0` + --> $DIR/unconstrained_impl_param.rs:21:5 + | +LL | (): Trait, + | ^^^^^^^^^ expected `0`, found `<(_,) as AssocConst>::A` + | + = note: expected constant `0` + found constant `<(_,) as AssocConst>::A` +note: required for `()` to implement `Trait` + --> $DIR/unconstrained_impl_param.rs:15:9 + | +LL | impl<U> Trait for () where (U,): AssocConst<A = { 0 }> {} + | ^^^^^ ^^ --------- unsatisfied trait bound introduced here + = help: see issue #48214 +help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + | +LL + #![feature(trivial_bounds)] + | + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0207, E0271, E0658. +For more information about an error, try `rustc --explain E0207`. diff --git a/tests/ui/const-generics/defaults/default-param-wf-concrete.next.stderr b/tests/ui/const-generics/defaults/default-param-wf-concrete.next.stderr index 35aae462443..133d8f6b0f0 100644 --- a/tests/ui/const-generics/defaults/default-param-wf-concrete.next.stderr +++ b/tests/ui/const-generics/defaults/default-param-wf-concrete.next.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow --> $DIR/default-param-wf-concrete.rs:4:28 | LL | struct Foo<const N: u8 = { 255 + 1 }>; - | ^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow + | ^^^^^^^ evaluation of `Foo::{constant#0}` failed here error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/defaults/default-param-wf-concrete.old.stderr b/tests/ui/const-generics/defaults/default-param-wf-concrete.old.stderr index 35aae462443..133d8f6b0f0 100644 --- a/tests/ui/const-generics/defaults/default-param-wf-concrete.old.stderr +++ b/tests/ui/const-generics/defaults/default-param-wf-concrete.old.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow --> $DIR/default-param-wf-concrete.rs:4:28 | LL | struct Foo<const N: u8 = { 255 + 1 }>; - | ^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow + | ^^^^^^^ evaluation of `Foo::{constant#0}` failed here error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/defaults/default-param-wf-concrete.rs b/tests/ui/const-generics/defaults/default-param-wf-concrete.rs index f181f582332..0385e55e3b2 100644 --- a/tests/ui/const-generics/defaults/default-param-wf-concrete.rs +++ b/tests/ui/const-generics/defaults/default-param-wf-concrete.rs @@ -2,5 +2,5 @@ //@[next] compile-flags: -Znext-solver struct Foo<const N: u8 = { 255 + 1 }>; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflow fn main() {} diff --git a/tests/ui/const-generics/defaults/wfness.rs b/tests/ui/const-generics/defaults/wfness.rs index a93f670815a..99e9452b46a 100644 --- a/tests/ui/const-generics/defaults/wfness.rs +++ b/tests/ui/const-generics/defaults/wfness.rs @@ -1,5 +1,5 @@ struct Ooopsies<const N: u8 = { u8::MAX + 1 }>; -//~^ error: evaluation of constant value failed +//~^ error: overflow trait Trait<const N: u8> {} impl Trait<3> for () {} diff --git a/tests/ui/const-generics/defaults/wfness.stderr b/tests/ui/const-generics/defaults/wfness.stderr index 290a80bd32f..4f42afed81d 100644 --- a/tests/ui/const-generics/defaults/wfness.stderr +++ b/tests/ui/const-generics/defaults/wfness.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow --> $DIR/wfness.rs:1:33 | LL | struct Ooopsies<const N: u8 = { u8::MAX + 1 }>; - | ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow + | ^^^^^^^^^^^ evaluation of `Ooopsies::{constant#0}` failed here error[E0277]: the trait bound `(): Trait<2>` is not satisfied --> $DIR/wfness.rs:8:9 diff --git a/tests/ui/const-generics/early/invalid-const-arguments.stderr b/tests/ui/const-generics/early/invalid-const-arguments.stderr index 86b4d006454..3a9868836ec 100644 --- a/tests/ui/const-generics/early/invalid-const-arguments.stderr +++ b/tests/ui/const-generics/early/invalid-const-arguments.stderr @@ -51,9 +51,13 @@ error[E0747]: type provided when a constant was expected --> $DIR/invalid-const-arguments.rs:10:19 | LL | impl<N> Foo for B<N> {} - | - ^ - | | - | help: consider changing this type parameter to a const parameter: `const N: u8` + | ^ + | +help: consider changing this type parameter to a const parameter + | +LL - impl<N> Foo for B<N> {} +LL + impl<const N: u8> Foo for B<N> {} + | error[E0747]: unresolved item provided when a constant was expected --> $DIR/invalid-const-arguments.rs:14:32 diff --git a/tests/crashes/auxiliary/aux133199.rs b/tests/ui/const-generics/generic_const_exprs/auxiliary/cross-crate-2.rs index 40765d92fbf..a8bda14f4bd 100644 --- a/tests/crashes/auxiliary/aux133199.rs +++ b/tests/ui/const-generics/generic_const_exprs/auxiliary/cross-crate-2.rs @@ -1,9 +1,9 @@ #![allow(incomplete_features)] #![feature(generic_const_exprs)] -pub struct FixedBitSet<const N: usize>; +pub struct Foo<const N: usize>; -impl<const N: usize> FixedBitSet<N> +impl<const N: usize> Foo<N> where [u8; N.div_ceil(8)]: Sized, { diff --git a/tests/ui/const-generics/generic_const_exprs/cross-crate-2.rs b/tests/ui/const-generics/generic_const_exprs/cross-crate-2.rs new file mode 100644 index 00000000000..77998c7ec0a --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/cross-crate-2.rs @@ -0,0 +1,10 @@ +//@ check-pass +//@ aux-build: cross-crate-2.rs + +extern crate cross_crate_2; + +use cross_crate_2::Foo; + +fn main() { + Foo::<7>::new(); +} diff --git a/tests/ui/const-generics/generic_const_exprs/dependence_lint.full.stderr b/tests/ui/const-generics/generic_const_exprs/dependence_lint.full.stderr index f454ff4e6c0..6b095f3818a 100644 --- a/tests/ui/const-generics/generic_const_exprs/dependence_lint.full.stderr +++ b/tests/ui/const-generics/generic_const_exprs/dependence_lint.full.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/dependence_lint.rs:14:32 + --> $DIR/dependence_lint.rs:15:32 | LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce | ^ cannot perform const operation using `T` @@ -8,7 +8,7 @@ LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/dependence_lint.rs:21:37 + --> $DIR/dependence_lint.rs:22:37 | LL | let _: [u8; if true { size_of::<T>() } else { 3 }]; // error on stable, error with gce | ^ cannot perform const operation using `T` @@ -27,7 +27,7 @@ LL | [0; size_of::<*mut T>()]; // lint on stable, error with `generic_const_ = note: `#[warn(const_evaluatable_unchecked)]` on by default warning: cannot use constants which depend on generic parameters in types - --> $DIR/dependence_lint.rs:17:9 + --> $DIR/dependence_lint.rs:18:9 | LL | [0; if false { size_of::<T>() } else { 3 }]; // lint on stable, error with gce | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/const-generics/generic_const_exprs/dependence_lint.gce.stderr b/tests/ui/const-generics/generic_const_exprs/dependence_lint.gce.stderr index f6119c17bf4..12ac980c975 100644 --- a/tests/ui/const-generics/generic_const_exprs/dependence_lint.gce.stderr +++ b/tests/ui/const-generics/generic_const_exprs/dependence_lint.gce.stderr @@ -9,8 +9,19 @@ help: try adding a `where` bound LL | fn foo<T>() where [(); size_of::<*mut T>()]: { | ++++++++++++++++++++++++++++++++ +error: unconstrained generic constant + --> $DIR/dependence_lint.rs:10:5 + | +LL | [0; size_of::<*mut T>()]; // lint on stable, error with `generic_const_exprs` + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try adding a `where` bound + | +LL | fn foo<T>() where [(); size_of::<*mut T>()]: { + | ++++++++++++++++++++++++++++++++ + error: overly complex generic constant - --> $DIR/dependence_lint.rs:17:9 + --> $DIR/dependence_lint.rs:18:9 | LL | [0; if false { size_of::<T>() } else { 3 }]; // lint on stable, error with gce | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ control flow is not supported in generic constants @@ -18,7 +29,7 @@ LL | [0; if false { size_of::<T>() } else { 3 }]; // lint on stable, error w = help: consider moving this anonymous constant into a `const` function error: unconstrained generic constant - --> $DIR/dependence_lint.rs:14:12 + --> $DIR/dependence_lint.rs:15:12 | LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -29,12 +40,12 @@ LL | fn foo<T>() where [(); size_of::<*mut T>()]: { | ++++++++++++++++++++++++++++++++ error: overly complex generic constant - --> $DIR/dependence_lint.rs:21:17 + --> $DIR/dependence_lint.rs:22:17 | LL | let _: [u8; if true { size_of::<T>() } else { 3 }]; // error on stable, error with gce | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ control flow is not supported in generic constants | = help: consider moving this anonymous constant into a `const` function -error: aborting due to 4 previous errors +error: aborting due to 5 previous errors diff --git a/tests/ui/const-generics/generic_const_exprs/dependence_lint.rs b/tests/ui/const-generics/generic_const_exprs/dependence_lint.rs index 107466cd1d9..6b3c8f84be3 100644 --- a/tests/ui/const-generics/generic_const_exprs/dependence_lint.rs +++ b/tests/ui/const-generics/generic_const_exprs/dependence_lint.rs @@ -9,7 +9,8 @@ use std::mem::size_of; fn foo<T>() { [0; size_of::<*mut T>()]; // lint on stable, error with `generic_const_exprs` //[gce]~^ ERROR unconstrained - //[full]~^^ WARNING cannot use constants + //[gce]~| ERROR unconstrained generic constant + //[full]~^^^ WARNING cannot use constants //[full]~| WARNING this was previously accepted let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce //[full]~^ ERROR generic parameters may not be used diff --git a/tests/ui/const-generics/generic_const_exprs/different-fn.stderr b/tests/ui/const-generics/generic_const_exprs/different-fn.stderr index ac80463480d..52917df0da1 100644 --- a/tests/ui/const-generics/generic_const_exprs/different-fn.stderr +++ b/tests/ui/const-generics/generic_const_exprs/different-fn.stderr @@ -2,10 +2,10 @@ error[E0308]: mismatched types --> $DIR/different-fn.rs:10:5 | LL | [0; size_of::<Foo<T>>()] - | ^^^^^^^^^^^^^^^^^^^^^^^^ expected `size_of::<T>()`, found `0` + | ^^^^^^^^^^^^^^^^^^^^^^^^ expected `size_of::<T>()`, found `size_of::<Foo<T>>()` | = note: expected constant `size_of::<T>()` - found constant `0` + found constant `size_of::<Foo<T>>()` error: unconstrained generic constant --> $DIR/different-fn.rs:10:9 diff --git a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.rs b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.rs index 9ab715d01f7..da9a75b50ef 100644 --- a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.rs +++ b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.rs @@ -15,7 +15,7 @@ impl Foo for () { } fn use_dyn(v: &dyn Foo) { //~ERROR the trait `Foo` is not dyn compatible - v.test(); //~ERROR the trait `Foo` is not dyn compatible + v.test(); } fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.stderr b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.stderr index 8bc6ef093d0..120ee435e25 100644 --- a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.stderr +++ b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.stderr @@ -17,25 +17,6 @@ LL | fn test(&self) -> [u8; bar::<Self>()]; = help: consider moving `test` to another trait = help: only type `()` implements `Foo`; consider using it directly instead. -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/dyn-compatibility-err-ret.rs:18:5 - | -LL | v.test(); - | ^^^^^^^^ `Foo` 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/dyn-compatibility-err-ret.rs:8:8 - | -LL | trait Foo { - | --- this trait is not dyn compatible... -LL | fn test(&self) -> [u8; bar::<Self>()]; - | ^^^^ ^^^^^^^^^^^^^^^^^^^ ...because method `test` references the `Self` type in its return type - | | - | ...because method `test` references the `Self` type in its `where` clause - = help: consider moving `test` to another trait - = help: only type `()` implements `Foo`; consider using it directly instead. - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.rs b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.rs index a7b771cd4f8..8b735188f32 100644 --- a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.rs +++ b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.rs @@ -15,7 +15,6 @@ impl Foo for () { fn use_dyn(v: &dyn Foo) { //~^ ERROR the trait `Foo` is not dyn compatible v.test(); - //~^ ERROR the trait `Foo` is not dyn compatible } fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.stderr b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.stderr index f5eaaa37916..c2ad4d14988 100644 --- a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.stderr +++ b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.stderr @@ -15,23 +15,6 @@ LL | fn test(&self) where [u8; bar::<Self>()]: Sized; = help: consider moving `test` to another trait = help: only type `()` implements `Foo`; consider using it directly instead. -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/dyn-compatibility-err-where-bounds.rs:17:5 - | -LL | v.test(); - | ^^^^^^^^ `Foo` 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/dyn-compatibility-err-where-bounds.rs:8:8 - | -LL | trait Foo { - | --- this trait is not dyn compatible... -LL | fn test(&self) where [u8; bar::<Self>()]: Sized; - | ^^^^ ...because method `test` references the `Self` type in its `where` clause - = help: consider moving `test` to another trait - = help: only type `()` implements `Foo`; consider using it directly instead. - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/const-generics/generic_const_exprs/from-sig-fail.rs b/tests/ui/const-generics/generic_const_exprs/from-sig-fail.rs index b8f9827ec91..16753749702 100644 --- a/tests/ui/const-generics/generic_const_exprs/from-sig-fail.rs +++ b/tests/ui/const-generics/generic_const_exprs/from-sig-fail.rs @@ -2,7 +2,7 @@ #![allow(incomplete_features)] fn test<const N: usize>() -> [u8; N - 1] { - //~^ ERROR evaluation of `test::<0>::{constant#0}` failed + //~^ ERROR overflow todo!() } diff --git a/tests/ui/const-generics/generic_const_exprs/from-sig-fail.stderr b/tests/ui/const-generics/generic_const_exprs/from-sig-fail.stderr index 080e920258d..72f2dac8fa2 100644 --- a/tests/ui/const-generics/generic_const_exprs/from-sig-fail.stderr +++ b/tests/ui/const-generics/generic_const_exprs/from-sig-fail.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `test::<0>::{constant#0}` failed +error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow --> $DIR/from-sig-fail.rs:4:35 | LL | fn test<const N: usize>() -> [u8; N - 1] { - | ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow + | ^^^^^ evaluation of `test::<0>::{constant#0}` failed here error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/generic_const_exprs/serializing_error_guaranteed.rs b/tests/ui/const-generics/generic_const_exprs/serializing_error_guaranteed.rs new file mode 100644 index 00000000000..83b73350f83 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/serializing_error_guaranteed.rs @@ -0,0 +1,16 @@ +//@ check-pass + +// regression test for #136894. +// I (BoxyUwU) don't know what the underlying cause was here + +#![feature(generic_const_exprs)] +#![crate_type = "lib"] +#![allow(incomplete_features, dead_code)] + +struct X<T>([(); f::<T>()]) +where + [(); f::<T>()]:; + +const fn f<T>() -> usize { + panic!() +} diff --git a/tests/ui/const-generics/generic_const_exprs/simple_fail.rs b/tests/ui/const-generics/generic_const_exprs/simple_fail.rs index cae54df4c12..e89b5707fe2 100644 --- a/tests/ui/const-generics/generic_const_exprs/simple_fail.rs +++ b/tests/ui/const-generics/generic_const_exprs/simple_fail.rs @@ -2,12 +2,12 @@ #![allow(incomplete_features)] type Arr<const N: usize> = [u8; N - 1]; -//~^ ERROR evaluation of `Arr::<0>::{constant#0}` failed +//~^ ERROR overflow fn test<const N: usize>() -> Arr<N> where [u8; N - 1]: Sized, - //~^ ERROR evaluation of `test::<0>::{constant#0}` failed + //~^ ERROR overflow { todo!() } diff --git a/tests/ui/const-generics/generic_const_exprs/simple_fail.stderr b/tests/ui/const-generics/generic_const_exprs/simple_fail.stderr index a25fa56b7d4..94a91159e95 100644 --- a/tests/ui/const-generics/generic_const_exprs/simple_fail.stderr +++ b/tests/ui/const-generics/generic_const_exprs/simple_fail.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of `test::<0>::{constant#0}` failed +error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow --> $DIR/simple_fail.rs:9:10 | LL | [u8; N - 1]: Sized, - | ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow + | ^^^^^ evaluation of `test::<0>::{constant#0}` failed here -error[E0080]: evaluation of `Arr::<0>::{constant#0}` failed +error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow --> $DIR/simple_fail.rs:4:33 | LL | type Arr<const N: usize> = [u8; N - 1]; - | ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow + | ^^^^^ evaluation of `Arr::<0>::{constant#0}` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/issues/issue-100313.rs b/tests/ui/const-generics/issues/issue-100313.rs index 7d43d7bee34..1f61356162c 100644 --- a/tests/ui/const-generics/issues/issue-100313.rs +++ b/tests/ui/const-generics/issues/issue-100313.rs @@ -15,7 +15,7 @@ impl<const B: &'static bool> T<B> { const _: () = { let x = T::<{ &true }>; - x.set_false(); //~ ERROR evaluation of constant value failed [E0080] + x.set_false(); //~ ERROR writing to ALLOC0 which is read-only }; fn main() {} diff --git a/tests/ui/const-generics/issues/issue-100313.stderr b/tests/ui/const-generics/issues/issue-100313.stderr index 98c3ec5379b..d1a0249728e 100644 --- a/tests/ui/const-generics/issues/issue-100313.stderr +++ b/tests/ui/const-generics/issues/issue-100313.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: writing to ALLOC0 which is read-only --> $DIR/issue-100313.rs:18:5 | LL | x.set_false(); - | ^^^^^^^^^^^^^ writing to ALLOC0 which is read-only + | ^^^^^^^^^^^^^ evaluation of `_` failed inside this call | note: inside `T::<&true>::set_false` --> $DIR/issue-100313.rs:11:13 diff --git a/tests/ui/const-generics/issues/issue-71202.rs b/tests/ui/const-generics/issues/issue-71202.rs index 0f955414d84..8ff49b55e6f 100644 --- a/tests/ui/const-generics/issues/issue-71202.rs +++ b/tests/ui/const-generics/issues/issue-71202.rs @@ -25,7 +25,9 @@ impl<T: Copy> DataHolder<T> { } <IsCopy<T>>::VALUE - } as usize] = []; //~ ERROR unconstrained generic constant + } as usize] = []; + //~^ ERROR unconstrained generic constant + //~^^ ERROR mismatched types } fn main() {} diff --git a/tests/ui/const-generics/issues/issue-71202.stderr b/tests/ui/const-generics/issues/issue-71202.stderr index cc3603d1145..b7c3db494a5 100644 --- a/tests/ui/const-generics/issues/issue-71202.stderr +++ b/tests/ui/const-generics/issues/issue-71202.stderr @@ -59,5 +59,49 @@ LL + <IsCopy<T>>::VALUE LL ~ } as usize]: = []; | -error: aborting due to 2 previous errors +error[E0308]: mismatched types + --> $DIR/issue-71202.rs:28:19 + | +LL | } as usize] = []; + | ^^ expected `1 - { + trait NotCopy { + const VALUE: bool = false; + } + + impl<__Type: ?Sized> NotCopy for __Type {} + + struct IsCopy<__Type: ?Sized>(PhantomData<__Type>); + + impl<__Type> IsCopy<__Type> + where + __Type: Sized + Copy, + { + const VALUE: bool = true; + } + + <IsCopy<T>>::VALUE + } as usize`, found `0` + | + = note: expected constant `1 - { + trait NotCopy { + const VALUE: bool = false; + } + + impl<__Type: ?Sized> NotCopy for __Type {} + + struct IsCopy<__Type: ?Sized>(PhantomData<__Type>); + + impl<__Type> IsCopy<__Type> + where + __Type: Sized + Copy, + { + const VALUE: bool = true; + } + + <IsCopy<T>>::VALUE + } as usize` + found constant `0` + +error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/const-generics/issues/issue-83765.rs b/tests/ui/const-generics/issues/issue-83765.rs index 0959f771c22..f31c61408e9 100644 --- a/tests/ui/const-generics/issues/issue-83765.rs +++ b/tests/ui/const-generics/issues/issue-83765.rs @@ -3,10 +3,6 @@ trait TensorDimension { const DIM: usize; - //~^ ERROR cycle detected when resolving instance - //~| ERROR cycle detected when resolving instance - // FIXME Given the current state of the compiler its expected that we cycle here, - // but the cycle is still wrong. const ISSCALAR: bool = Self::DIM == 0; fn is_scalar(&self) -> bool { Self::ISSCALAR @@ -49,6 +45,7 @@ impl<'a, T: Broadcastable, const DIM: usize> TensorDimension for LazyUpdim<'a, T impl<'a, T: Broadcastable, const DIM: usize> TensorSize for LazyUpdim<'a, T, { T::DIM }, DIM> { fn size(&self) -> [usize; DIM] { + //~^ ERROR: method not compatible with trait self.size } } @@ -56,12 +53,17 @@ impl<'a, T: Broadcastable, const DIM: usize> TensorSize for LazyUpdim<'a, T, { T impl<'a, T: Broadcastable, const DIM: usize> Broadcastable for LazyUpdim<'a, T, { T::DIM }, DIM> { type Element = T::Element; fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> { + //~^ ERROR: method not compatible with trait assert!(DIM >= T::DIM); if !self.inbounds(index) { + //~^ ERROR: unconstrained generic constant + //~| ERROR: mismatched types return None; } let size = self.size(); + //~^ ERROR: unconstrained generic constant let newindex: [usize; T::DIM] = Default::default(); + //~^ ERROR: the trait bound self.reference.bget(newindex) } } @@ -82,6 +84,8 @@ impl<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> TensorSi fn size(&self) -> [usize; DIM] { //~^ ERROR: method not compatible with trait self.reference.size() + //~^ ERROR: unconstrained generic constant + //~| ERROR: mismatched types } } @@ -92,6 +96,8 @@ impl<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> Broadcas fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> { //~^ ERROR: method not compatible with trait self.reference.bget(index).map(&self.closure) + //~^ ERROR: unconstrained generic constant + //~| ERROR: mismatched types } } @@ -100,12 +106,14 @@ impl<T> TensorDimension for Vec<T> { } impl<T> TensorSize for Vec<T> { fn size(&self) -> [usize; 1] { + //~^ ERROR: method not compatible with trait [self.len()] } } impl<T: Clone> Broadcastable for Vec<T> { type Element = T; fn bget(&self, index: [usize; 1]) -> Option<T> { + //~^ ERROR: method not compatible with trait self.get(index[0]).cloned() } } diff --git a/tests/ui/const-generics/issues/issue-83765.stderr b/tests/ui/const-generics/issues/issue-83765.stderr index 6b62012c14f..5a06ee7ddbc 100644 --- a/tests/ui/const-generics/issues/issue-83765.stderr +++ b/tests/ui/const-generics/issues/issue-83765.stderr @@ -1,43 +1,23 @@ -error[E0391]: cycle detected when resolving instance `<LazyUpdim<'_, T, <T as TensorDimension>::DIM, DIM> as TensorDimension>::DIM` - --> $DIR/issue-83765.rs:5:5 - | -LL | const DIM: usize; - | ^^^^^^^^^^^^^^^^ - | -note: ...which requires computing candidate for `<LazyUpdim<'_, T, <T as TensorDimension>::DIM, DIM> as TensorDimension>`... - --> $DIR/issue-83765.rs:4:1 - | -LL | trait TensorDimension { - | ^^^^^^^^^^^^^^^^^^^^^ - = note: ...which again requires resolving instance `<LazyUpdim<'_, T, <T as TensorDimension>::DIM, DIM> as TensorDimension>::DIM`, completing the cycle -note: cycle used when checking assoc item `<impl at $DIR/issue-83765.rs:50:1: 50:94>::size` is compatible with trait definition - --> $DIR/issue-83765.rs:51:5 +error[E0308]: method not compatible with trait + --> $DIR/issue-83765.rs:47:5 | LL | fn size(&self) -> [usize; DIM] { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = 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[E0391]: cycle detected when resolving instance `<LazyUpdim<'_, T, <T as TensorDimension>::DIM, DIM> as TensorDimension>::DIM` - --> $DIR/issue-83765.rs:5:5 - | -LL | const DIM: usize; - | ^^^^^^^^^^^^^^^^ - | -note: ...which requires computing candidate for `<LazyUpdim<'_, T, <T as TensorDimension>::DIM, DIM> as TensorDimension>`... - --> $DIR/issue-83765.rs:4:1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `DIM` | -LL | trait TensorDimension { - | ^^^^^^^^^^^^^^^^^^^^^ - = note: ...which again requires resolving instance `<LazyUpdim<'_, T, <T as TensorDimension>::DIM, DIM> as TensorDimension>::DIM`, completing the cycle -note: cycle used when checking assoc item `<impl at $DIR/issue-83765.rs:56:1: 56:97>::bget` is compatible with trait definition - --> $DIR/issue-83765.rs:58:5 + = note: expected constant `Self::DIM` + found constant `DIM` + +error[E0308]: method not compatible with trait + --> $DIR/issue-83765.rs:55:5 | LL | fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `DIM` + | + = note: expected constant `Self::DIM` + found constant `DIM` error[E0308]: method not compatible with trait - --> $DIR/issue-83765.rs:82:5 + --> $DIR/issue-83765.rs:84:5 | LL | fn size(&self) -> [usize; DIM] { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `DIM` @@ -46,7 +26,7 @@ LL | fn size(&self) -> [usize; DIM] { found constant `DIM` error[E0308]: method not compatible with trait - --> $DIR/issue-83765.rs:92:5 + --> $DIR/issue-83765.rs:96:5 | LL | fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `DIM` @@ -54,7 +34,127 @@ LL | fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> { = note: expected constant `Self::DIM` found constant `DIM` -error: aborting due to 4 previous errors +error[E0308]: method not compatible with trait + --> $DIR/issue-83765.rs:108:5 + | +LL | fn size(&self) -> [usize; 1] { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `1` + | + = note: expected constant `Self::DIM` + found constant `1` + +error[E0308]: method not compatible with trait + --> $DIR/issue-83765.rs:115:5 + | +LL | fn bget(&self, index: [usize; 1]) -> Option<T> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `1` + | + = note: expected constant `Self::DIM` + found constant `1` + +error: unconstrained generic constant + --> $DIR/issue-83765.rs:58:13 + | +LL | if !self.inbounds(index) { + | ^^^^ + | +note: required by a bound in `TensorSize::inbounds` + --> $DIR/issue-83765.rs:14:39 + | +LL | fn inbounds(&self, index: [usize; Self::DIM]) -> bool { + | ^^^^^^^^^ required by this bound in `TensorSize::inbounds` +help: try adding a `where` bound + | +LL | fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> where [(); Self::DIM]: { + | ++++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/issue-83765.rs:58:27 + | +LL | if !self.inbounds(index) { + | ^^^^^ expected `Self::DIM`, found `DIM` + | + = note: expected constant `Self::DIM` + found constant `DIM` + +error: unconstrained generic constant + --> $DIR/issue-83765.rs:63:25 + | +LL | let size = self.size(); + | ^^^^ + | +note: required by a bound in `TensorSize::size` + --> $DIR/issue-83765.rs:13:31 + | +LL | fn size(&self) -> [usize; Self::DIM]; + | ^^^^^^^^^ required by this bound in `TensorSize::size` +help: try adding a `where` bound + | +LL | fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> where [(); Self::DIM]: { + | ++++++++++++++++++++++ + +error[E0277]: the trait bound `[usize; T::DIM]: Default` is not satisfied + --> $DIR/issue-83765.rs:65:41 + | +LL | let newindex: [usize; T::DIM] = Default::default(); + | ^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `[usize; T::DIM]` + | +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement + | +LL | impl<'a, T: Broadcastable, const DIM: usize> Broadcastable for LazyUpdim<'a, T, { T::DIM }, DIM> where [usize; T::DIM]: Default { + | ++++++++++++++++++++++++++++++ + +error: unconstrained generic constant + --> $DIR/issue-83765.rs:86:24 + | +LL | self.reference.size() + | ^^^^ + | +note: required by a bound in `TensorSize::size` + --> $DIR/issue-83765.rs:13:31 + | +LL | fn size(&self) -> [usize; Self::DIM]; + | ^^^^^^^^^ required by this bound in `TensorSize::size` +help: try adding a `where` bound + | +LL | fn size(&self) -> [usize; DIM] where [(); Self::DIM]: { + | ++++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/issue-83765.rs:86:9 + | +LL | self.reference.size() + | ^^^^^^^^^^^^^^^^^^^^^ expected `DIM`, found `Self::DIM` + | + = note: expected constant `DIM` + found constant `Self::DIM` + +error: unconstrained generic constant + --> $DIR/issue-83765.rs:98:9 + | +LL | self.reference.bget(index).map(&self.closure) + | ^^^^^^^^^^^^^^ + | +note: required by a bound in `Broadcastable::bget` + --> $DIR/issue-83765.rs:21:35 + | +LL | fn bget(&self, index: [usize; Self::DIM]) -> Option<Self::Element>; + | ^^^^^^^^^ required by this bound in `Broadcastable::bget` +help: try adding a `where` bound + | +LL | fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> where [(); Self::DIM]: { + | ++++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/issue-83765.rs:98:29 + | +LL | self.reference.bget(index).map(&self.closure) + | ^^^^^ expected `Self::DIM`, found `DIM` + | + = note: expected constant `Self::DIM` + found constant `DIM` + +error: aborting due to 14 previous errors -Some errors have detailed explanations: E0308, E0391. -For more information about an error, try `rustc --explain E0308`. +Some errors have detailed explanations: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/const-generics/kind_mismatch.stderr b/tests/ui/const-generics/kind_mismatch.stderr index 1487b189619..12a2ab141a6 100644 --- a/tests/ui/const-generics/kind_mismatch.stderr +++ b/tests/ui/const-generics/kind_mismatch.stderr @@ -2,17 +2,25 @@ error[E0747]: type provided when a constant was expected --> $DIR/kind_mismatch.rs:11:38 | LL | impl<K> ContainsKey<K> for KeyHolder<K> {} - | - ^ - | | - | help: consider changing this type parameter to a const parameter: `const K: u8` + | ^ + | +help: consider changing this type parameter to a const parameter + | +LL - impl<K> ContainsKey<K> for KeyHolder<K> {} +LL + impl<const K: u8> ContainsKey<K> for KeyHolder<K> {} + | error[E0747]: type provided when a constant was expected --> $DIR/kind_mismatch.rs:11:21 | LL | impl<K> ContainsKey<K> for KeyHolder<K> {} - | - ^ - | | - | help: consider changing this type parameter to a const parameter: `const K: u8` + | ^ + | +help: consider changing this type parameter to a const parameter + | +LL - impl<K> ContainsKey<K> for KeyHolder<K> {} +LL + impl<const K: u8> ContainsKey<K> for KeyHolder<K> {} + | error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/mgca/projection-error.rs b/tests/ui/const-generics/mgca/projection-error.rs new file mode 100644 index 00000000000..d1c4fa8a492 --- /dev/null +++ b/tests/ui/const-generics/mgca/projection-error.rs @@ -0,0 +1,17 @@ +#![feature(min_generic_const_args)] +#![expect(incomplete_features)] + +// Regression test for #140642. Test that normalizing const aliases +// containing erroneous types normalizes to a const error instead of +// a type error. + + +pub trait Tr<A> { + const SIZE: usize; +} + +fn mk_array(_x: T) -> [(); <T as Tr<bool>>::SIZE] {} +//~^ ERROR: cannot find type `T` in this scope +//~| ERROR: cannot find type `T` in this scope + +fn main() {} diff --git a/tests/ui/const-generics/mgca/projection-error.stderr b/tests/ui/const-generics/mgca/projection-error.stderr new file mode 100644 index 00000000000..e6888351da1 --- /dev/null +++ b/tests/ui/const-generics/mgca/projection-error.stderr @@ -0,0 +1,39 @@ +error[E0412]: cannot find type `T` in this scope + --> $DIR/projection-error.rs:13:17 + | +LL | pub trait Tr<A> { + | --------------- similarly named trait `Tr` defined here +... +LL | fn mk_array(_x: T) -> [(); <T as Tr<bool>>::SIZE] {} + | ^ + | +help: a trait with a similar name exists + | +LL | fn mk_array(_x: Tr) -> [(); <T as Tr<bool>>::SIZE] {} + | + +help: you might be missing a type parameter + | +LL | fn mk_array<T>(_x: T) -> [(); <T as Tr<bool>>::SIZE] {} + | +++ + +error[E0412]: cannot find type `T` in this scope + --> $DIR/projection-error.rs:13:29 + | +LL | pub trait Tr<A> { + | --------------- similarly named trait `Tr` defined here +... +LL | fn mk_array(_x: T) -> [(); <T as Tr<bool>>::SIZE] {} + | ^ + | +help: a trait with a similar name exists + | +LL | fn mk_array(_x: T) -> [(); <Tr as Tr<bool>>::SIZE] {} + | + +help: you might be missing a type parameter + | +LL | fn mk_array<T>(_x: T) -> [(); <T as Tr<bool>>::SIZE] {} + | +++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0412`. 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 d1f3b08dd36..92b226fe0f7 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,36 +1,36 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/invalid-patterns.rs:40:32 | LL | get_flag::<false, { unsafe { char_raw.character } }>(); - | ^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^ evaluation of `main::{constant#7}` failed here -error[E0080]: it is undefined behavior to use this value - --> $DIR/invalid-patterns.rs:43:14 +error[E0080]: constructing invalid value: encountered 0x42, but expected a boolean + --> $DIR/invalid-patterns.rs:42:14 | LL | get_flag::<{ unsafe { bool_raw.boolean } }, 'z'>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x42, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 42 │ B } -error[E0080]: it is undefined behavior to use this value - --> $DIR/invalid-patterns.rs:45:14 +error[E0080]: constructing invalid value: encountered 0x42, but expected a boolean + --> $DIR/invalid-patterns.rs:44:14 | LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x42, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 42 │ B } -error[E0080]: evaluation of constant value failed - --> $DIR/invalid-patterns.rs:45:58 +error[E0080]: using uninitialized data, but this operation requires initialized memory + --> $DIR/invalid-patterns.rs:44:58 | LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); - | ^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^ evaluation of `main::{constant#11}` failed here error[E0308]: mismatched types --> $DIR/invalid-patterns.rs:31:21 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 d1f3b08dd36..92b226fe0f7 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,36 +1,36 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/invalid-patterns.rs:40:32 | LL | get_flag::<false, { unsafe { char_raw.character } }>(); - | ^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^ evaluation of `main::{constant#7}` failed here -error[E0080]: it is undefined behavior to use this value - --> $DIR/invalid-patterns.rs:43:14 +error[E0080]: constructing invalid value: encountered 0x42, but expected a boolean + --> $DIR/invalid-patterns.rs:42:14 | LL | get_flag::<{ unsafe { bool_raw.boolean } }, 'z'>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x42, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 42 │ B } -error[E0080]: it is undefined behavior to use this value - --> $DIR/invalid-patterns.rs:45:14 +error[E0080]: constructing invalid value: encountered 0x42, but expected a boolean + --> $DIR/invalid-patterns.rs:44:14 | LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x42, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 42 │ B } -error[E0080]: evaluation of constant value failed - --> $DIR/invalid-patterns.rs:45:58 +error[E0080]: using uninitialized data, but this operation requires initialized memory + --> $DIR/invalid-patterns.rs:44:58 | LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); - | ^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^ evaluation of `main::{constant#11}` failed here error[E0308]: mismatched types --> $DIR/invalid-patterns.rs:31:21 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 10b0d742a0a..85f019adf66 100644 --- a/tests/ui/const-generics/min_const_generics/invalid-patterns.rs +++ b/tests/ui/const-generics/min_const_generics/invalid-patterns.rs @@ -38,12 +38,10 @@ fn main() { get_flag::<false, { unsafe { char_raw.character } }>(); - //~^ ERROR evaluation of constant value failed - //~| NOTE uninitialized + //~^ ERROR uninitialized get_flag::<{ unsafe { bool_raw.boolean } }, 'z'>(); - //~^ ERROR it is undefined behavior + //~^ ERROR 0x42, but expected a boolean get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); - //~^ ERROR evaluation of constant value failed - //~| NOTE uninitialized - //~| ERROR it is undefined behavior + //~^ ERROR uninitialized + //~| ERROR 0x42, but expected a boolean } diff --git a/tests/ui/const-generics/type-dependent/issue-71348.full.stderr b/tests/ui/const-generics/type-dependent/issue-71348.full.stderr index 177ff20fbf9..f68fdb3b651 100644 --- a/tests/ui/const-generics/type-dependent/issue-71348.full.stderr +++ b/tests/ui/const-generics/type-dependent/issue-71348.full.stderr @@ -1,10 +1,17 @@ -warning: elided lifetime has a name - --> $DIR/issue-71348.rs:18:68 +warning: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/issue-71348.rs:18:40 | LL | fn ask<'a, const N: &'static str>(&'a self) -> &'a <Self as Get<N>>::Target - | -- lifetime `'a` declared here ^ this elided lifetime gets resolved as `'a` + | ^^ -- ------------------------ the lifetimes get resolved as `'a` + | | | + | | the lifetimes get resolved as `'a` + | this lifetime flows to the output | - = note: `#[warn(elided_named_lifetimes)]` on by default + = note: `#[warn(mismatched_lifetime_syntaxes)]` on by default +help: one option is to consistently use `'a` + | +LL | fn ask<'a, const N: &'static str>(&'a self) -> &'a <Self as Get<'a, N>>::Target + | +++ warning: 1 warning emitted diff --git a/tests/ui/const-generics/type-dependent/issue-71348.min.stderr b/tests/ui/const-generics/type-dependent/issue-71348.min.stderr index 8995c415863..c491469bcbd 100644 --- a/tests/ui/const-generics/type-dependent/issue-71348.min.stderr +++ b/tests/ui/const-generics/type-dependent/issue-71348.min.stderr @@ -1,11 +1,3 @@ -warning: elided lifetime has a name - --> $DIR/issue-71348.rs:18:68 - | -LL | fn ask<'a, const N: &'static str>(&'a self) -> &'a <Self as Get<N>>::Target - | -- lifetime `'a` declared here ^ this elided lifetime gets resolved as `'a` - | - = note: `#[warn(elided_named_lifetimes)]` on by default - error: `&'static str` is forbidden as the type of a const generic parameter --> $DIR/issue-71348.rs:10:24 | @@ -38,5 +30,5 @@ help: add `#![feature(unsized_const_params)]` to the crate attributes to enable LL + #![feature(unsized_const_params)] | -error: aborting due to 2 previous errors; 1 warning emitted +error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/type-dependent/issue-71348.rs b/tests/ui/const-generics/type-dependent/issue-71348.rs index 97e786405fe..c6563c80305 100644 --- a/tests/ui/const-generics/type-dependent/issue-71348.rs +++ b/tests/ui/const-generics/type-dependent/issue-71348.rs @@ -17,7 +17,7 @@ trait Get<'a, const N: &'static str> { impl Foo { fn ask<'a, const N: &'static str>(&'a self) -> &'a <Self as Get<N>>::Target //[min]~^ ERROR `&'static str` is forbidden as the type of a const generic parameter - //~^^ WARNING elided lifetime has a name + //[full]~^^ WARNING lifetime flowing from input to output with different syntax where Self: Get<'a, N>, { diff --git a/tests/ui/const-ptr/allowed_slices.rs b/tests/ui/const-ptr/allowed_slices.rs index e5b9966c609..23f63ff5feb 100644 --- a/tests/ui/const-ptr/allowed_slices.rs +++ b/tests/ui/const-ptr/allowed_slices.rs @@ -26,7 +26,7 @@ pub static S5: &[MaybeUninit<u8>] = unsafe { from_raw_parts((&D1) as *const _ as // is valid as [bool; 4], so this is not UB (it's basically a transmute) pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; -// Structs are considered single allocated objects, +// Structs are considered single allocations, // as long as you don't reinterpret padding as initialized // data everything is ok. pub static S7: &[u16] = unsafe { diff --git a/tests/ui/const-ptr/forbidden_slices.rs b/tests/ui/const-ptr/forbidden_slices.rs index 001cfd66ad1..fcb0dccf750 100644 --- a/tests/ui/const-ptr/forbidden_slices.rs +++ b/tests/ui/const-ptr/forbidden_slices.rs @@ -14,24 +14,24 @@ use std::{ // Null is never valid for references pub static S0: &[u32] = unsafe { from_raw_parts(ptr::null(), 0) }; -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: null reference pub static S1: &[()] = unsafe { from_raw_parts(ptr::null(), 0) }; -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: null reference // Out of bounds pub static S2: &[u32] = unsafe { from_raw_parts(&D0, 2) }; -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: dangling reference (going beyond the bounds of its allocation) // Reading uninitialized data -pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; //~ ERROR: it is undefined behavior to use this value +pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; //~ ERROR: uninitialized memory // Reinterpret pointers as integers (UB in CTFE.) -pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size_of::<&u32>()) }; //~ ERROR: it is undefined behavior to use this value +pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size_of::<&u32>()) }; //~ ERROR: pointer, but expected an integer // Layout mismatch -pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; //~ ERROR: it is undefined behavior to use this value +pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; //~ ERROR: 0x11, but expected a boolean // Reading padding is not ok pub static S7: &[u16] = unsafe { - //~^ ERROR: it is undefined behavior to use this value + //~^ ERROR: uninitialized memory let ptr = (&D2 as *const Struct as *const u16).add(1); from_raw_parts(ptr, 4) @@ -39,53 +39,53 @@ pub static S7: &[u16] = unsafe { // Unaligned read pub static S8: &[u64] = unsafe { - //~^ ERROR: it is undefined behavior to use this value + //~^ ERROR: dangling reference (going beyond the bounds of its allocation) let ptr = (&D4 as *const [u32; 2] as *const u32).byte_add(1).cast::<u64>(); from_raw_parts(ptr, 1) }; pub static R0: &[u32] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR encountered a null reference pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; // errors inside libcore -//~^ ERROR could not evaluate static initializer +//~^ ERROR 0 < pointee_size && pointee_size <= isize::MAX as usize pub static R2: &[u32] = unsafe { let ptr = &D0 as *const u32; from_ptr_range(ptr..ptr.add(2)) // errors inside libcore - //~^ ERROR could not evaluate static initializer + //~^ ERROR in-bounds pointer arithmetic failed }; pub static R4: &[u8] = unsafe { - //~^ ERROR: it is undefined behavior to use this value + //~^ ERROR: encountered uninitialized memory, but expected an integer let ptr = (&D1) as *const MaybeUninit<&u32> as *const u8; from_ptr_range(ptr..ptr.add(1)) }; pub static R5: &[u8] = unsafe { - //~^ ERROR: it is undefined behavior to use this value + //~^ ERROR: encountered a pointer, but expected an integer let ptr = &D3 as *const &u32; from_ptr_range(ptr.cast()..ptr.add(1).cast()) }; pub static R6: &[bool] = unsafe { - //~^ ERROR: it is undefined behavior to use this value + //~^ ERROR: 0x11, but expected a boolean let ptr = &D0 as *const u32 as *const bool; from_ptr_range(ptr..ptr.add(4)) }; pub static R7: &[u16] = unsafe { - //~^ ERROR: it is undefined behavior to use this value + //~^ ERROR: unaligned reference (required 2 byte alignment but found 1) let ptr = (&D2 as *const Struct as *const u16).byte_add(1); from_ptr_range(ptr..ptr.add(4)) }; pub static R8: &[u64] = unsafe { let ptr = (&D4 as *const [u32; 2] as *const u32).byte_add(1).cast::<u64>(); from_ptr_range(ptr..ptr.add(1)) - //~^ ERROR could not evaluate static initializer + //~^ ERROR in-bounds pointer arithmetic failed }; // This is sneaky: &D0 and &D0 point to different objects // (even if at runtime they have the same address) pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) }; -//~^ ERROR could not evaluate static initializer +//~^ ERROR not both derived from the same allocation pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) }; -//~^ ERROR could not evaluate static initializer +//~^ ERROR not both derived from the same allocation const D0: u32 = 0x11111111; // Constant chosen for endianness-independent behavior. const D1: MaybeUninit<&u32> = MaybeUninit::uninit(); diff --git a/tests/ui/const-ptr/forbidden_slices.stderr b/tests/ui/const-ptr/forbidden_slices.stderr index c73d2ca938c..25d6f0461a9 100644 --- a/tests/ui/const-ptr/forbidden_slices.stderr +++ b/tests/ui/const-ptr/forbidden_slices.stderr @@ -1,200 +1,179 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered a null reference --> $DIR/forbidden_slices.rs:16:1 | LL | pub static S0: &[u32] = unsafe { from_raw_parts(ptr::null(), 0) }; - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered a null reference --> $DIR/forbidden_slices.rs:18:1 | LL | pub static S1: &[()] = unsafe { from_raw_parts(ptr::null(), 0) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) --> $DIR/forbidden_slices.rs:22:1 | LL | pub static S2: &[u32] = unsafe { from_raw_parts(&D0, 2) }; - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer --> $DIR/forbidden_slices.rs:26: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 + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer --> $DIR/forbidden_slices.rs:28:1 | LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size_of::<&u32>()) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = 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 +error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean --> $DIR/forbidden_slices.rs:30: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 + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>[1]: encountered uninitialized memory, but expected an integer --> $DIR/forbidden_slices.rs:33:1 | LL | pub static S7: &[u16] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[1]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) --> $DIR/forbidden_slices.rs:41:1 | LL | pub static S8: &[u64] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered a null reference --> $DIR/forbidden_slices.rs:48:1 | LL | pub static R0: &[u32] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: could not evaluate static initializer +error[E0080]: evaluation panicked: assertion failed: 0 < pointee_size && pointee_size <= isize::MAX as usize --> $DIR/forbidden_slices.rs:50:33 | LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; // errors inside libcore - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: assertion failed: 0 < pointee_size && pointee_size <= isize::MAX as usize - | -note: inside `from_ptr_range::<'_, ()>` - --> $SRC_DIR/core/src/slice/raw.rs:LL:COL -note: inside `std::ptr::const_ptr::<impl *const ()>::offset_from_unsigned` - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `R1` failed here -error[E0080]: could not evaluate static initializer +error[E0080]: 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 --> $DIR/forbidden_slices.rs:54:25 | LL | from_ptr_range(ptr..ptr.add(2)) // errors inside libcore - | ^^^^^^^^^^ 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 + | ^^^^^^^^^^ evaluation of `R2` failed here -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer --> $DIR/forbidden_slices.rs:57:1 | LL | pub static R4: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer --> $DIR/forbidden_slices.rs:62:1 | LL | pub static R5: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = 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 +error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean --> $DIR/forbidden_slices.rs:67:1 | LL | pub static R6: &[bool] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) --> $DIR/forbidden_slices.rs:72:1 | LL | pub static R7: &[u16] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: could not evaluate static initializer +error[E0080]: 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 --> $DIR/forbidden_slices.rs:79:25 | LL | from_ptr_range(ptr..ptr.add(1)) - | ^^^^^^^^^^ 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 + | ^^^^^^^^^^ evaluation of `R8` failed here -error[E0080]: could not evaluate static initializer +error[E0080]: `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation --> $DIR/forbidden_slices.rs:85:34 | LL | pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation - | -note: inside `from_ptr_range::<'_, u32>` - --> $SRC_DIR/core/src/slice/raw.rs:LL:COL -note: inside `std::ptr::const_ptr::<impl *const u32>::offset_from_unsigned` - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `R9` failed here -error[E0080]: could not evaluate static initializer +error[E0080]: `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation --> $DIR/forbidden_slices.rs:87:35 | LL | pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation - | -note: inside `from_ptr_range::<'_, u32>` - --> $SRC_DIR/core/src/slice/raw.rs:LL:COL -note: inside `std::ptr::const_ptr::<impl *const u32>::offset_from_unsigned` - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `R10` failed here error: aborting due to 18 previous errors diff --git a/tests/ui/const-ptr/out_of_bounds_read.rs b/tests/ui/const-ptr/out_of_bounds_read.rs index ccf45bf324a..b09978badde 100644 --- a/tests/ui/const-ptr/out_of_bounds_read.rs +++ b/tests/ui/const-ptr/out_of_bounds_read.rs @@ -6,9 +6,9 @@ fn main() { const PAST_END_PTR: *const u32 = unsafe { DATA.as_ptr().add(1) }; const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR at or beyond the end of the allocation const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR at or beyond the end of the allocation const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR at or beyond the end of the allocation } diff --git a/tests/ui/const-ptr/out_of_bounds_read.stderr b/tests/ui/const-ptr/out_of_bounds_read.stderr index 1d625a26b78..a98765b15f2 100644 --- a/tests/ui/const-ptr/out_of_bounds_read.stderr +++ b/tests/ui/const-ptr/out_of_bounds_read.stderr @@ -1,33 +1,20 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: 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 --> $DIR/out_of_bounds_read.rs:8:33 | LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ 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 + | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::_READ` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: 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 --> $DIR/out_of_bounds_read.rs:10:39 | LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() }; - | ^^^^^^^^^^^^^^^^^^^ 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 -note: inside `std::ptr::read::<u32>` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^ evaluation of `main::_CONST_READ` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: 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 --> $DIR/out_of_bounds_read.rs:12:37 | LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 -note: inside `std::ptr::read::<u32>` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::_MUT_READ` failed here error: aborting due to 3 previous errors diff --git a/tests/ui/constructor-lifetime-args.rs b/tests/ui/constructor-lifetime-args.rs deleted file mode 100644 index f5802e7d8b1..00000000000 --- a/tests/ui/constructor-lifetime-args.rs +++ /dev/null @@ -1,26 +0,0 @@ -// All lifetime parameters in struct constructors are currently considered early bound, -// i.e., `S::<ARGS>` is interpreted kinda like an associated item `S::<ARGS>::ctor`. -// This behavior is a bit weird, because if equivalent constructor were written manually -// it would get late bound lifetime parameters. -// Variant constructors behave in the same way, lifetime parameters are considered -// belonging to the enum and being early bound. -// https://github.com/rust-lang/rust/issues/30904 - -struct S<'a, 'b>(&'a u8, &'b u8); -enum E<'a, 'b> { - V(&'a u8), - U(&'b u8), -} - -fn main() { - S(&0, &0); // OK - S::<'static>(&0, &0); - //~^ ERROR struct takes 2 lifetime arguments - S::<'static, 'static, 'static>(&0, &0); - //~^ ERROR struct takes 2 lifetime arguments - E::V(&0); // OK - E::V::<'static>(&0); - //~^ ERROR enum takes 2 lifetime arguments - E::V::<'static, 'static, 'static>(&0); - //~^ ERROR enum takes 2 lifetime arguments -} diff --git a/tests/ui/consts/assert-type-intrinsics.rs b/tests/ui/consts/assert-type-intrinsics.rs index 32b5f5c92c5..91c8dd00e89 100644 --- a/tests/ui/consts/assert-type-intrinsics.rs +++ b/tests/ui/consts/assert-type-intrinsics.rs @@ -9,14 +9,14 @@ fn main() { const _BAD1: () = unsafe { MaybeUninit::<!>::uninit().assume_init(); - //~^ERROR: evaluation of constant value failed + //~^ERROR: uninhabited }; const _BAD2: () = { intrinsics::assert_mem_uninitialized_valid::<&'static i32>(); - //~^ERROR: evaluation of constant value failed + //~^ERROR: uninitialized }; const _BAD3: () = { intrinsics::assert_zero_valid::<&'static i32>(); - //~^ERROR: evaluation of constant value failed + //~^ERROR: zero-initialize type `&i32` }; } diff --git a/tests/ui/consts/assert-type-intrinsics.stderr b/tests/ui/consts/assert-type-intrinsics.stderr index 92c0610a248..92fc90aebe4 100644 --- a/tests/ui/consts/assert-type-intrinsics.stderr +++ b/tests/ui/consts/assert-type-intrinsics.stderr @@ -1,20 +1,20 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: aborted execution: attempted to instantiate uninhabited type `!` --> $DIR/assert-type-intrinsics.rs:11:9 | LL | MaybeUninit::<!>::uninit().assume_init(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: aborted execution: attempted to instantiate uninhabited type `!` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::_BAD1` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: aborted execution: attempted to leave type `&i32` uninitialized, which is invalid --> $DIR/assert-type-intrinsics.rs:15:9 | LL | intrinsics::assert_mem_uninitialized_valid::<&'static i32>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: aborted execution: attempted to leave type `&i32` uninitialized, which is invalid + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::_BAD2` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: aborted execution: attempted to zero-initialize type `&i32`, which is invalid --> $DIR/assert-type-intrinsics.rs:19:9 | LL | intrinsics::assert_zero_valid::<&'static i32>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: aborted execution: attempted to zero-initialize type `&i32`, which is invalid + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::_BAD3` failed here error: aborting due to 3 previous errors diff --git a/tests/ui/consts/assoc_const_generic_impl.rs b/tests/ui/consts/assoc_const_generic_impl.rs index 5820a724d07..a4904795254 100644 --- a/tests/ui/consts/assoc_const_generic_impl.rs +++ b/tests/ui/consts/assoc_const_generic_impl.rs @@ -6,7 +6,7 @@ trait ZeroSized: Sized { } impl<T: Sized> ZeroSized for T { - const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::<Self>()]; //~ ERROR evaluation of `<u32 as ZeroSized>::I_AM_ZERO_SIZED` failed + const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::<Self>()]; //~ ERROR index out of bounds: the length is 1 but the index is 4 fn requires_zero_size(self) { Self::I_AM_ZERO_SIZED; println!("requires_zero_size called"); diff --git a/tests/ui/consts/assoc_const_generic_impl.stderr b/tests/ui/consts/assoc_const_generic_impl.stderr index 45219508396..fc8986a34c5 100644 --- a/tests/ui/consts/assoc_const_generic_impl.stderr +++ b/tests/ui/consts/assoc_const_generic_impl.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `<u32 as ZeroSized>::I_AM_ZERO_SIZED` failed - --> $DIR/assoc_const_generic_impl.rs:9:34 +error[E0080]: index out of bounds: the length is 1 but the index is 4 + --> $DIR/assoc_const_generic_impl.rs:9:33 | -LL | const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::<Self>()]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 4 +LL | const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::<Self>()]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `<u32 as ZeroSized>::I_AM_ZERO_SIZED` failed here note: erroneous constant encountered --> $DIR/assoc_const_generic_impl.rs:11:9 diff --git a/tests/ui/consts/const-array-oob.rs b/tests/ui/consts/const-array-oob.rs index 4b457d1c23c..dc713b74d7f 100644 --- a/tests/ui/consts/const-array-oob.rs +++ b/tests/ui/consts/const-array-oob.rs @@ -1,11 +1,9 @@ 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 +//~^ ERROR: 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] -//~| NOTE index out of bounds: the length is 3 but the index is 4 +//~^ ERROR 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 89427c051e7..7d5f23473c1 100644 --- a/tests/ui/consts/const-array-oob.stderr +++ b/tests/ui/consts/const-array-oob.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/const-array-oob.rs:6:19 +error[E0080]: index out of bounds: the length is 3 but the index is 4 + --> $DIR/const-array-oob.rs:5:19 | LL | const BLUB: [u32; FOO[4]] = [5, 6]; - | ^^^^^^ index out of bounds: the length is 3 but the index is 4 + | ^^^^^^ evaluation of `BLUB::{constant#0}` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: index out of bounds: the length is 3 but the index is 5 --> $DIR/const-array-oob.rs:2:20 | LL | const BAR: usize = FOO[5]; - | ^^^^^^ index out of bounds: the length is 3 but the index is 5 + | ^^^^^^ evaluation of `BAR` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-assert-unchecked-ub.rs b/tests/ui/consts/const-assert-unchecked-ub.rs index ffc02eedcb7..a62abcf12d6 100644 --- a/tests/ui/consts/const-assert-unchecked-ub.rs +++ b/tests/ui/consts/const-assert-unchecked-ub.rs @@ -1,6 +1,6 @@ const _: () = unsafe { let n = u32::MAX.count_ones(); - std::hint::assert_unchecked(n < 32); //~ ERROR evaluation of constant value failed + std::hint::assert_unchecked(n < 32); //~ ERROR `assume` called with `false` }; fn main() {} diff --git a/tests/ui/consts/const-assert-unchecked-ub.stderr b/tests/ui/consts/const-assert-unchecked-ub.stderr index 468f15f3472..d8e68fc9bee 100644 --- a/tests/ui/consts/const-assert-unchecked-ub.stderr +++ b/tests/ui/consts/const-assert-unchecked-ub.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: `assume` called with `false` --> $DIR/const-assert-unchecked-ub.rs:3:5 | LL | std::hint::assert_unchecked(n < 32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `assume` called with `false` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-blocks/fn-call-in-non-const.stderr b/tests/ui/consts/const-blocks/fn-call-in-non-const.stderr index a3d5054ced3..54982391b66 100644 --- a/tests/ui/consts/const-blocks/fn-call-in-non-const.stderr +++ b/tests/ui/consts/const-blocks/fn-call-in-non-const.stderr @@ -13,9 +13,8 @@ LL | struct Bar; | help: create an inline `const` block | -LL - let _: [Option<Bar>; 2] = [no_copy(); 2]; -LL + let _: [Option<Bar>; 2] = [const { no_copy() }; 2]; - | +LL | let _: [Option<Bar>; 2] = [const { no_copy() }; 2]; + | +++++++ + error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-blocks/migrate-fail.rs b/tests/ui/consts/const-blocks/migrate-fail.rs index fddbfbb9d32..e7dbb68d920 100644 --- a/tests/ui/consts/const-blocks/migrate-fail.rs +++ b/tests/ui/consts/const-blocks/migrate-fail.rs @@ -4,7 +4,7 @@ struct Bar; mod non_constants { - use Bar; + use crate::Bar; fn no_impl_copy_empty_value_multiple_elements() { let x = None; diff --git a/tests/ui/consts/const-blocks/migrate-pass.rs b/tests/ui/consts/const-blocks/migrate-pass.rs index 308834bd646..629d4db0dc6 100644 --- a/tests/ui/consts/const-blocks/migrate-pass.rs +++ b/tests/ui/consts/const-blocks/migrate-pass.rs @@ -5,7 +5,7 @@ struct Bar; mod constants { - use Bar; + use crate::Bar; fn no_impl_copy_empty_value_no_elements() { const FOO: Option<Bar> = None; @@ -69,7 +69,7 @@ mod constants { } mod non_constants { - use Bar; + use crate::Bar; fn no_impl_copy_empty_value_no_elements() { let x = None; diff --git a/tests/ui/consts/const-blocks/nll-fail.rs b/tests/ui/consts/const-blocks/nll-fail.rs index fddbfbb9d32..e7dbb68d920 100644 --- a/tests/ui/consts/const-blocks/nll-fail.rs +++ b/tests/ui/consts/const-blocks/nll-fail.rs @@ -4,7 +4,7 @@ struct Bar; mod non_constants { - use Bar; + use crate::Bar; fn no_impl_copy_empty_value_multiple_elements() { let x = None; diff --git a/tests/ui/consts/const-blocks/nll-pass.rs b/tests/ui/consts/const-blocks/nll-pass.rs index 308834bd646..629d4db0dc6 100644 --- a/tests/ui/consts/const-blocks/nll-pass.rs +++ b/tests/ui/consts/const-blocks/nll-pass.rs @@ -5,7 +5,7 @@ struct Bar; mod constants { - use Bar; + use crate::Bar; fn no_impl_copy_empty_value_no_elements() { const FOO: Option<Bar> = None; @@ -69,7 +69,7 @@ mod constants { } mod non_constants { - use Bar; + use crate::Bar; fn no_impl_copy_empty_value_no_elements() { let x = None; diff --git a/tests/ui/consts/const-blocks/trait-error.stderr b/tests/ui/consts/const-blocks/trait-error.stderr index 58ddc047d03..601d067e3d8 100644 --- a/tests/ui/consts/const-blocks/trait-error.stderr +++ b/tests/ui/consts/const-blocks/trait-error.stderr @@ -2,10 +2,7 @@ error[E0277]: the trait bound `String: Copy` is not satisfied --> $DIR/trait-error.rs:5:6 | LL | [Foo(String::new()); 4]; - | ^^^^^^^^^^^^^^^^^^ - | | - | the trait `Copy` is not implemented for `String` - | help: create an inline `const` block: `const { Foo(String::new()) }` + | ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` | note: required for `Foo<String>` to implement `Copy` --> $DIR/trait-error.rs:1:10 @@ -13,6 +10,10 @@ note: required for `Foo<String>` to implement `Copy` LL | #[derive(Copy, Clone)] | ^^^^ unsatisfied trait bound introduced in this `derive` macro = note: the `Copy` trait is required because this value will be copied for each element of the array +help: create an inline `const` block + | +LL | [const { Foo(String::new()) }; 4]; + | +++++++ + error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-compare-bytes-ub.rs b/tests/ui/consts/const-compare-bytes-ub.rs index 9dafae1efd1..0bc8585a4ee 100644 --- a/tests/ui/consts/const-compare-bytes-ub.rs +++ b/tests/ui/consts/const-compare-bytes-ub.rs @@ -7,34 +7,34 @@ use std::mem::MaybeUninit; fn main() { const LHS_NULL: i32 = unsafe { compare_bytes(0 as *const u8, 2 as *const u8, 1) - //~^ ERROR evaluation of constant value failed + //~^ ERROR memory access failed }; const RHS_NULL: i32 = unsafe { compare_bytes(1 as *const u8, 0 as *const u8, 1) - //~^ ERROR evaluation of constant value failed + //~^ ERROR memory access failed }; const DANGLING_PTR_NON_ZERO_LENGTH: i32 = unsafe { compare_bytes(1 as *const u8, 2 as *const u8, 1) - //~^ ERROR evaluation of constant value failed + //~^ ERROR memory access failed }; const LHS_OUT_OF_BOUNDS: i32 = unsafe { compare_bytes([1, 2, 3].as_ptr(), [1, 2, 3, 4].as_ptr(), 4) - //~^ ERROR evaluation of constant value failed + //~^ ERROR memory access failed }; const RHS_OUT_OF_BOUNDS: i32 = unsafe { compare_bytes([1, 2, 3, 4].as_ptr(), [1, 2, 3].as_ptr(), 4) - //~^ ERROR evaluation of constant value failed + //~^ ERROR memory access failed }; const LHS_UNINIT: i32 = unsafe { compare_bytes(MaybeUninit::uninit().as_ptr(), [1].as_ptr(), 1) - //~^ ERROR evaluation of constant value failed + //~^ ERROR memory is uninitialized }; const RHS_UNINIT: i32 = unsafe { compare_bytes([1].as_ptr(), MaybeUninit::uninit().as_ptr(), 1) - //~^ ERROR evaluation of constant value failed + //~^ ERROR memory is uninitialized }; const WITH_PROVENANCE: i32 = unsafe { compare_bytes([&1].as_ptr().cast(), [&2].as_ptr().cast(), std::mem::size_of::<usize>()) - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer }; } diff --git a/tests/ui/consts/const-compare-bytes-ub.stderr b/tests/ui/consts/const-compare-bytes-ub.stderr index 0e77310c6ba..c1706a8c4b0 100644 --- a/tests/ui/consts/const-compare-bytes-ub.stderr +++ b/tests/ui/consts/const-compare-bytes-ub.stderr @@ -1,50 +1,50 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: attempting to access 1 byte, but got null pointer --> $DIR/const-compare-bytes-ub.rs:9:9 | LL | compare_bytes(0 as *const u8, 2 as *const u8, 1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 1 byte, but got null pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::LHS_NULL` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) --> $DIR/const-compare-bytes-ub.rs:13:9 | LL | compare_bytes(1 as *const u8, 0 as *const u8, 1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::RHS_NULL` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) --> $DIR/const-compare-bytes-ub.rs:17:9 | LL | compare_bytes(1 as *const u8, 2 as *const u8, 1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::DANGLING_PTR_NON_ZERO_LENGTH` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0 which is only 3 bytes from the end of the allocation --> $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: attempting to access 4 bytes, but got ALLOC0 which is only 3 bytes from the end of the allocation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::LHS_OUT_OF_BOUNDS` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC1 which is only 3 bytes from the end of the allocation --> $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: attempting to access 4 bytes, but got ALLOC1 which is only 3 bytes from the end of the allocation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::RHS_OUT_OF_BOUNDS` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: reading memory at ALLOC2[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory --> $DIR/const-compare-bytes-ub.rs:29:9 | LL | compare_bytes(MaybeUninit::uninit().as_ptr(), [1].as_ptr(), 1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at ALLOC2[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::LHS_UNINIT` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: reading memory at ALLOC3[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory --> $DIR/const-compare-bytes-ub.rs:33:9 | LL | compare_bytes([1].as_ptr(), MaybeUninit::uninit().as_ptr(), 1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at ALLOC3[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::RHS_UNINIT` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/const-compare-bytes-ub.rs:37:9 | LL | compare_bytes([&1].as_ptr().cast(), [&2].as_ptr().cast(), std::mem::size_of::<usize>()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::WITH_PROVENANCE` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported diff --git a/tests/ui/consts/const-deref-ptr.rs b/tests/ui/consts/const-deref-ptr.rs index c80cb95ea93..ae928f55ebd 100644 --- a/tests/ui/consts/const-deref-ptr.rs +++ b/tests/ui/consts/const-deref-ptr.rs @@ -1,8 +1,7 @@ // Check that you can't dereference invalid raw pointers in constants. fn main() { - static C: u64 = unsafe {*(0xdeadbeef as *const u64)}; - //~^ ERROR could not evaluate static initializer - //~| NOTE dangling pointer + static C: u64 = unsafe { *(0xdeadbeef as *const u64) }; + //~^ ERROR dangling pointer println!("{}", C); } diff --git a/tests/ui/consts/const-deref-ptr.stderr b/tests/ui/consts/const-deref-ptr.stderr index 37502864947..aa89aedac31 100644 --- a/tests/ui/consts/const-deref-ptr.stderr +++ b/tests/ui/consts/const-deref-ptr.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer - --> $DIR/const-deref-ptr.rs:4:29 +error[E0080]: memory access failed: attempting to access 8 bytes, but got 0xdeadbeef[noalloc] which is a dangling pointer (it has no provenance) + --> $DIR/const-deref-ptr.rs:4:30 | -LL | static C: u64 = unsafe {*(0xdeadbeef as *const u64)}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 8 bytes, but got 0xdeadbeef[noalloc] which is a dangling pointer (it has no provenance) +LL | static C: u64 = unsafe { *(0xdeadbeef as *const u64) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::C` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-err-early.rs b/tests/ui/consts/const-err-early.rs index a3105b4fc4a..998ac951ea9 100644 --- a/tests/ui/consts/const-err-early.rs +++ b/tests/ui/consts/const-err-early.rs @@ -1,8 +1,8 @@ -pub const A: i8 = -i8::MIN; //~ ERROR constant -pub const B: u8 = 200u8 + 200u8; //~ ERROR constant -pub const C: u8 = 200u8 * 4; //~ ERROR constant -pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR constant -pub const E: u8 = [5u8][1]; //~ ERROR constant +pub const A: i8 = -i8::MIN; //~ ERROR overflow +pub const B: u8 = 200u8 + 200u8; //~ ERROR overflow +pub const C: u8 = 200u8 * 4; //~ ERROR overflow +pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR overflow +pub const E: u8 = [5u8][1]; //~ ERROR index out of bounds fn main() { let _a = A; diff --git a/tests/ui/consts/const-err-early.stderr b/tests/ui/consts/const-err-early.stderr index 59bf637b7ad..2d8dd08c1c8 100644 --- a/tests/ui/consts/const-err-early.stderr +++ b/tests/ui/consts/const-err-early.stderr @@ -1,32 +1,32 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to negate `i8::MIN`, which would overflow --> $DIR/const-err-early.rs:1:19 | LL | pub const A: i8 = -i8::MIN; - | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow + | ^^^^^^^^ evaluation of `A` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `200_u8 + 200_u8`, which would overflow --> $DIR/const-err-early.rs:2:19 | LL | pub const B: u8 = 200u8 + 200u8; - | ^^^^^^^^^^^^^ attempt to compute `200_u8 + 200_u8`, which would overflow + | ^^^^^^^^^^^^^ evaluation of `B` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `200_u8 * 4_u8`, which would overflow --> $DIR/const-err-early.rs:3:19 | LL | pub const C: u8 = 200u8 * 4; - | ^^^^^^^^^ attempt to compute `200_u8 * 4_u8`, which would overflow + | ^^^^^^^^^ evaluation of `C` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `42_u8 - 43_u8`, which would overflow --> $DIR/const-err-early.rs:4:19 | LL | pub const D: u8 = 42u8 - (42u8 + 1); - | ^^^^^^^^^^^^^^^^^ attempt to compute `42_u8 - 43_u8`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of `D` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: index out of bounds: the length is 1 but the index is 1 --> $DIR/const-err-early.rs:5:19 | LL | pub const E: u8 = [5u8][1]; - | ^^^^^^^^ index out of bounds: the length is 1 but the index is 1 + | ^^^^^^^^ evaluation of `E` failed here error: aborting due to 5 previous errors diff --git a/tests/ui/consts/const-err-enum-discriminant.rs b/tests/ui/consts/const-err-enum-discriminant.rs index 42165ff5346..190ef47f436 100644 --- a/tests/ui/consts/const-err-enum-discriminant.rs +++ b/tests/ui/consts/const-err-enum-discriminant.rs @@ -6,8 +6,7 @@ union Foo { enum Bar { Boo = [unsafe { Foo { b: () }.a }; 4][3], - //~^ ERROR evaluation of constant value failed - //~| NOTE uninitialized + //~^ ERROR uninitialized } fn main() { diff --git a/tests/ui/consts/const-err-enum-discriminant.stderr b/tests/ui/consts/const-err-enum-discriminant.stderr index 7cf34595dc9..8724333ad7a 100644 --- a/tests/ui/consts/const-err-enum-discriminant.stderr +++ b/tests/ui/consts/const-err-enum-discriminant.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/const-err-enum-discriminant.rs:8:21 | LL | Boo = [unsafe { Foo { b: () }.a }; 4][3], - | ^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^ evaluation of `Bar::Boo::{constant#0}` failed here 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 f8bea388109..9cc2196a954 100644 --- a/tests/ui/consts/const-err-late.rs +++ b/tests/ui/consts/const-err-late.rs @@ -12,8 +12,8 @@ struct S<T>(T); impl<T> S<T> { const FOO: u8 = [5u8][1]; - //~^ ERROR evaluation of `S::<i32>::FOO` failed - //~| ERROR evaluation of `S::<u32>::FOO` failed + //~^ ERROR index out of bounds: the length is 1 but the index is 1 + //~| ERROR index out of bounds: the length is 1 but the index is 1 } fn main() { diff --git a/tests/ui/consts/const-err-late.stderr b/tests/ui/consts/const-err-late.stderr index 0c021e8761e..02be7bbe10c 100644 --- a/tests/ui/consts/const-err-late.stderr +++ b/tests/ui/consts/const-err-late.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `S::<i32>::FOO` failed +error[E0080]: index out of bounds: the length is 1 but the index is 1 --> $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 + | ^^^^^^^^ evaluation of `S::<i32>::FOO` failed here note: erroneous constant encountered --> $DIR/const-err-late.rs:20:16 @@ -10,11 +10,11 @@ note: erroneous constant encountered LL | black_box((S::<i32>::FOO, S::<u32>::FOO)); | ^^^^^^^^^^^^^ -error[E0080]: evaluation of `S::<u32>::FOO` failed +error[E0080]: index out of bounds: the length is 1 but the index is 1 --> $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 + | ^^^^^^^^ evaluation of `S::<u32>::FOO` failed here note: erroneous constant encountered --> $DIR/const-err-late.rs:20:31 diff --git a/tests/ui/consts/const-err-multi.rs b/tests/ui/consts/const-err-multi.rs index f21cc97345c..90214b656ab 100644 --- a/tests/ui/consts/const-err-multi.rs +++ b/tests/ui/consts/const-err-multi.rs @@ -1,12 +1,12 @@ pub const A: i8 = -i8::MIN; -//~^ ERROR constant -//~| NOTE attempt to negate `i8::MIN`, which would overflow +//~^ NOTE failed here +//~| ERROR attempt to negate `i8::MIN`, which would overflow pub const B: i8 = A; -//~^ NOTE constant +//~^ NOTE erroneous constant pub const C: u8 = A as u8; -//~^ NOTE constant +//~^ NOTE erroneous constant pub const D: i8 = 50 - A; -//~^ NOTE constant +//~^ NOTE erroneous 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 c60be59b87d..515316523f6 100644 --- a/tests/ui/consts/const-err-multi.stderr +++ b/tests/ui/consts/const-err-multi.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to negate `i8::MIN`, which would overflow --> $DIR/const-err-multi.rs:1:19 | LL | pub const A: i8 = -i8::MIN; - | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow + | ^^^^^^^^ evaluation of `A` failed here note: erroneous constant encountered --> $DIR/const-err-multi.rs:4:19 diff --git a/tests/ui/consts/const-eval-fail-too-big.rs b/tests/ui/consts/const-eval-fail-too-big.rs index 4b5dbc1d7a4..b14505135fb 100644 --- a/tests/ui/consts/const-eval-fail-too-big.rs +++ b/tests/ui/consts/const-eval-fail-too-big.rs @@ -2,7 +2,7 @@ struct B< A: Sized = [(); { let x = [0u8; !0usize]; - //~^ ERROR evaluation of constant value failed + //~^ ERROR too big for the target architecture 1 }], > { diff --git a/tests/ui/consts/const-eval-fail-too-big.stderr b/tests/ui/consts/const-eval-fail-too-big.stderr index ae666483233..d58efbf6d8c 100644 --- a/tests/ui/consts/const-eval-fail-too-big.stderr +++ b/tests/ui/consts/const-eval-fail-too-big.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture --> $DIR/const-eval-fail-too-big.rs:4:28 | LL | let x = [0u8; !0usize]; - | ^^^^^^^^^^^^^^ values of the type `[u8; usize::MAX]` are too big for the target architecture + | ^^^^^^^^^^^^^^ evaluation of `B::{constant#0}` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/assign-to-static-within-other-static.rs b/tests/ui/consts/const-eval/assign-to-static-within-other-static.rs index 30e40bd8be1..7a7a2566940 100644 --- a/tests/ui/consts/const-eval/assign-to-static-within-other-static.rs +++ b/tests/ui/consts/const-eval/assign-to-static-within-other-static.rs @@ -6,7 +6,7 @@ use std::cell::UnsafeCell; static mut FOO: u32 = 42; static BOO: () = unsafe { FOO = 5; - //~^ ERROR could not evaluate static initializer [E0080] + //~^ ERROR modifying a static's initial value }; fn main() {} diff --git a/tests/ui/consts/const-eval/assign-to-static-within-other-static.stderr b/tests/ui/consts/const-eval/assign-to-static-within-other-static.stderr index 5300111a6b6..b232cbf25e7 100644 --- a/tests/ui/consts/const-eval/assign-to-static-within-other-static.stderr +++ b/tests/ui/consts/const-eval/assign-to-static-within-other-static.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: modifying a static's initial value from another static's initializer --> $DIR/assign-to-static-within-other-static.rs:8:5 | LL | FOO = 5; - | ^^^^^^^ modifying a static's initial value from another static's initializer + | ^^^^^^^ evaluation of `BOO` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/conditional_array_execution.rs b/tests/ui/consts/const-eval/conditional_array_execution.rs index 27d5383d6d4..1473efa7428 100644 --- a/tests/ui/consts/const-eval/conditional_array_execution.rs +++ b/tests/ui/consts/const-eval/conditional_array_execution.rs @@ -1,7 +1,7 @@ const X: u32 = 5; const Y: u32 = 6; const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; -//~^ ERROR constant +//~^ ERROR overflow fn main() { println!("{}", FOO); diff --git a/tests/ui/consts/const-eval/conditional_array_execution.stderr b/tests/ui/consts/const-eval/conditional_array_execution.stderr index 30034378079..9a0a7527277 100644 --- a/tests/ui/consts/const-eval/conditional_array_execution.stderr +++ b/tests/ui/consts/const-eval/conditional_array_execution.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `5_u32 - 6_u32`, which would overflow --> $DIR/conditional_array_execution.rs:3:19 | LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; - | ^^^^^ attempt to compute `5_u32 - 6_u32`, which would overflow + | ^^^^^ evaluation of `FOO` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/const-eval-overflow-2.rs b/tests/ui/consts/const-eval/const-eval-overflow-2.rs index bae8a7ce243..71ac655435b 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-2.rs +++ b/tests/ui/consts/const-eval/const-eval-overflow-2.rs @@ -8,7 +8,7 @@ use std::{i8, i16, i32, i64, isize}; use std::{u8, u16, u32, u64, usize}; const NEG_128: i8 = -128; -const NEG_NEG_128: i8 = -NEG_128; //~ ERROR constant +const NEG_NEG_128: i8 = -NEG_128; //~ ERROR overflow fn main() { match -128i8 { diff --git a/tests/ui/consts/const-eval/const-eval-overflow-2.stderr b/tests/ui/consts/const-eval/const-eval-overflow-2.stderr index 5599ff931e8..ffb8cade923 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-2.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow-2.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to negate `i8::MIN`, which would overflow --> $DIR/const-eval-overflow-2.rs:11:25 | LL | const NEG_NEG_128: i8 = -NEG_128; - | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow + | ^^^^^^^^ evaluation of `NEG_NEG_128` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/const-eval-overflow-3.rs b/tests/ui/consts/const-eval/const-eval-overflow-3.rs index bcc966dc962..bf7e791483a 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-3.rs +++ b/tests/ui/consts/const-eval/const-eval-overflow-3.rs @@ -16,7 +16,7 @@ use std::fmt; const A_I8_I : [u32; (i8::MAX as usize) + 1] = [0; (i8::MAX + 1) as usize]; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflow fn main() { foo(&A_I8_I[..]); diff --git a/tests/ui/consts/const-eval/const-eval-overflow-3.stderr b/tests/ui/consts/const-eval/const-eval-overflow-3.stderr index 0437cd3adb4..aeb88716f16 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-3.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow-3.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i8::MAX + 1_i8`, which would overflow --> $DIR/const-eval-overflow-3.rs:18:11 | LL | = [0; (i8::MAX + 1) as usize]; - | ^^^^^^^^^^^^^ attempt to compute `i8::MAX + 1_i8`, which would overflow + | ^^^^^^^^^^^^^ evaluation of `A_I8_I::{constant#1}` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/const-eval-overflow-4.rs b/tests/ui/consts/const-eval/const-eval-overflow-4.rs index 762c7a968a8..d42c29249af 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-4.rs +++ b/tests/ui/consts/const-eval/const-eval-overflow-4.rs @@ -9,7 +9,7 @@ use std::fmt; const A_I8_T : [u32; (i8::MAX as i8 + 1i8) as usize] - //~^ ERROR evaluation of constant value failed + //~^ ERROR overflow = [0; (i8::MAX as usize) + 1]; fn main() { diff --git a/tests/ui/consts/const-eval/const-eval-overflow-4.stderr b/tests/ui/consts/const-eval/const-eval-overflow-4.stderr index ce5e59901c1..daabb33e0f3 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-4.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow-4.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i8::MAX + 1_i8`, which would overflow --> $DIR/const-eval-overflow-4.rs:11:13 | LL | : [u32; (i8::MAX as i8 + 1i8) as usize] - | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `i8::MAX + 1_i8`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `A_I8_T::{constant#0}` failed here error: aborting due to 1 previous error 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 1a0832b8ba0..b996370ea3d 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr @@ -23,7 +23,7 @@ error[E0604]: only `u8` can be cast as `char`, not `i8` LL | : [u32; 5i8 as char as usize] | ^^^^^^^^^^^ invalid cast | -help: try casting from `u8` instead +help: consider casting from `u8` instead --> $DIR/const-eval-overflow-4b.rs:24:13 | LL | : [u32; 5i8 as char as usize] diff --git a/tests/ui/consts/const-eval/const-eval-overflow2.rs b/tests/ui/consts/const-eval/const-eval-overflow2.rs index 1676f7c2af6..348c8e06f66 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2.rs +++ b/tests/ui/consts/const-eval/const-eval-overflow2.rs @@ -11,47 +11,47 @@ const VALS_I8: (i8,) = ( i8::MIN - 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I16: (i16,) = ( i16::MIN - 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I32: (i32,) = ( i32::MIN - 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I64: (i64,) = ( i64::MIN - 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U8: (u8,) = ( u8::MIN - 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U16: (u16,) = ( u16::MIN - 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U32: (u32,) = ( u32::MIN - 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U64: (u64,) = ( u64::MIN - 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow fn main() { foo(VALS_I8); diff --git a/tests/ui/consts/const-eval/const-eval-overflow2.stderr b/tests/ui/consts/const-eval/const-eval-overflow2.stderr index 341c15daf65..6ec3fa73cb7 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow2.stderr @@ -1,50 +1,50 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i8::MIN - 1_i8`, which would overflow --> $DIR/const-eval-overflow2.rs:12:6 | LL | i8::MIN - 1, - | ^^^^^^^^^^^ attempt to compute `i8::MIN - 1_i8`, which would overflow + | ^^^^^^^^^^^ evaluation of `VALS_I8` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i16::MIN - 1_i16`, which would overflow --> $DIR/const-eval-overflow2.rs:18:6 | LL | i16::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `i16::MIN - 1_i16`, which would overflow + | ^^^^^^^^^^^^ evaluation of `VALS_I16` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i32::MIN - 1_i32`, which would overflow --> $DIR/const-eval-overflow2.rs:24:6 | LL | i32::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `i32::MIN - 1_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `VALS_I32` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i64::MIN - 1_i64`, which would overflow --> $DIR/const-eval-overflow2.rs:30:6 | LL | i64::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `i64::MIN - 1_i64`, which would overflow + | ^^^^^^^^^^^^ evaluation of `VALS_I64` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `0_u8 - 1_u8`, which would overflow --> $DIR/const-eval-overflow2.rs:36:6 | LL | u8::MIN - 1, - | ^^^^^^^^^^^ attempt to compute `0_u8 - 1_u8`, which would overflow + | ^^^^^^^^^^^ evaluation of `VALS_U8` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `0_u16 - 1_u16`, which would overflow --> $DIR/const-eval-overflow2.rs:41:6 | LL | u16::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `0_u16 - 1_u16`, which would overflow + | ^^^^^^^^^^^^ evaluation of `VALS_U16` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `0_u32 - 1_u32`, which would overflow --> $DIR/const-eval-overflow2.rs:46:6 | LL | u32::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `VALS_U32` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `0_u64 - 1_u64`, which would overflow --> $DIR/const-eval-overflow2.rs:52:6 | LL | u64::MIN - 1, - | ^^^^^^^^^^^^ attempt to compute `0_u64 - 1_u64`, which would overflow + | ^^^^^^^^^^^^ evaluation of `VALS_U64` failed here error: aborting due to 8 previous errors diff --git a/tests/ui/consts/const-eval/const-eval-overflow2b.rs b/tests/ui/consts/const-eval/const-eval-overflow2b.rs index 59d1df5680d..b05b0b11105 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2b.rs +++ b/tests/ui/consts/const-eval/const-eval-overflow2b.rs @@ -11,47 +11,47 @@ const VALS_I8: (i8,) = ( i8::MAX + 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I16: (i16,) = ( i16::MAX + 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I32: (i32,) = ( i32::MAX + 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I64: (i64,) = ( i64::MAX + 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U8: (u8,) = ( u8::MAX + 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U16: (u16,) = ( u16::MAX + 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U32: (u32,) = ( u32::MAX + 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U64: (u64,) = ( u64::MAX + 1, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow fn main() { foo(VALS_I8); diff --git a/tests/ui/consts/const-eval/const-eval-overflow2b.stderr b/tests/ui/consts/const-eval/const-eval-overflow2b.stderr index e661836b4b9..5b8e559d046 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2b.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow2b.stderr @@ -1,50 +1,50 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i8::MAX + 1_i8`, which would overflow --> $DIR/const-eval-overflow2b.rs:12:6 | LL | i8::MAX + 1, - | ^^^^^^^^^^^ attempt to compute `i8::MAX + 1_i8`, which would overflow + | ^^^^^^^^^^^ evaluation of `VALS_I8` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i16::MAX + 1_i16`, which would overflow --> $DIR/const-eval-overflow2b.rs:18:6 | LL | i16::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `i16::MAX + 1_i16`, which would overflow + | ^^^^^^^^^^^^ evaluation of `VALS_I16` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i32::MAX + 1_i32`, which would overflow --> $DIR/const-eval-overflow2b.rs:24:6 | LL | i32::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `i32::MAX + 1_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `VALS_I32` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i64::MAX + 1_i64`, which would overflow --> $DIR/const-eval-overflow2b.rs:30:6 | LL | i64::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `i64::MAX + 1_i64`, which would overflow + | ^^^^^^^^^^^^ evaluation of `VALS_I64` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow --> $DIR/const-eval-overflow2b.rs:36:6 | LL | u8::MAX + 1, - | ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow + | ^^^^^^^^^^^ evaluation of `VALS_U8` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u16::MAX + 1_u16`, which would overflow --> $DIR/const-eval-overflow2b.rs:41:6 | LL | u16::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `u16::MAX + 1_u16`, which would overflow + | ^^^^^^^^^^^^ evaluation of `VALS_U16` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u32::MAX + 1_u32`, which would overflow --> $DIR/const-eval-overflow2b.rs:46:6 | LL | u32::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `u32::MAX + 1_u32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `VALS_U32` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u64::MAX + 1_u64`, which would overflow --> $DIR/const-eval-overflow2b.rs:52:6 | LL | u64::MAX + 1, - | ^^^^^^^^^^^^ attempt to compute `u64::MAX + 1_u64`, which would overflow + | ^^^^^^^^^^^^ evaluation of `VALS_U64` failed here error: aborting due to 8 previous errors diff --git a/tests/ui/consts/const-eval/const-eval-overflow2c.rs b/tests/ui/consts/const-eval/const-eval-overflow2c.rs index 33b89260115..ec87f5e066c 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2c.rs +++ b/tests/ui/consts/const-eval/const-eval-overflow2c.rs @@ -11,47 +11,47 @@ const VALS_I8: (i8,) = ( i8::MIN * 2, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I16: (i16,) = ( i16::MIN * 2, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I32: (i32,) = ( i32::MIN * 2, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_I64: (i64,) = ( i64::MIN * 2, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U8: (u8,) = ( u8::MAX * 2, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U16: (u16,) = ( u16::MAX * 2, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U32: (u32,) = ( u32::MAX * 2, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow const VALS_U64: (u64,) = ( u64::MAX * 2, ); - //~^^ ERROR evaluation of constant value failed + //~^^ ERROR overflow fn main() { foo(VALS_I8); diff --git a/tests/ui/consts/const-eval/const-eval-overflow2c.stderr b/tests/ui/consts/const-eval/const-eval-overflow2c.stderr index 1fad15492fb..99eeadf6b0d 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2c.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow2c.stderr @@ -1,50 +1,50 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i8::MIN * 2_i8`, which would overflow --> $DIR/const-eval-overflow2c.rs:12:6 | LL | i8::MIN * 2, - | ^^^^^^^^^^^ attempt to compute `i8::MIN * 2_i8`, which would overflow + | ^^^^^^^^^^^ evaluation of `VALS_I8` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i16::MIN * 2_i16`, which would overflow --> $DIR/const-eval-overflow2c.rs:18:6 | LL | i16::MIN * 2, - | ^^^^^^^^^^^^ attempt to compute `i16::MIN * 2_i16`, which would overflow + | ^^^^^^^^^^^^ evaluation of `VALS_I16` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i32::MIN * 2_i32`, which would overflow --> $DIR/const-eval-overflow2c.rs:24:6 | LL | i32::MIN * 2, - | ^^^^^^^^^^^^ attempt to compute `i32::MIN * 2_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `VALS_I32` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `i64::MIN * 2_i64`, which would overflow --> $DIR/const-eval-overflow2c.rs:30:6 | LL | i64::MIN * 2, - | ^^^^^^^^^^^^ attempt to compute `i64::MIN * 2_i64`, which would overflow + | ^^^^^^^^^^^^ evaluation of `VALS_I64` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u8::MAX * 2_u8`, which would overflow --> $DIR/const-eval-overflow2c.rs:36:6 | LL | u8::MAX * 2, - | ^^^^^^^^^^^ attempt to compute `u8::MAX * 2_u8`, which would overflow + | ^^^^^^^^^^^ evaluation of `VALS_U8` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u16::MAX * 2_u16`, which would overflow --> $DIR/const-eval-overflow2c.rs:41:6 | LL | u16::MAX * 2, - | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 2_u16`, which would overflow + | ^^^^^^^^^^^^ evaluation of `VALS_U16` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u32::MAX * 2_u32`, which would overflow --> $DIR/const-eval-overflow2c.rs:46:6 | LL | u32::MAX * 2, - | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 2_u32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `VALS_U32` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `u64::MAX * 2_u64`, which would overflow --> $DIR/const-eval-overflow2c.rs:52:6 | LL | u64::MAX * 2, - | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 2_u64`, which would overflow + | ^^^^^^^^^^^^ evaluation of `VALS_U64` failed here error: aborting due to 8 previous errors diff --git a/tests/ui/consts/const-eval/const-eval-query-stack.rs b/tests/ui/consts/const-eval/const-eval-query-stack.rs index 8de398787b4..3728e2071d3 100644 --- a/tests/ui/consts/const-eval/const-eval-query-stack.rs +++ b/tests/ui/consts/const-eval/const-eval-query-stack.rs @@ -13,7 +13,7 @@ //@ normalize-stderr: ".*omitted \d{1,} frame.*\n" -> "" #![allow(unconditional_panic)] -const X: i32 = 1 / 0; //~ERROR constant +const X: i32 = 1 / 0; //~ERROR attempt to divide `1_i32` by zero fn main() { let x: &'static i32 = &X; diff --git a/tests/ui/consts/const-eval/const-eval-query-stack.stderr b/tests/ui/consts/const-eval/const-eval-query-stack.stderr index 5a71c770fdc..96206dc5078 100644 --- a/tests/ui/consts/const-eval/const-eval-query-stack.stderr +++ b/tests/ui/consts/const-eval/const-eval-query-stack.stderr @@ -1,8 +1,8 @@ -error: internal compiler error[E0080]: evaluation of constant value failed +error: internal compiler error[E0080]: attempt to divide `1_i32` by zero --> $DIR/const-eval-query-stack.rs:16:16 | LL | const X: i32 = 1 / 0; - | ^^^^^ attempt to divide `1_i32` by zero + | ^^^^^ evaluation of `X` failed here note: please make sure that you have updated to the latest nightly 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 3eccd596274..d28d6841ca9 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,254 +1,254 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_USIZE_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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 +error[E0080]: unable to turn pointer into integer --> $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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_U8_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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 +error[E0080]: unable to turn pointer into integer --> $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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_U16_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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 +error[E0080]: unable to turn pointer into integer --> $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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_U32_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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 +error[E0080]: unable to turn pointer into integer --> $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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_U64_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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 +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_U128_UNION` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:46:43 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:45:43 | LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_I8_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:49:45 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:48:45 | LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_I16_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:52:45 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:51:45 | LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_I32_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:55:45 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:54:45 | LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_I64_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:58:47 +error[E0080]: using uninitialized data, but this operation requires initialized memory + --> $DIR/const-pointer-values-in-various-types.rs:57: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_I128_UNION` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-pointer-values-in-various-types.rs:62:45 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:60:45 | LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_F32_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:65:45 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:63:45 | LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_F64_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:68:47 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:66:47 | LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_BOOL_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:71:47 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:69:47 | LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_CHAR_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:74:39 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:72:39 | LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_U8_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:77:41 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:75:41 | LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_U16_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:80:41 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:78:41 | LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_U32_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:83:41 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:81:41 | LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_U64_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:86:43 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:84:43 | LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_U128_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:89:39 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:87:39 | LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_I8_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:92:41 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:90:41 | LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_I16_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:95:41 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:93:41 | LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_I32_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:98:41 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:96:41 | LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_I64_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:101:43 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:99:43 | LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_I128_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:104:41 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:102:41 | LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_F32_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:107:41 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:105:41 | LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_F64_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:110:43 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:108:43 | LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_BOOL_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:113:43 +error[E0080]: unable to turn pointer into integer + --> $DIR/const-pointer-values-in-various-types.rs:111:43 | LL | const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_CHAR_UNION` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported 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 ce7380cd155..5720d6ea91e 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 @@ -25,91 +25,89 @@ union Nonsense { fn main() { const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }.u }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 }; - //~^ ERROR evaluation of constant value failed - //~| NOTE uninitialized + //~^ ERROR uninitialized const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 }; - //~^ ERROR evaluation of constant value failed - //~| NOTE uninitialized + //~^ ERROR uninitialized const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character }; - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer } diff --git a/tests/ui/consts/const-eval/const_fn_ptr_fail2.rs b/tests/ui/consts/const-eval/const_fn_ptr_fail2.rs index c6ae3af4427..8d928e26378 100644 --- a/tests/ui/consts/const-eval/const_fn_ptr_fail2.rs +++ b/tests/ui/consts/const-eval/const_fn_ptr_fail2.rs @@ -14,11 +14,11 @@ const fn bar(x: fn(usize) -> usize, y: usize) -> usize { } const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday -//~^ ERROR evaluation of constant value failed -//~| NOTE calling non-const function `double` +//~^ NOTE failed inside this call +//~| ERROR calling non-const function `double` const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday -//~^ ERROR evaluation of constant value failed -//~| NOTE calling non-const function `double` +//~^ NOTE failed inside this call +//~| ERROR calling non-const function `double` fn main() { assert_eq!(Y, 4); diff --git a/tests/ui/consts/const-eval/const_fn_ptr_fail2.stderr b/tests/ui/consts/const-eval/const_fn_ptr_fail2.stderr index a4d2e26c3af..3ac96b40994 100644 --- a/tests/ui/consts/const-eval/const_fn_ptr_fail2.stderr +++ b/tests/ui/consts/const-eval/const_fn_ptr_fail2.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: calling non-const function `double` --> $DIR/const_fn_ptr_fail2.rs:16:18 | LL | const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday - | ^^^^^^^^^ calling non-const function `double` + | ^^^^^^^^^ evaluation of `Y` failed inside this call | note: inside `bar` --> $DIR/const_fn_ptr_fail2.rs:9:5 @@ -10,11 +10,11 @@ note: inside `bar` LL | x(y) | ^^^^ the failure occurred here -error[E0080]: evaluation of constant value failed +error[E0080]: calling non-const function `double` --> $DIR/const_fn_ptr_fail2.rs:19:18 | LL | const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday - | ^^^^^^^^^^^^^^ calling non-const function `double` + | ^^^^^^^^^^^^^^ evaluation of `Z` failed inside this call | note: inside `bar` --> $DIR/const_fn_ptr_fail2.rs:9:5 diff --git a/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.rs b/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.rs index 0bf2f0e6669..45298df0243 100644 --- a/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.rs +++ b/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.rs @@ -1,5 +1,5 @@ #![crate_type = "lib"] struct Bug([u8; panic!{"\t"}]); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked //~| NOTE: in this expansion of panic! diff --git a/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr b/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr index fae971c09f2..7e7b59ce43f 100644 --- a/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr +++ b/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: --> $DIR/const_panic-normalize-tabs-115498.rs:3:17 | LL | struct Bug([u8; panic!{"\t"}]); - | ^^^^^^^^^^^^ evaluation panicked: + | ^^^^^^^^^^^^ evaluation of `Bug::0::{constant#0}` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/const_panic.rs b/tests/ui/consts/const-eval/const_panic.rs index 5b9a8f8e2a2..367396bab94 100644 --- a/tests/ui/consts/const-eval/const_panic.rs +++ b/tests/ui/consts/const-eval/const_panic.rs @@ -4,37 +4,37 @@ const MSG: &str = "hello"; const Z: () = std::panic!("cheese"); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const Z2: () = std::panic!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const Y: () = std::unreachable!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const X: () = std::unimplemented!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const W: () = std::panic!(MSG); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const W2: () = std::panic!("{}", MSG); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const Z_CORE: () = core::panic!("cheese"); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const Z2_CORE: () = core::panic!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const Y_CORE: () = core::unreachable!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const X_CORE: () = core::unimplemented!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const W_CORE: () = core::panic!(MSG); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const W2_CORE: () = core::panic!("{}", MSG); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked diff --git a/tests/ui/consts/const-eval/const_panic.stderr b/tests/ui/consts/const-eval/const_panic.stderr index 0874224e5f2..46b36ecfa6a 100644 --- a/tests/ui/consts/const-eval/const_panic.stderr +++ b/tests/ui/consts/const-eval/const_panic.stderr @@ -1,78 +1,78 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: cheese --> $DIR/const_panic.rs:6:15 | LL | const Z: () = std::panic!("cheese"); - | ^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: cheese + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `Z` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/const_panic.rs:9:16 | LL | const Z2: () = std::panic!(); - | ^^^^^^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^^^^^^ evaluation of `Z2` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: internal error: entered unreachable code --> $DIR/const_panic.rs:12:15 | LL | const Y: () = std::unreachable!(); - | ^^^^^^^^^^^^^^^^^^^ evaluation panicked: internal error: entered unreachable code + | ^^^^^^^^^^^^^^^^^^^ evaluation of `Y` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: not implemented --> $DIR/const_panic.rs:15:15 | LL | const X: () = std::unimplemented!(); - | ^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: not implemented + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `X` failed here | = note: this error originates in the macro `std::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: hello --> $DIR/const_panic.rs:18:15 | LL | const W: () = std::panic!(MSG); - | ^^^^^^^^^^^^^^^^ evaluation panicked: hello + | ^^^^^^^^^^^^^^^^ evaluation of `W` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: hello --> $DIR/const_panic.rs:21:16 | LL | const W2: () = std::panic!("{}", MSG); - | ^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: hello + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `W2` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: cheese --> $DIR/const_panic.rs:24:20 | LL | const Z_CORE: () = core::panic!("cheese"); - | ^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: cheese + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `Z_CORE` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/const_panic.rs:27:21 | LL | const Z2_CORE: () = core::panic!(); - | ^^^^^^^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^^^^^^^ evaluation of `Z2_CORE` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: internal error: entered unreachable code --> $DIR/const_panic.rs:30:20 | LL | const Y_CORE: () = core::unreachable!(); - | ^^^^^^^^^^^^^^^^^^^^ evaluation panicked: internal error: entered unreachable code + | ^^^^^^^^^^^^^^^^^^^^ evaluation of `Y_CORE` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: not implemented --> $DIR/const_panic.rs:33:20 | LL | const X_CORE: () = core::unimplemented!(); - | ^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: not implemented + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `X_CORE` failed here | = note: this error originates in the macro `core::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: hello --> $DIR/const_panic.rs:36:20 | LL | const W_CORE: () = core::panic!(MSG); - | ^^^^^^^^^^^^^^^^^ evaluation panicked: hello + | ^^^^^^^^^^^^^^^^^ evaluation of `W_CORE` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: hello --> $DIR/const_panic.rs:39:21 | LL | const W2_CORE: () = core::panic!("{}", MSG); - | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: hello + | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `W2_CORE` failed here error: aborting due to 12 previous errors diff --git a/tests/ui/consts/const-eval/const_panic_2021.rs b/tests/ui/consts/const-eval/const_panic_2021.rs index 31a80e71b7c..845f78beef9 100644 --- a/tests/ui/consts/const-eval/const_panic_2021.rs +++ b/tests/ui/consts/const-eval/const_panic_2021.rs @@ -4,31 +4,31 @@ const MSG: &str = "hello"; const A: () = std::panic!("blåhaj"); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const B: () = std::panic!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const C: () = std::unreachable!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const D: () = std::unimplemented!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const E: () = std::panic!("{}", MSG); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const A_CORE: () = core::panic!("shark"); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const B_CORE: () = core::panic!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const C_CORE: () = core::unreachable!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const D_CORE: () = core::unimplemented!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const E_CORE: () = core::panic!("{}", MSG); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked diff --git a/tests/ui/consts/const-eval/const_panic_2021.stderr b/tests/ui/consts/const-eval/const_panic_2021.stderr index 1496df4445a..ba771a35d03 100644 --- a/tests/ui/consts/const-eval/const_panic_2021.stderr +++ b/tests/ui/consts/const-eval/const_panic_2021.stderr @@ -1,66 +1,66 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: blåhaj --> $DIR/const_panic_2021.rs:6:15 | LL | const A: () = std::panic!("blåhaj"); - | ^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: blåhaj + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `A` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/const_panic_2021.rs:9:15 | LL | const B: () = std::panic!(); - | ^^^^^^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^^^^^^ evaluation of `B` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: internal error: entered unreachable code --> $DIR/const_panic_2021.rs:12:15 | LL | const C: () = std::unreachable!(); - | ^^^^^^^^^^^^^^^^^^^ evaluation panicked: internal error: entered unreachable code + | ^^^^^^^^^^^^^^^^^^^ evaluation of `C` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: not implemented --> $DIR/const_panic_2021.rs:15:15 | LL | const D: () = std::unimplemented!(); - | ^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: not implemented + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `D` failed here | = note: this error originates in the macro `std::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: hello --> $DIR/const_panic_2021.rs:18:15 | LL | const E: () = std::panic!("{}", MSG); - | ^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: hello + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `E` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: shark --> $DIR/const_panic_2021.rs:21:20 | LL | const A_CORE: () = core::panic!("shark"); - | ^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: shark + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `A_CORE` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/const_panic_2021.rs:24:20 | LL | const B_CORE: () = core::panic!(); - | ^^^^^^^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^^^^^^^ evaluation of `B_CORE` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: internal error: entered unreachable code --> $DIR/const_panic_2021.rs:27:20 | LL | const C_CORE: () = core::unreachable!(); - | ^^^^^^^^^^^^^^^^^^^^ evaluation panicked: internal error: entered unreachable code + | ^^^^^^^^^^^^^^^^^^^^ evaluation of `C_CORE` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: not implemented --> $DIR/const_panic_2021.rs:30:20 | LL | const D_CORE: () = core::unimplemented!(); - | ^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: not implemented + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `D_CORE` failed here | = note: this error originates in the macro `core::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: hello --> $DIR/const_panic_2021.rs:33:20 | LL | const E_CORE: () = core::panic!("{}", MSG); - | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: hello + | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `E_CORE` failed here error: aborting due to 10 previous errors diff --git a/tests/ui/consts/const-eval/const_panic_libcore_bin.rs b/tests/ui/consts/const-eval/const_panic_libcore_bin.rs index d4dc1a51d73..90ae5165d23 100644 --- a/tests/ui/consts/const-eval/const_panic_libcore_bin.rs +++ b/tests/ui/consts/const-eval/const_panic_libcore_bin.rs @@ -6,13 +6,13 @@ use core::panic::PanicInfo; const Z: () = panic!("cheese"); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const Y: () = unreachable!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked const X: () = unimplemented!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked #[lang = "eh_personality"] fn eh() {} diff --git a/tests/ui/consts/const-eval/const_panic_libcore_bin.stderr b/tests/ui/consts/const-eval/const_panic_libcore_bin.stderr index 2acab711290..e07b172d426 100644 --- a/tests/ui/consts/const-eval/const_panic_libcore_bin.stderr +++ b/tests/ui/consts/const-eval/const_panic_libcore_bin.stderr @@ -1,20 +1,20 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: cheese --> $DIR/const_panic_libcore_bin.rs:8:15 | LL | const Z: () = panic!("cheese"); - | ^^^^^^^^^^^^^^^^ evaluation panicked: cheese + | ^^^^^^^^^^^^^^^^ evaluation of `Z` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: internal error: entered unreachable code --> $DIR/const_panic_libcore_bin.rs:11:15 | LL | const Y: () = unreachable!(); - | ^^^^^^^^^^^^^^ evaluation panicked: internal error: entered unreachable code + | ^^^^^^^^^^^^^^ evaluation of `Y` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: not implemented --> $DIR/const_panic_libcore_bin.rs:14:15 | LL | const X: () = unimplemented!(); - | ^^^^^^^^^^^^^^^^ evaluation panicked: not implemented + | ^^^^^^^^^^^^^^^^ evaluation of `X` failed here | = note: this error originates in the macro `unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/const-eval/const_panic_track_caller.rs b/tests/ui/consts/const-eval/const_panic_track_caller.rs index 799a59d16ca..f5ede567b82 100644 --- a/tests/ui/consts/const-eval/const_panic_track_caller.rs +++ b/tests/ui/consts/const-eval/const_panic_track_caller.rs @@ -17,5 +17,5 @@ const fn c() -> u32 { } const X: u32 = c(); -//~^ ERROR evaluation of constant value failed -//~| NOTE hey +//~^ NOTE failed inside this call +//~| ERROR hey diff --git a/tests/ui/consts/const-eval/const_panic_track_caller.stderr b/tests/ui/consts/const-eval/const_panic_track_caller.stderr index 8736a8c9409..4793c5398fc 100644 --- a/tests/ui/consts/const-eval/const_panic_track_caller.stderr +++ b/tests/ui/consts/const-eval/const_panic_track_caller.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: hey --> $DIR/const_panic_track_caller.rs:19:16 | LL | const X: u32 = c(); - | ^^^ evaluation panicked: hey + | ^^^ evaluation of `X` failed inside this call | note: inside `c` --> $DIR/const_panic_track_caller.rs:15:5 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 0e88aa80c79..47998cf408c 100644 --- a/tests/ui/consts/const-eval/const_raw_ptr_ops2.rs +++ b/tests/ui/consts/const-eval/const_raw_ptr_ops2.rs @@ -4,7 +4,5 @@ fn main() {} 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 dangling pointer -const Z3: i32 = unsafe { *(44 as *const i32) }; //~ ERROR evaluation of constant value failed -//~| NOTE dangling pointer +const Z2: i32 = unsafe { *(42 as *const i32) }; //~ ERROR dangling pointer +const Z3: i32 = unsafe { *(44 as *const i32) }; //~ ERROR 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 a8a5560ccb9..6341292789c 100644 --- a/tests/ui/consts/const-eval/const_raw_ptr_ops2.stderr +++ b/tests/ui/consts/const-eval/const_raw_ptr_ops2.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: attempting to access 4 bytes, but got 0x2a[noalloc] which is a dangling pointer (it has no provenance) --> $DIR/const_raw_ptr_ops2.rs:7:26 | LL | const Z2: i32 = unsafe { *(42 as *const i32) }; - | ^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got 0x2a[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^ evaluation of `Z2` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const_raw_ptr_ops2.rs:9:26 +error[E0080]: memory access failed: attempting to access 4 bytes, but got 0x2c[noalloc] which is a dangling pointer (it has no provenance) + --> $DIR/const_raw_ptr_ops2.rs:8:26 | LL | const Z3: i32 = unsafe { *(44 as *const i32) }; - | ^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got 0x2c[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^ evaluation of `Z3` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/dont_promote_unstable_const_fn.stderr b/tests/ui/consts/const-eval/dont_promote_unstable_const_fn.stderr index a506f2a282b..b505b76a6ab 100644 --- a/tests/ui/consts/const-eval/dont_promote_unstable_const_fn.stderr +++ b/tests/ui/consts/const-eval/dont_promote_unstable_const_fn.stderr @@ -5,16 +5,11 @@ LL | const fn bar() -> u32 { foo() } | ^^^^^ | = help: mark the callee as `#[rustc_const_stable_indirect]` if it does not itself require any unstable features -help: if the caller is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the caller is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn bar() -> u32 { foo() } | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(foo)] -LL | const fn bar() -> u32 { foo() } - | error[E0716]: temporary value dropped while borrowed --> $DIR/dont_promote_unstable_const_fn.rs:17:28 diff --git a/tests/ui/consts/const-eval/float_methods.rs b/tests/ui/consts/const-eval/float_methods.rs deleted file mode 100644 index 853f75825ac..00000000000 --- a/tests/ui/consts/const-eval/float_methods.rs +++ /dev/null @@ -1,46 +0,0 @@ -//@ run-pass -//! Tests the float intrinsics: min, max, abs, copysign - -#![feature(f16, f128)] - -const F16_MIN: f16 = 1.0_f16.min(0.5_f16); -const F16_MAX: f16 = 1.0_f16.max(0.5_f16); -const F16_ABS: f16 = (-1.0_f16).abs(); -const F16_COPYSIGN: f16 = 1.0_f16.copysign(-2.0_f16); - -const F32_MIN: f32 = 1.0_f32.min(0.5_f32); -const F32_MAX: f32 = 1.0_f32.max(0.5_f32); -const F32_ABS: f32 = (-1.0_f32).abs(); -const F32_COPYSIGN: f32 = 1.0_f32.copysign(-2.0_f32); - -const F64_MIN: f64 = 1.0_f64.min(0.5_f64); -const F64_MAX: f64 = 1.0_f64.max(0.5_f64); -const F64_ABS: f64 = (-1.0_f64).abs(); -const F64_COPYSIGN: f64 = 1.0_f64.copysign(-2.0_f64); - -const F128_MIN: f128 = 1.0_f128.min(0.5_f128); -const F128_MAX: f128 = 1.0_f128.max(0.5_f128); -const F128_ABS: f128 = (-1.0_f128).abs(); -const F128_COPYSIGN: f128 = 1.0_f128.copysign(-2.0_f128); - -fn main() { - assert_eq!(F16_MIN, 0.5); - assert_eq!(F16_MAX, 1.0); - assert_eq!(F16_ABS, 1.0); - assert_eq!(F16_COPYSIGN, -1.0); - - assert_eq!(F32_MIN, 0.5); - assert_eq!(F32_MAX, 1.0); - assert_eq!(F32_ABS, 1.0); - assert_eq!(F32_COPYSIGN, -1.0); - - assert_eq!(F64_MIN, 0.5); - assert_eq!(F64_MAX, 1.0); - assert_eq!(F64_ABS, 1.0); - assert_eq!(F64_COPYSIGN, -1.0); - - assert_eq!(F128_MIN, 0.5); - assert_eq!(F128_MAX, 1.0); - assert_eq!(F128_ABS, 1.0); - assert_eq!(F128_COPYSIGN, -1.0); -} 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 b47e2b3c1ed..d6e5a69671b 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs @@ -4,7 +4,7 @@ #![feature(const_heap)] use std::intrinsics; -const FOO: i32 = foo(); //~ ERROR evaluation of constant value failed +const FOO: i32 = foo(); //~ ERROR 3 is not a power of 2 const fn foo() -> i32 { unsafe { let _ = intrinsics::const_allocate(4, 3) as *mut i32; //~ NOTE inside `foo` 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 9f7546df3a2..a1f0b7b2beb 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: invalid align passed to `const_allocate`: 3 is not a power of 2 --> $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 + | ^^^^^ evaluation of `FOO` failed inside this call | note: inside `foo` --> $DIR/alloc_intrinsic_errors.rs:10:17 diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr index 271c8611091..11ed0841a00 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>: encountered uninitialized memory, but expected an integer --> $DIR/alloc_intrinsic_uninit.rs:7:1 | LL | const BAR: &i32 = unsafe { &*(intrinsics::const_allocate(4, 4) as *mut i32) }; - | ^^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr index ec7cc7d4140..691bde87d2f 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>: encountered uninitialized memory, but expected an integer --> $DIR/alloc_intrinsic_uninit.rs:7:1 | LL | const BAR: &i32 = unsafe { &*(intrinsics::const_allocate(4, 4) as *mut i32) }; - | ^^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.rs b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.rs index c283a5fae7d..ffc35ca1ddc 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.rs +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.rs @@ -5,5 +5,5 @@ use std::intrinsics; const BAR: &i32 = unsafe { &*(intrinsics::const_allocate(4, 4) as *mut i32) }; -//~^ error: it is undefined behavior to use this value +//~^ ERROR: uninitialized memory fn main() {} diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs index 509c872f609..de9fc5d0921 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs @@ -9,7 +9,7 @@ use std::intrinsics; const _X: &'static u8 = unsafe { - //~^ error: it is undefined behavior to use this value + //~^ ERROR: dangling reference (use-after-free) let ptr = intrinsics::const_allocate(4, 4); intrinsics::const_deallocate(ptr, 4, 4); &*ptr @@ -20,7 +20,7 @@ const _Y: u8 = unsafe { let reference = &*ptr; intrinsics::const_deallocate(ptr, 4, 4); *reference - //~^ error: evaluation of constant value failed + //~^ ERROR: has been freed, so this pointer is dangling }; fn main() {} diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr index 0b0d2676dd3..d4039e1952c 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr @@ -1,19 +1,19 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered a dangling reference (use-after-free) --> $DIR/dealloc_intrinsic_dangling.rs:11:1 | LL | const _X: &'static u8 = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (use-after-free) + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: ALLOC1 has been freed, so this pointer is dangling --> $DIR/dealloc_intrinsic_dangling.rs:22:5 | LL | *reference - | ^^^^^^^^^^ memory access failed: ALLOC1 has been freed, so this pointer is dangling + | ^^^^^^^^^^ evaluation of `_Y` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.rs b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.rs index 4010b476990..5b7cd039b9b 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.rs +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.rs @@ -7,7 +7,7 @@ const _X: () = unsafe { let ptr = intrinsics::const_allocate(4, 4); intrinsics::const_deallocate(ptr, 4, 4); intrinsics::const_deallocate(ptr, 4, 4); - //~^ error: evaluation of constant value failed + //~^ ERROR: dangling }; fn main() {} diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr index d2d323e5a51..803b772615f 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: ALLOC0 has been freed, so this pointer is dangling --> $DIR/dealloc_intrinsic_duplicate.rs:9:5 | LL | intrinsics::const_deallocate(ptr, 4, 4); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC0 has been freed, so this pointer is dangling + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_X` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.rs b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.rs index 031d70fdc88..75c3601f216 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.rs +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.rs @@ -6,24 +6,24 @@ use std::intrinsics; const _X: () = unsafe { let ptr = intrinsics::const_allocate(4, 4); intrinsics::const_deallocate(ptr, 4, 2); - //~^ error: evaluation of constant value failed + //~^ error: incorrect layout on deallocation }; const _Y: () = unsafe { let ptr = intrinsics::const_allocate(4, 4); intrinsics::const_deallocate(ptr, 2, 4); - //~^ error: evaluation of constant value failed + //~^ error: incorrect layout on deallocation }; const _Z: () = unsafe { let ptr = intrinsics::const_allocate(4, 4); intrinsics::const_deallocate(ptr, 3, 4); - //~^ error: evaluation of constant value failed + //~^ error: incorrect layout on deallocation }; const _W: () = unsafe { let ptr = intrinsics::const_allocate(4, 4); intrinsics::const_deallocate(ptr, 4, 3); - //~^ error: evaluation of constant value failed + //~^ error: invalid align }; fn main() {} diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr index 4b1f0f686ca..2d61f06ac5c 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr @@ -1,26 +1,26 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: incorrect layout on deallocation: ALLOC0 has size 4 and alignment 4, but gave size 4 and alignment 2 --> $DIR/dealloc_intrinsic_incorrect_layout.rs:8:5 | LL | intrinsics::const_deallocate(ptr, 4, 2); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC0 has size 4 and alignment 4, but gave size 4 and alignment 2 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_X` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: incorrect layout on deallocation: ALLOC1 has size 4 and alignment 4, but gave size 2 and alignment 4 --> $DIR/dealloc_intrinsic_incorrect_layout.rs:13:5 | LL | intrinsics::const_deallocate(ptr, 2, 4); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC1 has size 4 and alignment 4, but gave size 2 and alignment 4 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_Y` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: incorrect layout on deallocation: ALLOC2 has size 4 and alignment 4, but gave size 3 and alignment 4 --> $DIR/dealloc_intrinsic_incorrect_layout.rs:19:5 | LL | intrinsics::const_deallocate(ptr, 3, 4); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC2 has size 4 and alignment 4, but gave size 3 and alignment 4 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_Z` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: invalid align passed to `const_deallocate`: 3 is not a power of 2 --> $DIR/dealloc_intrinsic_incorrect_layout.rs:25:5 | LL | intrinsics::const_deallocate(ptr, 4, 3); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid align passed to `const_deallocate`: 3 is not a power of 2 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_W` failed here error: aborting due to 4 previous errors diff --git a/tests/ui/consts/const-eval/index-out-of-bounds-never-type.rs b/tests/ui/consts/const-eval/index-out-of-bounds-never-type.rs index 25ffc9cbdba..6777bee050a 100644 --- a/tests/ui/consts/const-eval/index-out-of-bounds-never-type.rs +++ b/tests/ui/consts/const-eval/index-out-of-bounds-never-type.rs @@ -8,7 +8,7 @@ struct PrintName<T>(T); impl<T> PrintName<T> { const VOID: ! = { let x = 0 * std::mem::size_of::<T>(); [][x] }; - //~^ ERROR evaluation of `PrintName::<()>::VOID` failed + //~^ ERROR index out of bounds: the length is 0 but the index is 0 } diff --git a/tests/ui/consts/const-eval/index-out-of-bounds-never-type.stderr b/tests/ui/consts/const-eval/index-out-of-bounds-never-type.stderr index 7facb2d1a5c..7e57e16aa4f 100644 --- a/tests/ui/consts/const-eval/index-out-of-bounds-never-type.stderr +++ b/tests/ui/consts/const-eval/index-out-of-bounds-never-type.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `PrintName::<()>::VOID` failed +error[E0080]: index out of bounds: the length is 0 but the index is 0 --> $DIR/index-out-of-bounds-never-type.rs:10:61 | LL | const VOID: ! = { let x = 0 * std::mem::size_of::<T>(); [][x] }; - | ^^^^^ index out of bounds: the length is 0 but the index is 0 + | ^^^^^ evaluation of `PrintName::<()>::VOID` failed here note: erroneous constant encountered --> $DIR/index-out-of-bounds-never-type.rs:16:13 diff --git a/tests/ui/consts/const-eval/index_out_of_bounds.stderr b/tests/ui/consts/const-eval/index_out_of_bounds.stderr index d8df74fa010..56e340cfebd 100644 --- a/tests/ui/consts/const-eval/index_out_of_bounds.stderr +++ b/tests/ui/consts/const-eval/index_out_of_bounds.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: index out of bounds: the length is 0 but the index is 0 --> $DIR/index_out_of_bounds.rs:1:19 | LL | static FOO: i32 = [][0]; - | ^^^^^ index out of bounds: the length is 0 but the index is 0 + | ^^^^^ evaluation of `FOO` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/issue-43197.rs b/tests/ui/consts/const-eval/issue-43197.rs index 145463f0ae2..778a66facb8 100644 --- a/tests/ui/consts/const-eval/issue-43197.rs +++ b/tests/ui/consts/const-eval/issue-43197.rs @@ -4,8 +4,8 @@ const fn foo(x: u32) -> u32 { fn main() { const X: u32 = 0 - 1; - //~^ ERROR constant + //~^ ERROR overflow const Y: u32 = foo(0 - 1); - //~^ ERROR constant + //~^ ERROR overflow println!("{} {}", X, Y); } diff --git a/tests/ui/consts/const-eval/issue-43197.stderr b/tests/ui/consts/const-eval/issue-43197.stderr index c59f13e4888..c525fd1c13b 100644 --- a/tests/ui/consts/const-eval/issue-43197.stderr +++ b/tests/ui/consts/const-eval/issue-43197.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `0_u32 - 1_u32`, which would overflow --> $DIR/issue-43197.rs:6:20 | LL | const X: u32 = 0 - 1; - | ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow + | ^^^^^ evaluation of `main::X` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `0_u32 - 1_u32`, which would overflow --> $DIR/issue-43197.rs:8:24 | LL | const Y: u32 = foo(0 - 1); - | ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow + | ^^^^^ evaluation of `main::Y` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/issue-44578.rs b/tests/ui/consts/const-eval/issue-44578.rs index 565e1d3825b..ebd54f4079c 100644 --- a/tests/ui/consts/const-eval/issue-44578.rs +++ b/tests/ui/consts/const-eval/issue-44578.rs @@ -11,7 +11,7 @@ enum Bar<A, B> { } impl<A: Foo, B: Foo> Foo for Bar<A, B> { - const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; //~ERROR evaluation of `<Bar<u16, u8> as Foo>::AMT` failed + const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; //~ERROR the length is 1 but the index is 1 } impl Foo for u8 { diff --git a/tests/ui/consts/const-eval/issue-44578.stderr b/tests/ui/consts/const-eval/issue-44578.stderr index 5093cec81c7..fd0b9ae1e17 100644 --- a/tests/ui/consts/const-eval/issue-44578.stderr +++ b/tests/ui/consts/const-eval/issue-44578.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `<Bar<u16, u8> as Foo>::AMT` failed +error[E0080]: index out of bounds: the length is 1 but the index is 1 --> $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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `<Bar<u16, u8> as Foo>::AMT` failed here note: erroneous constant encountered --> $DIR/issue-44578.rs:26:20 diff --git a/tests/ui/consts/const-eval/issue-49296.rs b/tests/ui/consts/const-eval/issue-49296.rs index 917777a32ff..a427b642899 100644 --- a/tests/ui/consts/const-eval/issue-49296.rs +++ b/tests/ui/consts/const-eval/issue-49296.rs @@ -7,7 +7,7 @@ const fn wat(x: u64) -> &'static u64 { } const X: u64 = *wat(42); -//~^ ERROR evaluation of constant value failed +//~^ ERROR dangling fn main() { println!("{}", X); diff --git a/tests/ui/consts/const-eval/issue-49296.stderr b/tests/ui/consts/const-eval/issue-49296.stderr index 485a11d1f3c..9da3e3d6d30 100644 --- a/tests/ui/consts/const-eval/issue-49296.stderr +++ b/tests/ui/consts/const-eval/issue-49296.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: ALLOC0 has been freed, so this pointer is dangling --> $DIR/issue-49296.rs:9:16 | LL | const X: u64 = *wat(42); - | ^^^^^^^^ memory access failed: ALLOC0 has been freed, so this pointer is dangling + | ^^^^^^^^ evaluation of `X` failed here error: aborting due to 1 previous error 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 1f4f217b175..6c0d6cf8b21 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,8 +1,8 @@ -error[E0080]: evaluation of `<A<()> as Foo<()>>::BAR` failed +error[E0080]: index out of bounds: the length is 3 but the index is 42 --> $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 + | ^^^^^^^^^^^^^^^^^ evaluation of `<A<()> as Foo<()>>::BAR` failed here note: erroneous constant encountered --> $DIR/issue-50814-2.rs:21:6 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 f790862aef1..749c9dde1ce 100644 --- a/tests/ui/consts/const-eval/issue-50814-2.normal.stderr +++ b/tests/ui/consts/const-eval/issue-50814-2.normal.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `<A<()> as Foo<()>>::BAR` failed +error[E0080]: index out of bounds: the length is 3 but the index is 42 --> $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 + | ^^^^^^^^^^^^^^^^^ evaluation of `<A<()> as Foo<()>>::BAR` failed here note: erroneous constant encountered --> $DIR/issue-50814-2.rs:21:6 diff --git a/tests/ui/consts/const-eval/issue-50814-2.rs b/tests/ui/consts/const-eval/issue-50814-2.rs index 261dcd3aa4c..1b917a0916d 100644 --- a/tests/ui/consts/const-eval/issue-50814-2.rs +++ b/tests/ui/consts/const-eval/issue-50814-2.rs @@ -14,7 +14,7 @@ trait Foo<T> { struct A<T>(T); impl<T: C> Foo<T> for A<T> { - const BAR: usize = [5, 6, 7][T::BOO]; //~ ERROR evaluation of `<A<()> as Foo<()>>::BAR` failed + const BAR: usize = [5, 6, 7][T::BOO]; //~ ERROR index out of bounds: the length is 3 but the index is 42 } fn foo<T: C>() -> &'static usize { diff --git a/tests/ui/consts/const-eval/issue-50814.rs b/tests/ui/consts/const-eval/issue-50814.rs index 5495fb43bba..011f065ad81 100644 --- a/tests/ui/consts/const-eval/issue-50814.rs +++ b/tests/ui/consts/const-eval/issue-50814.rs @@ -14,8 +14,8 @@ struct Sum<A, B>(A, B); impl<A: Unsigned, B: Unsigned> Unsigned for Sum<A, B> { const MAX: u8 = A::MAX + B::MAX; - //~^ ERROR evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed - //~| ERROR evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed + //~^ ERROR attempt to compute `u8::MAX + u8::MAX`, which would overflow + //~| ERROR attempt to compute `u8::MAX + u8::MAX`, which would overflow } fn foo<T>(_: T) -> &'static u8 { diff --git a/tests/ui/consts/const-eval/issue-50814.stderr b/tests/ui/consts/const-eval/issue-50814.stderr index 5b23c48e450..1287c83ae0f 100644 --- a/tests/ui/consts/const-eval/issue-50814.stderr +++ b/tests/ui/consts/const-eval/issue-50814.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed +error[E0080]: attempt to compute `u8::MAX + u8::MAX`, which would overflow --> $DIR/issue-50814.rs:16:21 | LL | const MAX: u8 = A::MAX + B::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed here note: erroneous constant encountered --> $DIR/issue-50814.rs:22:6 @@ -10,11 +10,11 @@ note: erroneous constant encountered LL | &Sum::<U8, U8>::MAX | ^^^^^^^^^^^^^^^^^^ -error[E0080]: evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed +error[E0080]: attempt to compute `u8::MAX + u8::MAX`, which would overflow --> $DIR/issue-50814.rs:16:21 | LL | const MAX: u8 = A::MAX + B::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed here | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/consts/const-eval/issue-85155.rs b/tests/ui/consts/const-eval/issue-85155.rs index cb5b3a08375..c47101d04c2 100644 --- a/tests/ui/consts/const-eval/issue-85155.rs +++ b/tests/ui/consts/const-eval/issue-85155.rs @@ -20,5 +20,5 @@ fn main() { //~^ NOTE the above error was encountered while instantiating } -//~? ERROR evaluation of `post_monomorphization_error::ValidateConstImm::<2, 0, 1>::VALID` failed +//~? ERROR attempt to divide `1_usize` by zero //~? NOTE erroneous constant encountered diff --git a/tests/ui/consts/const-eval/issue-85155.stderr b/tests/ui/consts/const-eval/issue-85155.stderr index 99836a3fac6..f7777bfac02 100644 --- a/tests/ui/consts/const-eval/issue-85155.stderr +++ b/tests/ui/consts/const-eval/issue-85155.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `post_monomorphization_error::ValidateConstImm::<2, 0, 1>::VALID` failed +error[E0080]: attempt to divide `1_usize` by zero --> $DIR/auxiliary/post_monomorphization_error.rs:7:17 | LL | let _ = 1 / ((IMM >= MIN && IMM <= MAX) as usize); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to divide `1_usize` by zero + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `post_monomorphization_error::ValidateConstImm::<2, 0, 1>::VALID` failed here note: erroneous constant encountered --> $DIR/auxiliary/post_monomorphization_error.rs:19:5 diff --git a/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.rs b/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.rs index 3a932343ddd..12effde1a9b 100644 --- a/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.rs +++ b/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.rs @@ -36,8 +36,7 @@ const OFFSET: () = unsafe { // This needs to compute the field offset, but we don't know the type's alignment, so this // fails. let field = &x.a; - //~^ ERROR: evaluation of constant value failed - //~| NOTE does not have a known offset + //~^ ERROR: does not have a known offset }; fn main() {} diff --git a/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.stderr b/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.stderr index 54d45ee8ffb..d2c1e4fde9c 100644 --- a/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.stderr +++ b/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: `extern type` field does not have a known offset --> $DIR/issue-91827-extern-types-field-offset.rs:38:17 | LL | let field = &x.a; - | ^^^^ `extern type` field does not have a known offset + | ^^^^ evaluation of `OFFSET` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/mod-static-with-const-fn.rs b/tests/ui/consts/const-eval/mod-static-with-const-fn.rs index 7de9d44305d..ce2ecaa2638 100644 --- a/tests/ui/consts/const-eval/mod-static-with-const-fn.rs +++ b/tests/ui/consts/const-eval/mod-static-with-const-fn.rs @@ -12,7 +12,7 @@ static FOO: Foo = Foo(UnsafeCell::new(42)); static BAR: () = unsafe { *FOO.0.get() = 5; - //~^ ERROR could not evaluate static initializer + //~^ ERROR modifying a static's initial value }; fn main() { diff --git a/tests/ui/consts/const-eval/mod-static-with-const-fn.stderr b/tests/ui/consts/const-eval/mod-static-with-const-fn.stderr index 47bfc235a1a..f8a6fa24a36 100644 --- a/tests/ui/consts/const-eval/mod-static-with-const-fn.stderr +++ b/tests/ui/consts/const-eval/mod-static-with-const-fn.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: modifying a static's initial value from another static's initializer --> $DIR/mod-static-with-const-fn.rs:14:5 | LL | *FOO.0.get() = 5; - | ^^^^^^^^^^^^^^^^ modifying a static's initial value from another static's initializer + | ^^^^^^^^^^^^^^^^ evaluation of `BAR` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/nonnull_as_ref_ub.rs b/tests/ui/consts/const-eval/nonnull_as_ref_ub.rs index 19ab5239986..908833e6514 100644 --- a/tests/ui/consts/const-eval/nonnull_as_ref_ub.rs +++ b/tests/ui/consts/const-eval/nonnull_as_ref_ub.rs @@ -1,6 +1,6 @@ use std::ptr::NonNull; const NON_NULL: NonNull<u8> = unsafe { NonNull::dangling() }; -const _: () = assert!(42 == *unsafe { NON_NULL.as_ref() }); //~ERROR: evaluation of constant value failed +const _: () = assert!(42 == *unsafe { NON_NULL.as_ref() }); //~ERROR: dangling pointer (it has no provenance) fn main() {} 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 1996cd2721e..8dbb05c1572 100644 --- a/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr +++ b/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) --> $DIR/nonnull_as_ref_ub.rs:4:29 | LL | const _: () = assert!(42 == *unsafe { NON_NULL.as_ref() }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here 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 79b5dafaf15..a0a5ba36bfe 100644 --- a/tests/ui/consts/const-eval/panic-assoc-never-type.rs +++ b/tests/ui/consts/const-eval/panic-assoc-never-type.rs @@ -8,7 +8,7 @@ struct PrintName; impl PrintName { const VOID: ! = panic!(); - //~^ ERROR evaluation of constant value failed + //~^ ERROR explicit panic } fn main() { 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 03413f46b20..d3a29314928 100644 --- a/tests/ui/consts/const-eval/panic-assoc-never-type.stderr +++ b/tests/ui/consts/const-eval/panic-assoc-never-type.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/panic-assoc-never-type.rs:10:21 | LL | const VOID: ! = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `PrintName::VOID` failed here note: erroneous constant encountered --> $DIR/panic-assoc-never-type.rs:15:13 diff --git a/tests/ui/consts/const-eval/panic-never-type.rs b/tests/ui/consts/const-eval/panic-never-type.rs index a9e9026d9bc..d9b46e70b35 100644 --- a/tests/ui/consts/const-eval/panic-never-type.rs +++ b/tests/ui/consts/const-eval/panic-never-type.rs @@ -2,7 +2,7 @@ #![feature(never_type)] const VOID: ! = panic!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR explicit panic fn main() { let _ = VOID; diff --git a/tests/ui/consts/const-eval/panic-never-type.stderr b/tests/ui/consts/const-eval/panic-never-type.stderr index 1d9bba9aea2..317be64205e 100644 --- a/tests/ui/consts/const-eval/panic-never-type.stderr +++ b/tests/ui/consts/const-eval/panic-never-type.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/panic-never-type.rs:4:17 | LL | const VOID: ! = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `VOID` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/parse_ints.rs b/tests/ui/consts/const-eval/parse_ints.rs index 309b7ee5d27..409fae9e51d 100644 --- a/tests/ui/consts/const-eval/parse_ints.rs +++ b/tests/ui/consts/const-eval/parse_ints.rs @@ -2,7 +2,7 @@ const _OK: () = match i32::from_str_radix("-1234", 10) { Ok(x) => assert!(x == -1234), Err(_) => panic!(), }; -const _TOO_LOW: () = { u64::from_str_radix("12345ABCD", 1); }; //~ ERROR evaluation of constant value failed -const _TOO_HIGH: () = { u64::from_str_radix("12345ABCD", 37); }; //~ ERROR evaluation of constant value failed +const _TOO_LOW: () = { u64::from_str_radix("12345ABCD", 1); }; //~ ERROR radix must lie in the range `[2, 36]` +const _TOO_HIGH: () = { u64::from_str_radix("12345ABCD", 37); }; //~ ERROR radix must lie in the range `[2, 36]` fn main () {} diff --git a/tests/ui/consts/const-eval/parse_ints.stderr b/tests/ui/consts/const-eval/parse_ints.stderr index 7a855bb9e5c..7e529c03725 100644 --- a/tests/ui/consts/const-eval/parse_ints.stderr +++ b/tests/ui/consts/const-eval/parse_ints.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: from_ascii_radix: radix must lie in the range `[2, 36]` --> $DIR/parse_ints.rs:5:24 | LL | const _TOO_LOW: () = { u64::from_str_radix("12345ABCD", 1); }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: from_ascii_radix: radix must lie in the range `[2, 36]` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_TOO_LOW` failed inside this call | note: inside `core::num::<impl u64>::from_str_radix` --> $SRC_DIR/core/src/num/mod.rs:LL:COL @@ -10,11 +10,11 @@ note: inside `core::num::<impl u64>::from_ascii_radix` --> $SRC_DIR/core/src/num/mod.rs:LL:COL = note: this error originates in the macro `from_str_int_impl` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: from_ascii_radix: radix must lie in the range `[2, 36]` --> $DIR/parse_ints.rs:6:25 | LL | const _TOO_HIGH: () = { u64::from_str_radix("12345ABCD", 37); }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: from_ascii_radix: radix must lie in the range `[2, 36]` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_TOO_HIGH` failed inside this call | note: inside `core::num::<impl u64>::from_str_radix` --> $SRC_DIR/core/src/num/mod.rs:LL:COL diff --git a/tests/ui/consts/const-eval/partial_ptr_overwrite.rs b/tests/ui/consts/const-eval/partial_ptr_overwrite.rs index 9438de5e3fe..bd97bec0f71 100644 --- a/tests/ui/consts/const-eval/partial_ptr_overwrite.rs +++ b/tests/ui/consts/const-eval/partial_ptr_overwrite.rs @@ -4,8 +4,7 @@ const PARTIAL_OVERWRITE: () = { let mut p = &42; unsafe { let ptr: *mut _ = &mut p; - *(ptr as *mut u8) = 123; //~ ERROR constant - //~| NOTE unable to overwrite parts of a pointer + *(ptr as *mut u8) = 123; //~ ERROR unable to overwrite parts of a pointer } let x = *p; }; diff --git a/tests/ui/consts/const-eval/partial_ptr_overwrite.stderr b/tests/ui/consts/const-eval/partial_ptr_overwrite.stderr index 1443d353848..6ef1cfd35c8 100644 --- a/tests/ui/consts/const-eval/partial_ptr_overwrite.stderr +++ b/tests/ui/consts/const-eval/partial_ptr_overwrite.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: unable to overwrite parts of a pointer in memory at ALLOC0 --> $DIR/partial_ptr_overwrite.rs:7:9 | LL | *(ptr as *mut u8) = 123; - | ^^^^^^^^^^^^^^^^^^^^^^^ unable to overwrite parts of a pointer in memory at ALLOC0 + | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `PARTIAL_OVERWRITE` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported diff --git a/tests/ui/consts/const-eval/ptr-to-int-transmute-in-consts-issue-87525.rs b/tests/ui/consts/const-eval/ptr-to-int-transmute-in-consts-issue-87525.rs index 19c78f019aa..5fab075785a 100644 --- a/tests/ui/consts/const-eval/ptr-to-int-transmute-in-consts-issue-87525.rs +++ b/tests/ui/consts/const-eval/ptr-to-int-transmute-in-consts-issue-87525.rs @@ -1,7 +1,9 @@ +#![deny(ptr_to_integer_transmute_in_consts)] + const fn foo(ptr: *const u8) -> usize { unsafe { std::mem::transmute(ptr) - //~^ WARN pointers cannot be transmuted to integers + //~^ ERROR pointers cannot be transmuted to integers } } @@ -11,7 +13,7 @@ trait Human { let ptr: *const usize = &value; unsafe { std::mem::transmute(ptr) - //~^ WARN pointers cannot be transmuted to integers + //~^ ERROR pointers cannot be transmuted to integers } }; @@ -28,7 +30,7 @@ impl<T> Type<T> { let ptr: *const usize = &value; unsafe { std::mem::transmute(ptr) - //~^ WARN pointers cannot be transmuted to integers + //~^ ERROR pointers cannot be transmuted to integers } }; @@ -38,9 +40,7 @@ impl<T> Type<T> { } fn control(ptr: *const u8) -> usize { - unsafe { - std::mem::transmute(ptr) - } + unsafe { std::mem::transmute(ptr) } } struct ControlStruct; @@ -49,22 +49,15 @@ impl ControlStruct { fn new() -> usize { let value = 10; let ptr: *const i32 = &value; - unsafe { - std::mem::transmute(ptr) - } + unsafe { std::mem::transmute(ptr) } } } - const fn zoom(ptr: *const u8) -> usize { unsafe { std::mem::transmute(ptr) - //~^ WARN pointers cannot be transmuted to integers + //~^ ERROR pointers cannot be transmuted to integers } } -fn main() { - const a: u8 = 10; - const value: usize = zoom(&a); - //~^ ERROR evaluation of constant value failed -} +fn main() {} diff --git a/tests/ui/consts/const-eval/ptr-to-int-transmute-in-consts-issue-87525.stderr b/tests/ui/consts/const-eval/ptr-to-int-transmute-in-consts-issue-87525.stderr index ca6ad9408ab..2a9d9b5cb96 100644 --- a/tests/ui/consts/const-eval/ptr-to-int-transmute-in-consts-issue-87525.stderr +++ b/tests/ui/consts/const-eval/ptr-to-int-transmute-in-consts-issue-87525.stderr @@ -1,5 +1,5 @@ -warning: pointers cannot be transmuted to integers during const eval - --> $DIR/ptr-to-int-transmute-in-consts-issue-87525.rs:61:9 +error: pointers cannot be transmuted to integers during const eval + --> $DIR/ptr-to-int-transmute-in-consts-issue-87525.rs:5:9 | LL | std::mem::transmute(ptr) | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,29 +7,24 @@ LL | std::mem::transmute(ptr) = note: at compile-time, pointers do not have an integer value = note: avoiding this restriction via `union` or raw pointers leads to compile-time undefined behavior = help: for more information, see https://doc.rust-lang.org/std/mem/fn.transmute.html - = note: `#[warn(ptr_to_integer_transmute_in_consts)]` on by default - -error[E0080]: evaluation of constant value failed - --> $DIR/ptr-to-int-transmute-in-consts-issue-87525.rs:68:26 - | -LL | const value: usize = zoom(&a); - | ^^^^^^^^ unable to turn pointer into integer +note: the lint level is defined here + --> $DIR/ptr-to-int-transmute-in-consts-issue-87525.rs:1:9 | - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported +LL | #![deny(ptr_to_integer_transmute_in_consts)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: pointers cannot be transmuted to integers during const eval - --> $DIR/ptr-to-int-transmute-in-consts-issue-87525.rs:3:9 +error: pointers cannot be transmuted to integers during const eval + --> $DIR/ptr-to-int-transmute-in-consts-issue-87525.rs:15:13 | -LL | std::mem::transmute(ptr) - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | std::mem::transmute(ptr) + | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: at compile-time, pointers do not have an integer value = note: avoiding this restriction via `union` or raw pointers leads to compile-time undefined behavior = help: for more information, see https://doc.rust-lang.org/std/mem/fn.transmute.html -warning: pointers cannot be transmuted to integers during const eval - --> $DIR/ptr-to-int-transmute-in-consts-issue-87525.rs:13:13 +error: pointers cannot be transmuted to integers during const eval + --> $DIR/ptr-to-int-transmute-in-consts-issue-87525.rs:32:13 | LL | std::mem::transmute(ptr) | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -38,16 +33,15 @@ LL | std::mem::transmute(ptr) = note: avoiding this restriction via `union` or raw pointers leads to compile-time undefined behavior = help: for more information, see https://doc.rust-lang.org/std/mem/fn.transmute.html -warning: pointers cannot be transmuted to integers during const eval - --> $DIR/ptr-to-int-transmute-in-consts-issue-87525.rs:30:13 +error: pointers cannot be transmuted to integers during const eval + --> $DIR/ptr-to-int-transmute-in-consts-issue-87525.rs:58:9 | -LL | std::mem::transmute(ptr) - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | std::mem::transmute(ptr) + | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: at compile-time, pointers do not have an integer value = note: avoiding this restriction via `union` or raw pointers leads to compile-time undefined behavior = help: for more information, see https://doc.rust-lang.org/std/mem/fn.transmute.html -error: aborting due to 1 previous error; 4 warnings emitted +error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr index 120a08acc33..36183e28921 100644 --- a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr @@ -1,340 +1,340 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<enum-tag>: encountered 0x00000001, but expected a valid enum tag --> $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 + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 01 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<enum-tag>: encountered 0x00000000, but expected a valid enum tag --> $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 + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 00 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant --> $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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 01 │ . } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant --> $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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 03 │ . } -error[E0080]: it is undefined behavior to use this value +error[E0080]: 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`) --> $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`) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { 78 00 00 00 ff ff ff ff │ x....... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 00 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 00 │ . } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 00 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 42, but expected something in the range 10..=30 --> $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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 2a 00 00 00 │ *... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 20, but expected something less or equal to 10, or greater or equal to 30 --> $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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 14 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { 00 00 00 00 ╾ALLOC_ID╼ │ ....╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:86:1 +error[E0080]: constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) + --> $DIR/raw-bytes.rs:85:1 | LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { ╾ALLOC_ID╼ │ ╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:90:1 +error[E0080]: constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) + --> $DIR/raw-bytes.rs:88: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) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { ╾ALLOC_ID╼ │ ╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:94:1 +error[E0080]: constructing invalid value: encountered a null reference + --> $DIR/raw-bytes.rs:91:1 | LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference + | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 00 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:97:1 +error[E0080]: constructing invalid value: encountered a null box + --> $DIR/raw-bytes.rs:94:1 | LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null box + | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 00 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:100:1 +error[E0080]: constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance) + --> $DIR/raw-bytes.rs:97:1 | LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 39 05 00 00 │ 9... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:103:1 +error[E0080]: constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance) + --> $DIR/raw-bytes.rs:100:1 | LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 39 05 00 00 │ 9... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:106:1 +error[E0080]: constructing invalid value: encountered null pointer, but expected a function pointer + --> $DIR/raw-bytes.rs:103:1 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 00 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:108:1 +error[E0080]: constructing invalid value: encountered 0xd[noalloc], but expected a function pointer + --> $DIR/raw-bytes.rs:105:1 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 0d 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:110:1 +error[E0080]: constructing invalid value: encountered ALLOC3<imm>, but expected a function pointer + --> $DIR/raw-bytes.rs:107:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC3<imm>, but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { ╾ALLOC_ID╼ │ ╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:116:1 +error[E0080]: constructing invalid value: encountered a reference pointing to uninhabited type Bar + --> $DIR/raw-bytes.rs:113:1 | LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type Bar + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 01 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:141:1 +error[E0080]: constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + --> $DIR/raw-bytes.rs:137: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) + | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ e7 03 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:143:1 +error[E0080]: constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object + --> $DIR/raw-bytes.rs:139: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ ff ff ff ff │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:145:1 +error[E0080]: constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + --> $DIR/raw-bytes.rs:141: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ ff ff ff ff │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:148:1 +error[E0080]: constructing invalid value at .<deref>: encountered uninitialized memory, but expected a string + --> $DIR/raw-bytes.rs:144: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 + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:150:1 +error[E0080]: constructing invalid value at .<deref>.0: encountered uninitialized memory, but expected a string + --> $DIR/raw-bytes.rs:146: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:152:1 +error[E0080]: constructing invalid value at .<deref>.0: encountered a pointer, but expected a string + --> $DIR/raw-bytes.rs:148:1 | LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered a pointer, but expected a string + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼.... } - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = 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:156:1 +error[E0080]: constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + --> $DIR/raw-bytes.rs:152: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) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ e7 03 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:158:1 +error[E0080]: constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + --> $DIR/raw-bytes.rs:154: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ ff ff ff 7f │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:161:1 +error[E0080]: constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation) + --> $DIR/raw-bytes.rs:157: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) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ e7 03 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:164:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x03, but expected a boolean + --> $DIR/raw-bytes.rs:160:1 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { @@ -342,16 +342,16 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:164:40 + --> $DIR/raw-bytes.rs:160: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:170:1 +error[E0080]: constructing invalid value at .<deref>.0: encountered 0x03, but expected a boolean + --> $DIR/raw-bytes.rs:164: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { @@ -359,16 +359,16 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3 } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:170:42 + --> $DIR/raw-bytes.rs:164: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:174:1 +error[E0080]: constructing invalid value at .<deref>.1[0]: encountered 0x03, but expected a boolean + --> $DIR/raw-bytes.rs:167: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { @@ -376,196 +376,196 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:174:42 + --> $DIR/raw-bytes.rs:167: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:179:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC17<imm>, but expected a vtable pointer + --> $DIR/raw-bytes.rs:171: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:183:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC19<imm>, but expected a vtable pointer + --> $DIR/raw-bytes.rs:174: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:187:1 +error[E0080]: constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer + --> $DIR/raw-bytes.rs:177: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:190:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC22<imm>, but expected a vtable pointer + --> $DIR/raw-bytes.rs:179: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:194:1 +error[E0080]: constructing invalid value at .<deref>.<dyn-downcast>: encountered 0x03, but expected a boolean + --> $DIR/raw-bytes.rs:182: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:198:1 +error[E0080]: constructing invalid value: encountered null pointer, but expected a vtable pointer + --> $DIR/raw-bytes.rs:185: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 00 00 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:201:1 +error[E0080]: constructing invalid value: encountered ALLOC27<imm>, but expected a vtable pointer + --> $DIR/raw-bytes.rs:187: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:206:1 +error[E0080]: constructing invalid value: encountered a reference pointing to uninhabited type [!; 1] + --> $DIR/raw-bytes.rs:191:1 | LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; - | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type [!; 1] + | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 01 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:207:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered a value of the never type `!` + --> $DIR/raw-bytes.rs:192:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; - | ^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a value of the never type `!` + | ^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { 01 00 00 00 01 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:208:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered a value of the never type `!` + --> $DIR/raw-bytes.rs:193:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; - | ^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a value of the never type `!` + | ^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { 01 00 00 00 2a 00 00 00 │ ....*... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:212:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer + --> $DIR/raw-bytes.rs:196: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 + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:215:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer + --> $DIR/raw-bytes.rs:199: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 + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼.... } - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = 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:218:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean + --> $DIR/raw-bytes.rs:202: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 + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:222:1 +error[E0080]: constructing invalid value at .<deref>[1]: encountered uninitialized memory, but expected an integer + --> $DIR/raw-bytes.rs:206:1 | LL | pub static S7: &[u16] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[1]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID+0x2╼ 04 00 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:229:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer + --> $DIR/raw-bytes.rs:213:1 | LL | pub static R4: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼.... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:234:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer + --> $DIR/raw-bytes.rs:218:1 | LL | pub static R5: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼.... } - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = 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:239:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean + --> $DIR/raw-bytes.rs:223:1 | LL | pub static R6: &[bool] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { diff --git a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr index d54ad7c8546..c53326534fd 100644 --- a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr @@ -1,340 +1,340 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<enum-tag>: encountered 0x0000000000000001, but expected a valid enum tag --> $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 + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 01 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<enum-tag>: encountered 0x0000000000000000, but expected a valid enum tag --> $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 + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 00 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant --> $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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 01 │ . } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant --> $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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 03 │ . } -error[E0080]: it is undefined behavior to use this value +error[E0080]: 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`) --> $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`) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { 78 00 00 00 ff ff ff ff │ x....... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 00 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 00 │ . } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 00 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 42, but expected something in the range 10..=30 --> $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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 2a 00 00 00 │ *... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 20, but expected something less or equal to 10, or greater or equal to 30 --> $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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { 14 00 00 00 │ .... } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { 00 00 00 00 00 00 00 00 ╾ALLOC_ID╼ │ ........╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:86:1 +error[E0080]: constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) + --> $DIR/raw-bytes.rs:85:1 | LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { ╾ALLOC_ID╼ │ ╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:90:1 +error[E0080]: constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) + --> $DIR/raw-bytes.rs:88: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) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { ╾ALLOC_ID╼ │ ╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:94:1 +error[E0080]: constructing invalid value: encountered a null reference + --> $DIR/raw-bytes.rs:91:1 | LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference + | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 00 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:97:1 +error[E0080]: constructing invalid value: encountered a null box + --> $DIR/raw-bytes.rs:94:1 | LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null box + | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 00 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:100:1 +error[E0080]: constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance) + --> $DIR/raw-bytes.rs:97:1 | LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 39 05 00 00 00 00 00 00 │ 9....... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:103:1 +error[E0080]: constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance) + --> $DIR/raw-bytes.rs:100:1 | LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 39 05 00 00 00 00 00 00 │ 9....... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:106:1 +error[E0080]: constructing invalid value: encountered null pointer, but expected a function pointer + --> $DIR/raw-bytes.rs:103:1 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 00 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:108:1 +error[E0080]: constructing invalid value: encountered 0xd[noalloc], but expected a function pointer + --> $DIR/raw-bytes.rs:105:1 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 0d 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:110:1 +error[E0080]: constructing invalid value: encountered ALLOC3<imm>, but expected a function pointer + --> $DIR/raw-bytes.rs:107:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC3<imm>, but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { ╾ALLOC_ID╼ │ ╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:116:1 +error[E0080]: constructing invalid value: encountered a reference pointing to uninhabited type Bar + --> $DIR/raw-bytes.rs:113:1 | LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type Bar + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 01 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:141:1 +error[E0080]: constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + --> $DIR/raw-bytes.rs:137: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) + | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:143:1 +error[E0080]: constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object + --> $DIR/raw-bytes.rs:139: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ ff ff ff ff ff ff ff ff │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:145:1 +error[E0080]: constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + --> $DIR/raw-bytes.rs:141: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ ff ff ff ff ff ff ff ff │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:148:1 +error[E0080]: constructing invalid value at .<deref>: encountered uninitialized memory, but expected a string + --> $DIR/raw-bytes.rs:144: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 + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:150:1 +error[E0080]: constructing invalid value at .<deref>.0: encountered uninitialized memory, but expected a string + --> $DIR/raw-bytes.rs:146: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:152:1 +error[E0080]: constructing invalid value at .<deref>.0: encountered a pointer, but expected a string + --> $DIR/raw-bytes.rs:148:1 | LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered a pointer, but expected a string + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = 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:156:1 +error[E0080]: constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + --> $DIR/raw-bytes.rs:152: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) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:158:1 +error[E0080]: constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + --> $DIR/raw-bytes.rs:154: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ ff ff ff ff ff ff ff 7f │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:161:1 +error[E0080]: constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation) + --> $DIR/raw-bytes.rs:157: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) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:164:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x03, but expected a boolean + --> $DIR/raw-bytes.rs:160:1 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { @@ -342,16 +342,16 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:164:40 + --> $DIR/raw-bytes.rs:160: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:170:1 +error[E0080]: constructing invalid value at .<deref>.0: encountered 0x03, but expected a boolean + --> $DIR/raw-bytes.rs:164: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { @@ -359,16 +359,16 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3 } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:170:42 + --> $DIR/raw-bytes.rs:164: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:174:1 +error[E0080]: constructing invalid value at .<deref>.1[0]: encountered 0x03, but expected a boolean + --> $DIR/raw-bytes.rs:167: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { @@ -376,196 +376,196 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran } note: erroneous constant encountered - --> $DIR/raw-bytes.rs:174:42 + --> $DIR/raw-bytes.rs:167: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:179:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC17<imm>, but expected a vtable pointer + --> $DIR/raw-bytes.rs:171: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:183:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC19<imm>, but expected a vtable pointer + --> $DIR/raw-bytes.rs:174: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:187:1 +error[E0080]: constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer + --> $DIR/raw-bytes.rs:177: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:190:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC22<imm>, but expected a vtable pointer + --> $DIR/raw-bytes.rs:179: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:194:1 +error[E0080]: constructing invalid value at .<deref>.<dyn-downcast>: encountered 0x03, but expected a boolean + --> $DIR/raw-bytes.rs:182: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:198:1 +error[E0080]: constructing invalid value: encountered null pointer, but expected a vtable pointer + --> $DIR/raw-bytes.rs:185: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 00 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:201:1 +error[E0080]: constructing invalid value: encountered ALLOC27<imm>, but expected a vtable pointer + --> $DIR/raw-bytes.rs:187: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:206:1 +error[E0080]: constructing invalid value: encountered a reference pointing to uninhabited type [!; 1] + --> $DIR/raw-bytes.rs:191:1 | LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; - | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type [!; 1] + | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { 01 00 00 00 00 00 00 00 │ ........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:207:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered a value of the never type `!` + --> $DIR/raw-bytes.rs:192:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; - | ^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a value of the never type `!` + | ^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 │ ................ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:208:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered a value of the never type `!` + --> $DIR/raw-bytes.rs:193:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; - | ^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a value of the never type `!` + | ^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { 01 00 00 00 00 00 00 00 2a 00 00 00 00 00 00 00 │ ........*....... } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:212:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer + --> $DIR/raw-bytes.rs:196: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 + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:215:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer + --> $DIR/raw-bytes.rs:199: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 + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 08 00 00 00 00 00 00 00 │ ╾──────╼........ } - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = 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:218:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean + --> $DIR/raw-bytes.rs:202: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 + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:222:1 +error[E0080]: constructing invalid value at .<deref>[1]: encountered uninitialized memory, but expected an integer + --> $DIR/raw-bytes.rs:206:1 | LL | pub static S7: &[u16] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[1]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID+0x2╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:229:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer + --> $DIR/raw-bytes.rs:213:1 | LL | pub static R4: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/raw-bytes.rs:234:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer + --> $DIR/raw-bytes.rs:218:1 | LL | pub static R5: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 08 00 00 00 00 00 00 00 │ ╾──────╼........ } - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = 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:239:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean + --> $DIR/raw-bytes.rs:223:1 | LL | pub static R6: &[bool] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { diff --git a/tests/ui/consts/const-eval/raw-bytes.rs b/tests/ui/consts/const-eval/raw-bytes.rs index 1a585d55a5f..58ae763e017 100644 --- a/tests/ui/consts/const-eval/raw-bytes.rs +++ b/tests/ui/consts/const-eval/raw-bytes.rs @@ -21,7 +21,7 @@ enum Enum { A = 0, } const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; -//~^ ERROR is undefined behavior +//~^ ERROR constructing invalid value #[repr(usize)] #[derive(Copy, Clone)] @@ -29,7 +29,7 @@ enum Enum2 { A = 2, } const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; -//~^ ERROR is undefined behavior +//~^ ERROR constructing invalid value #[derive(Copy, Clone)] enum Never {} @@ -43,79 +43,75 @@ enum UninhDiscriminant { D(Never), } const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; -//~^ ERROR is undefined behavior +//~^ ERROR constructing invalid value const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; -//~^ ERROR is undefined behavior +//~^ ERROR constructing invalid value // Invalid enum field content (mostly to test printing of paths for enum tuple // variants and tuples). // Need to create something which does not clash with enum layout optimizations. const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); -//~^ ERROR is undefined behavior +//~^ ERROR constructing invalid value // # Bad pointers and references const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value #[rustc_layout_scalar_valid_range_start(10)] #[rustc_layout_scalar_valid_range_end(30)] struct RestrictedRange1(u32); const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value #[rustc_layout_scalar_valid_range_start(30)] #[rustc_layout_scalar_valid_range_end(10)] struct RestrictedRange2(u32); const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const NULL_FAT_PTR: NonNull<dyn Send> = unsafe { -//~^ ERROR it is undefined behavior to use this value + //~^ ERROR constructing invalid value let x: &dyn Send = &42; let meta = std::ptr::metadata(x); mem::transmute((0_usize, meta)) }; - const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) +//~^ ERROR 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 -//~| NOTE constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) +//~^ ERROR 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 +//~^ ERROR constructing invalid value const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value #[derive(Copy, Clone)] enum Bar {} const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; -//~^ ERROR it is undefined behavior to use this value - +//~^ ERROR constructing invalid value /// A newtype wrapper to prevent MIR generation from inserting reborrows that would affect the error /// message. @@ -139,105 +135,93 @@ struct MySlice<T: ?Sized>(bool, T); type MySliceBool = MySlice<[bool]>; const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: constructing invalid value // # slice const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value // bad slice box: length too big const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR constructing invalid value // bad data *inside* the slice const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constant - +//~^ ERROR encountered 0x03, but expected a boolean // 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 -//~| NOTE constant +//~^ ERROR encountered 0x03, but expected a boolean // 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 -//~| NOTE constant +//~^ ERROR encountered 0x03, but expected a boolean // 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 -//~| NOTE expected a vtable +//~^ ERROR 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 -//~| NOTE expected a vtable +//~^ ERROR 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 -//~| NOTE expected a vtable +//~^ ERROR 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 -//~| NOTE expected a vtable +//~^ ERROR 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 -//~| NOTE expected a boolean +//~^ ERROR 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 -//~| NOTE null pointer +//~^ ERROR 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 -//~| NOTE vtable +//~^ ERROR vtable // Uninhabited types -const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR undefined behavior -const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR undefined behavior -const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; //~ ERROR undefined behavior - +const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR constructing invalid value +const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR constructing invalid value +const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; //~ ERROR constructing invalid value // Reading uninitialized data pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: constructing invalid value // Reinterpret pointers as integers (UB in CTFE.) pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) }; -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: constructing invalid value // Layout mismatch pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: constructing invalid value // Reading padding is not ok pub static S7: &[u16] = unsafe { - //~^ ERROR: it is undefined behavior to use this value + //~^ ERROR: constructing invalid value let ptr = (&D2 as *const Struct as *const u16).add(1); from_raw_parts(ptr, 4) }; pub static R4: &[u8] = unsafe { - //~^ ERROR: it is undefined behavior to use this value + //~^ ERROR: constructing invalid value let ptr = (&D1) as *const mem::MaybeUninit<&u32> as *const u8; from_ptr_range(ptr..ptr.add(1)) }; pub static R5: &[u8] = unsafe { - //~^ ERROR: it is undefined behavior to use this value + //~^ ERROR: constructing invalid value let ptr = &D3 as *const &u32; from_ptr_range(ptr.cast()..ptr.add(1).cast()) }; pub static R6: &[bool] = unsafe { - //~^ ERROR: it is undefined behavior to use this value + //~^ ERROR: constructing invalid value let ptr = &D0 as *const u32 as *const bool; from_ptr_range(ptr..ptr.add(4)) }; diff --git a/tests/ui/consts/const-eval/raw-pointer-ub.rs b/tests/ui/consts/const-eval/raw-pointer-ub.rs index 13a95f9b78f..df7bc2fe4fb 100644 --- a/tests/ui/consts/const-eval/raw-pointer-ub.rs +++ b/tests/ui/consts/const-eval/raw-pointer-ub.rs @@ -1,15 +1,15 @@ const MISALIGNED_LOAD: () = unsafe { let mem = [0u32; 8]; let ptr = mem.as_ptr().byte_add(1); - let _val = *ptr; //~ERROR: evaluation of constant value failed - //~^NOTE: based on pointer with alignment 1, but alignment 4 is required + let _val = *ptr; //~NOTE: failed here + //~^ERROR: based on pointer with alignment 1, but alignment 4 is required }; const MISALIGNED_STORE: () = unsafe { let mut mem = [0u32; 8]; let ptr = mem.as_mut_ptr().byte_add(1); - *ptr = 0; //~ERROR: evaluation of constant value failed - //~^NOTE: based on pointer with alignment 1, but alignment 4 is required + *ptr = 0; //~NOTE: failed here + //~^ERROR: based on pointer with alignment 1, but alignment 4 is required }; const MISALIGNED_COPY: () = unsafe { @@ -17,10 +17,9 @@ const MISALIGNED_COPY: () = unsafe { let y = x.as_ptr().cast::<u32>(); let mut z = 123; y.copy_to_nonoverlapping(&mut z, 1); - //~^ ERROR evaluation of constant value failed - //~| NOTE inside `std::ptr::const_ptr - //~| NOTE inside `copy_nonoverlapping::<u32>` - //~| NOTE accessing memory with alignment 1, but alignment 4 is required + //~^ NOTE failed inside this call + //~| NOTE inside `std::ptr::copy_nonoverlapping::<u32>` + //~| ERROR accessing memory with alignment 1, but alignment 4 is required // The actual error points into the implementation of `copy_to_nonoverlapping`. }; @@ -31,15 +30,15 @@ const MISALIGNED_FIELD: () = unsafe { let mem = [0f32; 8]; let ptr = mem.as_ptr().cast::<Aligned>(); // Accessing an f32 field but we still require the alignment of the pointer type. - let _val = (*ptr).0; //~ERROR: evaluation of constant value failed - //~^NOTE: based on pointer with alignment 4, but alignment 16 is required + let _val = (*ptr).0; //~NOTE: failed here + //~^ERROR: based on pointer with alignment 4, but alignment 16 is required }; const OOB: () = unsafe { let mem = [0u32; 1]; let ptr = mem.as_ptr().cast::<u64>(); - let _val = *ptr; //~ERROR: evaluation of constant value failed - //~^NOTE: is only 4 bytes from the end of the allocation + let _val = *ptr; //~NOTE: failed here + //~^ERROR: 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 ed5793c84c5..00af20a722d 100644 --- a/tests/ui/consts/const-eval/raw-pointer-ub.stderr +++ b/tests/ui/consts/const-eval/raw-pointer-ub.stderr @@ -1,37 +1,35 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: accessing memory based on pointer with alignment 1, but alignment 4 is required --> $DIR/raw-pointer-ub.rs:4:16 | LL | let _val = *ptr; - | ^^^^ accessing memory based on pointer with alignment 1, but alignment 4 is required + | ^^^^ evaluation of `MISALIGNED_LOAD` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: accessing memory based on pointer with alignment 1, but alignment 4 is required --> $DIR/raw-pointer-ub.rs:11:5 | LL | *ptr = 0; - | ^^^^^^^^ accessing memory based on pointer with alignment 1, but alignment 4 is required + | ^^^^^^^^ evaluation of `MISALIGNED_STORE` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: accessing memory with alignment 1, but alignment 4 is required --> $DIR/raw-pointer-ub.rs:19:5 | LL | y.copy_to_nonoverlapping(&mut z, 1); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ accessing memory with alignment 1, but alignment 4 is required + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `MISALIGNED_COPY` failed inside this call | -note: inside `std::ptr::const_ptr::<impl *const u32>::copy_to_nonoverlapping` - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -note: inside `copy_nonoverlapping::<u32>` - --> $SRC_DIR/core/src/intrinsics/mod.rs:LL:COL +note: inside `std::ptr::copy_nonoverlapping::<u32>` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -error[E0080]: evaluation of constant value failed - --> $DIR/raw-pointer-ub.rs:34:16 +error[E0080]: accessing memory based on pointer with alignment 4, but alignment 16 is required + --> $DIR/raw-pointer-ub.rs:33:16 | LL | let _val = (*ptr).0; - | ^^^^^^^^ accessing memory based on pointer with alignment 4, but alignment 16 is required + | ^^^^^^^^ evaluation of `MISALIGNED_FIELD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/raw-pointer-ub.rs:41:16 +error[E0080]: memory access failed: attempting to access 8 bytes, but got ALLOC0 which is only 4 bytes from the end of the allocation + --> $DIR/raw-pointer-ub.rs:40:16 | LL | let _val = *ptr; - | ^^^^ memory access failed: attempting to access 8 bytes, but got ALLOC0 which is only 4 bytes from the end of the allocation + | ^^^^ evaluation of `OOB` failed here error: aborting due to 5 previous errors diff --git a/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr b/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr index 18935626af1..e435a1ed7ec 100644 --- a/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr +++ b/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/ref_to_int_match.rs:24:27 | LL | const BAR: Int = unsafe { Foo { r: &42 }.f }; - | ^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^ evaluation of `BAR` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported diff --git a/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr b/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr index 18935626af1..e435a1ed7ec 100644 --- a/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr +++ b/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/ref_to_int_match.rs:24:27 | LL | const BAR: Int = unsafe { Foo { r: &42 }.f }; - | ^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^ evaluation of `BAR` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported diff --git a/tests/ui/consts/const-eval/ref_to_int_match.rs b/tests/ui/consts/const-eval/ref_to_int_match.rs index be9420e0215..062df685f74 100644 --- a/tests/ui/consts/const-eval/ref_to_int_match.rs +++ b/tests/ui/consts/const-eval/ref_to_int_match.rs @@ -3,9 +3,9 @@ fn main() { let n: Int = 40; match n { - 0..=10 => {}, - 10..=BAR => {}, // ok, `const` error already emitted - _ => {}, + 0..=10 => {} + 10..=BAR => {} // ok, `const` error already emitted + _ => {} } } @@ -15,11 +15,11 @@ union Foo { r: &'static u32, } -#[cfg(target_pointer_width="64")] +#[cfg(target_pointer_width = "64")] type Int = u64; -#[cfg(target_pointer_width="32")] +#[cfg(target_pointer_width = "32")] type Int = u32; const BAR: Int = unsafe { Foo { r: &42 }.f }; -//~^ ERROR constant +//~^ ERROR unable to turn pointer into integer diff --git a/tests/ui/consts/const-eval/shift_overflow.stderr b/tests/ui/consts/const-eval/shift_overflow.stderr index 901bfa10ee8..8c32ddb5908 100644 --- a/tests/ui/consts/const-eval/shift_overflow.stderr +++ b/tests/ui/consts/const-eval/shift_overflow.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to shift left by `4294967296_u64`, which would overflow --> $DIR/shift_overflow.rs:3:9 | LL | X = 1 << ((u32::MAX as u64) + 1), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to shift left by `4294967296_u64`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `Foo::X::{constant#0}` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/transmute-const.rs b/tests/ui/consts/const-eval/transmute-const.rs index fb6cb77675f..e67406a6563 100644 --- a/tests/ui/consts/const-eval/transmute-const.rs +++ b/tests/ui/consts/const-eval/transmute-const.rs @@ -2,6 +2,6 @@ use std::mem; static FOO: bool = unsafe { mem::transmute(3u8) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR 0x03, but expected a bool fn main() {} diff --git a/tests/ui/consts/const-eval/transmute-const.stderr b/tests/ui/consts/const-eval/transmute-const.stderr index 35a5cabaa67..ed3b3df70dd 100644 --- a/tests/ui/consts/const-eval/transmute-const.stderr +++ b/tests/ui/consts/const-eval/transmute-const.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0x03, but expected a boolean --> $DIR/transmute-const.rs:4:1 | LL | static FOO: bool = unsafe { mem::transmute(3u8) }; - | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { diff --git a/tests/ui/consts/const-eval/transmute-size-mismatch.rs b/tests/ui/consts/const-eval/transmute-size-mismatch.rs index 8a7fd8257b0..15b69af14e9 100644 --- a/tests/ui/consts/const-eval/transmute-size-mismatch.rs +++ b/tests/ui/consts/const-eval/transmute-size-mismatch.rs @@ -19,10 +19,10 @@ const unsafe fn mir_transmute<T, U>(x: T) -> U { } } -const FROM_BIGGER: u16 = unsafe { mir_transmute(123_i32) }; //~ ERROR evaluation of constant value failed -//~^ NOTE transmuting from 4-byte type to 2-byte type: `i32` -> `u16` +const FROM_BIGGER: u16 = unsafe { mir_transmute(123_i32) }; //~ NOTE failed inside this call +//~^ ERROR transmuting from 4-byte type to 2-byte type: `i32` -> `u16` -const FROM_SMALLER: u32 = unsafe { mir_transmute(123_i16) }; //~ ERROR evaluation of constant value failed -//~^ NOTE transmuting from 2-byte type to 4-byte type: `i16` -> `u32` +const FROM_SMALLER: u32 = unsafe { mir_transmute(123_i16) }; //~ NOTE failed inside this call +//~^ ERROR transmuting from 2-byte type to 4-byte type: `i16` -> `u32` fn main() {} diff --git a/tests/ui/consts/const-eval/transmute-size-mismatch.stderr b/tests/ui/consts/const-eval/transmute-size-mismatch.stderr index 888df16ec4e..d0457e3ebee 100644 --- a/tests/ui/consts/const-eval/transmute-size-mismatch.stderr +++ b/tests/ui/consts/const-eval/transmute-size-mismatch.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: transmuting from 4-byte type to 2-byte type: `i32` -> `u16` --> $DIR/transmute-size-mismatch.rs:22:35 | LL | const FROM_BIGGER: u16 = unsafe { mir_transmute(123_i32) }; - | ^^^^^^^^^^^^^^^^^^^^^^ transmuting from 4-byte type to 2-byte type: `i32` -> `u16` + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `FROM_BIGGER` failed inside this call | note: inside `mir_transmute::<i32, u16>` --> $DIR/transmute-size-mismatch.rs:12:13 @@ -10,11 +10,11 @@ note: inside `mir_transmute::<i32, u16>` LL | RET = CastTransmute(x); | ^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here -error[E0080]: evaluation of constant value failed +error[E0080]: transmuting from 2-byte type to 4-byte type: `i16` -> `u32` --> $DIR/transmute-size-mismatch.rs:25:36 | LL | const FROM_SMALLER: u32 = unsafe { mir_transmute(123_i16) }; - | ^^^^^^^^^^^^^^^^^^^^^^ transmuting from 2-byte type to 4-byte type: `i16` -> `u32` + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `FROM_SMALLER` failed inside this call | note: inside `mir_transmute::<i16, u32>` --> $DIR/transmute-size-mismatch.rs:12:13 diff --git a/tests/ui/consts/const-eval/ub-enum-overwrite.rs b/tests/ui/consts/const-eval/ub-enum-overwrite.rs index e37c25718f8..005f3c78c1d 100644 --- a/tests/ui/consts/const-eval/ub-enum-overwrite.rs +++ b/tests/ui/consts/const-eval/ub-enum-overwrite.rs @@ -9,8 +9,7 @@ const _: u8 = { // Make sure overwriting `e` uninitializes other bytes e = E::B; unsafe { *p } - //~^ ERROR evaluation of constant value failed - //~| NOTE uninitialized + //~^ ERROR uninitialized }; fn main() {} diff --git a/tests/ui/consts/const-eval/ub-enum-overwrite.stderr b/tests/ui/consts/const-eval/ub-enum-overwrite.stderr index 315e865df93..52af52d3236 100644 --- a/tests/ui/consts/const-eval/ub-enum-overwrite.stderr +++ b/tests/ui/consts/const-eval/ub-enum-overwrite.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/ub-enum-overwrite.rs:11:14 | LL | unsafe { *p } - | ^^ using uninitialized data, but this operation requires initialized memory + | ^^ evaluation of `_` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/ub-enum.rs b/tests/ui/consts/const-eval/ub-enum.rs index ac543430da9..52fc9945068 100644 --- a/tests/ui/consts/const-eval/ub-enum.rs +++ b/tests/ui/consts/const-eval/ub-enum.rs @@ -27,13 +27,13 @@ enum Enum { const GOOD_ENUM: Enum = unsafe { mem::transmute(0usize) }; const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; -//~^ ERROR is undefined behavior +//~^ ERROR expected a valid enum tag const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer const BAD_ENUM_WRAPPED: Wrap<Enum> = unsafe { mem::transmute(&1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer // # simple enum with discriminant 2 @@ -45,12 +45,12 @@ enum Enum2 { } const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; -//~^ ERROR is undefined behavior +//~^ ERROR expected a valid enum tag const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer // something wrapping the enum so that we test layout first, not enum const BAD_ENUM2_WRAPPED: Wrap<Enum2> = unsafe { mem::transmute(&0) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer // Undef enum discriminant. #[repr(C)] @@ -58,13 +58,12 @@ union MaybeUninit<T: Copy> { uninit: (), init: T, } -const BAD_ENUM2_UNDEF : Enum2 = unsafe { MaybeUninit { uninit: () }.init }; -//~^ ERROR evaluation of constant value failed -//~| NOTE uninitialized +const BAD_ENUM2_UNDEF: Enum2 = unsafe { MaybeUninit { uninit: () }.init }; +//~^ ERROR 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) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer // # valid discriminant for uninhabited variant @@ -81,9 +80,9 @@ const GOOD_INHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(0u8) const GOOD_INHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(2u8) }; // variant C const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; -//~^ ERROR is undefined behavior +//~^ ERROR uninhabited enum variant const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; -//~^ ERROR is undefined behavior +//~^ ERROR uninhabited enum variant // # other @@ -91,20 +90,21 @@ const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) // variants and tuples). // Need to create something which does not clash with enum layout optimizations. const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); -//~^ ERROR is undefined behavior +//~^ ERROR expected a valid unicode scalar // All variants are uninhabited but also have data. // Use `0` as constant to make behavior endianness-independent. const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR uninhabited enum variant const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR uninhabited enum variant const TEST_ICE_89765: () = { // This is a regression test for https://github.com/rust-lang/rust/issues/89765. - unsafe { std::mem::discriminant(&*(&() as *const () as *const Never)); }; - //~^ ERROR evaluation of constant value failed + unsafe { + std::mem::discriminant(&*(&() as *const () as *const Never)); + //~^ ERROR uninhabited enum variant + }; }; -fn main() { -} +fn main() {} diff --git a/tests/ui/consts/const-eval/ub-enum.stderr b/tests/ui/consts/const-eval/ub-enum.stderr index faec412b004..29f7a1f051a 100644 --- a/tests/ui/consts/const-eval/ub-enum.stderr +++ b/tests/ui/consts/const-eval/ub-enum.stderr @@ -1,126 +1,126 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<enum-tag>: encountered 0x01, but expected a valid enum tag --> $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 + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/ub-enum.rs:32:1 | LL | const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_ENUM_PTR` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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 +error[E0080]: unable to turn pointer into integer --> $DIR/ub-enum.rs:35:1 | LL | const BAD_ENUM_WRAPPED: Wrap<Enum> = unsafe { mem::transmute(&1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_ENUM_WRAPPED` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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 +error[E0080]: constructing invalid value at .<enum-tag>: encountered 0x0, but expected a valid enum tag --> $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 + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/ub-enum.rs:49:1 | LL | const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_ENUM2_PTR` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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 +error[E0080]: unable to turn pointer into integer --> $DIR/ub-enum.rs:52:1 | LL | const BAD_ENUM2_WRAPPED: Wrap<Enum2> = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_ENUM2_WRAPPED` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:61:42 +error[E0080]: using uninitialized data, but this operation requires initialized memory + --> $DIR/ub-enum.rs:61:41 | -LL | const BAD_ENUM2_UNDEF : Enum2 = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory +LL | const BAD_ENUM2_UNDEF: Enum2 = unsafe { MaybeUninit { uninit: () }.init }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_ENUM2_UNDEF` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:66:1 +error[E0080]: unable to turn pointer into integer + --> $DIR/ub-enum.rs:65:1 | LL | const BAD_ENUM2_OPTION_PTR: Option<Enum2> = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_ENUM2_OPTION_PTR` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:83:1 +error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant + --> $DIR/ub-enum.rs:82:1 | LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:85:1 +error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant + --> $DIR/ub-enum.rs:84:1 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:93:1 +error[E0080]: 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`) + --> $DIR/ub-enum.rs:92: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`) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:98:77 +error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant + --> $DIR/ub-enum.rs:97: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 + | ^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_UNINHABITED_WITH_DATA1` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:100:77 +error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant + --> $DIR/ub-enum.rs:99: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 + | ^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_UNINHABITED_WITH_DATA2` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/ub-enum.rs:105:14 +error[E0080]: read discriminant of an uninhabited enum variant + --> $DIR/ub-enum.rs:105:9 | -LL | unsafe { std::mem::discriminant(&*(&() as *const () as *const Never)); }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ read discriminant of an uninhabited enum variant +LL | std::mem::discriminant(&*(&() as *const () as *const Never)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `TEST_ICE_89765` failed inside this call | note: inside `discriminant::<Never>` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL diff --git a/tests/ui/consts/const-eval/ub-incorrect-vtable.32bit.stderr b/tests/ui/consts/const-eval/ub-incorrect-vtable.32bit.stderr index 5c47cbfdf3b..86d6f8c52bc 100644 --- a/tests/ui/consts/const-eval/ub-incorrect-vtable.32bit.stderr +++ b/tests/ui/consts/const-eval/ub-incorrect-vtable.32bit.stderr @@ -1,63 +1,63 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered ALLOC1<imm>, but expected a vtable pointer --> $DIR/ub-incorrect-vtable.rs:18:1 | LL | const INVALID_VTABLE_ALIGNMENT: &dyn Trait = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC1<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC0<imm>╼ ╾ALLOC1<imm>╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:23:1 +error[E0080]: constructing invalid value: encountered ALLOC3<imm>, but expected a vtable pointer + --> $DIR/ub-incorrect-vtable.rs:22:1 | LL | const INVALID_VTABLE_SIZE: &dyn Trait = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC3<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC2<imm>╼ ╾ALLOC3<imm>╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:33:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC5<imm>, but expected a vtable pointer + --> $DIR/ub-incorrect-vtable.rs:31:1 | LL | const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC5<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC4<imm>╼ ╾ALLOC5<imm>╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:38:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC7<imm>, but expected a vtable pointer + --> $DIR/ub-incorrect-vtable.rs:35:1 | LL | const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC7<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC6<imm>╼ ╾ALLOC7<imm>╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:44:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC9<imm>, but expected a vtable pointer + --> $DIR/ub-incorrect-vtable.rs:40:1 | LL | const INVALID_VTABLE_UB: W<&dyn Trait> = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC9<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC8<imm>╼ ╾ALLOC9<imm>╼ │ ╾──╼╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:91:1 +error[E0080]: constructing invalid value at .1: encountered a dangling reference (going beyond the bounds of its allocation) + --> $DIR/ub-incorrect-vtable.rs:86:1 | LL | const G: Wide = unsafe { Transmute { t: FOO }.u }; - | ^^^^^^^^^^^^^ constructing invalid value at .1: encountered a dangling reference (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { diff --git a/tests/ui/consts/const-eval/ub-incorrect-vtable.64bit.stderr b/tests/ui/consts/const-eval/ub-incorrect-vtable.64bit.stderr index f400073aca2..a9518216dbd 100644 --- a/tests/ui/consts/const-eval/ub-incorrect-vtable.64bit.stderr +++ b/tests/ui/consts/const-eval/ub-incorrect-vtable.64bit.stderr @@ -1,63 +1,63 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered ALLOC1<imm>, but expected a vtable pointer --> $DIR/ub-incorrect-vtable.rs:18:1 | LL | const INVALID_VTABLE_ALIGNMENT: &dyn Trait = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC1<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC0<imm>╼ ╾ALLOC1<imm>╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:23:1 +error[E0080]: constructing invalid value: encountered ALLOC3<imm>, but expected a vtable pointer + --> $DIR/ub-incorrect-vtable.rs:22:1 | LL | const INVALID_VTABLE_SIZE: &dyn Trait = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC3<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC2<imm>╼ ╾ALLOC3<imm>╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:33:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC5<imm>, but expected a vtable pointer + --> $DIR/ub-incorrect-vtable.rs:31:1 | LL | const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC5<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC4<imm>╼ ╾ALLOC5<imm>╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:38:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC7<imm>, but expected a vtable pointer + --> $DIR/ub-incorrect-vtable.rs:35:1 | LL | const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC7<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC6<imm>╼ ╾ALLOC7<imm>╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:44:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC9<imm>, but expected a vtable pointer + --> $DIR/ub-incorrect-vtable.rs:40:1 | LL | const INVALID_VTABLE_UB: W<&dyn Trait> = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC9<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC8<imm>╼ ╾ALLOC9<imm>╼ │ ╾──────╼╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-incorrect-vtable.rs:91:1 +error[E0080]: constructing invalid value at .1: encountered a dangling reference (going beyond the bounds of its allocation) + --> $DIR/ub-incorrect-vtable.rs:86:1 | LL | const G: Wide = unsafe { Transmute { t: FOO }.u }; - | ^^^^^^^^^^^^^ constructing invalid value at .1: encountered a dangling reference (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { diff --git a/tests/ui/consts/const-eval/ub-incorrect-vtable.rs b/tests/ui/consts/const-eval/ub-incorrect-vtable.rs index 30c0ae3bb5a..4185b0261b2 100644 --- a/tests/ui/consts/const-eval/ub-incorrect-vtable.rs +++ b/tests/ui/consts/const-eval/ub-incorrect-vtable.rs @@ -17,13 +17,11 @@ 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 -//~| NOTE vtable +//~^^ ERROR 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 -//~| NOTE vtable +//~^^ ERROR vtable #[repr(transparent)] struct W<T>(T); @@ -32,19 +30,16 @@ 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 -//~| NOTE expected a vtable pointer +//~^^ ERROR 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 -//~| NOTE expected a vtable pointer +//~^^ ERROR 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 -//~| NOTE expected a vtable pointer +//~^^ ERROR expected a vtable pointer // Trying to access the data in a vtable does not work, either. @@ -89,8 +84,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 -//~| NOTE encountered a dangling reference +//~^ ERROR 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 169ac7f1519..eebbccaa7c1 100644 --- a/tests/ui/consts/const-eval/ub-int-array.rs +++ b/tests/ui/consts/const-eval/ub-int-array.rs @@ -18,8 +18,7 @@ impl<T: Copy> MaybeUninit<T> { } const UNINIT_INT_0: [u32; 3] = unsafe { - //~^ ERROR it is undefined behavior to use this value - //~| NOTE invalid value at [0] + //~^ ERROR invalid value at [0] mem::transmute([ MaybeUninit { uninit: () }, // Constants chosen to achieve endianness-independent hex dump. @@ -28,8 +27,7 @@ const UNINIT_INT_0: [u32; 3] = unsafe { ]) }; const UNINIT_INT_1: [u32; 3] = unsafe { - //~^ ERROR it is undefined behavior to use this value - //~| NOTE invalid value at [1] + //~^ ERROR invalid value at [1] mem::transmute([ MaybeUninit::new(0u8), MaybeUninit::new(0u8), @@ -46,8 +44,7 @@ const UNINIT_INT_1: [u32; 3] = unsafe { ]) }; const UNINIT_INT_2: [u32; 3] = unsafe { - //~^ ERROR it is undefined behavior to use this value - //~| NOTE invalid value at [2] + //~^ ERROR 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 d6ef9bcfeba..10eb7c46c92 100644 --- a/tests/ui/consts/const-eval/ub-int-array.stderr +++ b/tests/ui/consts/const-eval/ub-int-array.stderr @@ -1,30 +1,30 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at [0]: encountered uninitialized memory, but expected an integer --> $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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 12, align: 4) { __ __ __ __ 11 11 11 11 22 22 22 22 │ ░░░░...."""" } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:30:1 +error[E0080]: constructing invalid value at [1]: encountered uninitialized memory, but expected an integer + --> $DIR/ub-int-array.rs:29:1 | LL | const UNINIT_INT_1: [u32; 3] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [1]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 12, align: 4) { 00 00 00 00 01 __ 01 01 02 02 __ 02 │ .....░....░. } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:48:1 +error[E0080]: constructing invalid value at [2]: encountered uninitialized memory, but expected an integer + --> $DIR/ub-int-array.rs:46:1 | LL | const UNINIT_INT_2: [u32; 3] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [2]: encountered uninitialized memory, but expected an integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 12, align: 4) { diff --git a/tests/ui/consts/const-eval/ub-invalid-values.rs b/tests/ui/consts/const-eval/ub-invalid-values.rs index c0b68d7619a..8c47b1119f4 100644 --- a/tests/ui/consts/const-eval/ub-invalid-values.rs +++ b/tests/ui/consts/const-eval/ub-invalid-values.rs @@ -5,8 +5,8 @@ const fn bool_cast(ptr: *const bool) { unsafe { const _: () = { let v = 3_u8; - bool_cast(&v as *const u8 as *const bool); //~ ERROR: evaluation of constant value failed - //~^ NOTE interpreting an invalid 8-bit value as a bool + bool_cast(&v as *const u8 as *const bool); //~ NOTE: failed inside this call + //~^ ERROR interpreting an invalid 8-bit value as a bool }; fn main() {} diff --git a/tests/ui/consts/const-eval/ub-invalid-values.stderr b/tests/ui/consts/const-eval/ub-invalid-values.stderr index 76952c1f1a3..3a3b9bc16b8 100644 --- a/tests/ui/consts/const-eval/ub-invalid-values.stderr +++ b/tests/ui/consts/const-eval/ub-invalid-values.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: interpreting an invalid 8-bit value as a bool: 0x03 --> $DIR/ub-invalid-values.rs:8:5 | LL | bool_cast(&v as *const u8 as *const bool); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ interpreting an invalid 8-bit value as a bool: 0x03 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed inside this call | note: inside `bool_cast` --> $DIR/ub-invalid-values.rs:2:16 diff --git a/tests/ui/consts/const-eval/ub-nonnull.rs b/tests/ui/consts/const-eval/ub-nonnull.rs index 8ae913db1e4..91646842624 100644 --- a/tests/ui/consts/const-eval/ub-nonnull.rs +++ b/tests/ui/consts/const-eval/ub-nonnull.rs @@ -14,19 +14,19 @@ const NON_NULL: NonNull<u8> = unsafe { mem::transmute(1usize) }; const NON_NULL_PTR: NonNull<u8> = unsafe { mem::transmute(&1) }; const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value const OUT_OF_BOUNDS_PTR: NonNull<u8> = { unsafe { let ptr: &[u8; 256] = mem::transmute(&0u8); // &0 gets promoted so it does not dangle // Use address-of-element for pointer arithmetic. This could wrap around to null! - let out_of_bounds_ptr = &ptr[255]; //~ ERROR evaluation of constant value failed + let out_of_bounds_ptr = &ptr[255]; //~ ERROR in-bounds pointer arithmetic failed mem::transmute(out_of_bounds_ptr) } }; const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value #[repr(C)] union MaybeUninit<T: Copy> { @@ -34,8 +34,7 @@ union MaybeUninit<T: Copy> { init: T, } const UNINIT: NonZero<u8> = unsafe { MaybeUninit { uninit: () }.init }; -//~^ ERROR evaluation of constant value failed -//~| NOTE uninitialized +//~^ ERROR uninitialized // Also test other uses of rustc_layout_scalar_valid_range_start @@ -43,16 +42,16 @@ const UNINIT: NonZero<u8> = unsafe { MaybeUninit { uninit: () }.init }; #[rustc_layout_scalar_valid_range_end(30)] struct RestrictedRange1(u32); const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value #[rustc_layout_scalar_valid_range_start(30)] #[rustc_layout_scalar_valid_range_end(10)] struct RestrictedRange2(u32); const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value const NULL_FAT_PTR: NonNull<dyn Send> = unsafe { -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value let x: &dyn Send = &42; let meta = std::ptr::metadata(x); mem::transmute((0_usize, meta)) diff --git a/tests/ui/consts/const-eval/ub-nonnull.stderr b/tests/ui/consts/const-eval/ub-nonnull.stderr index 75dd0443ca4..314141e4837 100644 --- a/tests/ui/consts/const-eval/ub-nonnull.stderr +++ b/tests/ui/consts/const-eval/ub-nonnull.stderr @@ -1,75 +1,75 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed +error[E0080]: 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 --> $DIR/ub-nonnull.rs:22:29 | LL | let out_of_bounds_ptr = &ptr[255]; - | ^^^^^^^^^ 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 + | ^^^^^^^^^ evaluation of `OUT_OF_BOUNDS_PTR` failed here -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/ub-nonnull.rs:36:38 | LL | const UNINIT: NonZero<u8> = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNINIT` failed here -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:45:1 +error[E0080]: constructing invalid value: encountered 42, but expected something in the range 10..=30 + --> $DIR/ub-nonnull.rs:44:1 | LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 42, but expected something in the range 10..=30 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:51:1 +error[E0080]: constructing invalid value: encountered 20, but expected something less or equal to 10, or greater or equal to 30 + --> $DIR/ub-nonnull.rs:50: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:54:1 +error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1 + --> $DIR/ub-nonnull.rs:53:1 | LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.rs b/tests/ui/consts/const-eval/ub-ref-ptr.rs index 988e6c62e34..64b48939be6 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.rs +++ b/tests/ui/consts/const-eval/ub-ref-ptr.rs @@ -15,57 +15,53 @@ union MaybeUninit<T: Copy> { } const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) +//~^ ERROR 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 -//~| NOTE constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) +//~^ ERROR 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 +//~^ ERROR invalid value const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value // It is very important that we reject this: We do promote `&(4 * REF_AS_USIZE)`, // but that would fail to compile; so we ended up breaking user code that would // have worked fine had we not promoted. const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init }; -//~^ ERROR evaluation of constant value failed -//~| NOTE uninitialized +//~^ ERROR uninitialized const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init }; -//~^ ERROR evaluation of constant value failed -//~| NOTE uninitialized +//~^ ERROR uninitialized const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR invalid value const UNALIGNED_READ: () = unsafe { let x = &[0u8; 4]; let ptr = x.as_ptr().cast::<u32>(); - ptr.read(); //~ ERROR evaluation of constant value failed + ptr.read(); //~ ERROR accessing memory }; diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.stderr b/tests/ui/consts/const-eval/ub-ref-ptr.stderr index de5e721c3f7..d5ccc396b90 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.stderr +++ b/tests/ui/consts/const-eval/ub-ref-ptr.stderr @@ -1,163 +1,158 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 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) + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:21:1 +error[E0080]: constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1) + --> $DIR/ub-ref-ptr.rs:20: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) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:25:1 +error[E0080]: constructing invalid value: encountered a null reference + --> $DIR/ub-ref-ptr.rs:23:1 | LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference + | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:28:1 +error[E0080]: constructing invalid value: encountered a null box + --> $DIR/ub-ref-ptr.rs:26:1 | LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null box + | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:35:1 +error[E0080]: unable to turn pointer into integer + --> $DIR/ub-ref-ptr.rs:33:1 | LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `REF_AS_USIZE` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:38:39 +error[E0080]: unable to turn pointer into integer + --> $DIR/ub-ref-ptr.rs:36:39 | LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `REF_AS_USIZE_SLICE` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:38:38 + --> $DIR/ub-ref-ptr.rs:36:38 | LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:41:86 +error[E0080]: unable to turn pointer into integer + --> $DIR/ub-ref-ptr.rs:39:86 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; - | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^ evaluation of `REF_AS_USIZE_BOX_SLICE` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:41:85 + --> $DIR/ub-ref-ptr.rs:39: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:44:1 +error[E0080]: constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance) + --> $DIR/ub-ref-ptr.rs:42:1 | LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:47:1 +error[E0080]: constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance) + --> $DIR/ub-ref-ptr.rs:45:1 | LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:50:41 +error[E0080]: using uninitialized data, but this operation requires initialized memory + --> $DIR/ub-ref-ptr.rs:48:41 | LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNINIT_PTR` failed here -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:54:1 +error[E0080]: constructing invalid value: encountered null pointer, but expected a function pointer + --> $DIR/ub-ref-ptr.rs:51:1 | LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:56:38 +error[E0080]: using uninitialized data, but this operation requires initialized memory + --> $DIR/ub-ref-ptr.rs:53:38 | LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNINIT_FN_PTR` failed here -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:59:1 +error[E0080]: constructing invalid value: encountered 0xd[noalloc], but expected a function pointer + --> $DIR/ub-ref-ptr.rs:55:1 | LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-ref-ptr.rs:61:1 +error[E0080]: constructing invalid value: encountered ALLOC2<imm>, but expected a function pointer + --> $DIR/ub-ref-ptr.rs:57:1 | LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC2<imm>, but expected a function pointer + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-ref-ptr.rs:68:5 +error[E0080]: accessing memory based on pointer with alignment 1, but alignment 4 is required + --> $DIR/ub-ref-ptr.rs:64:5 | LL | ptr.read(); - | ^^^^^^^^^^ accessing memory based on pointer with alignment 1, but alignment 4 is required - | -note: inside `std::ptr::const_ptr::<impl *const u32>::read` - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -note: inside `std::ptr::read::<u32>` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | ^^^^^^^^^^ evaluation of `UNALIGNED_READ` failed here error: aborting due to 15 previous errors diff --git a/tests/ui/consts/const-eval/ub-uninhabit.rs b/tests/ui/consts/const-eval/ub-uninhabit.rs index 3a5e291d5df..188ad768a0e 100644 --- a/tests/ui/consts/const-eval/ub-uninhabit.rs +++ b/tests/ui/consts/const-eval/ub-uninhabit.rs @@ -6,8 +6,7 @@ #![feature(core_intrinsics)] #![feature(never_type)] -use std::intrinsics; -use std::mem; +use std::{intrinsics, mem}; #[derive(Copy, Clone)] enum Bar {} @@ -19,25 +18,19 @@ union MaybeUninit<T: Copy> { } const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init }; -//~^ ERROR evaluation of constant value failed -//~| NOTE constructing invalid value +//~^ ERROR constructing invalid value const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constructing invalid value +//~^ ERROR constructing invalid value const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init }; -//~^ ERROR evaluation of constant value failed -//~| NOTE constructing invalid value - +//~^ ERROR constructing invalid value const READ_NEVER: () = unsafe { let mem = [0u32; 8]; let ptr = mem.as_ptr().cast::<!>(); let _val = intrinsics::read_via_copy(ptr); - //~^ ERROR evaluation of constant value failed - //~| NOTE constructing invalid value + //~^ ERROR constructing invalid value }; - fn main() {} diff --git a/tests/ui/consts/const-eval/ub-uninhabit.stderr b/tests/ui/consts/const-eval/ub-uninhabit.stderr index 9d3f93279e5..b0f475fe938 100644 --- a/tests/ui/consts/const-eval/ub-uninhabit.stderr +++ b/tests/ui/consts/const-eval/ub-uninhabit.stderr @@ -1,31 +1,31 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/ub-uninhabit.rs:21:35 +error[E0080]: constructing invalid value: encountered a value of uninhabited type `Bar` + --> $DIR/ub-uninhabit.rs:20:35 | LL | const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type `Bar` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_BAD_BAD` failed here -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-uninhabit.rs:25:1 +error[E0080]: constructing invalid value: encountered a reference pointing to uninhabited type Bar + --> $DIR/ub-uninhabit.rs:23:1 | LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type Bar + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-uninhabit.rs:29:42 +error[E0080]: constructing invalid value at [0]: encountered a value of uninhabited type `Bar` + --> $DIR/ub-uninhabit.rs:26:42 | LL | const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered a value of uninhabited type `Bar` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_BAD_ARRAY` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/ub-uninhabit.rs:37:16 +error[E0080]: constructing invalid value: encountered a value of the never type `!` + --> $DIR/ub-uninhabit.rs:32:16 | LL | let _val = intrinsics::read_via_copy(ptr); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of the never type `!` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `READ_NEVER` failed here error: aborting due to 4 previous errors diff --git a/tests/ui/consts/const-eval/ub-upvars.32bit.stderr b/tests/ui/consts/const-eval/ub-upvars.32bit.stderr index 5342fea66bd..ecd1c768c28 100644 --- a/tests/ui/consts/const-eval/ub-upvars.32bit.stderr +++ b/tests/ui/consts/const-eval/ub-upvars.32bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>.<dyn-downcast>.<captured-var(bad_ref)>: encountered a null reference --> $DIR/ub-upvars.rs:6:1 | LL | const BAD_UPVAR: &dyn FnOnce() = &{ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.<dyn-downcast>.<captured-var(bad_ref)>: encountered a null reference + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { diff --git a/tests/ui/consts/const-eval/ub-upvars.64bit.stderr b/tests/ui/consts/const-eval/ub-upvars.64bit.stderr index a2496dfc287..108dfe6b27b 100644 --- a/tests/ui/consts/const-eval/ub-upvars.64bit.stderr +++ b/tests/ui/consts/const-eval/ub-upvars.64bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>.<dyn-downcast>.<captured-var(bad_ref)>: encountered a null reference --> $DIR/ub-upvars.rs:6:1 | LL | const BAD_UPVAR: &dyn FnOnce() = &{ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.<dyn-downcast>.<captured-var(bad_ref)>: encountered a null reference + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { diff --git a/tests/ui/consts/const-eval/ub-upvars.rs b/tests/ui/consts/const-eval/ub-upvars.rs index 817511180be..19722282984 100644 --- a/tests/ui/consts/const-eval/ub-upvars.rs +++ b/tests/ui/consts/const-eval/ub-upvars.rs @@ -3,7 +3,7 @@ use std::mem; -const BAD_UPVAR: &dyn FnOnce() = &{ //~ ERROR it is undefined behavior to use this value +const BAD_UPVAR: &dyn FnOnce() = &{ //~ ERROR null reference let bad_ref: &'static u16 = unsafe { mem::transmute(0usize) }; let another_var = 13; move || { let _ = bad_ref; let _ = another_var; } diff --git a/tests/ui/consts/const-eval/ub-wide-ptr.rs b/tests/ui/consts/const-eval/ub-wide-ptr.rs index 4b9bbb8066d..86235897e7e 100644 --- a/tests/ui/consts/const-eval/ub-wide-ptr.rs +++ b/tests/ui/consts/const-eval/ub-wide-ptr.rs @@ -37,74 +37,69 @@ type MySliceBool = MySlice<[bool]>; const STR_VALID: &str = unsafe { mem::transmute((&42u8, 1usize)) }; // bad str const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR encountered a dangling reference (going beyond the bounds of its allocation) const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR slice is bigger than largest supported object // bad str const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer // bad str in user-defined unsized type const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR slice is bigger than largest supported object // uninitialized byte const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR uninitialized memory, but expected a string // uninitialized byte in user-defined str-like const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR uninitialized memory, but expected a string // # slice // OK 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 -//~| NOTE uninitialized +//~^ ERROR uninitialized let uninit_len = MaybeUninit::<usize> { uninit: () }; mem::transmute((42, uninit_len)) }; // bad slice: length too big const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR dangling reference (going beyond the bounds of its allocation) // bad slice: length computation overflows const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR slice is bigger than largest supported object // bad slice: length not an int const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer // bad slice box: length too big const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR dangling box (going beyond the bounds of its allocation) // bad slice box: length not an int const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR unable to turn pointer into integer // bad data *inside* the slice const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE constant +//~^ ERROR 0x03, but expected a boolean // 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 -//~| NOTE constant +//~^ ERROR 0x03, but expected a boolean // 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 -//~| NOTE constant +//~^ ERROR 0x03, but expected a boolean // # raw slice const RAW_SLICE_VALID: *const [u8] = unsafe { mem::transmute((&42u8, 1usize)) }; // ok const RAW_SLICE_TOO_LONG: *const [u8] = unsafe { mem::transmute((&42u8, 999usize)) }; // ok because raw 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 -//~| NOTE uninitialized +//~^ ERROR uninitialized let uninit_len = MaybeUninit::<usize> { uninit: () }; mem::transmute((42, uninit_len)) }; @@ -112,41 +107,31 @@ const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe { // # trait object // 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 -//~| NOTE vtable +//~^ ERROR 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 -//~| NOTE vtable +//~^ ERROR 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 -//~| NOTE vtable +//~^ ERROR vtable const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE vtable +//~^ ERROR 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 -//~| NOTE vtable +//~^ ERROR 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 -//~| NOTE vtable +//~^ ERROR 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 -//~| NOTE vtable +//~^ ERROR 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 -//~| NOTE expected a boolean +//~^ ERROR 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 -//~| NOTE null pointer +//~^ ERROR 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 -//~| NOTE vtable +//~^ ERROR 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>()); @@ -154,13 +139,11 @@ 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 - //~| NOTE null pointer + //~^^ ERROR 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 - //~| NOTE vtable + //~^^ ERROR vtable }; fn main() {} diff --git a/tests/ui/consts/const-eval/ub-wide-ptr.stderr b/tests/ui/consts/const-eval/ub-wide-ptr.stderr index 92f0029a5b3..8724dd9a3c0 100644 --- a/tests/ui/consts/const-eval/ub-wide-ptr.stderr +++ b/tests/ui/consts/const-eval/ub-wide-ptr.stderr @@ -1,138 +1,138 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) --> $DIR/ub-wide-ptr.rs:39: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) + | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object --> $DIR/ub-wide-ptr.rs:41: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/ub-wide-ptr.rs:44:1 | LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `STR_LENGTH_PTR` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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 +error[E0080]: unable to turn pointer into integer --> $DIR/ub-wide-ptr.rs:47:1 | LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `MY_STR_LENGTH_PTR` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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 +error[E0080]: constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object --> $DIR/ub-wide-ptr.rs:49: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>: encountered uninitialized memory, but expected a string --> $DIR/ub-wide-ptr.rs:53: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 + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>.0: encountered uninitialized memory, but expected a string --> $DIR/ub-wide-ptr.rs:56: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/ub-wide-ptr.rs:63:1 | LL | const SLICE_LENGTH_UNINIT: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SLICE_LENGTH_UNINIT` failed here -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:70:1 +error[E0080]: constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation) + --> $DIR/ub-wide-ptr.rs:69: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) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:73:1 +error[E0080]: constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + --> $DIR/ub-wide-ptr.rs:72: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:76:1 +error[E0080]: unable to turn pointer into integer + --> $DIR/ub-wide-ptr.rs:75:1 | LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SLICE_LENGTH_PTR` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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-wide-ptr.rs:79:1 +error[E0080]: constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation) + --> $DIR/ub-wide-ptr.rs:78: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) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:82:1 +error[E0080]: unable to turn pointer into integer + --> $DIR/ub-wide-ptr.rs:81:1 | LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SLICE_LENGTH_PTR_BOX` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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-wide-ptr.rs:86:1 +error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x03, but expected a boolean + --> $DIR/ub-wide-ptr.rs:85:1 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -140,16 +140,16 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; } note: erroneous constant encountered - --> $DIR/ub-wide-ptr.rs:86:40 + --> $DIR/ub-wide-ptr.rs:85:40 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:93:1 +error[E0080]: constructing invalid value at .<deref>.0: encountered 0x03, but expected a boolean + --> $DIR/ub-wide-ptr.rs:91: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -157,16 +157,16 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3 } note: erroneous constant encountered - --> $DIR/ub-wide-ptr.rs:93:42 + --> $DIR/ub-wide-ptr.rs:91:42 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:97:1 +error[E0080]: constructing invalid value at .<deref>.1[0]: encountered 0x03, but expected a boolean + --> $DIR/ub-wide-ptr.rs:94: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -174,143 +174,143 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran } note: erroneous constant encountered - --> $DIR/ub-wide-ptr.rs:97:42 + --> $DIR/ub-wide-ptr.rs:94:42 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: evaluation of constant value failed - --> $DIR/ub-wide-ptr.rs:105:1 +error[E0080]: using uninitialized data, but this operation requires initialized memory + --> $DIR/ub-wide-ptr.rs:101:1 | LL | const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `RAW_SLICE_LENGTH_UNINIT` failed here -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:114:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC12<imm>, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:109:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC12<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:118:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC14<imm>, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:112:1 | LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC14<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:122:1 +error[E0080]: constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:115: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:125:1 +error[E0080]: constructing invalid value: encountered ALLOC17<imm>, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:117:1 | LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC17<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:128:1 +error[E0080]: constructing invalid value: encountered ALLOC19<imm>, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:119:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC19<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:131:1 +error[E0080]: constructing invalid value: encountered ALLOC21<imm>, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:121:1 | LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC21<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:134:1 +error[E0080]: constructing invalid value at .0: encountered ALLOC23<imm>, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:123: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 ALLOC23<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:139:1 +error[E0080]: constructing invalid value at .<deref>.<dyn-downcast>: encountered 0x03, but expected a boolean + --> $DIR/ub-wide-ptr.rs:127: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:144:1 +error[E0080]: constructing invalid value: encountered null pointer, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:131: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:147:1 +error[E0080]: constructing invalid value: encountered ALLOC28<imm>, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:133:1 | LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC28<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:155:1 +error[E0080]: constructing invalid value: encountered null pointer, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:140:1 | LL | static mut RAW_TRAIT_OBJ_VTABLE_NULL_THROUGH_REF: *const dyn Trait = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-wide-ptr.rs:160:1 +error[E0080]: constructing invalid value: encountered ALLOC31<imm>, but expected a vtable pointer + --> $DIR/ub-wide-ptr.rs:144:1 | LL | static mut RAW_TRAIT_OBJ_VTABLE_INVALID_THROUGH_REF: *const dyn Trait = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC31<imm>, but expected a vtable pointer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { diff --git a/tests/ui/consts/const-eval/ub-write-through-immutable.rs b/tests/ui/consts/const-eval/ub-write-through-immutable.rs index 795ac602a1c..28c7a617a4d 100644 --- a/tests/ui/consts/const-eval/ub-write-through-immutable.rs +++ b/tests/ui/consts/const-eval/ub-write-through-immutable.rs @@ -1,21 +1,19 @@ //! Ensure we catch UB due to writing through a shared reference. #![allow(invalid_reference_casting)] -use std::mem; use std::cell::UnsafeCell; +use std::mem; const WRITE_AFTER_CAST: () = unsafe { let mut x = 0; let ptr = &x as *const i32 as *mut i32; - *ptr = 0; //~ERROR: evaluation of constant value failed - //~| NOTE immutable + *ptr = 0; //~ERROR: immutable }; const WRITE_AFTER_TRANSMUTE: () = unsafe { let mut x = 0; let ptr: *mut i32 = mem::transmute(&x); - *ptr = 0; //~ERROR: evaluation of constant value failed - //~| NOTE immutable + *ptr = 0; //~ERROR: immutable }; // it's okay when there is interior mutability; diff --git a/tests/ui/consts/const-eval/ub-write-through-immutable.stderr b/tests/ui/consts/const-eval/ub-write-through-immutable.stderr index d30df33bc55..13b2585d4dc 100644 --- a/tests/ui/consts/const-eval/ub-write-through-immutable.stderr +++ b/tests/ui/consts/const-eval/ub-write-through-immutable.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: writing through a pointer that was derived from a shared (immutable) reference --> $DIR/ub-write-through-immutable.rs:10:5 | LL | *ptr = 0; - | ^^^^^^^^ writing through a pointer that was derived from a shared (immutable) reference + | ^^^^^^^^ evaluation of `WRITE_AFTER_CAST` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/ub-write-through-immutable.rs:17:5 +error[E0080]: writing through a pointer that was derived from a shared (immutable) reference + --> $DIR/ub-write-through-immutable.rs:16:5 | LL | *ptr = 0; - | ^^^^^^^^ writing through a pointer that was derived from a shared (immutable) reference + | ^^^^^^^^ evaluation of `WRITE_AFTER_TRANSMUTE` failed here error: aborting due to 2 previous errors 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 55e9abe72e0..0ad94eee7f4 100644 --- a/tests/ui/consts/const-eval/union-const-eval-field.rs +++ b/tests/ui/consts/const-eval/union-const-eval-field.rs @@ -26,8 +26,7 @@ const fn read_field2() -> Field2 { const fn read_field3() -> Field3 { const FIELD3: Field3 = unsafe { UNION.field3 }; - //~^ ERROR evaluation of constant value failed - //~| NOTE uninitialized + //~^ ERROR 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 4fd6b80381c..07ff4c3ca36 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 +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/union-const-eval-field.rs:28:37 | LL | const FIELD3: Field3 = unsafe { UNION.field3 }; - | ^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^ evaluation of `read_field3::FIELD3` failed here note: erroneous constant encountered - --> $DIR/union-const-eval-field.rs:31:5 + --> $DIR/union-const-eval-field.rs:30:5 | LL | FIELD3 | ^^^^^^ note: erroneous constant encountered - --> $DIR/union-const-eval-field.rs:31:5 + --> $DIR/union-const-eval-field.rs:30:5 | LL | FIELD3 | ^^^^^^ diff --git a/tests/ui/consts/const-eval/union-ice.rs b/tests/ui/consts/const-eval/union-ice.rs index 8ce5f6d89a8..7a4909e8ce2 100644 --- a/tests/ui/consts/const-eval/union-ice.rs +++ b/tests/ui/consts/const-eval/union-ice.rs @@ -12,14 +12,12 @@ union DummyUnion { const UNION: DummyUnion = DummyUnion { field1: 1065353216 }; const FIELD3: Field3 = unsafe { UNION.field3 }; -//~^ ERROR evaluation of constant value failed -//~| NOTE uninitialized +//~^ ERROR uninitialized const FIELD_PATH: Struct = Struct { a: 42, b: unsafe { UNION.field3 }, - //~^ ERROR evaluation of constant value failed - //~| NOTE uninitialized + //~^ ERROR uninitialized }; struct Struct { @@ -31,8 +29,7 @@ const FIELD_PATH2: Struct2 = Struct2 { b: [ 21, unsafe { UNION.field3 }, - //~^ ERROR evaluation of constant value failed - //~| NOTE uninitialized + //~^ ERROR uninitialized 23, 24, ], @@ -44,5 +41,4 @@ struct Struct2 { a: u8, } -fn main() { -} +fn main() {} diff --git a/tests/ui/consts/const-eval/union-ice.stderr b/tests/ui/consts/const-eval/union-ice.stderr index bd39a05510b..b00fcc91d68 100644 --- a/tests/ui/consts/const-eval/union-ice.stderr +++ b/tests/ui/consts/const-eval/union-ice.stderr @@ -1,20 +1,20 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/union-ice.rs:14:33 | LL | const FIELD3: Field3 = unsafe { UNION.field3 }; - | ^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^ evaluation of `FIELD3` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/union-ice.rs:20:17 +error[E0080]: using uninitialized data, but this operation requires initialized memory + --> $DIR/union-ice.rs:19:17 | LL | b: unsafe { UNION.field3 }, - | ^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^ evaluation of `FIELD_PATH` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/union-ice.rs:33:18 +error[E0080]: using uninitialized data, but this operation requires initialized memory + --> $DIR/union-ice.rs:31:18 | LL | unsafe { UNION.field3 }, - | ^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^ evaluation of `FIELD_PATH2` failed here error: aborting due to 3 previous errors diff --git a/tests/ui/consts/const-eval/union-ub.32bit.stderr b/tests/ui/consts/const-eval/union-ub.32bit.stderr index 38ded4d65cf..9f0697984e4 100644 --- a/tests/ui/consts/const-eval/union-ub.32bit.stderr +++ b/tests/ui/consts/const-eval/union-ub.32bit.stderr @@ -1,19 +1,19 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0x2a, but expected a boolean --> $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 +LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool }; + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 2a │ * } -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/union-ub.rs:35:36 | -LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory +LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNINIT_BOOL` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/union-ub.64bit.stderr b/tests/ui/consts/const-eval/union-ub.64bit.stderr index 38ded4d65cf..9f0697984e4 100644 --- a/tests/ui/consts/const-eval/union-ub.64bit.stderr +++ b/tests/ui/consts/const-eval/union-ub.64bit.stderr @@ -1,19 +1,19 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0x2a, but expected a boolean --> $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 +LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool }; + | ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { 2a │ * } -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/union-ub.rs:35:36 | -LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory +LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNINIT_BOOL` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/union-ub.rs b/tests/ui/consts/const-eval/union-ub.rs index 7d8fd7446a0..0fa5d312856 100644 --- a/tests/ui/consts/const-eval/union-ub.rs +++ b/tests/ui/consts/const-eval/union-ub.rs @@ -30,15 +30,13 @@ union Bar { } // the value is not valid for bools -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 -//~| NOTE uninitialized +const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool }; +//~^ ERROR invalid value +const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool }; +//~^ ERROR uninitialized // The value is not valid for any union variant, but that's fine // unions are just a convenient way to transmute bits around const BAD_UNION: Foo = unsafe { Bar { u8: 42 }.foo }; - fn main() {} diff --git a/tests/ui/consts/const-eval/unused-broken-const.rs b/tests/ui/consts/const-eval/unused-broken-const.rs index f7e229aa980..60206362665 100644 --- a/tests/ui/consts/const-eval/unused-broken-const.rs +++ b/tests/ui/consts/const-eval/unused-broken-const.rs @@ -3,6 +3,6 @@ //@ compile-flags: --emit=dep-info,metadata const FOO: i32 = [][0]; -//~^ ERROR evaluation of constant value failed +//~^ ERROR index out of bounds fn main() {} diff --git a/tests/ui/consts/const-eval/unused-broken-const.stderr b/tests/ui/consts/const-eval/unused-broken-const.stderr index fd0ee316fe2..57bce6ce650 100644 --- a/tests/ui/consts/const-eval/unused-broken-const.stderr +++ b/tests/ui/consts/const-eval/unused-broken-const.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: index out of bounds: the length is 0 but the index is 0 --> $DIR/unused-broken-const.rs:5:18 | LL | const FOO: i32 = [][0]; - | ^^^^^ index out of bounds: the length is 0 but the index is 0 + | ^^^^^ evaluation of `FOO` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/unwind-abort.rs b/tests/ui/consts/const-eval/unwind-abort.rs index b239dba0239..688bb085356 100644 --- a/tests/ui/consts/const-eval/unwind-abort.rs +++ b/tests/ui/consts/const-eval/unwind-abort.rs @@ -4,7 +4,7 @@ const extern "C" fn foo() { panic!() //~ NOTE inside `foo` } -const _: () = foo(); //~ ERROR evaluation of constant value failed +const _: () = foo(); //~ ERROR explicit panic // Ensure that the CTFE engine handles calls to `extern "C"` aborting gracefully fn main() { diff --git a/tests/ui/consts/const-eval/unwind-abort.stderr b/tests/ui/consts/const-eval/unwind-abort.stderr index 5ed7467e84b..cccfe569acb 100644 --- a/tests/ui/consts/const-eval/unwind-abort.stderr +++ b/tests/ui/consts/const-eval/unwind-abort.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/unwind-abort.rs:7:15 | LL | const _: () = foo(); - | ^^^^^ evaluation panicked: explicit panic + | ^^^^^ evaluation of `_` failed inside this call | note: inside `foo` --> $DIR/unwind-abort.rs:4:5 diff --git a/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs b/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs index 5f1d27b0de0..dbb165c64d9 100644 --- a/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs +++ b/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs @@ -15,10 +15,10 @@ pub mod empty { } const FOO: [empty::Empty; 3] = [foo(); 3]; -//~^ ERROR evaluation of constant value failed +//~^ ERROR value of the never type const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; -//~^ ERROR evaluation of constant value failed +//~^ ERROR value of uninhabited type fn main() { FOO; diff --git a/tests/ui/consts/const-eval/validate_uninhabited_zsts.stderr b/tests/ui/consts/const-eval/validate_uninhabited_zsts.stderr index 0407ae5c323..848c65f4764 100644 --- a/tests/ui/consts/const-eval/validate_uninhabited_zsts.stderr +++ b/tests/ui/consts/const-eval/validate_uninhabited_zsts.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: constructing invalid value: encountered a value of the never type `!` --> $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 `!` + | ^^^^^ evaluation of `FOO` failed inside this call | note: inside `foo` --> $DIR/validate_uninhabited_zsts.rs:4:14 @@ -10,11 +10,11 @@ note: inside `foo` LL | unsafe { std::mem::transmute(()) } | ^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here -error[E0080]: evaluation of constant value failed +error[E0080]: constructing invalid value at .0: encountered a value of uninhabited type `Void` --> $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` + | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAR` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/validation-ice-extern-type-field.rs b/tests/ui/consts/const-eval/validation-ice-extern-type-field.rs index 8a32b170c40..3081689ee90 100644 --- a/tests/ui/consts/const-eval/validation-ice-extern-type-field.rs +++ b/tests/ui/consts/const-eval/validation-ice-extern-type-field.rs @@ -10,6 +10,6 @@ struct ThinDst { } const C1: &ThinDst = unsafe { std::mem::transmute(b"d".as_ptr()) }; -//~^ERROR: evaluation of constant value failed +//~^ERROR: `extern type` field does not have a known offset fn main() {} diff --git a/tests/ui/consts/const-eval/validation-ice-extern-type-field.stderr b/tests/ui/consts/const-eval/validation-ice-extern-type-field.stderr index 1ec36abc2ec..61087392b76 100644 --- a/tests/ui/consts/const-eval/validation-ice-extern-type-field.stderr +++ b/tests/ui/consts/const-eval/validation-ice-extern-type-field.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: `extern type` field does not have a known offset --> $DIR/validation-ice-extern-type-field.rs:12:1 | LL | const C1: &ThinDst = unsafe { std::mem::transmute(b"d".as_ptr()) }; - | ^^^^^^^^^^^^^^^^^^ `extern type` field does not have a known offset + | ^^^^^^^^^^^^^^^^^^ evaluation of `C1` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-external-macro-const-err.rs b/tests/ui/consts/const-external-macro-const-err.rs index 3cb83823f1a..60cbe36071d 100644 --- a/tests/ui/consts/const-external-macro-const-err.rs +++ b/tests/ui/consts/const-external-macro-const-err.rs @@ -9,5 +9,5 @@ extern crate external_macro; use external_macro::static_assert; fn main() { - static_assert!(2 + 2 == 5); //~ ERROR constant + static_assert!(2 + 2 == 5); //~ ERROR index out of bounds: the length is 1 but the index is 1 } diff --git a/tests/ui/consts/const-external-macro-const-err.stderr b/tests/ui/consts/const-external-macro-const-err.stderr index 63f81ea18bc..3ec9e4f3200 100644 --- a/tests/ui/consts/const-external-macro-const-err.stderr +++ b/tests/ui/consts/const-external-macro-const-err.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: index out of bounds: the length is 1 but the index is 1 --> $DIR/const-external-macro-const-err.rs:12:5 | LL | static_assert!(2 + 2 == 5); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::_` failed here | = note: this error originates in the macro `static_assert` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/const-fn-in-vec.stderr b/tests/ui/consts/const-fn-in-vec.stderr index 5be26d7c121..890eb8040b9 100644 --- a/tests/ui/consts/const-fn-in-vec.stderr +++ b/tests/ui/consts/const-fn-in-vec.stderr @@ -2,36 +2,39 @@ error[E0277]: the trait bound `String: Copy` is not satisfied --> $DIR/const-fn-in-vec.rs:1:47 | LL | static _MAYBE_STRINGS: [Option<String>; 5] = [None; 5]; - | ^^^^ - | | - | the trait `Copy` is not implemented for `String` - | help: create an inline `const` block: `const { None }` + | ^^^^ the trait `Copy` is not implemented for `String` | = note: required for `Option<String>` to implement `Copy` = note: the `Copy` trait is required because this value will be copied for each element of the array +help: create an inline `const` block + | +LL | static _MAYBE_STRINGS: [Option<String>; 5] = [const { None }; 5]; + | +++++++ + error[E0277]: the trait bound `String: Copy` is not satisfied --> $DIR/const-fn-in-vec.rs:7:34 | LL | let _strings: [String; 5] = [String::new(); 5]; - | ^^^^^^^^^^^^^ - | | - | the trait `Copy` is not implemented for `String` - | help: create an inline `const` block: `const { String::new() }` + | ^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` | = note: the `Copy` trait is required because this value will be copied for each element of the array +help: create an inline `const` block + | +LL | let _strings: [String; 5] = [const { String::new() }; 5]; + | +++++++ + error[E0277]: the trait bound `String: Copy` is not satisfied --> $DIR/const-fn-in-vec.rs:12:48 | LL | let _maybe_strings: [Option<String>; 5] = [None; 5]; - | ^^^^ - | | - | the trait `Copy` is not implemented for `String` - | help: create an inline `const` block: `const { None }` + | ^^^^ the trait `Copy` is not implemented for `String` | = note: required for `Option<String>` to implement `Copy` = note: the `Copy` trait is required because this value will be copied for each element of the array +help: create an inline `const` block + | +LL | let _maybe_strings: [Option<String>; 5] = [const { None }; 5]; + | +++++++ + error: aborting due to 3 previous errors diff --git a/tests/ui/consts/const-int-unchecked.rs b/tests/ui/consts/const-int-unchecked.rs index 8de28aa2bb1..3fc58720cf1 100644 --- a/tests/ui/consts/const-int-unchecked.rs +++ b/tests/ui/consts/const-int-unchecked.rs @@ -1,6 +1,5 @@ #![feature(core_intrinsics)] - use std::intrinsics; // The documentation of `unchecked_shl` states that it: @@ -13,137 +12,137 @@ use std::intrinsics; // unsigned types: const SHL_U8: u8 = unsafe { intrinsics::unchecked_shl(5_u8, 8) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_U16: u16 = unsafe { intrinsics::unchecked_shl(5_u16, 16) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_U32: u32 = unsafe { intrinsics::unchecked_shl(5_u32, 32) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_U64: u64 = unsafe { intrinsics::unchecked_shl(5_u64, 64) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_U128: u128 = unsafe { intrinsics::unchecked_shl(5_u128, 128) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift // signed types: const SHL_I8: i8 = unsafe { intrinsics::unchecked_shl(5_i8, 8) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_I16: i16 = unsafe { intrinsics::unchecked_shl(5_i16, 16) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_I32: i32 = unsafe { intrinsics::unchecked_shl(5_i32, 32) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_I64: i64 = unsafe { intrinsics::unchecked_shl(5_i64, 64) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_I128: i128 = unsafe { intrinsics::unchecked_shl(5_i128, 128) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift // and make sure we capture y < 0: const SHL_I8_NEG: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_I16_NEG: i16 = unsafe { intrinsics::unchecked_shl(5_i16, -1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_I32_NEG: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_I64_NEG: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_I128_NEG: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift // and that there's no special relation to the value -1 by picking some // negative values at random: const SHL_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -6) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shl(5_i16, -13) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -25) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -30) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHL_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -93) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift // Repeat it all over for `unchecked_shr` // unsigned types: const SHR_U8: u8 = unsafe { intrinsics::unchecked_shr(5_u8, 8) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_U16: u16 = unsafe { intrinsics::unchecked_shr(5_u16, 16) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_U32: u32 = unsafe { intrinsics::unchecked_shr(5_u32, 32) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_U64: u64 = unsafe { intrinsics::unchecked_shr(5_u64, 64) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_U128: u128 = unsafe { intrinsics::unchecked_shr(5_u128, 128) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift // signed types: const SHR_I8: i8 = unsafe { intrinsics::unchecked_shr(5_i8, 8) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_I16: i16 = unsafe { intrinsics::unchecked_shr(5_i16, 16) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_I32: i32 = unsafe { intrinsics::unchecked_shr(5_i32, 32) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_I64: i64 = unsafe { intrinsics::unchecked_shr(5_i64, 64) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_I128: i128 = unsafe { intrinsics::unchecked_shr(5_i128, 128) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift // and make sure we capture y < 0: const SHR_I8_NEG: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_I16_NEG: i16 = unsafe { intrinsics::unchecked_shr(5_i16, -1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_I32_NEG: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_I64_NEG: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_I128_NEG: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift // and that there's no special relation to the value -1 by picking some // negative values at random: const SHR_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -6) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shr(5_i16, -13) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -25) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -30) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift const SHR_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -93) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflowing shift // Other arithmetic functions: const _: u16 = unsafe { std::intrinsics::unchecked_add(40000u16, 30000) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR arithmetic overflow const _: u32 = unsafe { std::intrinsics::unchecked_sub(14u32, 22) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR arithmetic overflow const _: u16 = unsafe { std::intrinsics::unchecked_mul(300u16, 250u16) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR arithmetic overflow const _: i32 = unsafe { std::intrinsics::unchecked_div(1, 0) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR dividing by zero const _: i32 = unsafe { std::intrinsics::unchecked_div(i32::MIN, -1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflow in signed division (dividing MIN by -1) const _: i32 = unsafe { std::intrinsics::unchecked_rem(1, 0) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR calculating the remainder with a divisor of zero const _: i32 = unsafe { std::intrinsics::unchecked_rem(i32::MIN, -1) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR overflow in signed remainder (dividing MIN by -1) // capture fault with zero value const _: u32 = unsafe { std::intrinsics::ctlz_nonzero(0) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR `ctlz_nonzero` called on 0 const _: u32 = unsafe { std::intrinsics::cttz_nonzero(0) }; -//~^ ERROR evaluation of constant value failed +//~^ ERROR `cttz_nonzero` called on 0 fn main() {} diff --git a/tests/ui/consts/const-int-unchecked.stderr b/tests/ui/consts/const-int-unchecked.stderr index 3130603231e..65a116295c7 100644 --- a/tests/ui/consts/const-int-unchecked.stderr +++ b/tests/ui/consts/const-int-unchecked.stderr @@ -1,296 +1,296 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:15:29 +error[E0080]: overflowing shift by 8 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:14:29 | LL | const SHL_U8: u8 = unsafe { intrinsics::unchecked_shl(5_u8, 8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 8 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_U8` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:17:31 +error[E0080]: overflowing shift by 16 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:16:31 | LL | const SHL_U16: u16 = unsafe { intrinsics::unchecked_shl(5_u16, 16) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 16 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_U16` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:19:31 +error[E0080]: overflowing shift by 32 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:18:31 | LL | const SHL_U32: u32 = unsafe { intrinsics::unchecked_shl(5_u32, 32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 32 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_U32` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:21:31 +error[E0080]: overflowing shift by 64 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:20:31 | LL | const SHL_U64: u64 = unsafe { intrinsics::unchecked_shl(5_u64, 64) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 64 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_U64` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:23:33 +error[E0080]: overflowing shift by 128 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:22:33 | LL | const SHL_U128: u128 = unsafe { intrinsics::unchecked_shl(5_u128, 128) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 128 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_U128` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:28:29 +error[E0080]: overflowing shift by 8 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:27:29 | LL | const SHL_I8: i8 = unsafe { intrinsics::unchecked_shl(5_i8, 8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 8 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I8` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:30:31 +error[E0080]: overflowing shift by 16 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:29:31 | LL | const SHL_I16: i16 = unsafe { intrinsics::unchecked_shl(5_i16, 16) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 16 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I16` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:32:31 +error[E0080]: overflowing shift by 32 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:31:31 | LL | const SHL_I32: i32 = unsafe { intrinsics::unchecked_shl(5_i32, 32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 32 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I32` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:34:31 +error[E0080]: overflowing shift by 64 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:33:31 | LL | const SHL_I64: i64 = unsafe { intrinsics::unchecked_shl(5_i64, 64) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 64 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I64` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:36:33 +error[E0080]: overflowing shift by 128 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:35:33 | LL | const SHL_I128: i128 = unsafe { intrinsics::unchecked_shl(5_i128, 128) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 128 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I128` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:41:33 +error[E0080]: overflowing shift by -1 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:40:33 | LL | const SHL_I8_NEG: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -1 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I8_NEG` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:43:35 +error[E0080]: overflowing shift by -1 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:42:35 | LL | const SHL_I16_NEG: i16 = unsafe { intrinsics::unchecked_shl(5_i16, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -1 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I16_NEG` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:45:35 +error[E0080]: overflowing shift by -1 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:44:35 | LL | const SHL_I32_NEG: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -1 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I32_NEG` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:47:35 +error[E0080]: overflowing shift by -1 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:46:35 | LL | const SHL_I64_NEG: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -1 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I64_NEG` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:49:37 +error[E0080]: overflowing shift by -1 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:48:37 | LL | const SHL_I128_NEG: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -1 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I128_NEG` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:55:40 +error[E0080]: overflowing shift by -6 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:54:40 | LL | const SHL_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -6) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -6 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I8_NEG_RANDOM` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:57:42 +error[E0080]: overflowing shift by -13 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:56:42 | LL | const SHL_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shl(5_i16, -13) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -13 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I16_NEG_RANDOM` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:59:42 +error[E0080]: overflowing shift by -25 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:58:42 | LL | const SHL_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -25) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -25 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I32_NEG_RANDOM` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:61:42 +error[E0080]: overflowing shift by -30 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:60:42 | LL | const SHL_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -30) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -30 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I64_NEG_RANDOM` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:63:44 +error[E0080]: overflowing shift by -93 in `unchecked_shl` + --> $DIR/const-int-unchecked.rs:62:44 | LL | const SHL_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -93) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -93 in `unchecked_shl` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I128_NEG_RANDOM` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:70:29 +error[E0080]: overflowing shift by 8 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:69:29 | LL | const SHR_U8: u8 = unsafe { intrinsics::unchecked_shr(5_u8, 8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 8 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_U8` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:72:31 +error[E0080]: overflowing shift by 16 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:71:31 | LL | const SHR_U16: u16 = unsafe { intrinsics::unchecked_shr(5_u16, 16) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 16 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_U16` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:74:31 +error[E0080]: overflowing shift by 32 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:73:31 | LL | const SHR_U32: u32 = unsafe { intrinsics::unchecked_shr(5_u32, 32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 32 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_U32` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:76:31 +error[E0080]: overflowing shift by 64 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:75:31 | LL | const SHR_U64: u64 = unsafe { intrinsics::unchecked_shr(5_u64, 64) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 64 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_U64` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:78:33 +error[E0080]: overflowing shift by 128 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:77:33 | LL | const SHR_U128: u128 = unsafe { intrinsics::unchecked_shr(5_u128, 128) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 128 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_U128` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:83:29 +error[E0080]: overflowing shift by 8 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:82:29 | LL | const SHR_I8: i8 = unsafe { intrinsics::unchecked_shr(5_i8, 8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 8 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I8` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:85:31 +error[E0080]: overflowing shift by 16 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:84:31 | LL | const SHR_I16: i16 = unsafe { intrinsics::unchecked_shr(5_i16, 16) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 16 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I16` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:87:31 +error[E0080]: overflowing shift by 32 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:86:31 | LL | const SHR_I32: i32 = unsafe { intrinsics::unchecked_shr(5_i32, 32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 32 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I32` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:89:31 +error[E0080]: overflowing shift by 64 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:88:31 | LL | const SHR_I64: i64 = unsafe { intrinsics::unchecked_shr(5_i64, 64) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 64 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I64` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:91:33 +error[E0080]: overflowing shift by 128 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:90:33 | LL | const SHR_I128: i128 = unsafe { intrinsics::unchecked_shr(5_i128, 128) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 128 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I128` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:96:33 +error[E0080]: overflowing shift by -1 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:95:33 | LL | const SHR_I8_NEG: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -1 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I8_NEG` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:98:35 +error[E0080]: overflowing shift by -1 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:97:35 | LL | const SHR_I16_NEG: i16 = unsafe { intrinsics::unchecked_shr(5_i16, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -1 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I16_NEG` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:100:35 +error[E0080]: overflowing shift by -1 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:99:35 | LL | const SHR_I32_NEG: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -1 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I32_NEG` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:102:35 +error[E0080]: overflowing shift by -1 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:101:35 | LL | const SHR_I64_NEG: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -1 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I64_NEG` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:104:37 +error[E0080]: overflowing shift by -1 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:103:37 | LL | const SHR_I128_NEG: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -1 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I128_NEG` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:110:40 +error[E0080]: overflowing shift by -6 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:109:40 | LL | const SHR_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -6) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -6 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I8_NEG_RANDOM` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:112:42 +error[E0080]: overflowing shift by -13 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:111:42 | LL | const SHR_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shr(5_i16, -13) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -13 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I16_NEG_RANDOM` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:114:42 +error[E0080]: overflowing shift by -25 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:113:42 | LL | const SHR_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -25) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -25 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I32_NEG_RANDOM` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:116:42 +error[E0080]: overflowing shift by -30 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:115:42 | LL | const SHR_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -30) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -30 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I64_NEG_RANDOM` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:118:44 +error[E0080]: overflowing shift by -93 in `unchecked_shr` + --> $DIR/const-int-unchecked.rs:117:44 | LL | const SHR_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -93) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by -93 in `unchecked_shr` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I128_NEG_RANDOM` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:123:25 +error[E0080]: arithmetic overflow in `unchecked_add` + --> $DIR/const-int-unchecked.rs:122:25 | LL | const _: u16 = unsafe { std::intrinsics::unchecked_add(40000u16, 30000) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ arithmetic overflow in `unchecked_add` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:126:25 +error[E0080]: arithmetic overflow in `unchecked_sub` + --> $DIR/const-int-unchecked.rs:125:25 | LL | const _: u32 = unsafe { std::intrinsics::unchecked_sub(14u32, 22) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ arithmetic overflow in `unchecked_sub` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:129:25 +error[E0080]: arithmetic overflow in `unchecked_mul` + --> $DIR/const-int-unchecked.rs:128:25 | LL | const _: u16 = unsafe { std::intrinsics::unchecked_mul(300u16, 250u16) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ arithmetic overflow in `unchecked_mul` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:132:25 +error[E0080]: dividing by zero + --> $DIR/const-int-unchecked.rs:131:25 | LL | const _: i32 = unsafe { std::intrinsics::unchecked_div(1, 0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dividing by zero + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:134:25 +error[E0080]: overflow in signed division (dividing MIN by -1) + --> $DIR/const-int-unchecked.rs:133:25 | LL | const _: i32 = unsafe { std::intrinsics::unchecked_div(i32::MIN, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:137:25 +error[E0080]: calculating the remainder with a divisor of zero + --> $DIR/const-int-unchecked.rs:136:25 | LL | const _: i32 = unsafe { std::intrinsics::unchecked_rem(1, 0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calculating the remainder with a divisor of zero + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:139:25 +error[E0080]: overflow in signed remainder (dividing MIN by -1) + --> $DIR/const-int-unchecked.rs:138:25 | LL | const _: i32 = unsafe { std::intrinsics::unchecked_rem(i32::MIN, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:144:25 +error[E0080]: `ctlz_nonzero` called on 0 + --> $DIR/const-int-unchecked.rs:143:25 | LL | const _: u32 = unsafe { std::intrinsics::ctlz_nonzero(0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ctlz_nonzero` called on 0 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-int-unchecked.rs:146:25 +error[E0080]: `cttz_nonzero` called on 0 + --> $DIR/const-int-unchecked.rs:145:25 | LL | const _: u32 = unsafe { std::intrinsics::cttz_nonzero(0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `cttz_nonzero` called on 0 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here error: aborting due to 49 previous errors 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 aacd74635e9..ef46522f7f5 100644 --- a/tests/ui/consts/const-len-underflow-separate-spans.next.stderr +++ b/tests/ui/consts/const-len-underflow-separate-spans.next.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `1_usize - 2_usize`, which would overflow --> $DIR/const-len-underflow-separate-spans.rs:10:20 | LL | const LEN: usize = ONE - TWO; - | ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, which would overflow + | ^^^^^^^^^ evaluation of `LEN` failed here note: erroneous constant encountered --> $DIR/const-len-underflow-separate-spans.rs:15:17 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 aacd74635e9..ef46522f7f5 100644 --- a/tests/ui/consts/const-len-underflow-separate-spans.old.stderr +++ b/tests/ui/consts/const-len-underflow-separate-spans.old.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `1_usize - 2_usize`, which would overflow --> $DIR/const-len-underflow-separate-spans.rs:10:20 | LL | const LEN: usize = ONE - TWO; - | ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, which would overflow + | ^^^^^^^^^ evaluation of `LEN` failed here note: erroneous constant encountered --> $DIR/const-len-underflow-separate-spans.rs:15:17 diff --git a/tests/ui/consts/const-len-underflow-separate-spans.rs b/tests/ui/consts/const-len-underflow-separate-spans.rs index 14eb88b1427..ee8c79dafa7 100644 --- a/tests/ui/consts/const-len-underflow-separate-spans.rs +++ b/tests/ui/consts/const-len-underflow-separate-spans.rs @@ -8,10 +8,10 @@ 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 +//~^ NOTE failed here +//~| ERROR attempt to compute `1_usize - 2_usize`, which would overflow fn main() { let a: [i8; LEN] = unimplemented!(); -//~^ NOTE constant + //~^ NOTE constant } diff --git a/tests/ui/consts/const-len-underflow-subspans.rs b/tests/ui/consts/const-len-underflow-subspans.rs index 5afb1bf89d0..1540bffa0ad 100644 --- a/tests/ui/consts/const-len-underflow-subspans.rs +++ b/tests/ui/consts/const-len-underflow-subspans.rs @@ -6,6 +6,5 @@ const TWO: usize = 2; fn main() { let a: [i8; ONE - TWO] = unimplemented!(); - //~^ ERROR evaluation of constant value failed - //~| NOTE attempt to compute `1_usize - 2_usize`, which would overflow + //~^ ERROR attempt to compute `1_usize - 2_usize`, which would overflow } diff --git a/tests/ui/consts/const-len-underflow-subspans.stderr b/tests/ui/consts/const-len-underflow-subspans.stderr index bfec056cc8a..51825a03db8 100644 --- a/tests/ui/consts/const-len-underflow-subspans.stderr +++ b/tests/ui/consts/const-len-underflow-subspans.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to compute `1_usize - 2_usize`, which would overflow --> $DIR/const-len-underflow-subspans.rs:8:17 | LL | let a: [i8; ONE - TWO] = unimplemented!(); - | ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, which would overflow + | ^^^^^^^^^ evaluation of `main::{constant#0}` failed here error: aborting due to 1 previous error 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 bc534be6832..29474c76320 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 @@ -25,8 +25,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 -//~| NOTE pointing to read-only memory +//~^ ERROR 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 1f49f08c401..834ea3410f6 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 @@ -24,11 +24,11 @@ LL | const B4: Option<&mut i32> = helper(&mut 42); | | creates a temporary value which is freed while still in use | using this value as a constant requires that borrow lasts for `'static` -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered mutable reference or box pointing to read-only memory --> $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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -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:51:65 + --> $DIR/mut_ref_in_final.rs:50: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:54:67 + --> $DIR/mut_ref_in_final.rs:53: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:57:71 + --> $DIR/mut_ref_in_final.rs:56: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:70:53 + --> $DIR/mut_ref_in_final.rs:69: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:72:54 + --> $DIR/mut_ref_in_final.rs:71: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:74:52 + --> $DIR/mut_ref_in_final.rs:73: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:76:53 + --> $DIR/mut_ref_in_final.rs:75: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 a58c4437e15..2707e8a14ec 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 @@ -16,24 +16,21 @@ static mut BUFFER: i32 = 42; 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 -//~^ NOTE encountered reference to mutable +const MUT: Option<&mut i32> = helper(); //~ ERROR 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 -//~^ NOTE encountered a dangling reference -static INT2PTR_STATIC: Option<&mut i32> = helper_int2ptr(); //~ ERROR it is undefined behavior to use this value -//~^ NOTE encountered a dangling reference +const INT2PTR: Option<&mut i32> = helper_int2ptr(); //~ ERROR encountered a dangling reference +static INT2PTR_STATIC: Option<&mut i32> = helper_int2ptr(); //~ ERROR encountered a dangling reference const fn helper_dangling() -> Option<&'static mut i32> { unsafe { // Undefined behaviour (dangling pointer), who doesn't love tests like this. Some(&mut *(&mut 42 as *mut i32)) } } -const DANGLING: Option<&mut i32> = helper_dangling(); //~ ERROR it is undefined behavior to use this value -static DANGLING_STATIC: Option<&mut i32> = helper_dangling(); //~ ERROR it is undefined behavior to use this value +const DANGLING: Option<&mut i32> = helper_dangling(); //~ ERROR dangling reference +static DANGLING_STATIC: Option<&mut i32> = helper_dangling(); //~ ERROR dangling reference // These are fine! Just statics pointing to mutable statics, nothing fundamentally wrong with this. static MUT_STATIC: Option<&mut i32> = helper(); 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 4ea6fa62475..6456587b77a 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,52 +1,52 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<enum-variant(Some)>.0: encountered reference to mutable memory in `const` --> $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` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/mut_ref_in_final_dynamic_check.rs:26:1 +error[E0080]: constructing invalid value at .<enum-variant(Some)>.0: encountered a dangling reference (0x2a[noalloc] has no provenance) + --> $DIR/mut_ref_in_final_dynamic_check.rs:25: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) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/mut_ref_in_final_dynamic_check.rs:28:1 +error[E0080]: constructing invalid value at .<enum-variant(Some)>.0: encountered a dangling reference (0x2a[noalloc] has no provenance) + --> $DIR/mut_ref_in_final_dynamic_check.rs:26: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) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/mut_ref_in_final_dynamic_check.rs:35:1 +error[E0080]: constructing invalid value at .<enum-variant(Some)>.0: encountered a dangling reference (use-after-free) + --> $DIR/mut_ref_in_final_dynamic_check.rs:32:1 | LL | const DANGLING: Option<&mut i32> = helper_dangling(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0: encountered a dangling reference (use-after-free) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/mut_ref_in_final_dynamic_check.rs:36:1 +error[E0080]: constructing invalid value at .<enum-variant(Some)>.0: encountered a dangling reference (use-after-free) + --> $DIR/mut_ref_in_final_dynamic_check.rs:33: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) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { diff --git a/tests/ui/consts/const-ptr-is-null.rs b/tests/ui/consts/const-ptr-is-null.rs index 319f6b1a62b..7e7b74c3520 100644 --- a/tests/ui/consts/const-ptr-is-null.rs +++ b/tests/ui/consts/const-ptr-is-null.rs @@ -19,7 +19,7 @@ const MAYBE_NULL: () = { assert!(!ptr.wrapping_byte_sub(1).is_null()); // ... but once we shift outside the allocation, with an offset divisible by 4, // we might become null. - assert!(!ptr.wrapping_sub(512).is_null()); //~ ERROR evaluation of constant value failed + assert!(!ptr.wrapping_sub(512).is_null()); //~ ERROR null-ness of this pointer cannot be determined }; fn main() {} diff --git a/tests/ui/consts/const-ptr-is-null.stderr b/tests/ui/consts/const-ptr-is-null.stderr index 1a2be3b3cb1..be0a1346c64 100644 --- a/tests/ui/consts/const-ptr-is-null.stderr +++ b/tests/ui/consts/const-ptr-is-null.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: null-ness of this pointer cannot be determined in const context --> $DIR/const-ptr-is-null.rs:22:14 | LL | assert!(!ptr.wrapping_sub(512).is_null()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: null-ness of this pointer cannot be determined in const context + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `MAYBE_NULL` failed inside this call | note: inside `std::ptr::const_ptr::<impl *const i32>::is_null` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL diff --git a/tests/ui/consts/const-size_of_val-align_of_val-extern-type.rs b/tests/ui/consts/const-size_of_val-align_of_val-extern-type.rs index 598904d3c44..14cdf6bb7c6 100644 --- a/tests/ui/consts/const-size_of_val-align_of_val-extern-type.rs +++ b/tests/ui/consts/const-size_of_val-align_of_val-extern-type.rs @@ -7,7 +7,7 @@ extern "C" { type Opaque; } -const _SIZE: usize = unsafe { size_of_val(&4 as *const i32 as *const Opaque) }; //~ ERROR constant -const _ALIGN: usize = unsafe { min_align_of_val(&4 as *const i32 as *const Opaque) }; //~ ERROR constant +const _SIZE: usize = unsafe { size_of_val(&4 as *const i32 as *const Opaque) }; //~ ERROR layout +const _ALIGN: usize = unsafe { min_align_of_val(&4 as *const i32 as *const Opaque) }; //~ ERROR layout fn main() {} diff --git a/tests/ui/consts/const-size_of_val-align_of_val-extern-type.stderr b/tests/ui/consts/const-size_of_val-align_of_val-extern-type.stderr index 4c0252123a4..64b7a4129e0 100644 --- a/tests/ui/consts/const-size_of_val-align_of_val-extern-type.stderr +++ b/tests/ui/consts/const-size_of_val-align_of_val-extern-type.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: `extern type` does not have known layout --> $DIR/const-size_of_val-align_of_val-extern-type.rs:10:31 | LL | const _SIZE: usize = unsafe { size_of_val(&4 as *const i32 as *const Opaque) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `extern type` does not have known layout + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_SIZE` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: `extern type` does not have known layout --> $DIR/const-size_of_val-align_of_val-extern-type.rs:11:32 | LL | const _ALIGN: usize = unsafe { min_align_of_val(&4 as *const i32 as *const Opaque) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `extern type` does not have known layout + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_ALIGN` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-slice-oob.rs b/tests/ui/consts/const-slice-oob.rs index 09202df72c0..6682c234eaf 100644 --- a/tests/ui/consts/const-slice-oob.rs +++ b/tests/ui/consts/const-slice-oob.rs @@ -1,7 +1,6 @@ -const FOO: &'static[u32] = &[1, 2, 3]; +const FOO: &'static [u32] = &[1, 2, 3]; const BAR: u32 = FOO[5]; -//~^ NOTE index out of bounds: the length is 3 but the index is 5 -//~| ERROR evaluation of constant value failed +//~^ ERROR index out of bounds: the length is 3 but the index is 5 fn main() { let _ = BAR; diff --git a/tests/ui/consts/const-slice-oob.stderr b/tests/ui/consts/const-slice-oob.stderr index 30ec340d2a2..9435baa0407 100644 --- a/tests/ui/consts/const-slice-oob.stderr +++ b/tests/ui/consts/const-slice-oob.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: index out of bounds: the length is 3 but the index is 5 --> $DIR/const-slice-oob.rs:2:18 | LL | const BAR: u32 = FOO[5]; - | ^^^^^^ index out of bounds: the length is 3 but the index is 5 + | ^^^^^^ evaluation of `BAR` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-unstable-intrinsic.stderr b/tests/ui/consts/const-unstable-intrinsic.stderr index 308b02386f5..7e7ba966cee 100644 --- a/tests/ui/consts/const-unstable-intrinsic.stderr +++ b/tests/ui/consts/const-unstable-intrinsic.stderr @@ -46,16 +46,11 @@ error: const function that might be (indirectly) exposed to stable cannot use `# LL | size_of_val(&x); | ^^^^^^^^^^^^^^^ | -help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the function is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn const_main() { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(local)] -LL | const fn const_main() { - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(local)]` --> $DIR/const-unstable-intrinsic.rs:26:9 @@ -63,16 +58,11 @@ error: const function that might be (indirectly) exposed to stable cannot use `# LL | min_align_of_val(&x); | ^^^^^^^^^^^^^^^^^^^^ | -help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the function is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn const_main() { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(local)] -LL | const fn const_main() { - | error: intrinsic `copy::copy` cannot be (indirectly) exposed to stable --> $DIR/const-unstable-intrinsic.rs:48:14 @@ -88,16 +78,11 @@ error: const function that might be (indirectly) exposed to stable cannot use `# LL | super::size_of_val(src); | ^^^^^^^^^^^^^^^^^^^^^^^ | -help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the function is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const unsafe fn copy<T>(src: *const T, _dst: *mut T, _count: usize) { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(local)] -LL | const unsafe fn copy<T>(src: *const T, _dst: *mut T, _count: usize) { - | error: aborting due to 8 previous errors diff --git a/tests/ui/consts/const-unwrap.rs b/tests/ui/consts/const-unwrap.rs index d48078a0834..38ebd5dd230 100644 --- a/tests/ui/consts/const-unwrap.rs +++ b/tests/ui/consts/const-unwrap.rs @@ -4,12 +4,10 @@ const FOO: i32 = Some(42i32).unwrap(); const BAR: i32 = Option::<i32>::None.unwrap(); -//~^ ERROR: evaluation of constant value failed -//~| NOTE: called `Option::unwrap()` on a `None` value +//~^ ERROR: called `Option::unwrap()` on a `None` value const BAZ: i32 = Option::<i32>::None.expect("absolutely not!"); -//~^ ERROR: evaluation of constant value failed -//~| NOTE: absolutely not! +//~^ ERROR: absolutely not! fn main() { println!("{}", FOO); diff --git a/tests/ui/consts/const-unwrap.stderr b/tests/ui/consts/const-unwrap.stderr index 832c95992c8..0b3e92d389f 100644 --- a/tests/ui/consts/const-unwrap.stderr +++ b/tests/ui/consts/const-unwrap.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: called `Option::unwrap()` on a `None` value --> $DIR/const-unwrap.rs:6:18 | LL | const BAR: i32 = Option::<i32>::None.unwrap(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: called `Option::unwrap()` on a `None` value + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/const-unwrap.rs:10:18 +error[E0080]: evaluation panicked: absolutely not! + --> $DIR/const-unwrap.rs:9:18 | LL | const BAZ: i32 = Option::<i32>::None.expect("absolutely not!"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: absolutely not! + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAZ` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const_refs_to_static_fail.rs b/tests/ui/consts/const_refs_to_static_fail.rs index e1f2262ba29..b8bab91e005 100644 --- a/tests/ui/consts/const_refs_to_static_fail.rs +++ b/tests/ui/consts/const_refs_to_static_fail.rs @@ -9,16 +9,13 @@ use std::cell::SyncUnsafeCell; static S: SyncUnsafeCell<i32> = SyncUnsafeCell::new(0); static mut S_MUT: i32 = 0; -const C1: &SyncUnsafeCell<i32> = &S; //~ERROR undefined behavior -//~| NOTE encountered reference to mutable memory +const C1: &SyncUnsafeCell<i32> = &S; //~ERROR 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 - //~^ NOTE constant accesses mutable global memory + assert!(*C2 == 0); //~ERROR constant accesses mutable global memory }; -fn main() { -} +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 245806da5c6..86d6c11dc0c 100644 --- a/tests/ui/consts/const_refs_to_static_fail.stderr +++ b/tests/ui/consts/const_refs_to_static_fail.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` --> $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` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -10,16 +10,16 @@ LL | const C1: &SyncUnsafeCell<i32> = &S; } note: erroneous constant encountered - --> $DIR/const_refs_to_static_fail.rs:15:14 + --> $DIR/const_refs_to_static_fail.rs:14:14 | LL | assert!(*C1.get() == 0); | ^^ -error[E0080]: evaluation of constant value failed - --> $DIR/const_refs_to_static_fail.rs:19:13 +error[E0080]: constant accesses mutable global memory + --> $DIR/const_refs_to_static_fail.rs:18:13 | LL | assert!(*C2 == 0); - | ^^^ constant accesses mutable global memory + | ^^^ evaluation of `C2_READ` failed here error: aborting due to 2 previous errors 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 f6ccfbfc52f..34ed8540f3f 100644 --- a/tests/ui/consts/const_refs_to_static_fail_invalid.rs +++ b/tests/ui/consts/const_refs_to_static_fail_invalid.rs @@ -8,8 +8,7 @@ fn invalid() { static S: i8 = 10; const C: &bool = unsafe { std::mem::transmute(&S) }; - //~^ERROR: undefined behavior - //~| NOTE expected a boolean + //~^ERROR: expected a boolean // This must be rejected here (or earlier), since it's not a valid `&bool`. match &true { @@ -24,8 +23,7 @@ fn extern_() { } const C: &i8 = unsafe { &S }; - //~^ERROR: undefined behavior - //~| NOTE `extern` static + //~^ERROR: `extern` static // This must be rejected here (or earlier), since the pattern cannot be read. match &0 { @@ -38,8 +36,7 @@ fn mutable() { static mut S_MUT: i32 = 0; const C: &i32 = unsafe { &S_MUT }; - //~^ERROR: undefined behavior - //~| NOTE encountered reference to mutable memory + //~^ERROR: 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 e0086e07af7..8a034aa00bc 100644 --- a/tests/ui/consts/const_refs_to_static_fail_invalid.stderr +++ b/tests/ui/consts/const_refs_to_static_fail_invalid.stderr @@ -1,30 +1,30 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>: encountered 0x0a, but expected a boolean --> $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 + | ^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refs_to_static_fail_invalid.rs:26:5 +error[E0080]: constructing invalid value: encountered reference to `extern` static in `const` + --> $DIR/const_refs_to_static_fail_invalid.rs:25:5 | LL | const C: &i8 = unsafe { &S }; - | ^^^^^^^^^^^^ constructing invalid value: encountered reference to `extern` static in `const` + | ^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refs_to_static_fail_invalid.rs:40:5 +error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` + --> $DIR/const_refs_to_static_fail_invalid.rs:38:5 | LL | const C: &i32 = unsafe { &S_MUT }; - | ^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` + | ^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { diff --git a/tests/ui/consts/const_unsafe_unreachable_ub.rs b/tests/ui/consts/const_unsafe_unreachable_ub.rs index a3f7fd46a75..39f05395127 100644 --- a/tests/ui/consts/const_unsafe_unreachable_ub.rs +++ b/tests/ui/consts/const_unsafe_unreachable_ub.rs @@ -1,14 +1,15 @@ const unsafe fn foo(x: bool) -> bool { match x { true => true, - false => std::hint::unreachable_unchecked(), //~ NOTE inside `foo` + false => std::hint::unreachable_unchecked(), + //~^ NOTE inside `foo` + //~| NOTE the failure occurred here } } const BAR: bool = unsafe { foo(false) }; -//~^ ERROR evaluation of constant value failed -//~| NOTE entering unreachable code -//~| NOTE inside `unreachable_unchecked` +//~^ NOTE failed inside this call +//~| ERROR entering unreachable code fn main() { assert_eq!(BAR, true); diff --git a/tests/ui/consts/const_unsafe_unreachable_ub.stderr b/tests/ui/consts/const_unsafe_unreachable_ub.stderr index 079ed77b219..7d2448cc3c6 100644 --- a/tests/ui/consts/const_unsafe_unreachable_ub.stderr +++ b/tests/ui/consts/const_unsafe_unreachable_ub.stderr @@ -1,16 +1,14 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/const_unsafe_unreachable_ub.rs:8:28 +error[E0080]: entering unreachable code + --> $DIR/const_unsafe_unreachable_ub.rs:10:28 | LL | const BAR: bool = unsafe { foo(false) }; - | ^^^^^^^^^^ entering unreachable code + | ^^^^^^^^^^ evaluation of `BAR` failed inside this call | note: inside `foo` --> $DIR/const_unsafe_unreachable_ub.rs:4:18 | LL | false => std::hint::unreachable_unchecked(), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: inside `unreachable_unchecked` - --> $SRC_DIR/core/src/hint.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here error: aborting due to 1 previous error diff --git a/tests/ui/consts/control-flow/assert.rs b/tests/ui/consts/control-flow/assert.rs index 9d17f65b93c..2c372075137 100644 --- a/tests/ui/consts/control-flow/assert.rs +++ b/tests/ui/consts/control-flow/assert.rs @@ -3,6 +3,6 @@ const _: () = assert!(true); const _: () = assert!(false); -//~^ ERROR evaluation of constant value failed +//~^ ERROR assertion failed fn main() {} diff --git a/tests/ui/consts/control-flow/assert.stderr b/tests/ui/consts/control-flow/assert.stderr index 3fa98b74bf6..026097a6ba0 100644 --- a/tests/ui/consts/control-flow/assert.stderr +++ b/tests/ui/consts/control-flow/assert.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: assertion failed: false --> $DIR/assert.rs:5:15 | LL | const _: () = assert!(false); - | ^^^^^^^^^^^^^^ evaluation panicked: assertion failed: false + | ^^^^^^^^^^^^^^ evaluation of `_` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/copy-intrinsic.rs b/tests/ui/consts/copy-intrinsic.rs index da483d671f9..480f1c5f460 100644 --- a/tests/ui/consts/copy-intrinsic.rs +++ b/tests/ui/consts/copy-intrinsic.rs @@ -1,22 +1,8 @@ -#![stable(feature = "dummy", since = "1.0.0")] - // ignore-tidy-linelength -#![feature(intrinsics, staged_api, rustc_attrs)] -use std::mem; +#![feature(core_intrinsics)] -#[stable(feature = "dummy", since = "1.0.0")] -#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] -#[rustc_intrinsic] -const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize) { - unimplemented!() -} - -#[stable(feature = "dummy", since = "1.0.0")] -#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] -#[rustc_intrinsic] -const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) { - unimplemented!() -} +use std::intrinsics::{copy, copy_nonoverlapping}; +use std::mem; const COPY_ZERO: () = unsafe { // Since we are not copying anything, this should be allowed. @@ -31,8 +17,7 @@ const COPY_OOB_1: () = unsafe { // Zero-sized copy is fine. 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 which is a dangling pointer + copy_nonoverlapping(0x100 as *const i32, dangle, 1); //~ ERROR which is a dangling pointer }; const COPY_OOB_2: () = unsafe { let x = 0i32; @@ -40,22 +25,18 @@ const COPY_OOB_2: () = unsafe { // Zero-sized copy is fine. 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 is at or beyond the end of the allocation of size 4 bytes + copy_nonoverlapping(dangle, 0x100 as *mut i32, 1); //~ ERROR is at or beyond the end of the allocation of size 4 bytes }; const COPY_SIZE_OVERFLOW: () = unsafe { let x = 0; let mut y = 0; - copy(&x, &mut y, 1usize << (mem::size_of::<usize>() * 8 - 1)); //~ ERROR evaluation of constant value failed [E0080] - //~| NOTE overflow computing total size of `copy` + copy(&x, &mut y, 1usize << (mem::size_of::<usize>() * 8 - 1)); //~ ERROR overflow computing total size of `copy` }; const COPY_NONOVERLAPPING_SIZE_OVERFLOW: () = unsafe { let x = 0; let mut y = 0; - copy_nonoverlapping(&x, &mut y, 1usize << (mem::size_of::<usize>() * 8 - 1)); //~ ERROR evaluation of constant value failed [E0080] - //~| NOTE overflow computing total size of `copy_nonoverlapping` + copy_nonoverlapping(&x, &mut y, 1usize << (mem::size_of::<usize>() * 8 - 1)); //~ ERROR overflow computing total size of `copy_nonoverlapping` }; -fn main() { -} +fn main() {} diff --git a/tests/ui/consts/copy-intrinsic.stderr b/tests/ui/consts/copy-intrinsic.stderr index 13321b5703a..41cf7e51357 100644 --- a/tests/ui/consts/copy-intrinsic.stderr +++ b/tests/ui/consts/copy-intrinsic.stderr @@ -1,26 +1,26 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/copy-intrinsic.rs:34:5 +error[E0080]: memory access failed: attempting to access 4 bytes, but got 0x100[noalloc] which is a dangling pointer (it has no provenance) + --> $DIR/copy-intrinsic.rs:20:5 | LL | copy_nonoverlapping(0x100 as *const i32, dangle, 1); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got 0x100[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `COPY_OOB_1` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/copy-intrinsic.rs:43:5 +error[E0080]: 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 + --> $DIR/copy-intrinsic.rs:28:5 | LL | copy_nonoverlapping(dangle, 0x100 as *mut i32, 1); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `COPY_OOB_2` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/copy-intrinsic.rs:50:5 +error[E0080]: overflow computing total size of `copy` + --> $DIR/copy-intrinsic.rs:34:5 | LL | copy(&x, &mut y, 1usize << (mem::size_of::<usize>() * 8 - 1)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `copy` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `COPY_SIZE_OVERFLOW` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/copy-intrinsic.rs:56:5 +error[E0080]: overflow computing total size of `copy_nonoverlapping` + --> $DIR/copy-intrinsic.rs:39:5 | LL | copy_nonoverlapping(&x, &mut y, 1usize << (mem::size_of::<usize>() * 8 - 1)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `copy_nonoverlapping` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `COPY_NONOVERLAPPING_SIZE_OVERFLOW` failed here error: aborting due to 4 previous errors diff --git a/tests/ui/consts/dangling-alloc-id-ice.rs b/tests/ui/consts/dangling-alloc-id-ice.rs index 8e9493c8d28..b77c5971b2b 100644 --- a/tests/ui/consts/dangling-alloc-id-ice.rs +++ b/tests/ui/consts/dangling-alloc-id-ice.rs @@ -10,7 +10,7 @@ union Foo<'a> { } const FOO: &() = { - //~^ ERROR it is undefined behavior to use this value + //~^ ERROR dangling reference let y = (); unsafe { Foo { y: &y }.long_live_the_unit } }; diff --git a/tests/ui/consts/dangling-alloc-id-ice.stderr b/tests/ui/consts/dangling-alloc-id-ice.stderr index 881c0b162ed..65a46b62dae 100644 --- a/tests/ui/consts/dangling-alloc-id-ice.stderr +++ b/tests/ui/consts/dangling-alloc-id-ice.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered a dangling reference (use-after-free) --> $DIR/dangling-alloc-id-ice.rs:12:1 | LL | const FOO: &() = { - | ^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (use-after-free) + | ^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { diff --git a/tests/ui/consts/dangling-zst-ice-issue-126393.rs b/tests/ui/consts/dangling-zst-ice-issue-126393.rs index 4beee913a97..6b667fdfd35 100644 --- a/tests/ui/consts/dangling-zst-ice-issue-126393.rs +++ b/tests/ui/consts/dangling-zst-ice-issue-126393.rs @@ -5,7 +5,7 @@ pub struct Wrapper; pub static MAGIC_FFI_REF: &'static Wrapper = unsafe { -//~^ERROR: it is undefined behavior to use this value + //~^ ERROR: dangling reference std::mem::transmute(&{ let y = 42; y diff --git a/tests/ui/consts/dangling-zst-ice-issue-126393.stderr b/tests/ui/consts/dangling-zst-ice-issue-126393.stderr index d32b427f14e..2f600e494c4 100644 --- a/tests/ui/consts/dangling-zst-ice-issue-126393.stderr +++ b/tests/ui/consts/dangling-zst-ice-issue-126393.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered a dangling reference (use-after-free) --> $DIR/dangling-zst-ice-issue-126393.rs:7:1 | LL | pub static MAGIC_FFI_REF: &'static Wrapper = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (use-after-free) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { diff --git a/tests/ui/consts/eval-enum.rs b/tests/ui/consts/eval-enum.rs index fa9ad6736e2..ae0296bd4c0 100644 --- a/tests/ui/consts/eval-enum.rs +++ b/tests/ui/consts/eval-enum.rs @@ -1,10 +1,8 @@ enum Test { - DivZero = 1/0, - //~^ NOTE attempt to divide `1_isize` by zero - //~| ERROR evaluation of constant value failed - RemZero = 1%0, - //~^ NOTE attempt to calculate the remainder of `1_isize` with a divisor of zero - //~| ERROR evaluation of constant value failed + DivZero = 1 / 0, + //~^ ERROR attempt to divide `1_isize` by zero + RemZero = 1 % 0, + //~^ ERROR attempt to calculate the remainder of `1_isize` with a divisor of zero } fn main() {} diff --git a/tests/ui/consts/eval-enum.stderr b/tests/ui/consts/eval-enum.stderr index fb4d903489f..d647485bc5d 100644 --- a/tests/ui/consts/eval-enum.stderr +++ b/tests/ui/consts/eval-enum.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to divide `1_isize` by zero --> $DIR/eval-enum.rs:2:15 | -LL | DivZero = 1/0, - | ^^^ attempt to divide `1_isize` by zero +LL | DivZero = 1 / 0, + | ^^^^^ evaluation of `Test::DivZero::{constant#0}` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/eval-enum.rs:5:15 +error[E0080]: attempt to calculate the remainder of `1_isize` with a divisor of zero + --> $DIR/eval-enum.rs:4:15 | -LL | RemZero = 1%0, - | ^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero +LL | RemZero = 1 % 0, + | ^^^^^ evaluation of `Test::RemZero::{constant#0}` failed here error: aborting due to 2 previous errors 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 c3bd8301d5c..e17bac603b4 100644 --- a/tests/ui/consts/extra-const-ub/detect-extra-ub.rs +++ b/tests/ui/consts/extra-const-ub/detect-extra-ub.rs @@ -28,41 +28,35 @@ enum UninhDiscriminant { const INVALID_BOOL: () = unsafe { let _x: bool = transmute(3u8); - //[with_flag]~^ ERROR: evaluation of constant value failed - //[with_flag]~| NOTE invalid value + //[with_flag]~^ ERROR: invalid value }; const INVALID_PTR_IN_INT: () = unsafe { let _x: usize = transmute(&3u8); - //[with_flag]~^ ERROR: evaluation of constant value failed - //[with_flag]~| NOTE invalid value + //[with_flag]~^ ERROR: invalid value }; const INVALID_PTR_IN_ENUM: () = unsafe { let _x: PtrSizedEnum = transmute(&3u8); - //[with_flag]~^ ERROR: evaluation of constant value failed - //[with_flag]~| NOTE invalid value + //[with_flag]~^ ERROR: invalid value }; const INVALID_SLICE_TO_USIZE_TRANSMUTE: () = unsafe { let x: &[u8] = &[0; 32]; let _x: (usize, usize) = transmute(x); - //[with_flag]~^ ERROR: evaluation of constant value failed - //[with_flag]~| NOTE invalid value + //[with_flag]~^ ERROR: invalid value }; const UNALIGNED_PTR: () = unsafe { let _x: &u32 = transmute(&[0u8; 4]); - //[with_flag]~^ ERROR: evaluation of constant value failed - //[with_flag]~| NOTE invalid value + //[with_flag]~^ ERROR: invalid value }; const UNINHABITED_VARIANT: () = unsafe { let data = [1u8]; // Not using transmute, we want to hit the ImmTy code path. let v = *addr_of!(data).cast::<UninhDiscriminant>(); - //[with_flag]~^ ERROR: evaluation of constant value failed - //[with_flag]~| NOTE invalid value + //[with_flag]~^ ERROR: invalid value }; const PARTIAL_POINTER: () = unsafe { @@ -81,8 +75,7 @@ const PARTIAL_POINTER: () = unsafe { let mem = Packed { pad1: 0, ptr: &0u8 as *const u8, pad2: [0; 7] }; let mem = Align { p: mem, align: 0 }; let _val = *(&mem as *const Align as *const [*const u8; 2]); - //[with_flag]~^ ERROR: evaluation of constant value failed - //[with_flag]~| NOTE invalid value + //[with_flag]~^ ERROR: invalid value }; // Regression tests for an ICE (related to <https://github.com/rust-lang/rust/issues/113988>). @@ -96,8 +89,7 @@ const VALID_ARRAY: [Option<i32>; 0] = { let e = [None; 0]; e }; const OVERSIZED_REF: () = { unsafe { let slice: *const [u8] = transmute((1usize, usize::MAX)); let _val = &*slice; - //[with_flag]~^ ERROR: evaluation of constant value failed - //[with_flag]~| NOTE slice is bigger than largest supported object + //[with_flag]~^ ERROR: slice is bigger than largest supported object } }; fn main() {} 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 ea3b0e70b82..6af72868045 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,62 +1,62 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: constructing invalid value: encountered 0x03, but expected a boolean --> $DIR/detect-extra-ub.rs:30:20 | LL | let _x: bool = transmute(3u8); - | ^^^^^^^^^^^^^^ constructing invalid value: encountered 0x03, but expected a boolean + | ^^^^^^^^^^^^^^ evaluation of `INVALID_BOOL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/detect-extra-ub.rs:36:21 +error[E0080]: constructing invalid value: encountered a pointer, but expected an integer + --> $DIR/detect-extra-ub.rs:35:21 | LL | let _x: usize = transmute(&3u8); - | ^^^^^^^^^^^^^^^ constructing invalid value: encountered a pointer, but expected an integer + | ^^^^^^^^^^^^^^^ evaluation of `INVALID_PTR_IN_INT` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:42:28 +error[E0080]: constructing invalid value at .<enum-tag>: encountered a pointer, but expected an integer + --> $DIR/detect-extra-ub.rs:40:28 | LL | let _x: PtrSizedEnum = transmute(&3u8); - | ^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered a pointer, but expected an integer + | ^^^^^^^^^^^^^^^ evaluation of `INVALID_PTR_IN_ENUM` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:49:30 +error[E0080]: constructing invalid value at .0: encountered a pointer, but expected an integer + --> $DIR/detect-extra-ub.rs:46:30 | LL | let _x: (usize, usize) = transmute(x); - | ^^^^^^^^^^^^ constructing invalid value at .0: encountered a pointer, but expected an integer + | ^^^^^^^^^^^^ evaluation of `INVALID_SLICE_TO_USIZE_TRANSMUTE` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:55:20 +error[E0080]: constructing invalid value: encountered an unaligned reference (required 4 byte alignment but found 1) + --> $DIR/detect-extra-ub.rs:51:20 | LL | let _x: &u32 = transmute(&[0u8; 4]); - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 4 byte alignment but found 1) + | ^^^^^^^^^^^^^^^^^^^^ evaluation of `UNALIGNED_PTR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/detect-extra-ub.rs:63:13 +error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant + --> $DIR/detect-extra-ub.rs:58:13 | LL | let v = *addr_of!(data).cast::<UninhDiscriminant>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNINHABITED_VARIANT` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/detect-extra-ub.rs:83:16 +error[E0080]: constructing invalid value at [0]: encountered a partial pointer or a mix of pointers + --> $DIR/detect-extra-ub.rs:77: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `PARTIAL_POINTER` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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:98:16 +error[E0080]: constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + --> $DIR/detect-extra-ub.rs:91:16 | LL | let _val = &*slice; - | ^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + | ^^^^^^^ evaluation of `OVERSIZED_REF` failed here error: aborting due to 8 previous errors diff --git a/tests/ui/consts/interior-mut-const-via-union.32bit.stderr b/tests/ui/consts/interior-mut-const-via-union.32bit.stderr index fb06643df85..47bb2e5e879 100644 --- a/tests/ui/consts/interior-mut-const-via-union.32bit.stderr +++ b/tests/ui/consts/interior-mut-const-via-union.32bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>.y.<enum-variant(B)>.0: encountered `UnsafeCell` in read-only memory --> $DIR/interior-mut-const-via-union.rs:34:1 | LL | fn main() { - | ^^^^^^^^^ constructing invalid value at .<deref>.y.<enum-variant(B)>.0: encountered `UnsafeCell` in read-only memory + | ^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { diff --git a/tests/ui/consts/interior-mut-const-via-union.64bit.stderr b/tests/ui/consts/interior-mut-const-via-union.64bit.stderr index f39ebe0afbd..b4c9a4bd47e 100644 --- a/tests/ui/consts/interior-mut-const-via-union.64bit.stderr +++ b/tests/ui/consts/interior-mut-const-via-union.64bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>.y.<enum-variant(B)>.0: encountered `UnsafeCell` in read-only memory --> $DIR/interior-mut-const-via-union.rs:34:1 | LL | fn main() { - | ^^^^^^^^^ constructing invalid value at .<deref>.y.<enum-variant(B)>.0: encountered `UnsafeCell` in read-only memory + | ^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { diff --git a/tests/ui/consts/interior-mut-const-via-union.rs b/tests/ui/consts/interior-mut-const-via-union.rs index 6d40a9ba850..5e624671aee 100644 --- a/tests/ui/consts/interior-mut-const-via-union.rs +++ b/tests/ui/consts/interior-mut-const-via-union.rs @@ -31,7 +31,7 @@ const C: S = { s }; -fn main() { //~ ERROR it is undefined behavior to use this value - // FIXME the span here is wrong, sould be pointing at the line below, not above. +fn main() { //~ ERROR encountered `UnsafeCell` in read-only memory + // FIXME the span here is wrong, should be pointing at the line below, not above. let _: &'static _ = &C; } diff --git a/tests/ui/consts/issue-17718-const-bad-values.rs b/tests/ui/consts/issue-17718-const-bad-values.rs index 286972365d5..40fc02cf644 100644 --- a/tests/ui/consts/issue-17718-const-bad-values.rs +++ b/tests/ui/consts/issue-17718-const-bad-values.rs @@ -9,7 +9,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 -//~| NOTE reference to mutable memory +//~^ ERROR: 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 102491e90ba..effb614b15b 100644 --- a/tests/ui/consts/issue-17718-const-bad-values.stderr +++ b/tests/ui/consts/issue-17718-const-bad-values.stderr @@ -4,11 +4,11 @@ error[E0764]: mutable references are not allowed in the final value of constants LL | const C1: &'static mut [usize] = &mut []; | ^^^^^^^ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` --> $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` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $PTR, align: $PTR) { diff --git a/tests/ui/consts/issue-32829.rs b/tests/ui/consts/issue-32829.rs index 25f323b9803..e02db69c686 100644 --- a/tests/ui/consts/issue-32829.rs +++ b/tests/ui/consts/issue-32829.rs @@ -1,5 +1,5 @@ static S : u64 = { { panic!("foo"); 0 } }; -//~^ ERROR could not evaluate static initializer +//~^ ERROR evaluation panicked: foo fn main() { println!("{:?}", S); diff --git a/tests/ui/consts/issue-32829.stderr b/tests/ui/consts/issue-32829.stderr index 542dce19151..b02b9122cec 100644 --- a/tests/ui/consts/issue-32829.stderr +++ b/tests/ui/consts/issue-32829.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: evaluation panicked: foo --> $DIR/issue-32829.rs:1:22 | LL | static S : u64 = { { panic!("foo"); 0 } }; - | ^^^^^^^^^^^^^ evaluation panicked: foo + | ^^^^^^^^^^^^^ evaluation of `S` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/issue-63952.32bit.stderr b/tests/ui/consts/issue-63952.32bit.stderr index f562f9104e3..e5340788167 100644 --- a/tests/ui/consts/issue-63952.32bit.stderr +++ b/tests/ui/consts/issue-63952.32bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object --> $DIR/issue-63952.rs:17:1 | LL | const SLICE_WAY_TOO_LONG: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { diff --git a/tests/ui/consts/issue-63952.64bit.stderr b/tests/ui/consts/issue-63952.64bit.stderr index fe66bec13a1..27e74833fc5 100644 --- a/tests/ui/consts/issue-63952.64bit.stderr +++ b/tests/ui/consts/issue-63952.64bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object --> $DIR/issue-63952.rs:17:1 | LL | const SLICE_WAY_TOO_LONG: &[u8] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { diff --git a/tests/ui/consts/issue-63952.rs b/tests/ui/consts/issue-63952.rs index aee06f8eb04..fce6013b4d3 100644 --- a/tests/ui/consts/issue-63952.rs +++ b/tests/ui/consts/issue-63952.rs @@ -14,7 +14,7 @@ union SliceTransmute { } // bad slice: length too big to even exist anywhere -const SLICE_WAY_TOO_LONG: &[u8] = unsafe { //~ ERROR: it is undefined behavior to use this value +const SLICE_WAY_TOO_LONG: &[u8] = unsafe { //~ ERROR: slice is bigger than largest supported object SliceTransmute { repr: SliceRepr { ptr: &42, diff --git a/tests/ui/consts/issue-64506.rs b/tests/ui/consts/issue-64506.rs index 096d29cbe49..8511c1edb30 100644 --- a/tests/ui/consts/issue-64506.rs +++ b/tests/ui/consts/issue-64506.rs @@ -14,7 +14,7 @@ const FOO: () = { b: (), } let x = unsafe { Foo { b: () }.a }; - //~^ ERROR: evaluation of constant value failed + //~^ ERROR: value of uninhabited type let x = &x.inner; }; diff --git a/tests/ui/consts/issue-64506.stderr b/tests/ui/consts/issue-64506.stderr index 4cc2b713741..9fce07c5850 100644 --- a/tests/ui/consts/issue-64506.stderr +++ b/tests/ui/consts/issue-64506.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: constructing invalid value at .inner: encountered a value of uninhabited type `AnonPipe` --> $DIR/issue-64506.rs:16:22 | LL | let x = unsafe { Foo { b: () }.a }; - | ^^^^^^^^^^^^^^^ constructing invalid value at .inner: encountered a value of uninhabited type `AnonPipe` + | ^^^^^^^^^^^^^^^ evaluation of `FOO` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/issue-66693-panic-in-array-len.rs b/tests/ui/consts/issue-66693-panic-in-array-len.rs index fc0dcd7a44d..2256970e337 100644 --- a/tests/ui/consts/issue-66693-panic-in-array-len.rs +++ b/tests/ui/consts/issue-66693-panic-in-array-len.rs @@ -8,7 +8,7 @@ fn main() { // ensure that conforming panics are handled correctly let _ = [false; panic!()]; - //~^ ERROR: evaluation of constant value failed + //~^ ERROR: explicit panic // typechecking halts before getting to this one let _ = ['a', panic!("panic in array len")]; diff --git a/tests/ui/consts/issue-66693-panic-in-array-len.stderr b/tests/ui/consts/issue-66693-panic-in-array-len.stderr index fdef515b6d4..241643a83be 100644 --- a/tests/ui/consts/issue-66693-panic-in-array-len.stderr +++ b/tests/ui/consts/issue-66693-panic-in-array-len.stderr @@ -4,11 +4,11 @@ error: argument to `panic!()` in a const context must have type `&str` LL | let _ = [0i32; panic!(2f32)]; | ^^^^^^^^^^^^ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/issue-66693-panic-in-array-len.rs:10:21 | LL | let _ = [false; panic!()]; - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `main::{constant#1}` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/issue-66693.rs b/tests/ui/consts/issue-66693.rs index 416bd8ec72a..9d82d5a42bd 100644 --- a/tests/ui/consts/issue-66693.rs +++ b/tests/ui/consts/issue-66693.rs @@ -14,9 +14,9 @@ const fn _foo() { // ensure that conforming panics don't cause an error beyond the failure to const eval const _: () = panic!(); -//~^ ERROR: evaluation of constant value failed +//~^ ERROR: explicit panic static _BAR: () = panic!("panic in static"); -//~^ ERROR could not evaluate static initializer +//~^ ERROR panic in static const fn _bar() { panic!("panic in const fn"); diff --git a/tests/ui/consts/issue-66693.stderr b/tests/ui/consts/issue-66693.stderr index ea657ec34bd..5540d4f2d22 100644 --- a/tests/ui/consts/issue-66693.stderr +++ b/tests/ui/consts/issue-66693.stderr @@ -10,17 +10,17 @@ error: argument to `panic!()` in a const context must have type `&str` LL | static _FOO: () = panic!(true); | ^^^^^^^^^^^^ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/issue-66693.rs:16:15 | LL | const _: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `_` failed here -error[E0080]: could not evaluate static initializer +error[E0080]: evaluation panicked: panic in static --> $DIR/issue-66693.rs:18:19 | LL | static _BAR: () = panic!("panic in static"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: panic in static + | ^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_BAR` failed here error: argument to `panic!()` in a const context must have type `&str` --> $DIR/issue-66693.rs:11:5 diff --git a/tests/ui/consts/issue-76064.rs b/tests/ui/consts/issue-76064.rs index 3c153ad726e..b878629138c 100644 --- a/tests/ui/consts/issue-76064.rs +++ b/tests/ui/consts/issue-76064.rs @@ -1,3 +1,3 @@ -struct Bug([u8; panic!("panic")]); //~ ERROR evaluation of constant value failed +struct Bug([u8; panic!("panic")]); //~ ERROR panic fn main() {} diff --git a/tests/ui/consts/issue-76064.stderr b/tests/ui/consts/issue-76064.stderr index 786d4213f1e..17dcb22aa1a 100644 --- a/tests/ui/consts/issue-76064.stderr +++ b/tests/ui/consts/issue-76064.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: panic --> $DIR/issue-76064.rs:1:17 | LL | struct Bug([u8; panic!("panic")]); - | ^^^^^^^^^^^^^^^ evaluation panicked: panic + | ^^^^^^^^^^^^^^^ evaluation of `Bug::0::{constant#0}` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/issue-79690.64bit.stderr b/tests/ui/consts/issue-79690.64bit.stderr index d603a1dc291..7488f7b7752 100644 --- a/tests/ui/consts/issue-79690.64bit.stderr +++ b/tests/ui/consts/issue-79690.64bit.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .1: encountered a dangling reference (going beyond the bounds of its allocation) --> $DIR/issue-79690.rs:30:1 | LL | const G: Fat = unsafe { Transmute { t: FOO }.u }; - | ^^^^^^^^^^^^ constructing invalid value at .1: encountered a dangling reference (going beyond the bounds of its allocation) + | ^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 16, align: 8) { diff --git a/tests/ui/consts/issue-79690.rs b/tests/ui/consts/issue-79690.rs index 3da4cb73f11..24e3220155d 100644 --- a/tests/ui/consts/issue-79690.rs +++ b/tests/ui/consts/issue-79690.rs @@ -28,6 +28,6 @@ const FOO: &dyn Bar = &Foo { bar: false, }; const G: Fat = unsafe { Transmute { t: FOO }.u }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR dangling reference fn main() {} diff --git a/tests/ui/consts/issue-miri-1910.rs b/tests/ui/consts/issue-miri-1910.rs index d194dd3c78b..6eae885ea8a 100644 --- a/tests/ui/consts/issue-miri-1910.rs +++ b/tests/ui/consts/issue-miri-1910.rs @@ -5,7 +5,7 @@ const C: () = unsafe { let foo = Some(&42 as *const i32); let one_and_a_half_pointers = std::mem::size_of::<*const i32>()/2*3; (&foo as *const _ as *const u8).add(one_and_a_half_pointers).read(); - //~^ ERROR evaluation of constant value failed + //~^ ERROR unable to turn pointer into integer }; fn main() { diff --git a/tests/ui/consts/issue-miri-1910.stderr b/tests/ui/consts/issue-miri-1910.stderr index 59cbccc13a7..140b1861bb4 100644 --- a/tests/ui/consts/issue-miri-1910.stderr +++ b/tests/ui/consts/issue-miri-1910.stderr @@ -1,13 +1,9 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/issue-miri-1910.rs:7:5 | LL | (&foo as *const _ as *const u8).add(one_and_a_half_pointers).read(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `C` failed here | -note: inside `std::ptr::const_ptr::<impl *const u8>::read` - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -note: inside `std::ptr::read::<u8>` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported diff --git a/tests/ui/consts/large_const_alloc.rs b/tests/ui/consts/large_const_alloc.rs index 3573a018630..c5b19dbc17f 100644 --- a/tests/ui/consts/large_const_alloc.rs +++ b/tests/ui/consts/large_const_alloc.rs @@ -9,12 +9,12 @@ const FOO: () = { // 128 TiB, unlikely anyone has that much RAM let x = [0_u8; (1 << 47) - 1]; - //~^ ERROR evaluation of constant value failed + //~^ ERROR tried to allocate more memory than available to compiler }; static FOO2: () = { let x = [0_u8; (1 << 47) - 1]; - //~^ ERROR could not evaluate static initializer + //~^ ERROR tried to allocate more memory than available to compiler }; fn main() { diff --git a/tests/ui/consts/large_const_alloc.stderr b/tests/ui/consts/large_const_alloc.stderr index f3f3de7af63..a0b21555608 100644 --- a/tests/ui/consts/large_const_alloc.stderr +++ b/tests/ui/consts/large_const_alloc.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: tried to allocate more memory than available to compiler --> $DIR/large_const_alloc.rs:11:13 | LL | let x = [0_u8; (1 << 47) - 1]; - | ^^^^^^^^^^^^^^^^^^^^^ tried to allocate more memory than available to compiler + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `FOO` failed here -error[E0080]: could not evaluate static initializer +error[E0080]: tried to allocate more memory than available to compiler --> $DIR/large_const_alloc.rs:16:13 | LL | let x = [0_u8; (1 << 47) - 1]; - | ^^^^^^^^^^^^^^^^^^^^^ tried to allocate more memory than available to compiler + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `FOO2` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/min_const_fn/min_const_fn_libstd_stability.stderr b/tests/ui/consts/min_const_fn/min_const_fn_libstd_stability.stderr index 26dedc49a39..9efc252ce6b 100644 --- a/tests/ui/consts/min_const_fn/min_const_fn_libstd_stability.stderr +++ b/tests/ui/consts/min_const_fn/min_const_fn_libstd_stability.stderr @@ -5,16 +5,11 @@ LL | const fn bar() -> u32 { foo() } | ^^^^^ | = help: mark the callee as `#[rustc_const_stable_indirect]` if it does not itself require any unstable features -help: if the caller is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the caller is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn bar() -> u32 { foo() } | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(foo)] -LL | const fn bar() -> u32 { foo() } - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(foo2)]` --> $DIR/min_const_fn_libstd_stability.rs:26:26 @@ -23,16 +18,11 @@ LL | const fn bar2() -> u32 { foo2() } | ^^^^^^ | = help: mark the callee as `#[rustc_const_stable_indirect]` if it does not itself require any unstable features -help: if the caller is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the caller is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn bar2() -> u32 { foo2() } | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(foo2)] -LL | const fn bar2() -> u32 { foo2() } - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(const_async_blocks)]` --> $DIR/min_const_fn_libstd_stability.rs:32:13 @@ -40,16 +30,11 @@ error: const function that might be (indirectly) exposed to stable cannot use `# LL | let x = async { 13 }; | ^^^^^^^^^^^^ | -help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the function is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn bar3() -> u32 { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(const_async_blocks)] -LL | const fn bar3() -> u32 { - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(foo)]` --> $DIR/min_const_fn_libstd_stability.rs:34:5 @@ -58,16 +43,11 @@ LL | foo() | ^^^^^ | = help: mark the callee as `#[rustc_const_stable_indirect]` if it does not itself require any unstable features -help: if the caller is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the caller is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn bar3() -> u32 { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(foo)] -LL | const fn bar3() -> u32 { - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(foo2)]` --> $DIR/min_const_fn_libstd_stability.rs:46:32 @@ -76,16 +56,11 @@ LL | const fn bar2_gated() -> u32 { foo2_gated() } | ^^^^^^^^^^^^ | = help: mark the callee as `#[rustc_const_stable_indirect]` if it does not itself require any unstable features -help: if the caller is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the caller is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn bar2_gated() -> u32 { foo2_gated() } | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(foo2)] -LL | const fn bar2_gated() -> u32 { foo2_gated() } - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(foo2)]` --> $DIR/min_const_fn_libstd_stability.rs:53:63 @@ -94,16 +69,11 @@ LL | pub(crate) const fn bar2_gated_stable_indirect() -> u32 { super::foo2_g | ^^^^^^^^^^^^^^^^^^^ | = help: mark the callee as `#[rustc_const_stable_indirect]` if it does not itself require any unstable features -help: if the caller is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the caller is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | pub(crate) const fn bar2_gated_stable_indirect() -> u32 { super::foo2_gated() } | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(foo2)] -LL | pub(crate) const fn bar2_gated_stable_indirect() -> u32 { super::foo2_gated() } - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(foo2)]` --> $DIR/min_const_fn_libstd_stability.rs:59:37 @@ -112,16 +82,11 @@ LL | const fn stable_indirect() -> u32 { foo2_gated() } | ^^^^^^^^^^^^ | = help: mark the callee as `#[rustc_const_stable_indirect]` if it does not itself require any unstable features -help: if the caller is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the caller is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn stable_indirect() -> u32 { foo2_gated() } | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(foo2)] -LL | const fn stable_indirect() -> u32 { foo2_gated() } - | error: aborting due to 7 previous errors diff --git a/tests/ui/consts/min_const_fn/min_const_unsafe_fn_libstd_stability.stderr b/tests/ui/consts/min_const_fn/min_const_unsafe_fn_libstd_stability.stderr index b61f7db6f43..0712a790955 100644 --- a/tests/ui/consts/min_const_fn/min_const_unsafe_fn_libstd_stability.stderr +++ b/tests/ui/consts/min_const_fn/min_const_unsafe_fn_libstd_stability.stderr @@ -5,16 +5,11 @@ LL | const unsafe fn bar() -> u32 { unsafe { foo() } } | ^^^^^ | = help: mark the callee as `#[rustc_const_stable_indirect]` if it does not itself require any unstable features -help: if the caller is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the caller is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const unsafe fn bar() -> u32 { unsafe { foo() } } | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(foo)] -LL | const unsafe fn bar() -> u32 { unsafe { foo() } } - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(foo2)]` --> $DIR/min_const_unsafe_fn_libstd_stability.rs:25:42 @@ -23,16 +18,11 @@ LL | const unsafe fn bar2() -> u32 { unsafe { foo2() } } | ^^^^^^ | = help: mark the callee as `#[rustc_const_stable_indirect]` if it does not itself require any unstable features -help: if the caller is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the caller is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const unsafe fn bar2() -> u32 { unsafe { foo2() } } | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(foo2)] -LL | const unsafe fn bar2() -> u32 { unsafe { foo2() } } - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(foo2)]` --> $DIR/min_const_unsafe_fn_libstd_stability.rs:35:48 @@ -41,16 +31,11 @@ LL | const unsafe fn bar2_gated() -> u32 { unsafe { foo2_gated() } } | ^^^^^^^^^^^^ | = help: mark the callee as `#[rustc_const_stable_indirect]` if it does not itself require any unstable features -help: if the caller is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the caller is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const unsafe fn bar2_gated() -> u32 { unsafe { foo2_gated() } } | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(foo2)] -LL | const unsafe fn bar2_gated() -> u32 { unsafe { foo2_gated() } } - | error: aborting due to 3 previous errors diff --git a/tests/ui/consts/min_const_fn/min_const_unsafe_fn_libstd_stability2.stderr b/tests/ui/consts/min_const_fn/min_const_unsafe_fn_libstd_stability2.stderr index fad8e396e9a..618b9a16dd4 100644 --- a/tests/ui/consts/min_const_fn/min_const_unsafe_fn_libstd_stability2.stderr +++ b/tests/ui/consts/min_const_fn/min_const_unsafe_fn_libstd_stability2.stderr @@ -5,16 +5,11 @@ LL | const unsafe fn bar() -> u32 { foo() } | ^^^^^ | = help: mark the callee as `#[rustc_const_stable_indirect]` if it does not itself require any unstable features -help: if the caller is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the caller is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const unsafe fn bar() -> u32 { foo() } | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(foo)] -LL | const unsafe fn bar() -> u32 { foo() } - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(foo2)]` --> $DIR/min_const_unsafe_fn_libstd_stability2.rs:25:33 @@ -23,16 +18,11 @@ LL | const unsafe fn bar2() -> u32 { foo2() } | ^^^^^^ | = help: mark the callee as `#[rustc_const_stable_indirect]` if it does not itself require any unstable features -help: if the caller is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the caller is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const unsafe fn bar2() -> u32 { foo2() } | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(foo2)] -LL | const unsafe fn bar2() -> u32 { foo2() } - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(foo2)]` --> $DIR/min_const_unsafe_fn_libstd_stability2.rs:35:39 @@ -41,16 +31,11 @@ LL | const unsafe fn bar2_gated() -> u32 { foo2_gated() } | ^^^^^^^^^^^^ | = help: mark the callee as `#[rustc_const_stable_indirect]` if it does not itself require any unstable features -help: if the caller is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the caller is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const unsafe fn bar2_gated() -> u32 { foo2_gated() } | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(foo2)] -LL | const unsafe fn bar2_gated() -> u32 { foo2_gated() } - | error: aborting due to 3 previous errors diff --git a/tests/ui/consts/min_const_fn/recursive_const_stab_unmarked_crate_imports.stderr b/tests/ui/consts/min_const_fn/recursive_const_stab_unmarked_crate_imports.stderr index bbe749f5958..04804cb6d33 100644 --- a/tests/ui/consts/min_const_fn/recursive_const_stab_unmarked_crate_imports.stderr +++ b/tests/ui/consts/min_const_fn/recursive_const_stab_unmarked_crate_imports.stderr @@ -5,16 +5,11 @@ LL | unstable_if_unmarked_const_fn_crate::not_stably_const(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: mark the callee as `#[rustc_const_stable_indirect]` if it does not itself require any unstable features -help: if the caller is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the caller is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn stable_fn() { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(rustc_private)] -LL | const fn stable_fn() { - | error: `just_a_fn` cannot be (indirectly) exposed to stable --> $DIR/recursive_const_stab_unmarked_crate_imports.rs:17:5 diff --git a/tests/ui/consts/min_const_fn/recursive_const_stab_unstable_if_unmarked.stderr b/tests/ui/consts/min_const_fn/recursive_const_stab_unstable_if_unmarked.stderr index 9d7b81c822b..14940ae93f8 100644 --- a/tests/ui/consts/min_const_fn/recursive_const_stab_unstable_if_unmarked.stderr +++ b/tests/ui/consts/min_const_fn/recursive_const_stab_unstable_if_unmarked.stderr @@ -5,16 +5,11 @@ LL | not_stably_const(); | ^^^^^^^^^^^^^^^^^^ | = help: mark the callee as `#[rustc_const_stable_indirect]` if it does not itself require any unstable features -help: if the caller is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the caller is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | pub const fn expose_on_stable() { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(rustc_private)] -LL | pub const fn expose_on_stable() { - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(const_async_blocks)]` --> $DIR/recursive_const_stab_unstable_if_unmarked.rs:18:14 @@ -22,16 +17,11 @@ error: const function that might be (indirectly) exposed to stable cannot use `# LL | let _x = async { 15 }; | ^^^^^^^^^^^^ | -help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the function is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | pub const fn expose_on_stable() { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(const_async_blocks)] -LL | pub const fn expose_on_stable() { - | error: aborting due to 2 previous errors diff --git a/tests/ui/consts/miri_unleashed/abi-mismatch.rs b/tests/ui/consts/miri_unleashed/abi-mismatch.rs index 6a46079b39b..843de1e63c6 100644 --- a/tests/ui/consts/miri_unleashed/abi-mismatch.rs +++ b/tests/ui/consts/miri_unleashed/abi-mismatch.rs @@ -9,8 +9,8 @@ const fn call_rust_fn(my_fn: extern "Rust" fn()) { } static VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) }); -//~^ ERROR could not evaluate static initializer -//~| NOTE calling a function with calling convention "C" using calling convention "Rust" +//~^ NOTE failed inside this call +//~| ERROR calling a function with calling convention "C" using calling convention "Rust" fn main() {} diff --git a/tests/ui/consts/miri_unleashed/abi-mismatch.stderr b/tests/ui/consts/miri_unleashed/abi-mismatch.stderr index 7d1fdcce526..4576eed2c88 100644 --- a/tests/ui/consts/miri_unleashed/abi-mismatch.stderr +++ b/tests/ui/consts/miri_unleashed/abi-mismatch.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: calling a function with calling convention "C" using calling convention "Rust" --> $DIR/abi-mismatch.rs:11:18 | LL | static VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calling a function with calling convention "C" using calling convention "Rust" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `VAL` failed inside this call | note: inside `call_rust_fn` --> $DIR/abi-mismatch.rs:7:5 diff --git a/tests/ui/consts/miri_unleashed/assoc_const.stderr b/tests/ui/consts/miri_unleashed/assoc_const.stderr index 758f1a25339..1ba4f3b2896 100644 --- a/tests/ui/consts/miri_unleashed/assoc_const.stderr +++ b/tests/ui/consts/miri_unleashed/assoc_const.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `drop_in_place::<Vec<u32>> - shim(Some(Vec<u32>))` failed +error[E0080]: calling non-const function `<Vec<u32> as Drop>::drop` --> $DIR/assoc_const.rs:12:31 | LL | const F: u32 = (U::X, 42).1; - | ^ calling non-const function `<Vec<u32> as Drop>::drop` + | ^ evaluation of `<std::string::String as Bar<std::vec::Vec<u32>, std::string::String>>::F` failed inside this call | note: inside `drop_in_place::<(Vec<u32>, u32)> - shim(Some((Vec<u32>, u32)))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL diff --git a/tests/ui/consts/miri_unleashed/assoc_const_2.rs b/tests/ui/consts/miri_unleashed/assoc_const_2.rs index 1d8ed2065a4..fa8ed682d98 100644 --- a/tests/ui/consts/miri_unleashed/assoc_const_2.rs +++ b/tests/ui/consts/miri_unleashed/assoc_const_2.rs @@ -8,7 +8,7 @@ trait Foo { } trait Bar<U: Foo> { - const F: u32 = 100 / U::X; //~ ERROR evaluation of `<std::string::String as Bar<std::string::String>>::F` failed + const F: u32 = 100 / U::X; //~ ERROR attempt to divide `100_u32` by zero } impl Foo for () { diff --git a/tests/ui/consts/miri_unleashed/assoc_const_2.stderr b/tests/ui/consts/miri_unleashed/assoc_const_2.stderr index 5503f8e56f0..a38fe346da6 100644 --- a/tests/ui/consts/miri_unleashed/assoc_const_2.stderr +++ b/tests/ui/consts/miri_unleashed/assoc_const_2.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `<std::string::String as Bar<std::string::String>>::F` failed +error[E0080]: attempt to divide `100_u32` by zero --> $DIR/assoc_const_2.rs:11:20 | LL | const F: u32 = 100 / U::X; - | ^^^^^^^^^^ attempt to divide `100_u32` by zero + | ^^^^^^^^^^ evaluation of `<std::string::String as Bar<std::string::String>>::F` failed here note: erroneous constant encountered --> $DIR/assoc_const_2.rs:28:13 diff --git a/tests/ui/consts/miri_unleashed/box.rs b/tests/ui/consts/miri_unleashed/box.rs index 1539083f09c..d361870b58a 100644 --- a/tests/ui/consts/miri_unleashed/box.rs +++ b/tests/ui/consts/miri_unleashed/box.rs @@ -6,8 +6,7 @@ fn main() {} static TEST_BAD: &mut i32 = { &mut *(Box::new(0)) - //~^ ERROR could not evaluate static initializer - //~| NOTE calling non-const function `Box::<i32>::new` + //~^ ERROR calling non-const function `Box::<i32>::new` }; //~? WARN skipping const checks diff --git a/tests/ui/consts/miri_unleashed/box.stderr b/tests/ui/consts/miri_unleashed/box.stderr index 25cefa036eb..25b717660ea 100644 --- a/tests/ui/consts/miri_unleashed/box.stderr +++ b/tests/ui/consts/miri_unleashed/box.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: calling non-const function `Box::<i32>::new` --> $DIR/box.rs:8:11 | LL | &mut *(Box::new(0)) - | ^^^^^^^^^^^^^ calling non-const function `Box::<i32>::new` + | ^^^^^^^^^^^^^ evaluation of `TEST_BAD` failed here warning: skipping const checks | 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 c66aaec8c56..6cc67094346 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static.rs +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static.rs @@ -8,20 +8,19 @@ use std::sync::atomic::Ordering; const MUTATE_INTERIOR_MUT: usize = { static FOO: AtomicUsize = AtomicUsize::new(0); - FOO.fetch_add(1, Ordering::Relaxed) //~ERROR evaluation of constant value failed + FOO.fetch_add(1, Ordering::Relaxed) //~ERROR calling non-const function `AtomicUsize::fetch_add` }; const READ_INTERIOR_MUT: usize = { static FOO: AtomicUsize = AtomicUsize::new(0); - unsafe { *(&FOO as *const _ as *const usize) } //~ERROR evaluation of constant value failed + unsafe { *(&FOO as *const _ as *const usize) } //~ERROR constant accesses mutable global memory }; static mut MUTABLE: u32 = 0; -const READ_MUT: u32 = unsafe { MUTABLE }; //~ERROR evaluation of constant value failed +const READ_MUT: u32 = unsafe { MUTABLE }; //~ERROR constant accesses mutable global memory // Evaluating this does not read anything mutable, but validation does, so this should error. -const REF_INTERIOR_MUT: &usize = { //~ ERROR undefined behavior - //~| NOTE encountered reference to mutable memory +const REF_INTERIOR_MUT: &usize = { //~ ERROR 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 f647107094d..eed3b4d9065 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr @@ -1,26 +1,26 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: calling non-const function `AtomicUsize::fetch_add` --> $DIR/const_refers_to_static.rs:11:5 | LL | FOO.fetch_add(1, Ordering::Relaxed) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calling non-const function `AtomicUsize::fetch_add` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `MUTATE_INTERIOR_MUT` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: constant accesses mutable global memory --> $DIR/const_refers_to_static.rs:16:14 | LL | unsafe { *(&FOO as *const _ as *const usize) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses mutable global memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `READ_INTERIOR_MUT` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: constant accesses mutable global memory --> $DIR/const_refers_to_static.rs:20:32 | LL | const READ_MUT: u32 = unsafe { MUTABLE }; - | ^^^^^^^ constant accesses mutable global memory + | ^^^^^^^ evaluation of `READ_MUT` failed here -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` --> $DIR/const_refers_to_static.rs:23:1 | LL | const REF_INTERIOR_MUT: &usize = { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { 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 86d23d44bff..6c7e7835661 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,7 +2,6 @@ //@ 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)] @@ -11,26 +10,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 - //~| NOTE encountered reference to mutable memory +const SLICE_MUT: &[u8; 1] = { + //~^ ERROR encountered reference to mutable memory unsafe { &static_cross_crate::ZERO } }; -const U8_MUT: &u8 = { //~ ERROR undefined behavior - //~| NOTE encountered reference to mutable memory +const U8_MUT: &u8 = { + //~^ ERROR 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 - //~| NOTE encountered reference to mutable memory +const U8_MUT2: &u8 = { + //~^ ERROR 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 - //~| NOTE constant accesses mutable global memory + //~^ ERROR 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 4e5052ed470..8af3a1948f0 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,41 +1,41 @@ -error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static_cross_crate.rs:14:1 +error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` + --> $DIR/const_refers_to_static_cross_crate.rs:13:1 | LL | const SLICE_MUT: &[u8; 1] = { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` + | ^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static_cross_crate.rs:19:1 +error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` + --> $DIR/const_refers_to_static_cross_crate.rs:18:1 | LL | const U8_MUT: &u8 = { - | ^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` + | ^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static_cross_crate.rs:25:1 +error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` + --> $DIR/const_refers_to_static_cross_crate.rs:24:1 | LL | const U8_MUT2: &u8 = { - | ^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` + | ^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/const_refers_to_static_cross_crate.rs:31:15 +error[E0080]: constant accesses mutable global memory + --> $DIR/const_refers_to_static_cross_crate.rs:30:15 | LL | match static_cross_crate::OPT_ZERO { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses mutable global memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `U8_MUT3` failed here error: aborting due to 4 previous errors diff --git a/tests/ui/consts/miri_unleashed/drop.rs b/tests/ui/consts/miri_unleashed/drop.rs index ff9281358d4..46af3388a96 100644 --- a/tests/ui/consts/miri_unleashed/drop.rs +++ b/tests/ui/consts/miri_unleashed/drop.rs @@ -13,8 +13,8 @@ static TEST_OK: () = { // The actual error is tested by the error-pattern above. static TEST_BAD: () = { let _v: Vec<i32> = Vec::new(); -}; //~ ERROR could not evaluate static initializer - //~| NOTE calling non-const function `<Vec<i32> as Drop>::drop` +}; //~ NOTE failed inside this call + //~| ERROR calling non-const function `<Vec<i32> as Drop>::drop` //~| NOTE inside `drop_in_place::<Vec<i32>> - shim(Some(Vec<i32>))` //~? WARN skipping const checks diff --git a/tests/ui/consts/miri_unleashed/drop.stderr b/tests/ui/consts/miri_unleashed/drop.stderr index 0286c431279..a66422956be 100644 --- a/tests/ui/consts/miri_unleashed/drop.stderr +++ b/tests/ui/consts/miri_unleashed/drop.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: calling non-const function `<Vec<i32> as Drop>::drop` --> $DIR/drop.rs:16:1 | LL | }; - | ^ calling non-const function `<Vec<i32> as Drop>::drop` + | ^ evaluation of `TEST_BAD` failed inside this call | note: inside `drop_in_place::<Vec<i32>> - shim(Some(Vec<i32>))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL diff --git a/tests/ui/consts/miri_unleashed/extern-static.rs b/tests/ui/consts/miri_unleashed/extern-static.rs index c9d9397518e..e5d3b806487 100644 --- a/tests/ui/consts/miri_unleashed/extern-static.rs +++ b/tests/ui/consts/miri_unleashed/extern-static.rs @@ -9,13 +9,11 @@ extern "C" { // Make sure we catch accessing extern static. static TEST_READ: () = { unsafe { let _val = DATA; } - //~^ ERROR could not evaluate static initializer - //~| NOTE cannot access extern static + //~^ ERROR cannot access extern static }; static TEST_WRITE: () = { unsafe { DATA = 0; } - //~^ ERROR could not evaluate static initializer - //~| NOTE cannot access extern static + //~^ ERROR cannot access extern static }; // Just creating a reference is fine, as long as we are not reading or writing. diff --git a/tests/ui/consts/miri_unleashed/extern-static.stderr b/tests/ui/consts/miri_unleashed/extern-static.stderr index 4dbabbe44a2..57b4f07b2fc 100644 --- a/tests/ui/consts/miri_unleashed/extern-static.stderr +++ b/tests/ui/consts/miri_unleashed/extern-static.stderr @@ -1,14 +1,14 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: cannot access extern static `DATA` --> $DIR/extern-static.rs:11:25 | LL | unsafe { let _val = DATA; } - | ^^^^ cannot access extern static `DATA` + | ^^^^ evaluation of `TEST_READ` failed here -error[E0080]: could not evaluate static initializer - --> $DIR/extern-static.rs:16:14 +error[E0080]: cannot access extern static `DATA` + --> $DIR/extern-static.rs:15:14 | LL | unsafe { DATA = 0; } - | ^^^^^^^^ cannot access extern static `DATA` + | ^^^^^^^^ evaluation of `TEST_WRITE` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/miri_unleashed/inline_asm.rs b/tests/ui/consts/miri_unleashed/inline_asm.rs index f1ce613b16e..51297aa6361 100644 --- a/tests/ui/consts/miri_unleashed/inline_asm.rs +++ b/tests/ui/consts/miri_unleashed/inline_asm.rs @@ -8,8 +8,7 @@ fn main() {} // Make sure we catch executing inline assembly. static TEST_BAD: () = { unsafe { asm!("nop"); } - //~^ ERROR could not evaluate static initializer - //~| NOTE inline assembly is not supported + //~^ ERROR inline assembly is not supported }; //~? WARN skipping const checks diff --git a/tests/ui/consts/miri_unleashed/inline_asm.stderr b/tests/ui/consts/miri_unleashed/inline_asm.stderr index e9643f02840..49e54825695 100644 --- a/tests/ui/consts/miri_unleashed/inline_asm.stderr +++ b/tests/ui/consts/miri_unleashed/inline_asm.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: inline assembly is not supported --> $DIR/inline_asm.rs:10:14 | LL | unsafe { asm!("nop"); } - | ^^^^^^^^^^^ inline assembly is not supported + | ^^^^^^^^^^^ evaluation of `TEST_BAD` failed here warning: skipping const checks | diff --git a/tests/ui/consts/miri_unleashed/mutable_references.rs b/tests/ui/consts/miri_unleashed/mutable_references.rs index 02a35487e8a..63d243f892c 100644 --- a/tests/ui/consts/miri_unleashed/mutable_references.rs +++ b/tests/ui/consts/miri_unleashed/mutable_references.rs @@ -11,11 +11,9 @@ use std::sync::atomic::*; // This requires walking nested statics. static FOO: &&mut u32 = &&mut 42; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE pointing to read-only memory +//~^ ERROR pointing to read-only memory static OH_YES: &mut i32 = &mut 42; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE pointing to read-only memory +//~^ ERROR pointing to read-only memory static BAR: &mut () = &mut (); //~^ ERROR encountered mutable pointer in final value of static @@ -25,12 +23,10 @@ static BOO: &mut Foo<()> = &mut Foo(()); //~^ ERROR encountered mutable pointer in final value of static const BLUNT: &mut i32 = &mut 42; -//~^ ERROR: it is undefined behavior to use this value -//~| NOTE pointing to read-only memory +//~^ ERROR: pointing to read-only memory const SUBTLE: &mut i32 = unsafe { - //~^ ERROR: it is undefined behavior to use this value - //~| NOTE constructing invalid value: encountered reference to mutable memory in `const` + //~^ ERROR: constructing invalid value: encountered reference to mutable memory in `const` static mut STATIC: i32 = 0; &mut STATIC }; @@ -42,14 +38,12 @@ struct Meh { } unsafe impl Sync for Meh {} static MEH: Meh = Meh { x: &UnsafeCell::new(42) }; -//~^ ERROR it is undefined behavior to use this value -//~| NOTE `UnsafeCell` in read-only memory +//~^ ERROR `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 - //~| NOTE `UnsafeCell` in read-only memory + //~^ ERROR `UnsafeCell` in read-only memory x: &UnsafeCell::new(42), }; @@ -60,25 +54,21 @@ 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 -//~| NOTE `UnsafeCell` in read-only memory +//~^ ERROR: `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 -//~| NOTE pointing to read-only memory +//~^ ERROR: 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 -//~| NOTE encountered reference to mutable memory +const POINTS_TO_MUTABLE: &i32 = unsafe { &MUTABLE }; //~ ERROR 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 -//~| NOTE accesses mutable global memory +//~^ ERROR accesses mutable global memory const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _; //~^ ERROR mutable pointer in final value diff --git a/tests/ui/consts/miri_unleashed/mutable_references.stderr b/tests/ui/consts/miri_unleashed/mutable_references.stderr index 3049be80adc..22860e4f6d9 100644 --- a/tests/ui/consts/miri_unleashed/mutable_references.stderr +++ b/tests/ui/consts/miri_unleashed/mutable_references.stderr @@ -1,19 +1,19 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>: encountered mutable reference or box pointing to read-only memory --> $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 + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references.rs:16:1 +error[E0080]: constructing invalid value: encountered mutable reference or box pointing to read-only memory + --> $DIR/mutable_references.rs:15:1 | LL | static OH_YES: &mut i32 = &mut 42; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -21,126 +21,126 @@ LL | static OH_YES: &mut i32 = &mut 42; } error: encountered mutable pointer in final value of static - --> $DIR/mutable_references.rs:19:1 + --> $DIR/mutable_references.rs:17:1 | LL | static BAR: &mut () = &mut (); | ^^^^^^^^^^^^^^^^^^^ error: encountered mutable pointer in final value of static - --> $DIR/mutable_references.rs:24:1 + --> $DIR/mutable_references.rs:22:1 | LL | static BOO: &mut Foo<()> = &mut Foo(()); | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references.rs:27:1 +error[E0080]: constructing invalid value: encountered mutable reference or box pointing to read-only memory + --> $DIR/mutable_references.rs:25:1 | LL | const BLUNT: &mut i32 = &mut 42; - | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory + | ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references.rs:31:1 +error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` + --> $DIR/mutable_references.rs:28:1 | LL | const SUBTLE: &mut i32 = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references.rs:44:1 +error[E0080]: constructing invalid value at .x.<deref>: encountered `UnsafeCell` in read-only memory + --> $DIR/mutable_references.rs:40:1 | LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) }; - | ^^^^^^^^^^^^^^^ constructing invalid value at .x.<deref>: encountered `UnsafeCell` in read-only memory + | ^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references.rs:50:1 +error[E0080]: constructing invalid value at .x.<deref>: encountered `UnsafeCell` in read-only memory + --> $DIR/mutable_references.rs:45:1 | LL | const MUH: Meh = Meh { - | ^^^^^^^^^^^^^^ constructing invalid value at .x.<deref>: encountered `UnsafeCell` in read-only memory + | ^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references.rs:62:1 +error[E0080]: constructing invalid value at .<deref>.<dyn-downcast>.x: encountered `UnsafeCell` in read-only memory + --> $DIR/mutable_references.rs:56: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 + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references.rs:69:1 +error[E0080]: constructing invalid value: encountered mutable reference or box pointing to read-only memory + --> $DIR/mutable_references.rs:62: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references.rs:76:1 +error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` + --> $DIR/mutable_references.rs:68:1 | LL | const POINTS_TO_MUTABLE: &i32 = unsafe { &MUTABLE }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: evaluation of constant value failed - --> $DIR/mutable_references.rs:79:43 +error[E0080]: constant accesses mutable global memory + --> $DIR/mutable_references.rs:70:43 | LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF }; - | ^^^^^^^^^^^^^ constant accesses mutable global memory + | ^^^^^^^^^^^^^ evaluation of `POINTS_TO_MUTABLE2` failed here error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references.rs:83:1 + --> $DIR/mutable_references.rs:73: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:86:1 + --> $DIR/mutable_references.rs:76: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:106:1 + --> $DIR/mutable_references.rs:96: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:109:1 + --> $DIR/mutable_references.rs:99: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:116:5 + --> $DIR/mutable_references.rs:106:5 | LL | *OH_YES = 99; | ^^^^^^^^^^^^ cannot assign @@ -153,67 +153,67 @@ help: skipping check that does not even have a feature gate LL | static FOO: &&mut u32 = &&mut 42; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:16:27 + --> $DIR/mutable_references.rs:15:27 | LL | static OH_YES: &mut i32 = &mut 42; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:19:23 + --> $DIR/mutable_references.rs:17:23 | LL | static BAR: &mut () = &mut (); | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:24:28 + --> $DIR/mutable_references.rs:22:28 | LL | static BOO: &mut Foo<()> = &mut Foo(()); | ^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:27:25 + --> $DIR/mutable_references.rs:25:25 | LL | const BLUNT: &mut i32 = &mut 42; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:44:28 + --> $DIR/mutable_references.rs:40: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:53:8 + --> $DIR/mutable_references.rs:47:8 | LL | x: &UnsafeCell::new(42), | ^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:62:27 + --> $DIR/mutable_references.rs:56: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:83:45 + --> $DIR/mutable_references.rs:73: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:86:46 + --> $DIR/mutable_references.rs:76: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:91:47 + --> $DIR/mutable_references.rs:81: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:103:51 + --> $DIR/mutable_references.rs:93: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:106:49 + --> $DIR/mutable_references.rs:96: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:109:51 + --> $DIR/mutable_references.rs:99:51 | LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 }; | ^^^^^^ diff --git a/tests/ui/consts/miri_unleashed/mutating_global.rs b/tests/ui/consts/miri_unleashed/mutating_global.rs index 77781360374..9a88f584a58 100644 --- a/tests/ui/consts/miri_unleashed/mutating_global.rs +++ b/tests/ui/consts/miri_unleashed/mutating_global.rs @@ -7,8 +7,7 @@ static mut GLOBAL: i32 = 0; static MUTATING_GLOBAL: () = { unsafe { GLOBAL = 99 - //~^ ERROR could not evaluate static initializer - //~| NOTE modifying a static's initial value + //~^ ERROR modifying a static's initial value } }; diff --git a/tests/ui/consts/miri_unleashed/mutating_global.stderr b/tests/ui/consts/miri_unleashed/mutating_global.stderr index c38e2d44d89..f97f88a4b90 100644 --- a/tests/ui/consts/miri_unleashed/mutating_global.stderr +++ b/tests/ui/consts/miri_unleashed/mutating_global.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: modifying a static's initial value from another static's initializer --> $DIR/mutating_global.rs:9:9 | LL | GLOBAL = 99 - | ^^^^^^^^^^^ modifying a static's initial value from another static's initializer + | ^^^^^^^^^^^ evaluation of `MUTATING_GLOBAL` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/miri_unleashed/non_const_fn.rs b/tests/ui/consts/miri_unleashed/non_const_fn.rs index 201647ac8d8..18bee124db4 100644 --- a/tests/ui/consts/miri_unleashed/non_const_fn.rs +++ b/tests/ui/consts/miri_unleashed/non_const_fn.rs @@ -5,8 +5,7 @@ fn foo() {} static C: () = foo(); -//~^ ERROR could not evaluate static initializer -//~| NOTE calling non-const function `foo` +//~^ ERROR calling non-const function `foo` fn main() {} diff --git a/tests/ui/consts/miri_unleashed/non_const_fn.stderr b/tests/ui/consts/miri_unleashed/non_const_fn.stderr index cc893896ecf..7755183cef0 100644 --- a/tests/ui/consts/miri_unleashed/non_const_fn.stderr +++ b/tests/ui/consts/miri_unleashed/non_const_fn.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: calling non-const function `foo` --> $DIR/non_const_fn.rs:7:16 | LL | static C: () = foo(); - | ^^^^^ calling non-const function `foo` + | ^^^^^ evaluation of `C` failed here warning: skipping const checks | diff --git a/tests/ui/consts/miri_unleashed/ptr_arith.rs b/tests/ui/consts/miri_unleashed/ptr_arith.rs index 408aa5db24d..3f34102833b 100644 --- a/tests/ui/consts/miri_unleashed/ptr_arith.rs +++ b/tests/ui/consts/miri_unleashed/ptr_arith.rs @@ -5,16 +5,14 @@ static PTR_INT_CAST: () = { let x = &0 as *const _ as usize; - //~^ ERROR could not evaluate static initializer - //~| NOTE exposing pointers + //~^ ERROR exposing pointers let _v = x == x; }; static PTR_INT_TRANSMUTE: () = unsafe { let x: usize = std::mem::transmute(&0); let _v = x + 0; - //~^ ERROR could not evaluate static initializer - //~| NOTE unable to turn pointer into integer + //~^ ERROR unable to turn pointer into integer }; // I'd love to test pointer comparison, but that is not possible since diff --git a/tests/ui/consts/miri_unleashed/ptr_arith.stderr b/tests/ui/consts/miri_unleashed/ptr_arith.stderr index 213966f90b8..661a8de6a15 100644 --- a/tests/ui/consts/miri_unleashed/ptr_arith.stderr +++ b/tests/ui/consts/miri_unleashed/ptr_arith.stderr @@ -1,14 +1,14 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: exposing pointers is not possible at compile-time --> $DIR/ptr_arith.rs:7:13 | LL | let x = &0 as *const _ as usize; - | ^^^^^^^^^^^^^^^^^^^^^^^ exposing pointers is not possible at compile-time + | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `PTR_INT_CAST` failed here -error[E0080]: could not evaluate static initializer - --> $DIR/ptr_arith.rs:15:14 +error[E0080]: unable to turn pointer into integer + --> $DIR/ptr_arith.rs:14:14 | LL | let _v = x + 0; - | ^ unable to turn pointer into integer + | ^ evaluation of `PTR_INT_TRANSMUTE` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported diff --git a/tests/ui/consts/miri_unleashed/static-no-inner-mut.32bit.stderr b/tests/ui/consts/miri_unleashed/static-no-inner-mut.32bit.stderr index 88a734bc241..1ef20689985 100644 --- a/tests/ui/consts/miri_unleashed/static-no-inner-mut.32bit.stderr +++ b/tests/ui/consts/miri_unleashed/static-no-inner-mut.32bit.stderr @@ -1,41 +1,41 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>.v: encountered `UnsafeCell` in read-only memory --> $DIR/static-no-inner-mut.rs:8:1 | LL | static REF: &AtomicI32 = &AtomicI32::new(42); - | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.v: encountered `UnsafeCell` in read-only memory + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { ╾ALLOC0╼ │ ╾──╼ } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered mutable reference or box pointing to read-only memory --> $DIR/static-no-inner-mut.rs:11:1 | LL | static REFMUT: &mut i32 = &mut 0; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { ╾ALLOC1╼ │ ╾──╼ } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>.v: encountered `UnsafeCell` in read-only memory --> $DIR/static-no-inner-mut.rs:15:1 | LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}}; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.v: encountered `UnsafeCell` in read-only memory + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { ╾ALLOC2╼ │ ╾──╼ } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered mutable reference or box pointing to read-only memory --> $DIR/static-no-inner-mut.rs:17:1 | LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}}; - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory + | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { diff --git a/tests/ui/consts/miri_unleashed/static-no-inner-mut.64bit.stderr b/tests/ui/consts/miri_unleashed/static-no-inner-mut.64bit.stderr index c4f3903e143..06f78e679b1 100644 --- a/tests/ui/consts/miri_unleashed/static-no-inner-mut.64bit.stderr +++ b/tests/ui/consts/miri_unleashed/static-no-inner-mut.64bit.stderr @@ -1,41 +1,41 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>.v: encountered `UnsafeCell` in read-only memory --> $DIR/static-no-inner-mut.rs:8:1 | LL | static REF: &AtomicI32 = &AtomicI32::new(42); - | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.v: encountered `UnsafeCell` in read-only memory + | ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { ╾ALLOC0╼ │ ╾──────╼ } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered mutable reference or box pointing to read-only memory --> $DIR/static-no-inner-mut.rs:11:1 | LL | static REFMUT: &mut i32 = &mut 0; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { ╾ALLOC1╼ │ ╾──────╼ } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>.v: encountered `UnsafeCell` in read-only memory --> $DIR/static-no-inner-mut.rs:15:1 | LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}}; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.v: encountered `UnsafeCell` in read-only memory + | ^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { ╾ALLOC2╼ │ ╾──────╼ } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered mutable reference or box pointing to read-only memory --> $DIR/static-no-inner-mut.rs:17:1 | LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}}; - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory + | ^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { diff --git a/tests/ui/consts/miri_unleashed/static-no-inner-mut.rs b/tests/ui/consts/miri_unleashed/static-no-inner-mut.rs index 7fa173d8d9d..0e87442f6a6 100644 --- a/tests/ui/consts/miri_unleashed/static-no-inner-mut.rs +++ b/tests/ui/consts/miri_unleashed/static-no-inner-mut.rs @@ -6,16 +6,16 @@ use std::sync::atomic::*; static REF: &AtomicI32 = &AtomicI32::new(42); -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR `UnsafeCell` in read-only memory static REFMUT: &mut i32 = &mut 0; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR mutable reference or box pointing to read-only memory // Different way of writing this that avoids promotion. static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}}; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR `UnsafeCell` in read-only memory static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}}; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR mutable reference or box pointing to read-only memory // This one is obvious, since it is non-Sync. (It also suppresses the other errors, so it is // commented out.) diff --git a/tests/ui/consts/miri_unleashed/tls.rs b/tests/ui/consts/miri_unleashed/tls.rs index ab23a524998..8f8a1bd9618 100644 --- a/tests/ui/consts/miri_unleashed/tls.rs +++ b/tests/ui/consts/miri_unleashed/tls.rs @@ -9,8 +9,7 @@ static A: u8 = 0; // Make sure we catch accessing thread-local storage. static TEST_BAD: () = { unsafe { let _val = A; } - //~^ ERROR could not evaluate static initializer - //~| NOTE cannot access thread local static + //~^ ERROR cannot access thread local static }; // Make sure we catch taking a reference to thread-local storage. @@ -18,8 +17,7 @@ static TEST_BAD: () = { // sense at compile-time. static TEST_BAD_REF: () = { unsafe { let _val = &A; } - //~^ ERROR could not evaluate static initializer - //~| NOTE cannot access thread local static + //~^ ERROR cannot access thread local static }; fn main() {} diff --git a/tests/ui/consts/miri_unleashed/tls.stderr b/tests/ui/consts/miri_unleashed/tls.stderr index ef836544303..08e069dc3ff 100644 --- a/tests/ui/consts/miri_unleashed/tls.stderr +++ b/tests/ui/consts/miri_unleashed/tls.stderr @@ -1,14 +1,14 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: cannot access thread local static `A` --> $DIR/tls.rs:11:25 | LL | unsafe { let _val = A; } - | ^ cannot access thread local static `A` + | ^ evaluation of `TEST_BAD` failed here -error[E0080]: could not evaluate static initializer - --> $DIR/tls.rs:20:26 +error[E0080]: cannot access thread local static `A` + --> $DIR/tls.rs:19:26 | LL | unsafe { let _val = &A; } - | ^ cannot access thread local static `A` + | ^ evaluation of `TEST_BAD_REF` failed here warning: skipping const checks | @@ -18,7 +18,7 @@ help: skipping check that does not even have a feature gate LL | unsafe { let _val = A; } | ^ help: skipping check that does not even have a feature gate - --> $DIR/tls.rs:20:26 + --> $DIR/tls.rs:19:26 | LL | unsafe { let _val = &A; } | ^ diff --git a/tests/ui/consts/missing_span_in_backtrace.rs b/tests/ui/consts/missing_span_in_backtrace.rs index 490eb57c24d..893dc321604 100644 --- a/tests/ui/consts/missing_span_in_backtrace.rs +++ b/tests/ui/consts/missing_span_in_backtrace.rs @@ -11,7 +11,7 @@ const X: () = { // Swap them, bytewise. unsafe { - ptr::swap_nonoverlapping( //~ ERROR evaluation of constant value failed + ptr::swap_nonoverlapping( //~ ERROR unable to copy parts of a pointer &mut ptr1 as *mut _ as *mut MaybeUninit<u8>, &mut ptr2 as *mut _ as *mut MaybeUninit<u8>, mem::size_of::<&i32>(), diff --git a/tests/ui/consts/missing_span_in_backtrace.stderr b/tests/ui/consts/missing_span_in_backtrace.stderr index 88b3e37bb84..de4acbffa28 100644 --- a/tests/ui/consts/missing_span_in_backtrace.stderr +++ b/tests/ui/consts/missing_span_in_backtrace.stderr @@ -1,4 +1,4 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: unable to copy parts of a pointer from memory at ALLOC0 --> $DIR/missing_span_in_backtrace.rs:14:9 | 14 | / ptr::swap_nonoverlapping( @@ -6,19 +6,16 @@ error[E0080]: evaluation of constant value failed 16 | | &mut ptr2 as *mut _ as *mut MaybeUninit<u8>, 17 | | mem::size_of::<&i32>(), 18 | | ); - | |_________^ unable to copy parts of a pointer from memory at ALLOC0 + | |_________^ evaluation of `X` failed inside this call | -note: inside `swap_nonoverlapping::<MaybeUninit<u8>>` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported note: inside `swap_nonoverlapping::compiletime::<MaybeUninit<u8>>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `std::ptr::swap_nonoverlapping_const::<MaybeUninit<u8>>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -note: inside `copy_nonoverlapping::<MaybeUninit<u8>>` - --> $SRC_DIR/core/src/intrinsics/mod.rs:LL:COL - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - = note: this error originates in the macro `$crate::intrinsics::const_eval_select` which comes from the expansion of the macro `const_eval_select` (in Nightly builds, run with -Z macro-backtrace for more info) +note: inside `std::ptr::copy_nonoverlapping::<MaybeUninit<u8>>` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/mono-reachable-invalid-const.rs b/tests/ui/consts/mono-reachable-invalid-const.rs index aabdb071bc9..aba41dabe71 100644 --- a/tests/ui/consts/mono-reachable-invalid-const.rs +++ b/tests/ui/consts/mono-reachable-invalid-const.rs @@ -5,7 +5,7 @@ struct Bar<const BITS: usize>; impl<const BITS: usize> Bar<BITS> { const ASSERT: bool = { let b = std::convert::identity(1); - ["oops"][b]; //~ ERROR evaluation of `Bar::<0>::ASSERT` failed + ["oops"][b]; //~ ERROR index out of bounds: the length is 1 but the index is 1 true }; @@ -17,7 +17,6 @@ impl<const BITS: usize> Bar<BITS> { } } - fn main() { Bar::<0>::assert(); } diff --git a/tests/ui/consts/mono-reachable-invalid-const.stderr b/tests/ui/consts/mono-reachable-invalid-const.stderr index 6b7b25b59b8..e357fd096fd 100644 --- a/tests/ui/consts/mono-reachable-invalid-const.stderr +++ b/tests/ui/consts/mono-reachable-invalid-const.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Bar::<0>::ASSERT` failed +error[E0080]: index out of bounds: the length is 1 but the index is 1 --> $DIR/mono-reachable-invalid-const.rs:8:9 | LL | ["oops"][b]; - | ^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1 + | ^^^^^^^^^^^ evaluation of `Bar::<0>::ASSERT` failed here note: erroneous constant encountered --> $DIR/mono-reachable-invalid-const.rs:13:19 @@ -19,7 +19,7 @@ LL | let val = Self::ASSERT; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` note: the above error was encountered while instantiating `fn Bar::<0>::assert` - --> $DIR/mono-reachable-invalid-const.rs:22:5 + --> $DIR/mono-reachable-invalid-const.rs:21:5 | LL | Bar::<0>::assert(); | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/consts/no-ice-from-static-in-const-issue-52060.rs b/tests/ui/consts/no-ice-from-static-in-const-issue-52060.rs index e3cd8ec7d8a..2ad5d18d72d 100644 --- a/tests/ui/consts/no-ice-from-static-in-const-issue-52060.rs +++ b/tests/ui/consts/no-ice-from-static-in-const-issue-52060.rs @@ -3,7 +3,6 @@ static mut A: &'static [u32] = &[1]; static B: [u32; 1] = [0; unsafe { A.len() }]; -//~^ ERROR: evaluation of constant value failed -//~| NOTE mutable global memory +//~^ ERROR: mutable global memory fn main() {} diff --git a/tests/ui/consts/no-ice-from-static-in-const-issue-52060.stderr b/tests/ui/consts/no-ice-from-static-in-const-issue-52060.stderr index ca4d3224ec7..210bb345e7b 100644 --- a/tests/ui/consts/no-ice-from-static-in-const-issue-52060.stderr +++ b/tests/ui/consts/no-ice-from-static-in-const-issue-52060.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: constant accesses mutable global memory --> $DIR/no-ice-from-static-in-const-issue-52060.rs:5:35 | LL | static B: [u32; 1] = [0; unsafe { A.len() }]; - | ^ constant accesses mutable global memory + | ^ evaluation of `B::{constant#1}` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/offset_from_ub.rs b/tests/ui/consts/offset_from_ub.rs index 47511c0343d..ccbe591f97e 100644 --- a/tests/ui/consts/offset_from_ub.rs +++ b/tests/ui/consts/offset_from_ub.rs @@ -17,28 +17,30 @@ pub const DIFFERENT_ALLOC: usize = { let base_ptr: *const Struct = &uninit as *const _ as *const Struct; 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 - //~| NOTE not both derived from the same allocation + let offset = unsafe { ptr_offset_from(field_ptr, base_ptr) }; + //~^ ERROR not both derived from the same allocation offset as usize }; pub const NOT_PTR: usize = { - unsafe { (42 as *const u8).offset_from(&5u8) as usize } //~ ERROR evaluation of constant value failed + unsafe { (42 as *const u8).offset_from(&5u8) as usize } + //~^ ERROR not both derived from the same allocation }; pub const NOT_MULTIPLE_OF_SIZE: isize = { let data = [5u8, 6, 7]; 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 - //~| NOTE 1_isize cannot be divided by 2_isize without remainder + unsafe { ptr_offset_from(field_ptr, base_ptr as *const u16) } + //~^ ERROR 1_isize cannot be divided by 2_isize without remainder }; -pub const DIFFERENT_INT: isize = { // offset_from with two different integers: like DIFFERENT_ALLOC +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 - //~| NOTE not both derived from the same allocation + unsafe { ptr_offset_from(ptr2, ptr1) } + //~^ ERROR not both derived from the same allocation }; const OUT_OF_BOUNDS_1: isize = { @@ -46,8 +48,8 @@ const OUT_OF_BOUNDS_1: isize = { let length = 10; 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 - //~| NOTE the memory range between them is not in-bounds of an allocation + unsafe { ptr_offset_from(end_ptr, start_ptr) } + //~^ ERROR the memory range between them is not in-bounds of an allocation }; const OUT_OF_BOUNDS_2: isize = { @@ -55,8 +57,8 @@ const OUT_OF_BOUNDS_2: isize = { let length = 10; 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 - //~| NOTE the memory range between them is not in-bounds of an allocation + unsafe { ptr_offset_from(start_ptr, end_ptr) } + //~^ ERROR the memory range between them is not in-bounds of an allocation }; pub const DIFFERENT_ALLOC_UNSIGNED: usize = { @@ -64,43 +66,42 @@ pub const DIFFERENT_ALLOC_UNSIGNED: usize = { let base_ptr: *const Struct = &uninit as *const _ as *const Struct; 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 - //~| NOTE not both derived from the same allocation + unsafe { ptr_offset_from_unsigned(field_ptr, base_ptr) } + //~^ ERROR 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 - //~| NOTE too far ahead + unsafe { ptr_offset_from(ptr2, ptr1) } + //~^ ERROR 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 - //~| NOTE too far before + unsafe { ptr_offset_from(ptr1, ptr2) } + //~^ ERROR too far before }; pub const TOO_FAR_APART3: isize = { let ptr1 = &0u8 as *const u8; let ptr2 = ptr1.wrapping_offset(isize::MIN); // 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 - //~| NOTE too far before + unsafe { ptr_offset_from(ptr1, ptr2) } + //~^ ERROR 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 - //~| NOTE first pointer has smaller offset than second: 0 < 8 + unsafe { ptr_offset_from_unsigned(p, p.add(2)) } + //~^ ERROR 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 - //~| NOTE too far ahead + unsafe { ptr_offset_from_unsigned(ptr2, ptr1) } //~ERROR too far ahead }; // These do NOT complain that pointers are too far apart; they pass that check (to then fail the @@ -109,13 +110,13 @@ pub const OFFSET_VERY_FAR1: isize = { let ptr1 = ptr::null::<u8>(); let ptr2 = ptr1.wrapping_offset(isize::MAX); unsafe { ptr2.offset_from(ptr1) } - //~^ ERROR evaluation of constant value failed + //~^ ERROR called on two different pointers that are not both derived from the same allocation }; pub const OFFSET_VERY_FAR2: isize = { let ptr1 = ptr::null::<u8>(); let ptr2 = ptr1.wrapping_offset(isize::MAX); unsafe { ptr1.offset_from(ptr2.wrapping_offset(1)) } - //~^ ERROR evaluation of constant value failed + //~^ ERROR ptr_offset_from` called when first pointer is too far before second }; // If the pointers are the same, OOB/null/UAF is fine. diff --git a/tests/ui/consts/offset_from_ub.stderr b/tests/ui/consts/offset_from_ub.stderr index 5bfb9a1170c..558e1ea02c6 100644 --- a/tests/ui/consts/offset_from_ub.stderr +++ b/tests/ui/consts/offset_from_ub.stderr @@ -1,92 +1,92 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: `ptr_offset_from` called on two different pointers that are not both derived from the same allocation --> $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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `DIFFERENT_ALLOC` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: `ptr_offset_from` called on two different pointers that are not both derived from the same allocation --> $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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `NOT_PTR` failed inside this call | 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:33:14 +error[E0080]: exact_div: 1_isize cannot be divided by 2_isize without remainder + --> $DIR/offset_from_ub.rs:34: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `NOT_MULTIPLE_OF_SIZE` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:40:14 +error[E0080]: `ptr_offset_from` called on two different pointers that are not both derived from the same allocation + --> $DIR/offset_from_ub.rs:42: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `DIFFERENT_INT` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:49:14 +error[E0080]: `ptr_offset_from` called on two different pointers where the memory range between them is not in-bounds of an allocation + --> $DIR/offset_from_ub.rs:51: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `OUT_OF_BOUNDS_1` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:58:14 +error[E0080]: `ptr_offset_from` called on two different pointers where the memory range between them is not in-bounds of an allocation + --> $DIR/offset_from_ub.rs:60: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `OUT_OF_BOUNDS_2` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:67:14 +error[E0080]: `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation + --> $DIR/offset_from_ub.rs:69: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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `DIFFERENT_ALLOC_UNSIGNED` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:74:14 +error[E0080]: `ptr_offset_from` called when first pointer is too far ahead of second + --> $DIR/offset_from_ub.rs:76:14 | LL | unsafe { ptr_offset_from(ptr2, ptr1) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called when first pointer is too far ahead of second + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `TOO_FAR_APART1` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:80:14 +error[E0080]: `ptr_offset_from` called when first pointer is too far before second + --> $DIR/offset_from_ub.rs:82:14 | LL | unsafe { ptr_offset_from(ptr1, ptr2) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called when first pointer is too far before second + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `TOO_FAR_APART2` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:88:14 +error[E0080]: `ptr_offset_from` called when first pointer is too far before second + --> $DIR/offset_from_ub.rs:90:14 | LL | unsafe { ptr_offset_from(ptr1, ptr2) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called when first pointer is too far before second + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `TOO_FAR_APART3` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:95:14 +error[E0080]: `ptr_offset_from_unsigned` called when first pointer has smaller offset than second: 0 < 8 + --> $DIR/offset_from_ub.rs:97: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 +LL | unsafe { ptr_offset_from_unsigned(p, p.add(2)) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `WRONG_ORDER_UNSIGNED` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:102:14 +error[E0080]: `ptr_offset_from_unsigned` called when first pointer is too far ahead of second + --> $DIR/offset_from_ub.rs:104:14 | LL | unsafe { ptr_offset_from_unsigned(ptr2, ptr1) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called when first pointer is too far ahead of second + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `TOO_FAR_APART_UNSIGNED` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/offset_from_ub.rs:111:14 +error[E0080]: `ptr_offset_from` called on two different pointers that are not both derived from the same allocation + --> $DIR/offset_from_ub.rs:112:14 | LL | unsafe { ptr2.offset_from(ptr1) } - | ^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on two different pointers that are not both derived from the same allocation + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `OFFSET_VERY_FAR1` failed inside this call | 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:117:14 +error[E0080]: `ptr_offset_from` called when first pointer is too far before second + --> $DIR/offset_from_ub.rs:118:14 | LL | unsafe { ptr1.offset_from(ptr2.wrapping_offset(1)) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called when first pointer is too far before second + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `OFFSET_VERY_FAR2` failed inside this call | note: inside `std::ptr::const_ptr::<impl *const u8>::offset_from` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL diff --git a/tests/ui/consts/offset_ub.stderr b/tests/ui/consts/offset_ub.stderr index 699b63dfd66..255583ce91c 100644 --- a/tests/ui/consts/offset_ub.stderr +++ b/tests/ui/consts/offset_ub.stderr @@ -1,101 +1,68 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got ALLOC0 which is at the beginning of the allocation --> $DIR/offset_ub.rs:8:46 | LL | pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BEFORE_START` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: 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 --> $DIR/offset_ub.rs:9:43 | LL | pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `AFTER_END` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: 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 --> $DIR/offset_ub.rs:10:45 | LL | pub const AFTER_ARRAY: *const u8 = unsafe { [0u8; 100].as_ptr().offset(101) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `AFTER_ARRAY` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: overflowing pointer arithmetic: the total offset in bytes does not fit in an `isize` --> $DIR/offset_ub.rs:12:43 | LL | pub const OVERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MAX) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing pointer arithmetic: the total offset in bytes does not fit in an `isize` - | -note: inside `std::ptr::const_ptr::<impl *const u16>::offset` - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `OVERFLOW` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: overflowing pointer arithmetic: the total offset in bytes does not fit in an `isize` --> $DIR/offset_ub.rs:13:44 | LL | pub const UNDERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MIN) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing pointer arithmetic: the total offset in bytes does not fit in an `isize` - | -note: inside `std::ptr::const_ptr::<impl *const u16>::offset` - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNDERFLOW` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: 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) --> $DIR/offset_ub.rs:14:56 | LL | pub const OVERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (usize::MAX as *const u8).offset(2) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `OVERFLOW_ADDRESS_SPACE` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: 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) --> $DIR/offset_ub.rs:15:57 | LL | pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).offset(-2) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNDERFLOW_ADDRESS_SPACE` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: 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 --> $DIR/offset_ub.rs:16:49 | LL | pub const NEGATIVE_OFFSET: *const u8 = unsafe { [0u8; 1].as_ptr().wrapping_offset(-2).offset(-2) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `NEGATIVE_OFFSET` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: 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 --> $DIR/offset_ub.rs:18:50 | LL | pub const ZERO_SIZED_ALLOC: *const u8 = unsafe { [0u8; 0].as_ptr().offset(1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `ZERO_SIZED_ALLOC` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: 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) --> $DIR/offset_ub.rs:19:42 | LL | pub const DANGLING: *const u8 = unsafe { ptr::NonNull::<u8>::dangling().as_ptr().offset(4) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `DANGLING` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: 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) --> $DIR/offset_ub.rs:22:47 | LL | pub const UNDERFLOW_ABS: *const u8 = unsafe { (usize::MAX as *const u8).offset(isize::MIN) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNDERFLOW_ABS` failed here error: aborting due to 11 previous errors diff --git a/tests/ui/consts/overflowing-consts.noopt.stderr b/tests/ui/consts/overflowing-consts.noopt.stderr index 81f22944adb..1ef2a60b647 100644 --- a/tests/ui/consts/overflowing-consts.noopt.stderr +++ b/tests/ui/consts/overflowing-consts.noopt.stderr @@ -1,1022 +1,1022 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:19:22 +error[E0080]: attempt to shift left by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:18:22 | LL | const _NI8_SHL: i8 = 1i8 << 8; - | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | ^^^^^^^^ evaluation of `_NI8_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:20:26 +error[E0080]: attempt to shift left by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:19:26 | LL | const _NI8_SHL_P: &i8 = &(1i8 << 8); - | ^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NI8_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:22:24 +error[E0080]: attempt to shift left by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:21:24 | LL | const _NI16_SHL: i16 = 1i16 << 16; - | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NI16_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:23:28 +error[E0080]: attempt to shift left by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:22:28 | LL | const _NI16_SHL_P: &i16 = &(1i16 << 16); - | ^^^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI16_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:25:24 +error[E0080]: attempt to shift left by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:24:24 | LL | const _NI32_SHL: i32 = 1i32 << 32; - | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NI32_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:26:28 +error[E0080]: attempt to shift left by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:25:28 | LL | const _NI32_SHL_P: &i32 = &(1i32 << 32); - | ^^^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI32_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:28:24 +error[E0080]: attempt to shift left by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:27:24 | LL | const _NI64_SHL: i64 = 1i64 << 64; - | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NI64_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:29:28 +error[E0080]: attempt to shift left by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:28:28 | LL | const _NI64_SHL_P: &i64 = &(1i64 << 64); - | ^^^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI64_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:31:26 +error[E0080]: attempt to shift left by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:30:26 | LL | const _NI128_SHL: i128 = 1i128 << 128; - | ^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI128_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:32:30 +error[E0080]: attempt to shift left by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:31:30 | LL | const _NI128_SHL_P: &i128 = &(1i128 << 128); - | ^^^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NI128_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:34:22 +error[E0080]: attempt to shift left by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:33:22 | LL | const _NU8_SHL: u8 = 1u8 << 8; - | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | ^^^^^^^^ evaluation of `_NU8_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:35:26 +error[E0080]: attempt to shift left by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:34:26 | LL | const _NU8_SHL_P: &u8 = &(1u8 << 8); - | ^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU8_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:37:24 +error[E0080]: attempt to shift left by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:36:24 | LL | const _NU16_SHL: u16 = 1u16 << 16; - | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU16_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:38:28 +error[E0080]: attempt to shift left by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:37:28 | LL | const _NU16_SHL_P: &u16 = &(1u16 << 16); - | ^^^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU16_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:40:24 +error[E0080]: attempt to shift left by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:39:24 | LL | const _NU32_SHL: u32 = 1u32 << 32; - | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU32_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:41:28 +error[E0080]: attempt to shift left by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:40:28 | LL | const _NU32_SHL_P: &u32 = &(1u32 << 32); - | ^^^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU32_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:43:24 +error[E0080]: attempt to shift left by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:42:24 | LL | const _NU64_SHL: u64 = 1u64 << 64; - | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU64_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:44:28 +error[E0080]: attempt to shift left by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:43:28 | LL | const _NU64_SHL_P: &u64 = &(1u64 << 64); - | ^^^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU64_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:46:26 +error[E0080]: attempt to shift left by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:45:26 | LL | const _NU128_SHL: u128 = 1u128 << 128; - | ^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU128_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:47:30 +error[E0080]: attempt to shift left by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:46:30 | LL | const _NU128_SHL_P: &u128 = &(1u128 << 128); - | ^^^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NU128_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:49:28 +error[E0080]: attempt to shift left by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:48:28 | LL | const _NISIZE_SHL: isize = 1isize << BITS; - | ^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NISIZE_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:50:32 +error[E0080]: attempt to shift left by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:49:32 | LL | const _NISIZE_SHL_P: &isize = &(1isize << BITS); - | ^^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:52:28 +error[E0080]: attempt to shift left by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:51:28 | LL | const _NUSIZE_SHL: usize = 1usize << BITS; - | ^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NUSIZE_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:53:32 +error[E0080]: attempt to shift left by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:52:32 | LL | const _NUSIZE_SHL_P: &usize = &(1usize << BITS); - | ^^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:57:22 +error[E0080]: attempt to shift right by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:55:22 | LL | const _NI8_SHR: i8 = 1i8 >> 8; - | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + | ^^^^^^^^ evaluation of `_NI8_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:58:26 +error[E0080]: attempt to shift right by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:56:26 | LL | const _NI8_SHR_P: &i8 = &(1i8 >> 8); - | ^^^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NI8_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:60:24 +error[E0080]: attempt to shift right by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:58:24 | LL | const _NI16_SHR: i16 = 1i16 >> 16; - | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NI16_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:61:28 +error[E0080]: attempt to shift right by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:59:28 | LL | const _NI16_SHR_P: &i16 = &(1i16 >> 16); - | ^^^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI16_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:63:24 +error[E0080]: attempt to shift right by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:61:24 | LL | const _NI32_SHR: i32 = 1i32 >> 32; - | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NI32_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:64:28 +error[E0080]: attempt to shift right by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:62:28 | LL | const _NI32_SHR_P: &i32 = &(1i32 >> 32); - | ^^^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI32_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:66:24 +error[E0080]: attempt to shift right by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:64:24 | LL | const _NI64_SHR: i64 = 1i64 >> 64; - | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NI64_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:67:28 +error[E0080]: attempt to shift right by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:65:28 | LL | const _NI64_SHR_P: &i64 = &(1i64 >> 64); - | ^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI64_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:69:26 +error[E0080]: attempt to shift right by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:67:26 | LL | const _NI128_SHR: i128 = 1i128 >> 128; - | ^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI128_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:70:30 +error[E0080]: attempt to shift right by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:68:30 | LL | const _NI128_SHR_P: &i128 = &(1i128 >> 128); - | ^^^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NI128_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:72:22 +error[E0080]: attempt to shift right by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:70:22 | LL | const _NU8_SHR: u8 = 1u8 >> 8; - | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + | ^^^^^^^^ evaluation of `_NU8_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:73:26 +error[E0080]: attempt to shift right by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:71:26 | LL | const _NU8_SHR_P: &u8 = &(1u8 >> 8); - | ^^^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU8_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:75:24 +error[E0080]: attempt to shift right by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:73:24 | LL | const _NU16_SHR: u16 = 1u16 >> 16; - | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU16_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:76:28 +error[E0080]: attempt to shift right by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:74:28 | LL | const _NU16_SHR_P: &u16 = &(1u16 >> 16); - | ^^^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU16_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:78:24 +error[E0080]: attempt to shift right by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:76:24 | LL | const _NU32_SHR: u32 = 1u32 >> 32; - | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU32_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:79:28 +error[E0080]: attempt to shift right by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:77:28 | LL | const _NU32_SHR_P: &u32 = &(1u32 >> 32); - | ^^^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU32_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:81:24 +error[E0080]: attempt to shift right by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:79:24 | LL | const _NU64_SHR: u64 = 1u64 >> 64; - | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU64_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:82:28 +error[E0080]: attempt to shift right by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:80:28 | LL | const _NU64_SHR_P: &u64 = &(1u64 >> 64); - | ^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU64_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:84:26 +error[E0080]: attempt to shift right by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:82:26 | LL | const _NU128_SHR: u128 = 1u128 >> 128; - | ^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU128_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:85:30 +error[E0080]: attempt to shift right by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:83:30 | LL | const _NU128_SHR_P: &u128 = &(1u128 >> 128); - | ^^^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NU128_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:87:28 +error[E0080]: attempt to shift right by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:85:28 | LL | const _NISIZE_SHR: isize = 1isize >> BITS; - | ^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NISIZE_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:88:32 +error[E0080]: attempt to shift right by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:86:32 | LL | const _NISIZE_SHR_P: &isize = &(1isize >> BITS); - | ^^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:90:28 +error[E0080]: attempt to shift right by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:88:28 | LL | const _NUSIZE_SHR: usize = 1usize >> BITS; - | ^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NUSIZE_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:91:32 +error[E0080]: attempt to shift right by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:89:32 | LL | const _NUSIZE_SHR_P: &usize = &(1usize >> BITS); - | ^^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:95:22 +error[E0080]: attempt to compute `1_i8 + i8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:92:22 | LL | const _NI8_ADD: i8 = 1i8 + i8::MAX; - | ^^^^^^^^^^^^^ attempt to compute `1_i8 + i8::MAX`, which would overflow + | ^^^^^^^^^^^^^ evaluation of `_NI8_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:96:26 +error[E0080]: attempt to compute `1_i8 + i8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:93:26 | LL | const _NI8_ADD_P: &i8 = &(1i8 + i8::MAX); - | ^^^^^^^^^^^^^^^ attempt to compute `1_i8 + i8::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NI8_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:98:24 +error[E0080]: attempt to compute `1_i16 + i16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:95:24 | LL | const _NI16_ADD: i16 = 1i16 + i16::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_i16 + i16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NI16_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:99:28 +error[E0080]: attempt to compute `1_i16 + i16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:96:28 | LL | const _NI16_ADD_P: &i16 = &(1i16 + i16::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i16 + i16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of `_NI16_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:101:24 +error[E0080]: attempt to compute `1_i32 + i32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:98:24 | LL | const _NI32_ADD: i32 = 1i32 + i32::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NI32_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:102:28 +error[E0080]: attempt to compute `1_i32 + i32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:99:28 | LL | const _NI32_ADD_P: &i32 = &(1i32 + i32::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of `_NI32_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:104:24 +error[E0080]: attempt to compute `1_i64 + i64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:101:24 | LL | const _NI64_ADD: i64 = 1i64 + i64::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_i64 + i64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NI64_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:105:28 +error[E0080]: attempt to compute `1_i64 + i64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:102:28 | LL | const _NI64_ADD_P: &i64 = &(1i64 + i64::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i64 + i64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of `_NI64_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:107:26 +error[E0080]: attempt to compute `1_i128 + i128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:104:26 | LL | const _NI128_ADD: i128 = 1i128 + i128::MAX; - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i128 + i128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of `_NI128_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:108:30 +error[E0080]: attempt to compute `1_i128 + i128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:105:30 | LL | const _NI128_ADD_P: &i128 = &(1i128 + i128::MAX); - | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_i128 + i128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^ evaluation of `_NI128_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:110:22 +error[E0080]: attempt to compute `1_u8 + u8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:107:22 | LL | const _NU8_ADD: u8 = 1u8 + u8::MAX; - | ^^^^^^^^^^^^^ attempt to compute `1_u8 + u8::MAX`, which would overflow + | ^^^^^^^^^^^^^ evaluation of `_NU8_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:111:26 +error[E0080]: attempt to compute `1_u8 + u8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:108:26 | LL | const _NU8_ADD_P: &u8 = &(1u8 + u8::MAX); - | ^^^^^^^^^^^^^^^ attempt to compute `1_u8 + u8::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NU8_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:113:24 +error[E0080]: attempt to compute `1_u16 + u16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:110:24 | LL | const _NU16_ADD: u16 = 1u16 + u16::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_u16 + u16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NU16_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:114:28 +error[E0080]: attempt to compute `1_u16 + u16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:111:28 | LL | const _NU16_ADD_P: &u16 = &(1u16 + u16::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u16 + u16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of `_NU16_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:116:24 +error[E0080]: attempt to compute `1_u32 + u32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:113:24 | LL | const _NU32_ADD: u32 = 1u32 + u32::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_u32 + u32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NU32_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:117:28 +error[E0080]: attempt to compute `1_u32 + u32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:114:28 | LL | const _NU32_ADD_P: &u32 = &(1u32 + u32::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u32 + u32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of `_NU32_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:119:24 +error[E0080]: attempt to compute `1_u64 + u64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:116:24 | LL | const _NU64_ADD: u64 = 1u64 + u64::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_u64 + u64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NU64_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:120:28 +error[E0080]: attempt to compute `1_u64 + u64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:117:28 | LL | const _NU64_ADD_P: &u64 = &(1u64 + u64::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u64 + u64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of `_NU64_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:122:26 +error[E0080]: attempt to compute `1_u128 + u128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:119:26 | LL | const _NU128_ADD: u128 = 1u128 + u128::MAX; - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u128 + u128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of `_NU128_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:123:30 +error[E0080]: attempt to compute `1_u128 + u128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:120:30 | LL | const _NU128_ADD_P: &u128 = &(1u128 + u128::MAX); - | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_u128 + u128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^ evaluation of `_NU128_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:125:28 +error[E0080]: attempt to compute `1_isize + isize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:122:28 | LL | const _NISIZE_ADD: isize = 1isize + isize::MAX; - | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_isize + isize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:126:32 +error[E0080]: attempt to compute `1_isize + isize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:123:32 | LL | const _NISIZE_ADD_P: &isize = &(1isize + isize::MAX); - | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_isize + isize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:128:28 +error[E0080]: attempt to compute `1_usize + usize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:125:28 | LL | const _NUSIZE_ADD: usize = 1usize + usize::MAX; - | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize + usize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:129:32 +error[E0080]: attempt to compute `1_usize + usize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:126:32 | LL | const _NUSIZE_ADD_P: &usize = &(1usize + usize::MAX); - | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize + usize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:133:22 +error[E0080]: attempt to compute `-5_i8 - i8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:129:22 | LL | const _NI8_SUB: i8 = -5i8 - i8::MAX; - | ^^^^^^^^^^^^^^ attempt to compute `-5_i8 - i8::MAX`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NI8_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:134:26 +error[E0080]: attempt to compute `-5_i8 - i8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:130:26 | LL | const _NI8_SUB_P: &i8 = &(-5i8 - i8::MAX); - | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i8 - i8::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NI8_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:136:24 +error[E0080]: attempt to compute `-5_i16 - i16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:132:24 | LL | const _NI16_SUB: i16 = -5i16 - i16::MAX; - | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i16 - i16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NI16_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:137:28 +error[E0080]: attempt to compute `-5_i16 - i16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:133:28 | LL | const _NI16_SUB_P: &i16 = &(-5i16 - i16::MAX); - | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i16 - i16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^ evaluation of `_NI16_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:139:24 +error[E0080]: attempt to compute `-5_i32 - i32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:135:24 | LL | const _NI32_SUB: i32 = -5i32 - i32::MAX; - | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NI32_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:140:28 +error[E0080]: attempt to compute `-5_i32 - i32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:136:28 | LL | const _NI32_SUB_P: &i32 = &(-5i32 - i32::MAX); - | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^ evaluation of `_NI32_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:142:24 +error[E0080]: attempt to compute `-5_i64 - i64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:138:24 | LL | const _NI64_SUB: i64 = -5i64 - i64::MAX; - | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i64 - i64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NI64_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:143:28 +error[E0080]: attempt to compute `-5_i64 - i64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:139:28 | LL | const _NI64_SUB_P: &i64 = &(-5i64 - i64::MAX); - | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i64 - i64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^ evaluation of `_NI64_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:145:26 +error[E0080]: attempt to compute `-5_i128 - i128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:141:26 | LL | const _NI128_SUB: i128 = -5i128 - i128::MAX; - | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i128 - i128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^ evaluation of `_NI128_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:146:30 +error[E0080]: attempt to compute `-5_i128 - i128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:142:30 | LL | const _NI128_SUB_P: &i128 = &(-5i128 - i128::MAX); - | ^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i128 - i128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^ evaluation of `_NI128_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:148:22 +error[E0080]: attempt to compute `1_u8 - 5_u8`, which would overflow + --> $DIR/overflowing-consts.rs:144:22 | LL | const _NU8_SUB: u8 = 1u8 - 5; - | ^^^^^^^ attempt to compute `1_u8 - 5_u8`, which would overflow + | ^^^^^^^ evaluation of `_NU8_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:149:26 +error[E0080]: attempt to compute `1_u8 - 5_u8`, which would overflow + --> $DIR/overflowing-consts.rs:145:26 | LL | const _NU8_SUB_P: &u8 = &(1u8 - 5); - | ^^^^^^^^^ attempt to compute `1_u8 - 5_u8`, which would overflow + | ^^^^^^^^^ evaluation of `_NU8_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:151:24 +error[E0080]: attempt to compute `1_u16 - 5_u16`, which would overflow + --> $DIR/overflowing-consts.rs:147:24 | LL | const _NU16_SUB: u16 = 1u16 - 5; - | ^^^^^^^^ attempt to compute `1_u16 - 5_u16`, which would overflow + | ^^^^^^^^ evaluation of `_NU16_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:152:28 +error[E0080]: attempt to compute `1_u16 - 5_u16`, which would overflow + --> $DIR/overflowing-consts.rs:148:28 | LL | const _NU16_SUB_P: &u16 = &(1u16 - 5); - | ^^^^^^^^^^ attempt to compute `1_u16 - 5_u16`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU16_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:154:24 +error[E0080]: attempt to compute `1_u32 - 5_u32`, which would overflow + --> $DIR/overflowing-consts.rs:150:24 | LL | const _NU32_SUB: u32 = 1u32 - 5; - | ^^^^^^^^ attempt to compute `1_u32 - 5_u32`, which would overflow + | ^^^^^^^^ evaluation of `_NU32_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:155:28 +error[E0080]: attempt to compute `1_u32 - 5_u32`, which would overflow + --> $DIR/overflowing-consts.rs:151:28 | LL | const _NU32_SUB_P: &u32 = &(1u32 - 5); - | ^^^^^^^^^^ attempt to compute `1_u32 - 5_u32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU32_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:157:24 +error[E0080]: attempt to compute `1_u64 - 5_u64`, which would overflow + --> $DIR/overflowing-consts.rs:153:24 | LL | const _NU64_SUB: u64 = 1u64 - 5; - | ^^^^^^^^ attempt to compute `1_u64 - 5_u64`, which would overflow + | ^^^^^^^^ evaluation of `_NU64_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:158:28 +error[E0080]: attempt to compute `1_u64 - 5_u64`, which would overflow + --> $DIR/overflowing-consts.rs:154:28 | LL | const _NU64_SUB_P: &u64 = &(1u64 - 5); - | ^^^^^^^^^^ attempt to compute `1_u64 - 5_u64`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU64_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:160:26 +error[E0080]: attempt to compute `1_u128 - 5_u128`, which would overflow + --> $DIR/overflowing-consts.rs:156:26 | LL | const _NU128_SUB: u128 = 1u128 - 5; - | ^^^^^^^^^ attempt to compute `1_u128 - 5_u128`, which would overflow + | ^^^^^^^^^ evaluation of `_NU128_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:161:30 +error[E0080]: attempt to compute `1_u128 - 5_u128`, which would overflow + --> $DIR/overflowing-consts.rs:157:30 | LL | const _NU128_SUB_P: &u128 = &(1u128 - 5); - | ^^^^^^^^^^^ attempt to compute `1_u128 - 5_u128`, which would overflow + | ^^^^^^^^^^^ evaluation of `_NU128_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:163:28 +error[E0080]: attempt to compute `-5_isize - isize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:159:28 | LL | const _NISIZE_SUB: isize = -5isize - isize::MAX; - | ^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_isize - isize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:164:32 +error[E0080]: attempt to compute `-5_isize - isize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:160:32 | LL | const _NISIZE_SUB_P: &isize = &(-5isize - isize::MAX); - | ^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_isize - isize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:166:28 +error[E0080]: attempt to compute `1_usize - 5_usize`, which would overflow + --> $DIR/overflowing-consts.rs:162:28 | -LL | const _NUSIZE_SUB: usize = 1usize - 5 ; - | ^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow +LL | const _NUSIZE_SUB: usize = 1usize - 5; + | ^^^^^^^^^^ evaluation of `_NUSIZE_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:167:32 +error[E0080]: attempt to compute `1_usize - 5_usize`, which would overflow + --> $DIR/overflowing-consts.rs:163:32 | -LL | const _NUSIZE_SUB_P: &usize = &(1usize - 5 ); - | ^^^^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow +LL | const _NUSIZE_SUB_P: &usize = &(1usize - 5); + | ^^^^^^^^^^^^ evaluation of `_NUSIZE_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:171:22 +error[E0080]: attempt to compute `i8::MAX * 5_i8`, which would overflow + --> $DIR/overflowing-consts.rs:166:22 | LL | const _NI8_MUL: i8 = i8::MAX * 5; - | ^^^^^^^^^^^ attempt to compute `i8::MAX * 5_i8`, which would overflow + | ^^^^^^^^^^^ evaluation of `_NI8_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:172:26 +error[E0080]: attempt to compute `i8::MAX * 5_i8`, which would overflow + --> $DIR/overflowing-consts.rs:167:26 | LL | const _NI8_MUL_P: &i8 = &(i8::MAX * 5); - | ^^^^^^^^^^^^^ attempt to compute `i8::MAX * 5_i8`, which would overflow + | ^^^^^^^^^^^^^ evaluation of `_NI8_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:174:24 +error[E0080]: attempt to compute `i16::MAX * 5_i16`, which would overflow + --> $DIR/overflowing-consts.rs:169:24 | LL | const _NI16_MUL: i16 = i16::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI16_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:175:28 +error[E0080]: attempt to compute `i16::MAX * 5_i16`, which would overflow + --> $DIR/overflowing-consts.rs:170:28 | LL | const _NI16_MUL_P: &i16 = &(i16::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NI16_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:177:24 +error[E0080]: attempt to compute `i32::MAX * 5_i32`, which would overflow + --> $DIR/overflowing-consts.rs:172:24 | LL | const _NI32_MUL: i32 = i32::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI32_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:178:28 +error[E0080]: attempt to compute `i32::MAX * 5_i32`, which would overflow + --> $DIR/overflowing-consts.rs:173:28 | LL | const _NI32_MUL_P: &i32 = &(i32::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NI32_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:180:24 +error[E0080]: attempt to compute `i64::MAX * 5_i64`, which would overflow + --> $DIR/overflowing-consts.rs:175:24 | LL | const _NI64_MUL: i64 = i64::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI64_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:181:28 +error[E0080]: attempt to compute `i64::MAX * 5_i64`, which would overflow + --> $DIR/overflowing-consts.rs:176:28 | LL | const _NI64_MUL_P: &i64 = &(i64::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NI64_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:183:26 +error[E0080]: attempt to compute `i128::MAX * 5_i128`, which would overflow + --> $DIR/overflowing-consts.rs:178:26 | LL | const _NI128_MUL: i128 = i128::MAX * 5; - | ^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow + | ^^^^^^^^^^^^^ evaluation of `_NI128_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:184:30 +error[E0080]: attempt to compute `i128::MAX * 5_i128`, which would overflow + --> $DIR/overflowing-consts.rs:179:30 | LL | const _NI128_MUL_P: &i128 = &(i128::MAX * 5); - | ^^^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NI128_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:186:22 +error[E0080]: attempt to compute `u8::MAX * 5_u8`, which would overflow + --> $DIR/overflowing-consts.rs:181:22 | LL | const _NU8_MUL: u8 = u8::MAX * 5; - | ^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow + | ^^^^^^^^^^^ evaluation of `_NU8_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:187:26 +error[E0080]: attempt to compute `u8::MAX * 5_u8`, which would overflow + --> $DIR/overflowing-consts.rs:182:26 | LL | const _NU8_MUL_P: &u8 = &(u8::MAX * 5); - | ^^^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow + | ^^^^^^^^^^^^^ evaluation of `_NU8_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:189:24 +error[E0080]: attempt to compute `u16::MAX * 5_u16`, which would overflow + --> $DIR/overflowing-consts.rs:184:24 | LL | const _NU16_MUL: u16 = u16::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU16_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:190:28 +error[E0080]: attempt to compute `u16::MAX * 5_u16`, which would overflow + --> $DIR/overflowing-consts.rs:185:28 | LL | const _NU16_MUL_P: &u16 = &(u16::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NU16_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:192:24 +error[E0080]: attempt to compute `u32::MAX * 5_u32`, which would overflow + --> $DIR/overflowing-consts.rs:187:24 | LL | const _NU32_MUL: u32 = u32::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU32_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:193:28 +error[E0080]: attempt to compute `u32::MAX * 5_u32`, which would overflow + --> $DIR/overflowing-consts.rs:188:28 | LL | const _NU32_MUL_P: &u32 = &(u32::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NU32_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:195:24 +error[E0080]: attempt to compute `u64::MAX * 5_u64`, which would overflow + --> $DIR/overflowing-consts.rs:190:24 | LL | const _NU64_MUL: u64 = u64::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU64_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:196:28 +error[E0080]: attempt to compute `u64::MAX * 5_u64`, which would overflow + --> $DIR/overflowing-consts.rs:191:28 | LL | const _NU64_MUL_P: &u64 = &(u64::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NU64_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:198:26 +error[E0080]: attempt to compute `u128::MAX * 5_u128`, which would overflow + --> $DIR/overflowing-consts.rs:193:26 | LL | const _NU128_MUL: u128 = u128::MAX * 5; - | ^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow + | ^^^^^^^^^^^^^ evaluation of `_NU128_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:199:30 +error[E0080]: attempt to compute `u128::MAX * 5_u128`, which would overflow + --> $DIR/overflowing-consts.rs:194:30 | LL | const _NU128_MUL_P: &u128 = &(u128::MAX * 5); - | ^^^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NU128_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:201:28 +error[E0080]: attempt to compute `isize::MAX * 5_isize`, which would overflow + --> $DIR/overflowing-consts.rs:196:28 | LL | const _NISIZE_MUL: isize = isize::MAX * 5; - | ^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NISIZE_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:202:32 +error[E0080]: attempt to compute `isize::MAX * 5_isize`, which would overflow + --> $DIR/overflowing-consts.rs:197:32 | LL | const _NISIZE_MUL_P: &isize = &(isize::MAX * 5); - | ^^^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:204:28 +error[E0080]: attempt to compute `usize::MAX * 5_usize`, which would overflow + --> $DIR/overflowing-consts.rs:199:28 | LL | const _NUSIZE_MUL: usize = usize::MAX * 5; - | ^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NUSIZE_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:205:32 +error[E0080]: attempt to compute `usize::MAX * 5_usize`, which would overflow + --> $DIR/overflowing-consts.rs:200:32 | LL | const _NUSIZE_MUL_P: &usize = &(usize::MAX * 5); - | ^^^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:209:22 +error[E0080]: attempt to divide `1_i8` by zero + --> $DIR/overflowing-consts.rs:203:22 | LL | const _NI8_DIV: i8 = 1i8 / 0; - | ^^^^^^^ attempt to divide `1_i8` by zero + | ^^^^^^^ evaluation of `_NI8_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:210:26 +error[E0080]: attempt to divide `1_i8` by zero + --> $DIR/overflowing-consts.rs:204:26 | LL | const _NI8_DIV_P: &i8 = &(1i8 / 0); - | ^^^^^^^^^ attempt to divide `1_i8` by zero + | ^^^^^^^^^ evaluation of `_NI8_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:212:24 +error[E0080]: attempt to divide `1_i16` by zero + --> $DIR/overflowing-consts.rs:206:24 | LL | const _NI16_DIV: i16 = 1i16 / 0; - | ^^^^^^^^ attempt to divide `1_i16` by zero + | ^^^^^^^^ evaluation of `_NI16_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:213:28 +error[E0080]: attempt to divide `1_i16` by zero + --> $DIR/overflowing-consts.rs:207:28 | LL | const _NI16_DIV_P: &i16 = &(1i16 / 0); - | ^^^^^^^^^^ attempt to divide `1_i16` by zero + | ^^^^^^^^^^ evaluation of `_NI16_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:215:24 +error[E0080]: attempt to divide `1_i32` by zero + --> $DIR/overflowing-consts.rs:209:24 | LL | const _NI32_DIV: i32 = 1i32 / 0; - | ^^^^^^^^ attempt to divide `1_i32` by zero + | ^^^^^^^^ evaluation of `_NI32_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:216:28 +error[E0080]: attempt to divide `1_i32` by zero + --> $DIR/overflowing-consts.rs:210:28 | LL | const _NI32_DIV_P: &i32 = &(1i32 / 0); - | ^^^^^^^^^^ attempt to divide `1_i32` by zero + | ^^^^^^^^^^ evaluation of `_NI32_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:218:24 +error[E0080]: attempt to divide `1_i64` by zero + --> $DIR/overflowing-consts.rs:212:24 | LL | const _NI64_DIV: i64 = 1i64 / 0; - | ^^^^^^^^ attempt to divide `1_i64` by zero + | ^^^^^^^^ evaluation of `_NI64_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:219:28 +error[E0080]: attempt to divide `1_i64` by zero + --> $DIR/overflowing-consts.rs:213:28 | LL | const _NI64_DIV_P: &i64 = &(1i64 / 0); - | ^^^^^^^^^^ attempt to divide `1_i64` by zero + | ^^^^^^^^^^ evaluation of `_NI64_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:221:26 +error[E0080]: attempt to divide `1_i128` by zero + --> $DIR/overflowing-consts.rs:215:26 | LL | const _NI128_DIV: i128 = 1i128 / 0; - | ^^^^^^^^^ attempt to divide `1_i128` by zero + | ^^^^^^^^^ evaluation of `_NI128_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:222:30 +error[E0080]: attempt to divide `1_i128` by zero + --> $DIR/overflowing-consts.rs:216:30 | LL | const _NI128_DIV_P: &i128 = &(1i128 / 0); - | ^^^^^^^^^^^ attempt to divide `1_i128` by zero + | ^^^^^^^^^^^ evaluation of `_NI128_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:224:22 +error[E0080]: attempt to divide `1_u8` by zero + --> $DIR/overflowing-consts.rs:218:22 | LL | const _NU8_DIV: u8 = 1u8 / 0; - | ^^^^^^^ attempt to divide `1_u8` by zero + | ^^^^^^^ evaluation of `_NU8_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:225:26 +error[E0080]: attempt to divide `1_u8` by zero + --> $DIR/overflowing-consts.rs:219:26 | LL | const _NU8_DIV_P: &u8 = &(1u8 / 0); - | ^^^^^^^^^ attempt to divide `1_u8` by zero + | ^^^^^^^^^ evaluation of `_NU8_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:227:24 +error[E0080]: attempt to divide `1_u16` by zero + --> $DIR/overflowing-consts.rs:221:24 | LL | const _NU16_DIV: u16 = 1u16 / 0; - | ^^^^^^^^ attempt to divide `1_u16` by zero + | ^^^^^^^^ evaluation of `_NU16_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:228:28 +error[E0080]: attempt to divide `1_u16` by zero + --> $DIR/overflowing-consts.rs:222:28 | LL | const _NU16_DIV_P: &u16 = &(1u16 / 0); - | ^^^^^^^^^^ attempt to divide `1_u16` by zero + | ^^^^^^^^^^ evaluation of `_NU16_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:230:24 +error[E0080]: attempt to divide `1_u32` by zero + --> $DIR/overflowing-consts.rs:224:24 | LL | const _NU32_DIV: u32 = 1u32 / 0; - | ^^^^^^^^ attempt to divide `1_u32` by zero + | ^^^^^^^^ evaluation of `_NU32_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:231:28 +error[E0080]: attempt to divide `1_u32` by zero + --> $DIR/overflowing-consts.rs:225:28 | LL | const _NU32_DIV_P: &u32 = &(1u32 / 0); - | ^^^^^^^^^^ attempt to divide `1_u32` by zero + | ^^^^^^^^^^ evaluation of `_NU32_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:233:24 +error[E0080]: attempt to divide `1_u64` by zero + --> $DIR/overflowing-consts.rs:227:24 | LL | const _NU64_DIV: u64 = 1u64 / 0; - | ^^^^^^^^ attempt to divide `1_u64` by zero + | ^^^^^^^^ evaluation of `_NU64_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:234:28 +error[E0080]: attempt to divide `1_u64` by zero + --> $DIR/overflowing-consts.rs:228:28 | LL | const _NU64_DIV_P: &u64 = &(1u64 / 0); - | ^^^^^^^^^^ attempt to divide `1_u64` by zero + | ^^^^^^^^^^ evaluation of `_NU64_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:236:26 +error[E0080]: attempt to divide `1_u128` by zero + --> $DIR/overflowing-consts.rs:230:26 | LL | const _NU128_DIV: u128 = 1u128 / 0; - | ^^^^^^^^^ attempt to divide `1_u128` by zero + | ^^^^^^^^^ evaluation of `_NU128_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:237:30 +error[E0080]: attempt to divide `1_u128` by zero + --> $DIR/overflowing-consts.rs:231:30 | LL | const _NU128_DIV_P: &u128 = &(1u128 / 0); - | ^^^^^^^^^^^ attempt to divide `1_u128` by zero + | ^^^^^^^^^^^ evaluation of `_NU128_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:239:28 +error[E0080]: attempt to divide `1_isize` by zero + --> $DIR/overflowing-consts.rs:233:28 | LL | const _NISIZE_DIV: isize = 1isize / 0; - | ^^^^^^^^^^ attempt to divide `1_isize` by zero + | ^^^^^^^^^^ evaluation of `_NISIZE_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:240:32 +error[E0080]: attempt to divide `1_isize` by zero + --> $DIR/overflowing-consts.rs:234:32 | LL | const _NISIZE_DIV_P: &isize = &(1isize / 0); - | ^^^^^^^^^^^^ attempt to divide `1_isize` by zero + | ^^^^^^^^^^^^ evaluation of `_NISIZE_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:242:28 +error[E0080]: attempt to divide `1_usize` by zero + --> $DIR/overflowing-consts.rs:236:28 | LL | const _NUSIZE_DIV: usize = 1usize / 0; - | ^^^^^^^^^^ attempt to divide `1_usize` by zero + | ^^^^^^^^^^ evaluation of `_NUSIZE_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:243:32 +error[E0080]: attempt to divide `1_usize` by zero + --> $DIR/overflowing-consts.rs:237:32 | LL | const _NUSIZE_DIV_P: &usize = &(1usize / 0); - | ^^^^^^^^^^^^ attempt to divide `1_usize` by zero + | ^^^^^^^^^^^^ evaluation of `_NUSIZE_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:246:22 +error[E0080]: attempt to calculate the remainder of `1_i8` with a divisor of zero + --> $DIR/overflowing-consts.rs:240:22 | LL | const _NI8_MOD: i8 = 1i8 % 0; - | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero + | ^^^^^^^ evaluation of `_NI8_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:247:26 +error[E0080]: attempt to calculate the remainder of `1_i8` with a divisor of zero + --> $DIR/overflowing-consts.rs:241:26 | LL | const _NI8_MOD_P: &i8 = &(1i8 % 0); - | ^^^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero + | ^^^^^^^^^ evaluation of `_NI8_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:249:24 +error[E0080]: attempt to calculate the remainder of `1_i16` with a divisor of zero + --> $DIR/overflowing-consts.rs:243:24 | LL | const _NI16_MOD: i16 = 1i16 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero + | ^^^^^^^^ evaluation of `_NI16_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:250:28 +error[E0080]: attempt to calculate the remainder of `1_i16` with a divisor of zero + --> $DIR/overflowing-consts.rs:244:28 | LL | const _NI16_MOD_P: &i16 = &(1i16 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero + | ^^^^^^^^^^ evaluation of `_NI16_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:252:24 +error[E0080]: attempt to calculate the remainder of `1_i32` with a divisor of zero + --> $DIR/overflowing-consts.rs:246:24 | LL | const _NI32_MOD: i32 = 1i32 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + | ^^^^^^^^ evaluation of `_NI32_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:253:28 +error[E0080]: attempt to calculate the remainder of `1_i32` with a divisor of zero + --> $DIR/overflowing-consts.rs:247:28 | LL | const _NI32_MOD_P: &i32 = &(1i32 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + | ^^^^^^^^^^ evaluation of `_NI32_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:255:24 +error[E0080]: attempt to calculate the remainder of `1_i64` with a divisor of zero + --> $DIR/overflowing-consts.rs:249:24 | LL | const _NI64_MOD: i64 = 1i64 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero + | ^^^^^^^^ evaluation of `_NI64_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:256:28 +error[E0080]: attempt to calculate the remainder of `1_i64` with a divisor of zero + --> $DIR/overflowing-consts.rs:250:28 | LL | const _NI64_MOD_P: &i64 = &(1i64 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero + | ^^^^^^^^^^ evaluation of `_NI64_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:258:26 +error[E0080]: attempt to calculate the remainder of `1_i128` with a divisor of zero + --> $DIR/overflowing-consts.rs:252:26 | LL | const _NI128_MOD: i128 = 1i128 % 0; - | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero + | ^^^^^^^^^ evaluation of `_NI128_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:259:30 +error[E0080]: attempt to calculate the remainder of `1_i128` with a divisor of zero + --> $DIR/overflowing-consts.rs:253:30 | LL | const _NI128_MOD_P: &i128 = &(1i128 % 0); - | ^^^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero + | ^^^^^^^^^^^ evaluation of `_NI128_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:261:22 +error[E0080]: attempt to calculate the remainder of `1_u8` with a divisor of zero + --> $DIR/overflowing-consts.rs:255:22 | LL | const _NU8_MOD: u8 = 1u8 % 0; - | ^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero + | ^^^^^^^ evaluation of `_NU8_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:262:26 +error[E0080]: attempt to calculate the remainder of `1_u8` with a divisor of zero + --> $DIR/overflowing-consts.rs:256:26 | LL | const _NU8_MOD_P: &u8 = &(1u8 % 0); - | ^^^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero + | ^^^^^^^^^ evaluation of `_NU8_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:264:24 +error[E0080]: attempt to calculate the remainder of `1_u16` with a divisor of zero + --> $DIR/overflowing-consts.rs:258:24 | LL | const _NU16_MOD: u16 = 1u16 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero + | ^^^^^^^^ evaluation of `_NU16_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:265:28 +error[E0080]: attempt to calculate the remainder of `1_u16` with a divisor of zero + --> $DIR/overflowing-consts.rs:259:28 | LL | const _NU16_MOD_P: &u16 = &(1u16 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero + | ^^^^^^^^^^ evaluation of `_NU16_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:267:24 +error[E0080]: attempt to calculate the remainder of `1_u32` with a divisor of zero + --> $DIR/overflowing-consts.rs:261:24 | LL | const _NU32_MOD: u32 = 1u32 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero + | ^^^^^^^^ evaluation of `_NU32_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:268:28 +error[E0080]: attempt to calculate the remainder of `1_u32` with a divisor of zero + --> $DIR/overflowing-consts.rs:262:28 | LL | const _NU32_MOD_P: &u32 = &(1u32 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero + | ^^^^^^^^^^ evaluation of `_NU32_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:270:24 +error[E0080]: attempt to calculate the remainder of `1_u64` with a divisor of zero + --> $DIR/overflowing-consts.rs:264:24 | LL | const _NU64_MOD: u64 = 1u64 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero + | ^^^^^^^^ evaluation of `_NU64_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:271:28 +error[E0080]: attempt to calculate the remainder of `1_u64` with a divisor of zero + --> $DIR/overflowing-consts.rs:265:28 | LL | const _NU64_MOD_P: &u64 = &(1u64 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero + | ^^^^^^^^^^ evaluation of `_NU64_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:273:26 +error[E0080]: attempt to calculate the remainder of `1_u128` with a divisor of zero + --> $DIR/overflowing-consts.rs:267:26 | LL | const _NU128_MOD: u128 = 1u128 % 0; - | ^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero + | ^^^^^^^^^ evaluation of `_NU128_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:274:30 +error[E0080]: attempt to calculate the remainder of `1_u128` with a divisor of zero + --> $DIR/overflowing-consts.rs:268:30 | LL | const _NU128_MOD_P: &u128 = &(1u128 % 0); - | ^^^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero + | ^^^^^^^^^^^ evaluation of `_NU128_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:276:28 +error[E0080]: attempt to calculate the remainder of `1_isize` with a divisor of zero + --> $DIR/overflowing-consts.rs:270:28 | LL | const _NISIZE_MOD: isize = 1isize % 0; - | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero + | ^^^^^^^^^^ evaluation of `_NISIZE_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:277:32 +error[E0080]: attempt to calculate the remainder of `1_isize` with a divisor of zero + --> $DIR/overflowing-consts.rs:271:32 | LL | const _NISIZE_MOD_P: &isize = &(1isize % 0); - | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero + | ^^^^^^^^^^^^ evaluation of `_NISIZE_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:279:28 +error[E0080]: attempt to calculate the remainder of `1_usize` with a divisor of zero + --> $DIR/overflowing-consts.rs:273:28 | LL | const _NUSIZE_MOD: usize = 1usize % 0; - | ^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero + | ^^^^^^^^^^ evaluation of `_NUSIZE_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:280:32 +error[E0080]: attempt to calculate the remainder of `1_usize` with a divisor of zero + --> $DIR/overflowing-consts.rs:274:32 | LL | const _NUSIZE_MOD_P: &usize = &(1usize % 0); - | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero + | ^^^^^^^^^^^^ evaluation of `_NUSIZE_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:284:24 +error[E0080]: index out of bounds: the length is 3 but the index is 4 + --> $DIR/overflowing-consts.rs:277:24 | LL | const _NI32_OOB: i32 = [1, 2, 3][4]; - | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + | ^^^^^^^^^^^^ evaluation of `_NI32_OOB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:285:28 +error[E0080]: index out of bounds: the length is 3 but the index is 4 + --> $DIR/overflowing-consts.rs:278:28 | LL | const _NI32_OOB_P: &i32 = &([1, 2, 3][4]); - | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + | ^^^^^^^^^^^^^^ evaluation of `_NI32_OOB_P` failed here error: aborting due to 170 previous errors diff --git a/tests/ui/consts/overflowing-consts.opt.stderr b/tests/ui/consts/overflowing-consts.opt.stderr index 81f22944adb..1ef2a60b647 100644 --- a/tests/ui/consts/overflowing-consts.opt.stderr +++ b/tests/ui/consts/overflowing-consts.opt.stderr @@ -1,1022 +1,1022 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:19:22 +error[E0080]: attempt to shift left by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:18:22 | LL | const _NI8_SHL: i8 = 1i8 << 8; - | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | ^^^^^^^^ evaluation of `_NI8_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:20:26 +error[E0080]: attempt to shift left by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:19:26 | LL | const _NI8_SHL_P: &i8 = &(1i8 << 8); - | ^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NI8_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:22:24 +error[E0080]: attempt to shift left by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:21:24 | LL | const _NI16_SHL: i16 = 1i16 << 16; - | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NI16_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:23:28 +error[E0080]: attempt to shift left by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:22:28 | LL | const _NI16_SHL_P: &i16 = &(1i16 << 16); - | ^^^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI16_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:25:24 +error[E0080]: attempt to shift left by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:24:24 | LL | const _NI32_SHL: i32 = 1i32 << 32; - | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NI32_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:26:28 +error[E0080]: attempt to shift left by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:25:28 | LL | const _NI32_SHL_P: &i32 = &(1i32 << 32); - | ^^^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI32_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:28:24 +error[E0080]: attempt to shift left by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:27:24 | LL | const _NI64_SHL: i64 = 1i64 << 64; - | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NI64_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:29:28 +error[E0080]: attempt to shift left by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:28:28 | LL | const _NI64_SHL_P: &i64 = &(1i64 << 64); - | ^^^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI64_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:31:26 +error[E0080]: attempt to shift left by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:30:26 | LL | const _NI128_SHL: i128 = 1i128 << 128; - | ^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI128_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:32:30 +error[E0080]: attempt to shift left by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:31:30 | LL | const _NI128_SHL_P: &i128 = &(1i128 << 128); - | ^^^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NI128_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:34:22 +error[E0080]: attempt to shift left by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:33:22 | LL | const _NU8_SHL: u8 = 1u8 << 8; - | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | ^^^^^^^^ evaluation of `_NU8_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:35:26 +error[E0080]: attempt to shift left by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:34:26 | LL | const _NU8_SHL_P: &u8 = &(1u8 << 8); - | ^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU8_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:37:24 +error[E0080]: attempt to shift left by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:36:24 | LL | const _NU16_SHL: u16 = 1u16 << 16; - | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU16_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:38:28 +error[E0080]: attempt to shift left by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:37:28 | LL | const _NU16_SHL_P: &u16 = &(1u16 << 16); - | ^^^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU16_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:40:24 +error[E0080]: attempt to shift left by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:39:24 | LL | const _NU32_SHL: u32 = 1u32 << 32; - | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU32_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:41:28 +error[E0080]: attempt to shift left by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:40:28 | LL | const _NU32_SHL_P: &u32 = &(1u32 << 32); - | ^^^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU32_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:43:24 +error[E0080]: attempt to shift left by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:42:24 | LL | const _NU64_SHL: u64 = 1u64 << 64; - | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU64_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:44:28 +error[E0080]: attempt to shift left by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:43:28 | LL | const _NU64_SHL_P: &u64 = &(1u64 << 64); - | ^^^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU64_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:46:26 +error[E0080]: attempt to shift left by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:45:26 | LL | const _NU128_SHL: u128 = 1u128 << 128; - | ^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU128_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:47:30 +error[E0080]: attempt to shift left by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:46:30 | LL | const _NU128_SHL_P: &u128 = &(1u128 << 128); - | ^^^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NU128_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:49:28 +error[E0080]: attempt to shift left by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:48:28 | LL | const _NISIZE_SHL: isize = 1isize << BITS; - | ^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NISIZE_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:50:32 +error[E0080]: attempt to shift left by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:49:32 | LL | const _NISIZE_SHL_P: &isize = &(1isize << BITS); - | ^^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:52:28 +error[E0080]: attempt to shift left by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:51:28 | LL | const _NUSIZE_SHL: usize = 1usize << BITS; - | ^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NUSIZE_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:53:32 +error[E0080]: attempt to shift left by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:52:32 | LL | const _NUSIZE_SHL_P: &usize = &(1usize << BITS); - | ^^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:57:22 +error[E0080]: attempt to shift right by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:55:22 | LL | const _NI8_SHR: i8 = 1i8 >> 8; - | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + | ^^^^^^^^ evaluation of `_NI8_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:58:26 +error[E0080]: attempt to shift right by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:56:26 | LL | const _NI8_SHR_P: &i8 = &(1i8 >> 8); - | ^^^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NI8_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:60:24 +error[E0080]: attempt to shift right by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:58:24 | LL | const _NI16_SHR: i16 = 1i16 >> 16; - | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NI16_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:61:28 +error[E0080]: attempt to shift right by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:59:28 | LL | const _NI16_SHR_P: &i16 = &(1i16 >> 16); - | ^^^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI16_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:63:24 +error[E0080]: attempt to shift right by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:61:24 | LL | const _NI32_SHR: i32 = 1i32 >> 32; - | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NI32_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:64:28 +error[E0080]: attempt to shift right by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:62:28 | LL | const _NI32_SHR_P: &i32 = &(1i32 >> 32); - | ^^^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI32_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:66:24 +error[E0080]: attempt to shift right by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:64:24 | LL | const _NI64_SHR: i64 = 1i64 >> 64; - | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NI64_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:67:28 +error[E0080]: attempt to shift right by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:65:28 | LL | const _NI64_SHR_P: &i64 = &(1i64 >> 64); - | ^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI64_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:69:26 +error[E0080]: attempt to shift right by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:67:26 | LL | const _NI128_SHR: i128 = 1i128 >> 128; - | ^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI128_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:70:30 +error[E0080]: attempt to shift right by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:68:30 | LL | const _NI128_SHR_P: &i128 = &(1i128 >> 128); - | ^^^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NI128_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:72:22 +error[E0080]: attempt to shift right by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:70:22 | LL | const _NU8_SHR: u8 = 1u8 >> 8; - | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + | ^^^^^^^^ evaluation of `_NU8_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:73:26 +error[E0080]: attempt to shift right by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:71:26 | LL | const _NU8_SHR_P: &u8 = &(1u8 >> 8); - | ^^^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU8_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:75:24 +error[E0080]: attempt to shift right by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:73:24 | LL | const _NU16_SHR: u16 = 1u16 >> 16; - | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU16_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:76:28 +error[E0080]: attempt to shift right by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:74:28 | LL | const _NU16_SHR_P: &u16 = &(1u16 >> 16); - | ^^^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU16_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:78:24 +error[E0080]: attempt to shift right by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:76:24 | LL | const _NU32_SHR: u32 = 1u32 >> 32; - | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU32_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:79:28 +error[E0080]: attempt to shift right by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:77:28 | LL | const _NU32_SHR_P: &u32 = &(1u32 >> 32); - | ^^^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU32_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:81:24 +error[E0080]: attempt to shift right by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:79:24 | LL | const _NU64_SHR: u64 = 1u64 >> 64; - | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU64_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:82:28 +error[E0080]: attempt to shift right by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:80:28 | LL | const _NU64_SHR_P: &u64 = &(1u64 >> 64); - | ^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU64_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:84:26 +error[E0080]: attempt to shift right by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:82:26 | LL | const _NU128_SHR: u128 = 1u128 >> 128; - | ^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU128_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:85:30 +error[E0080]: attempt to shift right by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:83:30 | LL | const _NU128_SHR_P: &u128 = &(1u128 >> 128); - | ^^^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NU128_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:87:28 +error[E0080]: attempt to shift right by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:85:28 | LL | const _NISIZE_SHR: isize = 1isize >> BITS; - | ^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NISIZE_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:88:32 +error[E0080]: attempt to shift right by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:86:32 | LL | const _NISIZE_SHR_P: &isize = &(1isize >> BITS); - | ^^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:90:28 +error[E0080]: attempt to shift right by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:88:28 | LL | const _NUSIZE_SHR: usize = 1usize >> BITS; - | ^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NUSIZE_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:91:32 +error[E0080]: attempt to shift right by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:89:32 | LL | const _NUSIZE_SHR_P: &usize = &(1usize >> BITS); - | ^^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:95:22 +error[E0080]: attempt to compute `1_i8 + i8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:92:22 | LL | const _NI8_ADD: i8 = 1i8 + i8::MAX; - | ^^^^^^^^^^^^^ attempt to compute `1_i8 + i8::MAX`, which would overflow + | ^^^^^^^^^^^^^ evaluation of `_NI8_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:96:26 +error[E0080]: attempt to compute `1_i8 + i8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:93:26 | LL | const _NI8_ADD_P: &i8 = &(1i8 + i8::MAX); - | ^^^^^^^^^^^^^^^ attempt to compute `1_i8 + i8::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NI8_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:98:24 +error[E0080]: attempt to compute `1_i16 + i16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:95:24 | LL | const _NI16_ADD: i16 = 1i16 + i16::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_i16 + i16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NI16_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:99:28 +error[E0080]: attempt to compute `1_i16 + i16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:96:28 | LL | const _NI16_ADD_P: &i16 = &(1i16 + i16::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i16 + i16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of `_NI16_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:101:24 +error[E0080]: attempt to compute `1_i32 + i32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:98:24 | LL | const _NI32_ADD: i32 = 1i32 + i32::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NI32_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:102:28 +error[E0080]: attempt to compute `1_i32 + i32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:99:28 | LL | const _NI32_ADD_P: &i32 = &(1i32 + i32::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of `_NI32_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:104:24 +error[E0080]: attempt to compute `1_i64 + i64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:101:24 | LL | const _NI64_ADD: i64 = 1i64 + i64::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_i64 + i64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NI64_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:105:28 +error[E0080]: attempt to compute `1_i64 + i64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:102:28 | LL | const _NI64_ADD_P: &i64 = &(1i64 + i64::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i64 + i64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of `_NI64_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:107:26 +error[E0080]: attempt to compute `1_i128 + i128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:104:26 | LL | const _NI128_ADD: i128 = 1i128 + i128::MAX; - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i128 + i128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of `_NI128_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:108:30 +error[E0080]: attempt to compute `1_i128 + i128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:105:30 | LL | const _NI128_ADD_P: &i128 = &(1i128 + i128::MAX); - | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_i128 + i128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^ evaluation of `_NI128_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:110:22 +error[E0080]: attempt to compute `1_u8 + u8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:107:22 | LL | const _NU8_ADD: u8 = 1u8 + u8::MAX; - | ^^^^^^^^^^^^^ attempt to compute `1_u8 + u8::MAX`, which would overflow + | ^^^^^^^^^^^^^ evaluation of `_NU8_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:111:26 +error[E0080]: attempt to compute `1_u8 + u8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:108:26 | LL | const _NU8_ADD_P: &u8 = &(1u8 + u8::MAX); - | ^^^^^^^^^^^^^^^ attempt to compute `1_u8 + u8::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NU8_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:113:24 +error[E0080]: attempt to compute `1_u16 + u16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:110:24 | LL | const _NU16_ADD: u16 = 1u16 + u16::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_u16 + u16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NU16_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:114:28 +error[E0080]: attempt to compute `1_u16 + u16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:111:28 | LL | const _NU16_ADD_P: &u16 = &(1u16 + u16::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u16 + u16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of `_NU16_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:116:24 +error[E0080]: attempt to compute `1_u32 + u32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:113:24 | LL | const _NU32_ADD: u32 = 1u32 + u32::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_u32 + u32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NU32_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:117:28 +error[E0080]: attempt to compute `1_u32 + u32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:114:28 | LL | const _NU32_ADD_P: &u32 = &(1u32 + u32::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u32 + u32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of `_NU32_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:119:24 +error[E0080]: attempt to compute `1_u64 + u64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:116:24 | LL | const _NU64_ADD: u64 = 1u64 + u64::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_u64 + u64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NU64_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:120:28 +error[E0080]: attempt to compute `1_u64 + u64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:117:28 | LL | const _NU64_ADD_P: &u64 = &(1u64 + u64::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u64 + u64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of `_NU64_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:122:26 +error[E0080]: attempt to compute `1_u128 + u128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:119:26 | LL | const _NU128_ADD: u128 = 1u128 + u128::MAX; - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u128 + u128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of `_NU128_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:123:30 +error[E0080]: attempt to compute `1_u128 + u128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:120:30 | LL | const _NU128_ADD_P: &u128 = &(1u128 + u128::MAX); - | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_u128 + u128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^ evaluation of `_NU128_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:125:28 +error[E0080]: attempt to compute `1_isize + isize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:122:28 | LL | const _NISIZE_ADD: isize = 1isize + isize::MAX; - | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_isize + isize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:126:32 +error[E0080]: attempt to compute `1_isize + isize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:123:32 | LL | const _NISIZE_ADD_P: &isize = &(1isize + isize::MAX); - | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_isize + isize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:128:28 +error[E0080]: attempt to compute `1_usize + usize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:125:28 | LL | const _NUSIZE_ADD: usize = 1usize + usize::MAX; - | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize + usize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:129:32 +error[E0080]: attempt to compute `1_usize + usize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:126:32 | LL | const _NUSIZE_ADD_P: &usize = &(1usize + usize::MAX); - | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize + usize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:133:22 +error[E0080]: attempt to compute `-5_i8 - i8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:129:22 | LL | const _NI8_SUB: i8 = -5i8 - i8::MAX; - | ^^^^^^^^^^^^^^ attempt to compute `-5_i8 - i8::MAX`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NI8_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:134:26 +error[E0080]: attempt to compute `-5_i8 - i8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:130:26 | LL | const _NI8_SUB_P: &i8 = &(-5i8 - i8::MAX); - | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i8 - i8::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NI8_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:136:24 +error[E0080]: attempt to compute `-5_i16 - i16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:132:24 | LL | const _NI16_SUB: i16 = -5i16 - i16::MAX; - | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i16 - i16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NI16_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:137:28 +error[E0080]: attempt to compute `-5_i16 - i16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:133:28 | LL | const _NI16_SUB_P: &i16 = &(-5i16 - i16::MAX); - | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i16 - i16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^ evaluation of `_NI16_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:139:24 +error[E0080]: attempt to compute `-5_i32 - i32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:135:24 | LL | const _NI32_SUB: i32 = -5i32 - i32::MAX; - | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NI32_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:140:28 +error[E0080]: attempt to compute `-5_i32 - i32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:136:28 | LL | const _NI32_SUB_P: &i32 = &(-5i32 - i32::MAX); - | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^ evaluation of `_NI32_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:142:24 +error[E0080]: attempt to compute `-5_i64 - i64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:138:24 | LL | const _NI64_SUB: i64 = -5i64 - i64::MAX; - | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i64 - i64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NI64_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:143:28 +error[E0080]: attempt to compute `-5_i64 - i64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:139:28 | LL | const _NI64_SUB_P: &i64 = &(-5i64 - i64::MAX); - | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i64 - i64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^ evaluation of `_NI64_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:145:26 +error[E0080]: attempt to compute `-5_i128 - i128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:141:26 | LL | const _NI128_SUB: i128 = -5i128 - i128::MAX; - | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i128 - i128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^ evaluation of `_NI128_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:146:30 +error[E0080]: attempt to compute `-5_i128 - i128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:142:30 | LL | const _NI128_SUB_P: &i128 = &(-5i128 - i128::MAX); - | ^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i128 - i128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^ evaluation of `_NI128_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:148:22 +error[E0080]: attempt to compute `1_u8 - 5_u8`, which would overflow + --> $DIR/overflowing-consts.rs:144:22 | LL | const _NU8_SUB: u8 = 1u8 - 5; - | ^^^^^^^ attempt to compute `1_u8 - 5_u8`, which would overflow + | ^^^^^^^ evaluation of `_NU8_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:149:26 +error[E0080]: attempt to compute `1_u8 - 5_u8`, which would overflow + --> $DIR/overflowing-consts.rs:145:26 | LL | const _NU8_SUB_P: &u8 = &(1u8 - 5); - | ^^^^^^^^^ attempt to compute `1_u8 - 5_u8`, which would overflow + | ^^^^^^^^^ evaluation of `_NU8_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:151:24 +error[E0080]: attempt to compute `1_u16 - 5_u16`, which would overflow + --> $DIR/overflowing-consts.rs:147:24 | LL | const _NU16_SUB: u16 = 1u16 - 5; - | ^^^^^^^^ attempt to compute `1_u16 - 5_u16`, which would overflow + | ^^^^^^^^ evaluation of `_NU16_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:152:28 +error[E0080]: attempt to compute `1_u16 - 5_u16`, which would overflow + --> $DIR/overflowing-consts.rs:148:28 | LL | const _NU16_SUB_P: &u16 = &(1u16 - 5); - | ^^^^^^^^^^ attempt to compute `1_u16 - 5_u16`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU16_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:154:24 +error[E0080]: attempt to compute `1_u32 - 5_u32`, which would overflow + --> $DIR/overflowing-consts.rs:150:24 | LL | const _NU32_SUB: u32 = 1u32 - 5; - | ^^^^^^^^ attempt to compute `1_u32 - 5_u32`, which would overflow + | ^^^^^^^^ evaluation of `_NU32_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:155:28 +error[E0080]: attempt to compute `1_u32 - 5_u32`, which would overflow + --> $DIR/overflowing-consts.rs:151:28 | LL | const _NU32_SUB_P: &u32 = &(1u32 - 5); - | ^^^^^^^^^^ attempt to compute `1_u32 - 5_u32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU32_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:157:24 +error[E0080]: attempt to compute `1_u64 - 5_u64`, which would overflow + --> $DIR/overflowing-consts.rs:153:24 | LL | const _NU64_SUB: u64 = 1u64 - 5; - | ^^^^^^^^ attempt to compute `1_u64 - 5_u64`, which would overflow + | ^^^^^^^^ evaluation of `_NU64_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:158:28 +error[E0080]: attempt to compute `1_u64 - 5_u64`, which would overflow + --> $DIR/overflowing-consts.rs:154:28 | LL | const _NU64_SUB_P: &u64 = &(1u64 - 5); - | ^^^^^^^^^^ attempt to compute `1_u64 - 5_u64`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU64_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:160:26 +error[E0080]: attempt to compute `1_u128 - 5_u128`, which would overflow + --> $DIR/overflowing-consts.rs:156:26 | LL | const _NU128_SUB: u128 = 1u128 - 5; - | ^^^^^^^^^ attempt to compute `1_u128 - 5_u128`, which would overflow + | ^^^^^^^^^ evaluation of `_NU128_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:161:30 +error[E0080]: attempt to compute `1_u128 - 5_u128`, which would overflow + --> $DIR/overflowing-consts.rs:157:30 | LL | const _NU128_SUB_P: &u128 = &(1u128 - 5); - | ^^^^^^^^^^^ attempt to compute `1_u128 - 5_u128`, which would overflow + | ^^^^^^^^^^^ evaluation of `_NU128_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:163:28 +error[E0080]: attempt to compute `-5_isize - isize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:159:28 | LL | const _NISIZE_SUB: isize = -5isize - isize::MAX; - | ^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_isize - isize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:164:32 +error[E0080]: attempt to compute `-5_isize - isize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:160:32 | LL | const _NISIZE_SUB_P: &isize = &(-5isize - isize::MAX); - | ^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_isize - isize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:166:28 +error[E0080]: attempt to compute `1_usize - 5_usize`, which would overflow + --> $DIR/overflowing-consts.rs:162:28 | -LL | const _NUSIZE_SUB: usize = 1usize - 5 ; - | ^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow +LL | const _NUSIZE_SUB: usize = 1usize - 5; + | ^^^^^^^^^^ evaluation of `_NUSIZE_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:167:32 +error[E0080]: attempt to compute `1_usize - 5_usize`, which would overflow + --> $DIR/overflowing-consts.rs:163:32 | -LL | const _NUSIZE_SUB_P: &usize = &(1usize - 5 ); - | ^^^^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow +LL | const _NUSIZE_SUB_P: &usize = &(1usize - 5); + | ^^^^^^^^^^^^ evaluation of `_NUSIZE_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:171:22 +error[E0080]: attempt to compute `i8::MAX * 5_i8`, which would overflow + --> $DIR/overflowing-consts.rs:166:22 | LL | const _NI8_MUL: i8 = i8::MAX * 5; - | ^^^^^^^^^^^ attempt to compute `i8::MAX * 5_i8`, which would overflow + | ^^^^^^^^^^^ evaluation of `_NI8_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:172:26 +error[E0080]: attempt to compute `i8::MAX * 5_i8`, which would overflow + --> $DIR/overflowing-consts.rs:167:26 | LL | const _NI8_MUL_P: &i8 = &(i8::MAX * 5); - | ^^^^^^^^^^^^^ attempt to compute `i8::MAX * 5_i8`, which would overflow + | ^^^^^^^^^^^^^ evaluation of `_NI8_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:174:24 +error[E0080]: attempt to compute `i16::MAX * 5_i16`, which would overflow + --> $DIR/overflowing-consts.rs:169:24 | LL | const _NI16_MUL: i16 = i16::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI16_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:175:28 +error[E0080]: attempt to compute `i16::MAX * 5_i16`, which would overflow + --> $DIR/overflowing-consts.rs:170:28 | LL | const _NI16_MUL_P: &i16 = &(i16::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NI16_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:177:24 +error[E0080]: attempt to compute `i32::MAX * 5_i32`, which would overflow + --> $DIR/overflowing-consts.rs:172:24 | LL | const _NI32_MUL: i32 = i32::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI32_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:178:28 +error[E0080]: attempt to compute `i32::MAX * 5_i32`, which would overflow + --> $DIR/overflowing-consts.rs:173:28 | LL | const _NI32_MUL_P: &i32 = &(i32::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NI32_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:180:24 +error[E0080]: attempt to compute `i64::MAX * 5_i64`, which would overflow + --> $DIR/overflowing-consts.rs:175:24 | LL | const _NI64_MUL: i64 = i64::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI64_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:181:28 +error[E0080]: attempt to compute `i64::MAX * 5_i64`, which would overflow + --> $DIR/overflowing-consts.rs:176:28 | LL | const _NI64_MUL_P: &i64 = &(i64::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NI64_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:183:26 +error[E0080]: attempt to compute `i128::MAX * 5_i128`, which would overflow + --> $DIR/overflowing-consts.rs:178:26 | LL | const _NI128_MUL: i128 = i128::MAX * 5; - | ^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow + | ^^^^^^^^^^^^^ evaluation of `_NI128_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:184:30 +error[E0080]: attempt to compute `i128::MAX * 5_i128`, which would overflow + --> $DIR/overflowing-consts.rs:179:30 | LL | const _NI128_MUL_P: &i128 = &(i128::MAX * 5); - | ^^^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NI128_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:186:22 +error[E0080]: attempt to compute `u8::MAX * 5_u8`, which would overflow + --> $DIR/overflowing-consts.rs:181:22 | LL | const _NU8_MUL: u8 = u8::MAX * 5; - | ^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow + | ^^^^^^^^^^^ evaluation of `_NU8_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:187:26 +error[E0080]: attempt to compute `u8::MAX * 5_u8`, which would overflow + --> $DIR/overflowing-consts.rs:182:26 | LL | const _NU8_MUL_P: &u8 = &(u8::MAX * 5); - | ^^^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow + | ^^^^^^^^^^^^^ evaluation of `_NU8_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:189:24 +error[E0080]: attempt to compute `u16::MAX * 5_u16`, which would overflow + --> $DIR/overflowing-consts.rs:184:24 | LL | const _NU16_MUL: u16 = u16::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU16_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:190:28 +error[E0080]: attempt to compute `u16::MAX * 5_u16`, which would overflow + --> $DIR/overflowing-consts.rs:185:28 | LL | const _NU16_MUL_P: &u16 = &(u16::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NU16_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:192:24 +error[E0080]: attempt to compute `u32::MAX * 5_u32`, which would overflow + --> $DIR/overflowing-consts.rs:187:24 | LL | const _NU32_MUL: u32 = u32::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU32_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:193:28 +error[E0080]: attempt to compute `u32::MAX * 5_u32`, which would overflow + --> $DIR/overflowing-consts.rs:188:28 | LL | const _NU32_MUL_P: &u32 = &(u32::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NU32_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:195:24 +error[E0080]: attempt to compute `u64::MAX * 5_u64`, which would overflow + --> $DIR/overflowing-consts.rs:190:24 | LL | const _NU64_MUL: u64 = u64::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU64_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:196:28 +error[E0080]: attempt to compute `u64::MAX * 5_u64`, which would overflow + --> $DIR/overflowing-consts.rs:191:28 | LL | const _NU64_MUL_P: &u64 = &(u64::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NU64_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:198:26 +error[E0080]: attempt to compute `u128::MAX * 5_u128`, which would overflow + --> $DIR/overflowing-consts.rs:193:26 | LL | const _NU128_MUL: u128 = u128::MAX * 5; - | ^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow + | ^^^^^^^^^^^^^ evaluation of `_NU128_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:199:30 +error[E0080]: attempt to compute `u128::MAX * 5_u128`, which would overflow + --> $DIR/overflowing-consts.rs:194:30 | LL | const _NU128_MUL_P: &u128 = &(u128::MAX * 5); - | ^^^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NU128_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:201:28 +error[E0080]: attempt to compute `isize::MAX * 5_isize`, which would overflow + --> $DIR/overflowing-consts.rs:196:28 | LL | const _NISIZE_MUL: isize = isize::MAX * 5; - | ^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NISIZE_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:202:32 +error[E0080]: attempt to compute `isize::MAX * 5_isize`, which would overflow + --> $DIR/overflowing-consts.rs:197:32 | LL | const _NISIZE_MUL_P: &isize = &(isize::MAX * 5); - | ^^^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:204:28 +error[E0080]: attempt to compute `usize::MAX * 5_usize`, which would overflow + --> $DIR/overflowing-consts.rs:199:28 | LL | const _NUSIZE_MUL: usize = usize::MAX * 5; - | ^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NUSIZE_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:205:32 +error[E0080]: attempt to compute `usize::MAX * 5_usize`, which would overflow + --> $DIR/overflowing-consts.rs:200:32 | LL | const _NUSIZE_MUL_P: &usize = &(usize::MAX * 5); - | ^^^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:209:22 +error[E0080]: attempt to divide `1_i8` by zero + --> $DIR/overflowing-consts.rs:203:22 | LL | const _NI8_DIV: i8 = 1i8 / 0; - | ^^^^^^^ attempt to divide `1_i8` by zero + | ^^^^^^^ evaluation of `_NI8_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:210:26 +error[E0080]: attempt to divide `1_i8` by zero + --> $DIR/overflowing-consts.rs:204:26 | LL | const _NI8_DIV_P: &i8 = &(1i8 / 0); - | ^^^^^^^^^ attempt to divide `1_i8` by zero + | ^^^^^^^^^ evaluation of `_NI8_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:212:24 +error[E0080]: attempt to divide `1_i16` by zero + --> $DIR/overflowing-consts.rs:206:24 | LL | const _NI16_DIV: i16 = 1i16 / 0; - | ^^^^^^^^ attempt to divide `1_i16` by zero + | ^^^^^^^^ evaluation of `_NI16_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:213:28 +error[E0080]: attempt to divide `1_i16` by zero + --> $DIR/overflowing-consts.rs:207:28 | LL | const _NI16_DIV_P: &i16 = &(1i16 / 0); - | ^^^^^^^^^^ attempt to divide `1_i16` by zero + | ^^^^^^^^^^ evaluation of `_NI16_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:215:24 +error[E0080]: attempt to divide `1_i32` by zero + --> $DIR/overflowing-consts.rs:209:24 | LL | const _NI32_DIV: i32 = 1i32 / 0; - | ^^^^^^^^ attempt to divide `1_i32` by zero + | ^^^^^^^^ evaluation of `_NI32_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:216:28 +error[E0080]: attempt to divide `1_i32` by zero + --> $DIR/overflowing-consts.rs:210:28 | LL | const _NI32_DIV_P: &i32 = &(1i32 / 0); - | ^^^^^^^^^^ attempt to divide `1_i32` by zero + | ^^^^^^^^^^ evaluation of `_NI32_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:218:24 +error[E0080]: attempt to divide `1_i64` by zero + --> $DIR/overflowing-consts.rs:212:24 | LL | const _NI64_DIV: i64 = 1i64 / 0; - | ^^^^^^^^ attempt to divide `1_i64` by zero + | ^^^^^^^^ evaluation of `_NI64_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:219:28 +error[E0080]: attempt to divide `1_i64` by zero + --> $DIR/overflowing-consts.rs:213:28 | LL | const _NI64_DIV_P: &i64 = &(1i64 / 0); - | ^^^^^^^^^^ attempt to divide `1_i64` by zero + | ^^^^^^^^^^ evaluation of `_NI64_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:221:26 +error[E0080]: attempt to divide `1_i128` by zero + --> $DIR/overflowing-consts.rs:215:26 | LL | const _NI128_DIV: i128 = 1i128 / 0; - | ^^^^^^^^^ attempt to divide `1_i128` by zero + | ^^^^^^^^^ evaluation of `_NI128_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:222:30 +error[E0080]: attempt to divide `1_i128` by zero + --> $DIR/overflowing-consts.rs:216:30 | LL | const _NI128_DIV_P: &i128 = &(1i128 / 0); - | ^^^^^^^^^^^ attempt to divide `1_i128` by zero + | ^^^^^^^^^^^ evaluation of `_NI128_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:224:22 +error[E0080]: attempt to divide `1_u8` by zero + --> $DIR/overflowing-consts.rs:218:22 | LL | const _NU8_DIV: u8 = 1u8 / 0; - | ^^^^^^^ attempt to divide `1_u8` by zero + | ^^^^^^^ evaluation of `_NU8_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:225:26 +error[E0080]: attempt to divide `1_u8` by zero + --> $DIR/overflowing-consts.rs:219:26 | LL | const _NU8_DIV_P: &u8 = &(1u8 / 0); - | ^^^^^^^^^ attempt to divide `1_u8` by zero + | ^^^^^^^^^ evaluation of `_NU8_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:227:24 +error[E0080]: attempt to divide `1_u16` by zero + --> $DIR/overflowing-consts.rs:221:24 | LL | const _NU16_DIV: u16 = 1u16 / 0; - | ^^^^^^^^ attempt to divide `1_u16` by zero + | ^^^^^^^^ evaluation of `_NU16_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:228:28 +error[E0080]: attempt to divide `1_u16` by zero + --> $DIR/overflowing-consts.rs:222:28 | LL | const _NU16_DIV_P: &u16 = &(1u16 / 0); - | ^^^^^^^^^^ attempt to divide `1_u16` by zero + | ^^^^^^^^^^ evaluation of `_NU16_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:230:24 +error[E0080]: attempt to divide `1_u32` by zero + --> $DIR/overflowing-consts.rs:224:24 | LL | const _NU32_DIV: u32 = 1u32 / 0; - | ^^^^^^^^ attempt to divide `1_u32` by zero + | ^^^^^^^^ evaluation of `_NU32_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:231:28 +error[E0080]: attempt to divide `1_u32` by zero + --> $DIR/overflowing-consts.rs:225:28 | LL | const _NU32_DIV_P: &u32 = &(1u32 / 0); - | ^^^^^^^^^^ attempt to divide `1_u32` by zero + | ^^^^^^^^^^ evaluation of `_NU32_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:233:24 +error[E0080]: attempt to divide `1_u64` by zero + --> $DIR/overflowing-consts.rs:227:24 | LL | const _NU64_DIV: u64 = 1u64 / 0; - | ^^^^^^^^ attempt to divide `1_u64` by zero + | ^^^^^^^^ evaluation of `_NU64_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:234:28 +error[E0080]: attempt to divide `1_u64` by zero + --> $DIR/overflowing-consts.rs:228:28 | LL | const _NU64_DIV_P: &u64 = &(1u64 / 0); - | ^^^^^^^^^^ attempt to divide `1_u64` by zero + | ^^^^^^^^^^ evaluation of `_NU64_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:236:26 +error[E0080]: attempt to divide `1_u128` by zero + --> $DIR/overflowing-consts.rs:230:26 | LL | const _NU128_DIV: u128 = 1u128 / 0; - | ^^^^^^^^^ attempt to divide `1_u128` by zero + | ^^^^^^^^^ evaluation of `_NU128_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:237:30 +error[E0080]: attempt to divide `1_u128` by zero + --> $DIR/overflowing-consts.rs:231:30 | LL | const _NU128_DIV_P: &u128 = &(1u128 / 0); - | ^^^^^^^^^^^ attempt to divide `1_u128` by zero + | ^^^^^^^^^^^ evaluation of `_NU128_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:239:28 +error[E0080]: attempt to divide `1_isize` by zero + --> $DIR/overflowing-consts.rs:233:28 | LL | const _NISIZE_DIV: isize = 1isize / 0; - | ^^^^^^^^^^ attempt to divide `1_isize` by zero + | ^^^^^^^^^^ evaluation of `_NISIZE_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:240:32 +error[E0080]: attempt to divide `1_isize` by zero + --> $DIR/overflowing-consts.rs:234:32 | LL | const _NISIZE_DIV_P: &isize = &(1isize / 0); - | ^^^^^^^^^^^^ attempt to divide `1_isize` by zero + | ^^^^^^^^^^^^ evaluation of `_NISIZE_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:242:28 +error[E0080]: attempt to divide `1_usize` by zero + --> $DIR/overflowing-consts.rs:236:28 | LL | const _NUSIZE_DIV: usize = 1usize / 0; - | ^^^^^^^^^^ attempt to divide `1_usize` by zero + | ^^^^^^^^^^ evaluation of `_NUSIZE_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:243:32 +error[E0080]: attempt to divide `1_usize` by zero + --> $DIR/overflowing-consts.rs:237:32 | LL | const _NUSIZE_DIV_P: &usize = &(1usize / 0); - | ^^^^^^^^^^^^ attempt to divide `1_usize` by zero + | ^^^^^^^^^^^^ evaluation of `_NUSIZE_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:246:22 +error[E0080]: attempt to calculate the remainder of `1_i8` with a divisor of zero + --> $DIR/overflowing-consts.rs:240:22 | LL | const _NI8_MOD: i8 = 1i8 % 0; - | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero + | ^^^^^^^ evaluation of `_NI8_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:247:26 +error[E0080]: attempt to calculate the remainder of `1_i8` with a divisor of zero + --> $DIR/overflowing-consts.rs:241:26 | LL | const _NI8_MOD_P: &i8 = &(1i8 % 0); - | ^^^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero + | ^^^^^^^^^ evaluation of `_NI8_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:249:24 +error[E0080]: attempt to calculate the remainder of `1_i16` with a divisor of zero + --> $DIR/overflowing-consts.rs:243:24 | LL | const _NI16_MOD: i16 = 1i16 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero + | ^^^^^^^^ evaluation of `_NI16_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:250:28 +error[E0080]: attempt to calculate the remainder of `1_i16` with a divisor of zero + --> $DIR/overflowing-consts.rs:244:28 | LL | const _NI16_MOD_P: &i16 = &(1i16 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero + | ^^^^^^^^^^ evaluation of `_NI16_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:252:24 +error[E0080]: attempt to calculate the remainder of `1_i32` with a divisor of zero + --> $DIR/overflowing-consts.rs:246:24 | LL | const _NI32_MOD: i32 = 1i32 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + | ^^^^^^^^ evaluation of `_NI32_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:253:28 +error[E0080]: attempt to calculate the remainder of `1_i32` with a divisor of zero + --> $DIR/overflowing-consts.rs:247:28 | LL | const _NI32_MOD_P: &i32 = &(1i32 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + | ^^^^^^^^^^ evaluation of `_NI32_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:255:24 +error[E0080]: attempt to calculate the remainder of `1_i64` with a divisor of zero + --> $DIR/overflowing-consts.rs:249:24 | LL | const _NI64_MOD: i64 = 1i64 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero + | ^^^^^^^^ evaluation of `_NI64_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:256:28 +error[E0080]: attempt to calculate the remainder of `1_i64` with a divisor of zero + --> $DIR/overflowing-consts.rs:250:28 | LL | const _NI64_MOD_P: &i64 = &(1i64 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero + | ^^^^^^^^^^ evaluation of `_NI64_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:258:26 +error[E0080]: attempt to calculate the remainder of `1_i128` with a divisor of zero + --> $DIR/overflowing-consts.rs:252:26 | LL | const _NI128_MOD: i128 = 1i128 % 0; - | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero + | ^^^^^^^^^ evaluation of `_NI128_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:259:30 +error[E0080]: attempt to calculate the remainder of `1_i128` with a divisor of zero + --> $DIR/overflowing-consts.rs:253:30 | LL | const _NI128_MOD_P: &i128 = &(1i128 % 0); - | ^^^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero + | ^^^^^^^^^^^ evaluation of `_NI128_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:261:22 +error[E0080]: attempt to calculate the remainder of `1_u8` with a divisor of zero + --> $DIR/overflowing-consts.rs:255:22 | LL | const _NU8_MOD: u8 = 1u8 % 0; - | ^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero + | ^^^^^^^ evaluation of `_NU8_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:262:26 +error[E0080]: attempt to calculate the remainder of `1_u8` with a divisor of zero + --> $DIR/overflowing-consts.rs:256:26 | LL | const _NU8_MOD_P: &u8 = &(1u8 % 0); - | ^^^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero + | ^^^^^^^^^ evaluation of `_NU8_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:264:24 +error[E0080]: attempt to calculate the remainder of `1_u16` with a divisor of zero + --> $DIR/overflowing-consts.rs:258:24 | LL | const _NU16_MOD: u16 = 1u16 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero + | ^^^^^^^^ evaluation of `_NU16_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:265:28 +error[E0080]: attempt to calculate the remainder of `1_u16` with a divisor of zero + --> $DIR/overflowing-consts.rs:259:28 | LL | const _NU16_MOD_P: &u16 = &(1u16 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero + | ^^^^^^^^^^ evaluation of `_NU16_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:267:24 +error[E0080]: attempt to calculate the remainder of `1_u32` with a divisor of zero + --> $DIR/overflowing-consts.rs:261:24 | LL | const _NU32_MOD: u32 = 1u32 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero + | ^^^^^^^^ evaluation of `_NU32_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:268:28 +error[E0080]: attempt to calculate the remainder of `1_u32` with a divisor of zero + --> $DIR/overflowing-consts.rs:262:28 | LL | const _NU32_MOD_P: &u32 = &(1u32 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero + | ^^^^^^^^^^ evaluation of `_NU32_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:270:24 +error[E0080]: attempt to calculate the remainder of `1_u64` with a divisor of zero + --> $DIR/overflowing-consts.rs:264:24 | LL | const _NU64_MOD: u64 = 1u64 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero + | ^^^^^^^^ evaluation of `_NU64_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:271:28 +error[E0080]: attempt to calculate the remainder of `1_u64` with a divisor of zero + --> $DIR/overflowing-consts.rs:265:28 | LL | const _NU64_MOD_P: &u64 = &(1u64 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero + | ^^^^^^^^^^ evaluation of `_NU64_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:273:26 +error[E0080]: attempt to calculate the remainder of `1_u128` with a divisor of zero + --> $DIR/overflowing-consts.rs:267:26 | LL | const _NU128_MOD: u128 = 1u128 % 0; - | ^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero + | ^^^^^^^^^ evaluation of `_NU128_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:274:30 +error[E0080]: attempt to calculate the remainder of `1_u128` with a divisor of zero + --> $DIR/overflowing-consts.rs:268:30 | LL | const _NU128_MOD_P: &u128 = &(1u128 % 0); - | ^^^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero + | ^^^^^^^^^^^ evaluation of `_NU128_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:276:28 +error[E0080]: attempt to calculate the remainder of `1_isize` with a divisor of zero + --> $DIR/overflowing-consts.rs:270:28 | LL | const _NISIZE_MOD: isize = 1isize % 0; - | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero + | ^^^^^^^^^^ evaluation of `_NISIZE_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:277:32 +error[E0080]: attempt to calculate the remainder of `1_isize` with a divisor of zero + --> $DIR/overflowing-consts.rs:271:32 | LL | const _NISIZE_MOD_P: &isize = &(1isize % 0); - | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero + | ^^^^^^^^^^^^ evaluation of `_NISIZE_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:279:28 +error[E0080]: attempt to calculate the remainder of `1_usize` with a divisor of zero + --> $DIR/overflowing-consts.rs:273:28 | LL | const _NUSIZE_MOD: usize = 1usize % 0; - | ^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero + | ^^^^^^^^^^ evaluation of `_NUSIZE_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:280:32 +error[E0080]: attempt to calculate the remainder of `1_usize` with a divisor of zero + --> $DIR/overflowing-consts.rs:274:32 | LL | const _NUSIZE_MOD_P: &usize = &(1usize % 0); - | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero + | ^^^^^^^^^^^^ evaluation of `_NUSIZE_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:284:24 +error[E0080]: index out of bounds: the length is 3 but the index is 4 + --> $DIR/overflowing-consts.rs:277:24 | LL | const _NI32_OOB: i32 = [1, 2, 3][4]; - | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + | ^^^^^^^^^^^^ evaluation of `_NI32_OOB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:285:28 +error[E0080]: index out of bounds: the length is 3 but the index is 4 + --> $DIR/overflowing-consts.rs:278:28 | LL | const _NI32_OOB_P: &i32 = &([1, 2, 3][4]); - | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + | ^^^^^^^^^^^^^^ evaluation of `_NI32_OOB_P` failed here error: aborting due to 170 previous errors diff --git a/tests/ui/consts/overflowing-consts.opt_with_overflow_checks.stderr b/tests/ui/consts/overflowing-consts.opt_with_overflow_checks.stderr index 81f22944adb..1ef2a60b647 100644 --- a/tests/ui/consts/overflowing-consts.opt_with_overflow_checks.stderr +++ b/tests/ui/consts/overflowing-consts.opt_with_overflow_checks.stderr @@ -1,1022 +1,1022 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:19:22 +error[E0080]: attempt to shift left by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:18:22 | LL | const _NI8_SHL: i8 = 1i8 << 8; - | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | ^^^^^^^^ evaluation of `_NI8_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:20:26 +error[E0080]: attempt to shift left by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:19:26 | LL | const _NI8_SHL_P: &i8 = &(1i8 << 8); - | ^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NI8_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:22:24 +error[E0080]: attempt to shift left by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:21:24 | LL | const _NI16_SHL: i16 = 1i16 << 16; - | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NI16_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:23:28 +error[E0080]: attempt to shift left by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:22:28 | LL | const _NI16_SHL_P: &i16 = &(1i16 << 16); - | ^^^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI16_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:25:24 +error[E0080]: attempt to shift left by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:24:24 | LL | const _NI32_SHL: i32 = 1i32 << 32; - | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NI32_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:26:28 +error[E0080]: attempt to shift left by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:25:28 | LL | const _NI32_SHL_P: &i32 = &(1i32 << 32); - | ^^^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI32_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:28:24 +error[E0080]: attempt to shift left by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:27:24 | LL | const _NI64_SHL: i64 = 1i64 << 64; - | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NI64_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:29:28 +error[E0080]: attempt to shift left by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:28:28 | LL | const _NI64_SHL_P: &i64 = &(1i64 << 64); - | ^^^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI64_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:31:26 +error[E0080]: attempt to shift left by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:30:26 | LL | const _NI128_SHL: i128 = 1i128 << 128; - | ^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI128_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:32:30 +error[E0080]: attempt to shift left by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:31:30 | LL | const _NI128_SHL_P: &i128 = &(1i128 << 128); - | ^^^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NI128_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:34:22 +error[E0080]: attempt to shift left by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:33:22 | LL | const _NU8_SHL: u8 = 1u8 << 8; - | ^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | ^^^^^^^^ evaluation of `_NU8_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:35:26 +error[E0080]: attempt to shift left by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:34:26 | LL | const _NU8_SHL_P: &u8 = &(1u8 << 8); - | ^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU8_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:37:24 +error[E0080]: attempt to shift left by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:36:24 | LL | const _NU16_SHL: u16 = 1u16 << 16; - | ^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU16_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:38:28 +error[E0080]: attempt to shift left by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:37:28 | LL | const _NU16_SHL_P: &u16 = &(1u16 << 16); - | ^^^^^^^^^^^^ attempt to shift left by `16_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU16_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:40:24 +error[E0080]: attempt to shift left by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:39:24 | LL | const _NU32_SHL: u32 = 1u32 << 32; - | ^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU32_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:41:28 +error[E0080]: attempt to shift left by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:40:28 | LL | const _NU32_SHL_P: &u32 = &(1u32 << 32); - | ^^^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU32_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:43:24 +error[E0080]: attempt to shift left by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:42:24 | LL | const _NU64_SHL: u64 = 1u64 << 64; - | ^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU64_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:44:28 +error[E0080]: attempt to shift left by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:43:28 | LL | const _NU64_SHL_P: &u64 = &(1u64 << 64); - | ^^^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU64_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:46:26 +error[E0080]: attempt to shift left by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:45:26 | LL | const _NU128_SHL: u128 = 1u128 << 128; - | ^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU128_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:47:30 +error[E0080]: attempt to shift left by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:46:30 | LL | const _NU128_SHL_P: &u128 = &(1u128 << 128); - | ^^^^^^^^^^^^^^ attempt to shift left by `128_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NU128_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:49:28 +error[E0080]: attempt to shift left by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:48:28 | LL | const _NISIZE_SHL: isize = 1isize << BITS; - | ^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NISIZE_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:50:32 +error[E0080]: attempt to shift left by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:49:32 | LL | const _NISIZE_SHL_P: &isize = &(1isize << BITS); - | ^^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:52:28 +error[E0080]: attempt to shift left by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:51:28 | LL | const _NUSIZE_SHL: usize = 1usize << BITS; - | ^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NUSIZE_SHL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:53:32 +error[E0080]: attempt to shift left by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:52:32 | LL | const _NUSIZE_SHL_P: &usize = &(1usize << BITS); - | ^^^^^^^^^^^^^^^^ attempt to shift left by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_SHL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:57:22 +error[E0080]: attempt to shift right by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:55:22 | LL | const _NI8_SHR: i8 = 1i8 >> 8; - | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + | ^^^^^^^^ evaluation of `_NI8_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:58:26 +error[E0080]: attempt to shift right by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:56:26 | LL | const _NI8_SHR_P: &i8 = &(1i8 >> 8); - | ^^^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NI8_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:60:24 +error[E0080]: attempt to shift right by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:58:24 | LL | const _NI16_SHR: i16 = 1i16 >> 16; - | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NI16_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:61:28 +error[E0080]: attempt to shift right by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:59:28 | LL | const _NI16_SHR_P: &i16 = &(1i16 >> 16); - | ^^^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI16_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:63:24 +error[E0080]: attempt to shift right by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:61:24 | LL | const _NI32_SHR: i32 = 1i32 >> 32; - | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NI32_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:64:28 +error[E0080]: attempt to shift right by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:62:28 | LL | const _NI32_SHR_P: &i32 = &(1i32 >> 32); - | ^^^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI32_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:66:24 +error[E0080]: attempt to shift right by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:64:24 | LL | const _NI64_SHR: i64 = 1i64 >> 64; - | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NI64_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:67:28 +error[E0080]: attempt to shift right by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:65:28 | LL | const _NI64_SHR_P: &i64 = &(1i64 >> 64); - | ^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI64_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:69:26 +error[E0080]: attempt to shift right by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:67:26 | LL | const _NI128_SHR: i128 = 1i128 >> 128; - | ^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI128_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:70:30 +error[E0080]: attempt to shift right by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:68:30 | LL | const _NI128_SHR_P: &i128 = &(1i128 >> 128); - | ^^^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NI128_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:72:22 +error[E0080]: attempt to shift right by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:70:22 | LL | const _NU8_SHR: u8 = 1u8 >> 8; - | ^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + | ^^^^^^^^ evaluation of `_NU8_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:73:26 +error[E0080]: attempt to shift right by `8_i32`, which would overflow + --> $DIR/overflowing-consts.rs:71:26 | LL | const _NU8_SHR_P: &u8 = &(1u8 >> 8); - | ^^^^^^^^^^ attempt to shift right by `8_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU8_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:75:24 +error[E0080]: attempt to shift right by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:73:24 | LL | const _NU16_SHR: u16 = 1u16 >> 16; - | ^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU16_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:76:28 +error[E0080]: attempt to shift right by `16_i32`, which would overflow + --> $DIR/overflowing-consts.rs:74:28 | LL | const _NU16_SHR_P: &u16 = &(1u16 >> 16); - | ^^^^^^^^^^^^ attempt to shift right by `16_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU16_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:78:24 +error[E0080]: attempt to shift right by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:76:24 | LL | const _NU32_SHR: u32 = 1u32 >> 32; - | ^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU32_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:79:28 +error[E0080]: attempt to shift right by `32_i32`, which would overflow + --> $DIR/overflowing-consts.rs:77:28 | LL | const _NU32_SHR_P: &u32 = &(1u32 >> 32); - | ^^^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU32_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:81:24 +error[E0080]: attempt to shift right by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:79:24 | LL | const _NU64_SHR: u64 = 1u64 >> 64; - | ^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU64_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:82:28 +error[E0080]: attempt to shift right by `64_i32`, which would overflow + --> $DIR/overflowing-consts.rs:80:28 | LL | const _NU64_SHR_P: &u64 = &(1u64 >> 64); - | ^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU64_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:84:26 +error[E0080]: attempt to shift right by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:82:26 | LL | const _NU128_SHR: u128 = 1u128 >> 128; - | ^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU128_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:85:30 +error[E0080]: attempt to shift right by `128_i32`, which would overflow + --> $DIR/overflowing-consts.rs:83:30 | LL | const _NU128_SHR_P: &u128 = &(1u128 >> 128); - | ^^^^^^^^^^^^^^ attempt to shift right by `128_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NU128_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:87:28 +error[E0080]: attempt to shift right by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:85:28 | LL | const _NISIZE_SHR: isize = 1isize >> BITS; - | ^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NISIZE_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:88:32 +error[E0080]: attempt to shift right by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:86:32 | LL | const _NISIZE_SHR_P: &isize = &(1isize >> BITS); - | ^^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:90:28 +error[E0080]: attempt to shift right by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:88:28 | LL | const _NUSIZE_SHR: usize = 1usize >> BITS; - | ^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NUSIZE_SHR` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:91:32 +error[E0080]: attempt to shift right by `%BITS%`, which would overflow + --> $DIR/overflowing-consts.rs:89:32 | LL | const _NUSIZE_SHR_P: &usize = &(1usize >> BITS); - | ^^^^^^^^^^^^^^^^ attempt to shift right by `%BITS%`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_SHR_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:95:22 +error[E0080]: attempt to compute `1_i8 + i8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:92:22 | LL | const _NI8_ADD: i8 = 1i8 + i8::MAX; - | ^^^^^^^^^^^^^ attempt to compute `1_i8 + i8::MAX`, which would overflow + | ^^^^^^^^^^^^^ evaluation of `_NI8_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:96:26 +error[E0080]: attempt to compute `1_i8 + i8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:93:26 | LL | const _NI8_ADD_P: &i8 = &(1i8 + i8::MAX); - | ^^^^^^^^^^^^^^^ attempt to compute `1_i8 + i8::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NI8_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:98:24 +error[E0080]: attempt to compute `1_i16 + i16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:95:24 | LL | const _NI16_ADD: i16 = 1i16 + i16::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_i16 + i16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NI16_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:99:28 +error[E0080]: attempt to compute `1_i16 + i16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:96:28 | LL | const _NI16_ADD_P: &i16 = &(1i16 + i16::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i16 + i16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of `_NI16_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:101:24 +error[E0080]: attempt to compute `1_i32 + i32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:98:24 | LL | const _NI32_ADD: i32 = 1i32 + i32::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NI32_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:102:28 +error[E0080]: attempt to compute `1_i32 + i32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:99:28 | LL | const _NI32_ADD_P: &i32 = &(1i32 + i32::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i32 + i32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of `_NI32_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:104:24 +error[E0080]: attempt to compute `1_i64 + i64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:101:24 | LL | const _NI64_ADD: i64 = 1i64 + i64::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_i64 + i64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NI64_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:105:28 +error[E0080]: attempt to compute `1_i64 + i64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:102:28 | LL | const _NI64_ADD_P: &i64 = &(1i64 + i64::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i64 + i64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of `_NI64_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:107:26 +error[E0080]: attempt to compute `1_i128 + i128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:104:26 | LL | const _NI128_ADD: i128 = 1i128 + i128::MAX; - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_i128 + i128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of `_NI128_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:108:30 +error[E0080]: attempt to compute `1_i128 + i128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:105:30 | LL | const _NI128_ADD_P: &i128 = &(1i128 + i128::MAX); - | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_i128 + i128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^ evaluation of `_NI128_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:110:22 +error[E0080]: attempt to compute `1_u8 + u8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:107:22 | LL | const _NU8_ADD: u8 = 1u8 + u8::MAX; - | ^^^^^^^^^^^^^ attempt to compute `1_u8 + u8::MAX`, which would overflow + | ^^^^^^^^^^^^^ evaluation of `_NU8_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:111:26 +error[E0080]: attempt to compute `1_u8 + u8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:108:26 | LL | const _NU8_ADD_P: &u8 = &(1u8 + u8::MAX); - | ^^^^^^^^^^^^^^^ attempt to compute `1_u8 + u8::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NU8_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:113:24 +error[E0080]: attempt to compute `1_u16 + u16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:110:24 | LL | const _NU16_ADD: u16 = 1u16 + u16::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_u16 + u16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NU16_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:114:28 +error[E0080]: attempt to compute `1_u16 + u16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:111:28 | LL | const _NU16_ADD_P: &u16 = &(1u16 + u16::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u16 + u16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of `_NU16_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:116:24 +error[E0080]: attempt to compute `1_u32 + u32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:113:24 | LL | const _NU32_ADD: u32 = 1u32 + u32::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_u32 + u32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NU32_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:117:28 +error[E0080]: attempt to compute `1_u32 + u32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:114:28 | LL | const _NU32_ADD_P: &u32 = &(1u32 + u32::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u32 + u32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of `_NU32_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:119:24 +error[E0080]: attempt to compute `1_u64 + u64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:116:24 | LL | const _NU64_ADD: u64 = 1u64 + u64::MAX; - | ^^^^^^^^^^^^^^^ attempt to compute `1_u64 + u64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NU64_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:120:28 +error[E0080]: attempt to compute `1_u64 + u64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:117:28 | LL | const _NU64_ADD_P: &u64 = &(1u64 + u64::MAX); - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u64 + u64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of `_NU64_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:122:26 +error[E0080]: attempt to compute `1_u128 + u128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:119:26 | LL | const _NU128_ADD: u128 = 1u128 + u128::MAX; - | ^^^^^^^^^^^^^^^^^ attempt to compute `1_u128 + u128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^ evaluation of `_NU128_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:123:30 +error[E0080]: attempt to compute `1_u128 + u128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:120:30 | LL | const _NU128_ADD_P: &u128 = &(1u128 + u128::MAX); - | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_u128 + u128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^ evaluation of `_NU128_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:125:28 +error[E0080]: attempt to compute `1_isize + isize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:122:28 | LL | const _NISIZE_ADD: isize = 1isize + isize::MAX; - | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_isize + isize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:126:32 +error[E0080]: attempt to compute `1_isize + isize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:123:32 | LL | const _NISIZE_ADD_P: &isize = &(1isize + isize::MAX); - | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_isize + isize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:128:28 +error[E0080]: attempt to compute `1_usize + usize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:125:28 | LL | const _NUSIZE_ADD: usize = 1usize + usize::MAX; - | ^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize + usize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_ADD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:129:32 +error[E0080]: attempt to compute `1_usize + usize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:126:32 | LL | const _NUSIZE_ADD_P: &usize = &(1usize + usize::MAX); - | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize + usize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_ADD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:133:22 +error[E0080]: attempt to compute `-5_i8 - i8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:129:22 | LL | const _NI8_SUB: i8 = -5i8 - i8::MAX; - | ^^^^^^^^^^^^^^ attempt to compute `-5_i8 - i8::MAX`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NI8_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:134:26 +error[E0080]: attempt to compute `-5_i8 - i8::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:130:26 | LL | const _NI8_SUB_P: &i8 = &(-5i8 - i8::MAX); - | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i8 - i8::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NI8_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:136:24 +error[E0080]: attempt to compute `-5_i16 - i16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:132:24 | LL | const _NI16_SUB: i16 = -5i16 - i16::MAX; - | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i16 - i16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NI16_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:137:28 +error[E0080]: attempt to compute `-5_i16 - i16::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:133:28 | LL | const _NI16_SUB_P: &i16 = &(-5i16 - i16::MAX); - | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i16 - i16::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^ evaluation of `_NI16_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:139:24 +error[E0080]: attempt to compute `-5_i32 - i32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:135:24 | LL | const _NI32_SUB: i32 = -5i32 - i32::MAX; - | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NI32_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:140:28 +error[E0080]: attempt to compute `-5_i32 - i32::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:136:28 | LL | const _NI32_SUB_P: &i32 = &(-5i32 - i32::MAX); - | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i32 - i32::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^ evaluation of `_NI32_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:142:24 +error[E0080]: attempt to compute `-5_i64 - i64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:138:24 | LL | const _NI64_SUB: i64 = -5i64 - i64::MAX; - | ^^^^^^^^^^^^^^^^ attempt to compute `-5_i64 - i64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NI64_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:143:28 +error[E0080]: attempt to compute `-5_i64 - i64::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:139:28 | LL | const _NI64_SUB_P: &i64 = &(-5i64 - i64::MAX); - | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i64 - i64::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^ evaluation of `_NI64_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:145:26 +error[E0080]: attempt to compute `-5_i128 - i128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:141:26 | LL | const _NI128_SUB: i128 = -5i128 - i128::MAX; - | ^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i128 - i128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^ evaluation of `_NI128_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:146:30 +error[E0080]: attempt to compute `-5_i128 - i128::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:142:30 | LL | const _NI128_SUB_P: &i128 = &(-5i128 - i128::MAX); - | ^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_i128 - i128::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^ evaluation of `_NI128_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:148:22 +error[E0080]: attempt to compute `1_u8 - 5_u8`, which would overflow + --> $DIR/overflowing-consts.rs:144:22 | LL | const _NU8_SUB: u8 = 1u8 - 5; - | ^^^^^^^ attempt to compute `1_u8 - 5_u8`, which would overflow + | ^^^^^^^ evaluation of `_NU8_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:149:26 +error[E0080]: attempt to compute `1_u8 - 5_u8`, which would overflow + --> $DIR/overflowing-consts.rs:145:26 | LL | const _NU8_SUB_P: &u8 = &(1u8 - 5); - | ^^^^^^^^^ attempt to compute `1_u8 - 5_u8`, which would overflow + | ^^^^^^^^^ evaluation of `_NU8_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:151:24 +error[E0080]: attempt to compute `1_u16 - 5_u16`, which would overflow + --> $DIR/overflowing-consts.rs:147:24 | LL | const _NU16_SUB: u16 = 1u16 - 5; - | ^^^^^^^^ attempt to compute `1_u16 - 5_u16`, which would overflow + | ^^^^^^^^ evaluation of `_NU16_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:152:28 +error[E0080]: attempt to compute `1_u16 - 5_u16`, which would overflow + --> $DIR/overflowing-consts.rs:148:28 | LL | const _NU16_SUB_P: &u16 = &(1u16 - 5); - | ^^^^^^^^^^ attempt to compute `1_u16 - 5_u16`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU16_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:154:24 +error[E0080]: attempt to compute `1_u32 - 5_u32`, which would overflow + --> $DIR/overflowing-consts.rs:150:24 | LL | const _NU32_SUB: u32 = 1u32 - 5; - | ^^^^^^^^ attempt to compute `1_u32 - 5_u32`, which would overflow + | ^^^^^^^^ evaluation of `_NU32_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:155:28 +error[E0080]: attempt to compute `1_u32 - 5_u32`, which would overflow + --> $DIR/overflowing-consts.rs:151:28 | LL | const _NU32_SUB_P: &u32 = &(1u32 - 5); - | ^^^^^^^^^^ attempt to compute `1_u32 - 5_u32`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU32_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:157:24 +error[E0080]: attempt to compute `1_u64 - 5_u64`, which would overflow + --> $DIR/overflowing-consts.rs:153:24 | LL | const _NU64_SUB: u64 = 1u64 - 5; - | ^^^^^^^^ attempt to compute `1_u64 - 5_u64`, which would overflow + | ^^^^^^^^ evaluation of `_NU64_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:158:28 +error[E0080]: attempt to compute `1_u64 - 5_u64`, which would overflow + --> $DIR/overflowing-consts.rs:154:28 | LL | const _NU64_SUB_P: &u64 = &(1u64 - 5); - | ^^^^^^^^^^ attempt to compute `1_u64 - 5_u64`, which would overflow + | ^^^^^^^^^^ evaluation of `_NU64_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:160:26 +error[E0080]: attempt to compute `1_u128 - 5_u128`, which would overflow + --> $DIR/overflowing-consts.rs:156:26 | LL | const _NU128_SUB: u128 = 1u128 - 5; - | ^^^^^^^^^ attempt to compute `1_u128 - 5_u128`, which would overflow + | ^^^^^^^^^ evaluation of `_NU128_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:161:30 +error[E0080]: attempt to compute `1_u128 - 5_u128`, which would overflow + --> $DIR/overflowing-consts.rs:157:30 | LL | const _NU128_SUB_P: &u128 = &(1u128 - 5); - | ^^^^^^^^^^^ attempt to compute `1_u128 - 5_u128`, which would overflow + | ^^^^^^^^^^^ evaluation of `_NU128_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:163:28 +error[E0080]: attempt to compute `-5_isize - isize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:159:28 | LL | const _NISIZE_SUB: isize = -5isize - isize::MAX; - | ^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_isize - isize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:164:32 +error[E0080]: attempt to compute `-5_isize - isize::MAX`, which would overflow + --> $DIR/overflowing-consts.rs:160:32 | LL | const _NISIZE_SUB_P: &isize = &(-5isize - isize::MAX); - | ^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `-5_isize - isize::MAX`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:166:28 +error[E0080]: attempt to compute `1_usize - 5_usize`, which would overflow + --> $DIR/overflowing-consts.rs:162:28 | -LL | const _NUSIZE_SUB: usize = 1usize - 5 ; - | ^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow +LL | const _NUSIZE_SUB: usize = 1usize - 5; + | ^^^^^^^^^^ evaluation of `_NUSIZE_SUB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:167:32 +error[E0080]: attempt to compute `1_usize - 5_usize`, which would overflow + --> $DIR/overflowing-consts.rs:163:32 | -LL | const _NUSIZE_SUB_P: &usize = &(1usize - 5 ); - | ^^^^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow +LL | const _NUSIZE_SUB_P: &usize = &(1usize - 5); + | ^^^^^^^^^^^^ evaluation of `_NUSIZE_SUB_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:171:22 +error[E0080]: attempt to compute `i8::MAX * 5_i8`, which would overflow + --> $DIR/overflowing-consts.rs:166:22 | LL | const _NI8_MUL: i8 = i8::MAX * 5; - | ^^^^^^^^^^^ attempt to compute `i8::MAX * 5_i8`, which would overflow + | ^^^^^^^^^^^ evaluation of `_NI8_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:172:26 +error[E0080]: attempt to compute `i8::MAX * 5_i8`, which would overflow + --> $DIR/overflowing-consts.rs:167:26 | LL | const _NI8_MUL_P: &i8 = &(i8::MAX * 5); - | ^^^^^^^^^^^^^ attempt to compute `i8::MAX * 5_i8`, which would overflow + | ^^^^^^^^^^^^^ evaluation of `_NI8_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:174:24 +error[E0080]: attempt to compute `i16::MAX * 5_i16`, which would overflow + --> $DIR/overflowing-consts.rs:169:24 | LL | const _NI16_MUL: i16 = i16::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI16_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:175:28 +error[E0080]: attempt to compute `i16::MAX * 5_i16`, which would overflow + --> $DIR/overflowing-consts.rs:170:28 | LL | const _NI16_MUL_P: &i16 = &(i16::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NI16_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:177:24 +error[E0080]: attempt to compute `i32::MAX * 5_i32`, which would overflow + --> $DIR/overflowing-consts.rs:172:24 | LL | const _NI32_MUL: i32 = i32::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI32_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:178:28 +error[E0080]: attempt to compute `i32::MAX * 5_i32`, which would overflow + --> $DIR/overflowing-consts.rs:173:28 | LL | const _NI32_MUL_P: &i32 = &(i32::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NI32_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:180:24 +error[E0080]: attempt to compute `i64::MAX * 5_i64`, which would overflow + --> $DIR/overflowing-consts.rs:175:24 | LL | const _NI64_MUL: i64 = i64::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NI64_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:181:28 +error[E0080]: attempt to compute `i64::MAX * 5_i64`, which would overflow + --> $DIR/overflowing-consts.rs:176:28 | LL | const _NI64_MUL_P: &i64 = &(i64::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NI64_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:183:26 +error[E0080]: attempt to compute `i128::MAX * 5_i128`, which would overflow + --> $DIR/overflowing-consts.rs:178:26 | LL | const _NI128_MUL: i128 = i128::MAX * 5; - | ^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow + | ^^^^^^^^^^^^^ evaluation of `_NI128_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:184:30 +error[E0080]: attempt to compute `i128::MAX * 5_i128`, which would overflow + --> $DIR/overflowing-consts.rs:179:30 | LL | const _NI128_MUL_P: &i128 = &(i128::MAX * 5); - | ^^^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NI128_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:186:22 +error[E0080]: attempt to compute `u8::MAX * 5_u8`, which would overflow + --> $DIR/overflowing-consts.rs:181:22 | LL | const _NU8_MUL: u8 = u8::MAX * 5; - | ^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow + | ^^^^^^^^^^^ evaluation of `_NU8_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:187:26 +error[E0080]: attempt to compute `u8::MAX * 5_u8`, which would overflow + --> $DIR/overflowing-consts.rs:182:26 | LL | const _NU8_MUL_P: &u8 = &(u8::MAX * 5); - | ^^^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow + | ^^^^^^^^^^^^^ evaluation of `_NU8_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:189:24 +error[E0080]: attempt to compute `u16::MAX * 5_u16`, which would overflow + --> $DIR/overflowing-consts.rs:184:24 | LL | const _NU16_MUL: u16 = u16::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU16_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:190:28 +error[E0080]: attempt to compute `u16::MAX * 5_u16`, which would overflow + --> $DIR/overflowing-consts.rs:185:28 | LL | const _NU16_MUL_P: &u16 = &(u16::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NU16_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:192:24 +error[E0080]: attempt to compute `u32::MAX * 5_u32`, which would overflow + --> $DIR/overflowing-consts.rs:187:24 | LL | const _NU32_MUL: u32 = u32::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU32_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:193:28 +error[E0080]: attempt to compute `u32::MAX * 5_u32`, which would overflow + --> $DIR/overflowing-consts.rs:188:28 | LL | const _NU32_MUL_P: &u32 = &(u32::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NU32_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:195:24 +error[E0080]: attempt to compute `u64::MAX * 5_u64`, which would overflow + --> $DIR/overflowing-consts.rs:190:24 | LL | const _NU64_MUL: u64 = u64::MAX * 5; - | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow + | ^^^^^^^^^^^^ evaluation of `_NU64_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:196:28 +error[E0080]: attempt to compute `u64::MAX * 5_u64`, which would overflow + --> $DIR/overflowing-consts.rs:191:28 | LL | const _NU64_MUL_P: &u64 = &(u64::MAX * 5); - | ^^^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NU64_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:198:26 +error[E0080]: attempt to compute `u128::MAX * 5_u128`, which would overflow + --> $DIR/overflowing-consts.rs:193:26 | LL | const _NU128_MUL: u128 = u128::MAX * 5; - | ^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow + | ^^^^^^^^^^^^^ evaluation of `_NU128_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:199:30 +error[E0080]: attempt to compute `u128::MAX * 5_u128`, which would overflow + --> $DIR/overflowing-consts.rs:194:30 | LL | const _NU128_MUL_P: &u128 = &(u128::MAX * 5); - | ^^^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow + | ^^^^^^^^^^^^^^^ evaluation of `_NU128_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:201:28 +error[E0080]: attempt to compute `isize::MAX * 5_isize`, which would overflow + --> $DIR/overflowing-consts.rs:196:28 | LL | const _NISIZE_MUL: isize = isize::MAX * 5; - | ^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NISIZE_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:202:32 +error[E0080]: attempt to compute `isize::MAX * 5_isize`, which would overflow + --> $DIR/overflowing-consts.rs:197:32 | LL | const _NISIZE_MUL_P: &isize = &(isize::MAX * 5); - | ^^^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:204:28 +error[E0080]: attempt to compute `usize::MAX * 5_usize`, which would overflow + --> $DIR/overflowing-consts.rs:199:28 | LL | const _NUSIZE_MUL: usize = usize::MAX * 5; - | ^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + | ^^^^^^^^^^^^^^ evaluation of `_NUSIZE_MUL` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:205:32 +error[E0080]: attempt to compute `usize::MAX * 5_usize`, which would overflow + --> $DIR/overflowing-consts.rs:200:32 | LL | const _NUSIZE_MUL_P: &usize = &(usize::MAX * 5); - | ^^^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + | ^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_MUL_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:209:22 +error[E0080]: attempt to divide `1_i8` by zero + --> $DIR/overflowing-consts.rs:203:22 | LL | const _NI8_DIV: i8 = 1i8 / 0; - | ^^^^^^^ attempt to divide `1_i8` by zero + | ^^^^^^^ evaluation of `_NI8_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:210:26 +error[E0080]: attempt to divide `1_i8` by zero + --> $DIR/overflowing-consts.rs:204:26 | LL | const _NI8_DIV_P: &i8 = &(1i8 / 0); - | ^^^^^^^^^ attempt to divide `1_i8` by zero + | ^^^^^^^^^ evaluation of `_NI8_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:212:24 +error[E0080]: attempt to divide `1_i16` by zero + --> $DIR/overflowing-consts.rs:206:24 | LL | const _NI16_DIV: i16 = 1i16 / 0; - | ^^^^^^^^ attempt to divide `1_i16` by zero + | ^^^^^^^^ evaluation of `_NI16_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:213:28 +error[E0080]: attempt to divide `1_i16` by zero + --> $DIR/overflowing-consts.rs:207:28 | LL | const _NI16_DIV_P: &i16 = &(1i16 / 0); - | ^^^^^^^^^^ attempt to divide `1_i16` by zero + | ^^^^^^^^^^ evaluation of `_NI16_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:215:24 +error[E0080]: attempt to divide `1_i32` by zero + --> $DIR/overflowing-consts.rs:209:24 | LL | const _NI32_DIV: i32 = 1i32 / 0; - | ^^^^^^^^ attempt to divide `1_i32` by zero + | ^^^^^^^^ evaluation of `_NI32_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:216:28 +error[E0080]: attempt to divide `1_i32` by zero + --> $DIR/overflowing-consts.rs:210:28 | LL | const _NI32_DIV_P: &i32 = &(1i32 / 0); - | ^^^^^^^^^^ attempt to divide `1_i32` by zero + | ^^^^^^^^^^ evaluation of `_NI32_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:218:24 +error[E0080]: attempt to divide `1_i64` by zero + --> $DIR/overflowing-consts.rs:212:24 | LL | const _NI64_DIV: i64 = 1i64 / 0; - | ^^^^^^^^ attempt to divide `1_i64` by zero + | ^^^^^^^^ evaluation of `_NI64_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:219:28 +error[E0080]: attempt to divide `1_i64` by zero + --> $DIR/overflowing-consts.rs:213:28 | LL | const _NI64_DIV_P: &i64 = &(1i64 / 0); - | ^^^^^^^^^^ attempt to divide `1_i64` by zero + | ^^^^^^^^^^ evaluation of `_NI64_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:221:26 +error[E0080]: attempt to divide `1_i128` by zero + --> $DIR/overflowing-consts.rs:215:26 | LL | const _NI128_DIV: i128 = 1i128 / 0; - | ^^^^^^^^^ attempt to divide `1_i128` by zero + | ^^^^^^^^^ evaluation of `_NI128_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:222:30 +error[E0080]: attempt to divide `1_i128` by zero + --> $DIR/overflowing-consts.rs:216:30 | LL | const _NI128_DIV_P: &i128 = &(1i128 / 0); - | ^^^^^^^^^^^ attempt to divide `1_i128` by zero + | ^^^^^^^^^^^ evaluation of `_NI128_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:224:22 +error[E0080]: attempt to divide `1_u8` by zero + --> $DIR/overflowing-consts.rs:218:22 | LL | const _NU8_DIV: u8 = 1u8 / 0; - | ^^^^^^^ attempt to divide `1_u8` by zero + | ^^^^^^^ evaluation of `_NU8_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:225:26 +error[E0080]: attempt to divide `1_u8` by zero + --> $DIR/overflowing-consts.rs:219:26 | LL | const _NU8_DIV_P: &u8 = &(1u8 / 0); - | ^^^^^^^^^ attempt to divide `1_u8` by zero + | ^^^^^^^^^ evaluation of `_NU8_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:227:24 +error[E0080]: attempt to divide `1_u16` by zero + --> $DIR/overflowing-consts.rs:221:24 | LL | const _NU16_DIV: u16 = 1u16 / 0; - | ^^^^^^^^ attempt to divide `1_u16` by zero + | ^^^^^^^^ evaluation of `_NU16_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:228:28 +error[E0080]: attempt to divide `1_u16` by zero + --> $DIR/overflowing-consts.rs:222:28 | LL | const _NU16_DIV_P: &u16 = &(1u16 / 0); - | ^^^^^^^^^^ attempt to divide `1_u16` by zero + | ^^^^^^^^^^ evaluation of `_NU16_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:230:24 +error[E0080]: attempt to divide `1_u32` by zero + --> $DIR/overflowing-consts.rs:224:24 | LL | const _NU32_DIV: u32 = 1u32 / 0; - | ^^^^^^^^ attempt to divide `1_u32` by zero + | ^^^^^^^^ evaluation of `_NU32_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:231:28 +error[E0080]: attempt to divide `1_u32` by zero + --> $DIR/overflowing-consts.rs:225:28 | LL | const _NU32_DIV_P: &u32 = &(1u32 / 0); - | ^^^^^^^^^^ attempt to divide `1_u32` by zero + | ^^^^^^^^^^ evaluation of `_NU32_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:233:24 +error[E0080]: attempt to divide `1_u64` by zero + --> $DIR/overflowing-consts.rs:227:24 | LL | const _NU64_DIV: u64 = 1u64 / 0; - | ^^^^^^^^ attempt to divide `1_u64` by zero + | ^^^^^^^^ evaluation of `_NU64_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:234:28 +error[E0080]: attempt to divide `1_u64` by zero + --> $DIR/overflowing-consts.rs:228:28 | LL | const _NU64_DIV_P: &u64 = &(1u64 / 0); - | ^^^^^^^^^^ attempt to divide `1_u64` by zero + | ^^^^^^^^^^ evaluation of `_NU64_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:236:26 +error[E0080]: attempt to divide `1_u128` by zero + --> $DIR/overflowing-consts.rs:230:26 | LL | const _NU128_DIV: u128 = 1u128 / 0; - | ^^^^^^^^^ attempt to divide `1_u128` by zero + | ^^^^^^^^^ evaluation of `_NU128_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:237:30 +error[E0080]: attempt to divide `1_u128` by zero + --> $DIR/overflowing-consts.rs:231:30 | LL | const _NU128_DIV_P: &u128 = &(1u128 / 0); - | ^^^^^^^^^^^ attempt to divide `1_u128` by zero + | ^^^^^^^^^^^ evaluation of `_NU128_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:239:28 +error[E0080]: attempt to divide `1_isize` by zero + --> $DIR/overflowing-consts.rs:233:28 | LL | const _NISIZE_DIV: isize = 1isize / 0; - | ^^^^^^^^^^ attempt to divide `1_isize` by zero + | ^^^^^^^^^^ evaluation of `_NISIZE_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:240:32 +error[E0080]: attempt to divide `1_isize` by zero + --> $DIR/overflowing-consts.rs:234:32 | LL | const _NISIZE_DIV_P: &isize = &(1isize / 0); - | ^^^^^^^^^^^^ attempt to divide `1_isize` by zero + | ^^^^^^^^^^^^ evaluation of `_NISIZE_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:242:28 +error[E0080]: attempt to divide `1_usize` by zero + --> $DIR/overflowing-consts.rs:236:28 | LL | const _NUSIZE_DIV: usize = 1usize / 0; - | ^^^^^^^^^^ attempt to divide `1_usize` by zero + | ^^^^^^^^^^ evaluation of `_NUSIZE_DIV` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:243:32 +error[E0080]: attempt to divide `1_usize` by zero + --> $DIR/overflowing-consts.rs:237:32 | LL | const _NUSIZE_DIV_P: &usize = &(1usize / 0); - | ^^^^^^^^^^^^ attempt to divide `1_usize` by zero + | ^^^^^^^^^^^^ evaluation of `_NUSIZE_DIV_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:246:22 +error[E0080]: attempt to calculate the remainder of `1_i8` with a divisor of zero + --> $DIR/overflowing-consts.rs:240:22 | LL | const _NI8_MOD: i8 = 1i8 % 0; - | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero + | ^^^^^^^ evaluation of `_NI8_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:247:26 +error[E0080]: attempt to calculate the remainder of `1_i8` with a divisor of zero + --> $DIR/overflowing-consts.rs:241:26 | LL | const _NI8_MOD_P: &i8 = &(1i8 % 0); - | ^^^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero + | ^^^^^^^^^ evaluation of `_NI8_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:249:24 +error[E0080]: attempt to calculate the remainder of `1_i16` with a divisor of zero + --> $DIR/overflowing-consts.rs:243:24 | LL | const _NI16_MOD: i16 = 1i16 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero + | ^^^^^^^^ evaluation of `_NI16_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:250:28 +error[E0080]: attempt to calculate the remainder of `1_i16` with a divisor of zero + --> $DIR/overflowing-consts.rs:244:28 | LL | const _NI16_MOD_P: &i16 = &(1i16 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero + | ^^^^^^^^^^ evaluation of `_NI16_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:252:24 +error[E0080]: attempt to calculate the remainder of `1_i32` with a divisor of zero + --> $DIR/overflowing-consts.rs:246:24 | LL | const _NI32_MOD: i32 = 1i32 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + | ^^^^^^^^ evaluation of `_NI32_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:253:28 +error[E0080]: attempt to calculate the remainder of `1_i32` with a divisor of zero + --> $DIR/overflowing-consts.rs:247:28 | LL | const _NI32_MOD_P: &i32 = &(1i32 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero + | ^^^^^^^^^^ evaluation of `_NI32_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:255:24 +error[E0080]: attempt to calculate the remainder of `1_i64` with a divisor of zero + --> $DIR/overflowing-consts.rs:249:24 | LL | const _NI64_MOD: i64 = 1i64 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero + | ^^^^^^^^ evaluation of `_NI64_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:256:28 +error[E0080]: attempt to calculate the remainder of `1_i64` with a divisor of zero + --> $DIR/overflowing-consts.rs:250:28 | LL | const _NI64_MOD_P: &i64 = &(1i64 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero + | ^^^^^^^^^^ evaluation of `_NI64_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:258:26 +error[E0080]: attempt to calculate the remainder of `1_i128` with a divisor of zero + --> $DIR/overflowing-consts.rs:252:26 | LL | const _NI128_MOD: i128 = 1i128 % 0; - | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero + | ^^^^^^^^^ evaluation of `_NI128_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:259:30 +error[E0080]: attempt to calculate the remainder of `1_i128` with a divisor of zero + --> $DIR/overflowing-consts.rs:253:30 | LL | const _NI128_MOD_P: &i128 = &(1i128 % 0); - | ^^^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero + | ^^^^^^^^^^^ evaluation of `_NI128_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:261:22 +error[E0080]: attempt to calculate the remainder of `1_u8` with a divisor of zero + --> $DIR/overflowing-consts.rs:255:22 | LL | const _NU8_MOD: u8 = 1u8 % 0; - | ^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero + | ^^^^^^^ evaluation of `_NU8_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:262:26 +error[E0080]: attempt to calculate the remainder of `1_u8` with a divisor of zero + --> $DIR/overflowing-consts.rs:256:26 | LL | const _NU8_MOD_P: &u8 = &(1u8 % 0); - | ^^^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero + | ^^^^^^^^^ evaluation of `_NU8_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:264:24 +error[E0080]: attempt to calculate the remainder of `1_u16` with a divisor of zero + --> $DIR/overflowing-consts.rs:258:24 | LL | const _NU16_MOD: u16 = 1u16 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero + | ^^^^^^^^ evaluation of `_NU16_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:265:28 +error[E0080]: attempt to calculate the remainder of `1_u16` with a divisor of zero + --> $DIR/overflowing-consts.rs:259:28 | LL | const _NU16_MOD_P: &u16 = &(1u16 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero + | ^^^^^^^^^^ evaluation of `_NU16_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:267:24 +error[E0080]: attempt to calculate the remainder of `1_u32` with a divisor of zero + --> $DIR/overflowing-consts.rs:261:24 | LL | const _NU32_MOD: u32 = 1u32 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero + | ^^^^^^^^ evaluation of `_NU32_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:268:28 +error[E0080]: attempt to calculate the remainder of `1_u32` with a divisor of zero + --> $DIR/overflowing-consts.rs:262:28 | LL | const _NU32_MOD_P: &u32 = &(1u32 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero + | ^^^^^^^^^^ evaluation of `_NU32_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:270:24 +error[E0080]: attempt to calculate the remainder of `1_u64` with a divisor of zero + --> $DIR/overflowing-consts.rs:264:24 | LL | const _NU64_MOD: u64 = 1u64 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero + | ^^^^^^^^ evaluation of `_NU64_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:271:28 +error[E0080]: attempt to calculate the remainder of `1_u64` with a divisor of zero + --> $DIR/overflowing-consts.rs:265:28 | LL | const _NU64_MOD_P: &u64 = &(1u64 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero + | ^^^^^^^^^^ evaluation of `_NU64_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:273:26 +error[E0080]: attempt to calculate the remainder of `1_u128` with a divisor of zero + --> $DIR/overflowing-consts.rs:267:26 | LL | const _NU128_MOD: u128 = 1u128 % 0; - | ^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero + | ^^^^^^^^^ evaluation of `_NU128_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:274:30 +error[E0080]: attempt to calculate the remainder of `1_u128` with a divisor of zero + --> $DIR/overflowing-consts.rs:268:30 | LL | const _NU128_MOD_P: &u128 = &(1u128 % 0); - | ^^^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero + | ^^^^^^^^^^^ evaluation of `_NU128_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:276:28 +error[E0080]: attempt to calculate the remainder of `1_isize` with a divisor of zero + --> $DIR/overflowing-consts.rs:270:28 | LL | const _NISIZE_MOD: isize = 1isize % 0; - | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero + | ^^^^^^^^^^ evaluation of `_NISIZE_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:277:32 +error[E0080]: attempt to calculate the remainder of `1_isize` with a divisor of zero + --> $DIR/overflowing-consts.rs:271:32 | LL | const _NISIZE_MOD_P: &isize = &(1isize % 0); - | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero + | ^^^^^^^^^^^^ evaluation of `_NISIZE_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:279:28 +error[E0080]: attempt to calculate the remainder of `1_usize` with a divisor of zero + --> $DIR/overflowing-consts.rs:273:28 | LL | const _NUSIZE_MOD: usize = 1usize % 0; - | ^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero + | ^^^^^^^^^^ evaluation of `_NUSIZE_MOD` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:280:32 +error[E0080]: attempt to calculate the remainder of `1_usize` with a divisor of zero + --> $DIR/overflowing-consts.rs:274:32 | LL | const _NUSIZE_MOD_P: &usize = &(1usize % 0); - | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero + | ^^^^^^^^^^^^ evaluation of `_NUSIZE_MOD_P` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:284:24 +error[E0080]: index out of bounds: the length is 3 but the index is 4 + --> $DIR/overflowing-consts.rs:277:24 | LL | const _NI32_OOB: i32 = [1, 2, 3][4]; - | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + | ^^^^^^^^^^^^ evaluation of `_NI32_OOB` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/overflowing-consts.rs:285:28 +error[E0080]: index out of bounds: the length is 3 but the index is 4 + --> $DIR/overflowing-consts.rs:278:28 | LL | const _NI32_OOB_P: &i32 = &([1, 2, 3][4]); - | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + | ^^^^^^^^^^^^^^ evaluation of `_NI32_OOB_P` failed here error: aborting due to 170 previous errors diff --git a/tests/ui/consts/overflowing-consts.rs b/tests/ui/consts/overflowing-consts.rs index 5ff205ce58e..7c008573b87 100644 --- a/tests/ui/consts/overflowing-consts.rs +++ b/tests/ui/consts/overflowing-consts.rs @@ -9,280 +9,272 @@ //@ normalize-stderr: "shift left by `(64|32)_usize`, which" -> "shift left by `%BITS%`, which" //@ normalize-stderr: "shift right by `(64|32)_usize`, which" -> "shift right by `%BITS%`, which" - #[cfg(target_pointer_width = "32")] const BITS: usize = 32; #[cfg(target_pointer_width = "64")] const BITS: usize = 64; // Shift left -const _NI8_SHL: i8 = 1i8 << 8; //~ ERROR: evaluation of constant value failed -const _NI8_SHL_P: &i8 = &(1i8 << 8); //~ ERROR: evaluation of constant value failed - -const _NI16_SHL: i16 = 1i16 << 16; //~ ERROR: evaluation of constant value failed -const _NI16_SHL_P: &i16 = &(1i16 << 16); //~ ERROR: evaluation of constant value failed +const _NI8_SHL: i8 = 1i8 << 8; //~ ERROR: overflow +const _NI8_SHL_P: &i8 = &(1i8 << 8); //~ ERROR: overflow -const _NI32_SHL: i32 = 1i32 << 32; //~ ERROR: evaluation of constant value failed -const _NI32_SHL_P: &i32 = &(1i32 << 32); //~ ERROR: evaluation of constant value failed +const _NI16_SHL: i16 = 1i16 << 16; //~ ERROR: overflow +const _NI16_SHL_P: &i16 = &(1i16 << 16); //~ ERROR: overflow -const _NI64_SHL: i64 = 1i64 << 64; //~ ERROR: evaluation of constant value failed -const _NI64_SHL_P: &i64 = &(1i64 << 64); //~ ERROR: evaluation of constant value failed +const _NI32_SHL: i32 = 1i32 << 32; //~ ERROR: overflow +const _NI32_SHL_P: &i32 = &(1i32 << 32); //~ ERROR: overflow -const _NI128_SHL: i128 = 1i128 << 128; //~ ERROR: evaluation of constant value failed -const _NI128_SHL_P: &i128 = &(1i128 << 128); //~ ERROR: evaluation of constant value failed +const _NI64_SHL: i64 = 1i64 << 64; //~ ERROR: overflow +const _NI64_SHL_P: &i64 = &(1i64 << 64); //~ ERROR: overflow -const _NU8_SHL: u8 = 1u8 << 8; //~ ERROR: evaluation of constant value failed -const _NU8_SHL_P: &u8 = &(1u8 << 8); //~ ERROR: evaluation of constant value failed +const _NI128_SHL: i128 = 1i128 << 128; //~ ERROR: overflow +const _NI128_SHL_P: &i128 = &(1i128 << 128); //~ ERROR: overflow -const _NU16_SHL: u16 = 1u16 << 16; //~ ERROR: evaluation of constant value failed -const _NU16_SHL_P: &u16 = &(1u16 << 16); //~ ERROR: evaluation of constant value failed +const _NU8_SHL: u8 = 1u8 << 8; //~ ERROR: overflow +const _NU8_SHL_P: &u8 = &(1u8 << 8); //~ ERROR: overflow -const _NU32_SHL: u32 = 1u32 << 32; //~ ERROR: evaluation of constant value failed -const _NU32_SHL_P: &u32 = &(1u32 << 32); //~ ERROR: evaluation of constant value failed +const _NU16_SHL: u16 = 1u16 << 16; //~ ERROR: overflow +const _NU16_SHL_P: &u16 = &(1u16 << 16); //~ ERROR: overflow -const _NU64_SHL: u64 = 1u64 << 64; //~ ERROR: evaluation of constant value failed -const _NU64_SHL_P: &u64 = &(1u64 << 64); //~ ERROR: evaluation of constant value failed +const _NU32_SHL: u32 = 1u32 << 32; //~ ERROR: overflow +const _NU32_SHL_P: &u32 = &(1u32 << 32); //~ ERROR: overflow -const _NU128_SHL: u128 = 1u128 << 128; //~ ERROR: evaluation of constant value failed -const _NU128_SHL_P: &u128 = &(1u128 << 128); //~ ERROR: evaluation of constant value failed +const _NU64_SHL: u64 = 1u64 << 64; //~ ERROR: overflow +const _NU64_SHL_P: &u64 = &(1u64 << 64); //~ ERROR: overflow -const _NISIZE_SHL: isize = 1isize << BITS; //~ ERROR: evaluation of constant value failed -const _NISIZE_SHL_P: &isize = &(1isize << BITS); //~ ERROR: evaluation of constant value failed +const _NU128_SHL: u128 = 1u128 << 128; //~ ERROR: overflow +const _NU128_SHL_P: &u128 = &(1u128 << 128); //~ ERROR: overflow -const _NUSIZE_SHL: usize = 1usize << BITS; //~ ERROR: evaluation of constant value failed -const _NUSIZE_SHL_P: &usize = &(1usize << BITS); //~ ERROR: evaluation of constant value failed +const _NISIZE_SHL: isize = 1isize << BITS; //~ ERROR: overflow +const _NISIZE_SHL_P: &isize = &(1isize << BITS); //~ ERROR: overflow +const _NUSIZE_SHL: usize = 1usize << BITS; //~ ERROR: overflow +const _NUSIZE_SHL_P: &usize = &(1usize << BITS); //~ ERROR: overflow // Shift right -const _NI8_SHR: i8 = 1i8 >> 8; //~ ERROR: evaluation of constant value failed -const _NI8_SHR_P: &i8 = &(1i8 >> 8); //~ ERROR: evaluation of constant value failed +const _NI8_SHR: i8 = 1i8 >> 8; //~ ERROR: overflow +const _NI8_SHR_P: &i8 = &(1i8 >> 8); //~ ERROR: overflow -const _NI16_SHR: i16 = 1i16 >> 16; //~ ERROR: evaluation of constant value failed -const _NI16_SHR_P: &i16 = &(1i16 >> 16); //~ ERROR: evaluation of constant value failed +const _NI16_SHR: i16 = 1i16 >> 16; //~ ERROR: overflow +const _NI16_SHR_P: &i16 = &(1i16 >> 16); //~ ERROR: overflow -const _NI32_SHR: i32 = 1i32 >> 32; //~ ERROR: evaluation of constant value failed -const _NI32_SHR_P: &i32 = &(1i32 >> 32); //~ ERROR: evaluation of constant value failed +const _NI32_SHR: i32 = 1i32 >> 32; //~ ERROR: overflow +const _NI32_SHR_P: &i32 = &(1i32 >> 32); //~ ERROR: overflow -const _NI64_SHR: i64 = 1i64 >> 64; //~ ERROR: evaluation of constant value failed -const _NI64_SHR_P: &i64 = &(1i64 >> 64); //~ ERROR: evaluation of constant value failed +const _NI64_SHR: i64 = 1i64 >> 64; //~ ERROR: overflow +const _NI64_SHR_P: &i64 = &(1i64 >> 64); //~ ERROR: overflow -const _NI128_SHR: i128 = 1i128 >> 128; //~ ERROR: evaluation of constant value failed -const _NI128_SHR_P: &i128 = &(1i128 >> 128); //~ ERROR: evaluation of constant value failed +const _NI128_SHR: i128 = 1i128 >> 128; //~ ERROR: overflow +const _NI128_SHR_P: &i128 = &(1i128 >> 128); //~ ERROR: overflow -const _NU8_SHR: u8 = 1u8 >> 8; //~ ERROR: evaluation of constant value failed -const _NU8_SHR_P: &u8 = &(1u8 >> 8); //~ ERROR: evaluation of constant value failed +const _NU8_SHR: u8 = 1u8 >> 8; //~ ERROR: overflow +const _NU8_SHR_P: &u8 = &(1u8 >> 8); //~ ERROR: overflow -const _NU16_SHR: u16 = 1u16 >> 16; //~ ERROR: evaluation of constant value failed -const _NU16_SHR_P: &u16 = &(1u16 >> 16); //~ ERROR: evaluation of constant value failed +const _NU16_SHR: u16 = 1u16 >> 16; //~ ERROR: overflow +const _NU16_SHR_P: &u16 = &(1u16 >> 16); //~ ERROR: overflow -const _NU32_SHR: u32 = 1u32 >> 32; //~ ERROR: evaluation of constant value failed -const _NU32_SHR_P: &u32 = &(1u32 >> 32); //~ ERROR: evaluation of constant value failed +const _NU32_SHR: u32 = 1u32 >> 32; //~ ERROR: overflow +const _NU32_SHR_P: &u32 = &(1u32 >> 32); //~ ERROR: overflow -const _NU64_SHR: u64 = 1u64 >> 64; //~ ERROR: evaluation of constant value failed -const _NU64_SHR_P: &u64 = &(1u64 >> 64); //~ ERROR: evaluation of constant value failed +const _NU64_SHR: u64 = 1u64 >> 64; //~ ERROR: overflow +const _NU64_SHR_P: &u64 = &(1u64 >> 64); //~ ERROR: overflow -const _NU128_SHR: u128 = 1u128 >> 128; //~ ERROR: evaluation of constant value failed -const _NU128_SHR_P: &u128 = &(1u128 >> 128); //~ ERROR: evaluation of constant value failed +const _NU128_SHR: u128 = 1u128 >> 128; //~ ERROR: overflow +const _NU128_SHR_P: &u128 = &(1u128 >> 128); //~ ERROR: overflow -const _NISIZE_SHR: isize = 1isize >> BITS; //~ ERROR: evaluation of constant value failed -const _NISIZE_SHR_P: &isize = &(1isize >> BITS); //~ ERROR: evaluation of constant value failed - -const _NUSIZE_SHR: usize = 1usize >> BITS; //~ ERROR: evaluation of constant value failed -const _NUSIZE_SHR_P: &usize = &(1usize >> BITS); //~ ERROR: evaluation of constant value failed +const _NISIZE_SHR: isize = 1isize >> BITS; //~ ERROR: overflow +const _NISIZE_SHR_P: &isize = &(1isize >> BITS); //~ ERROR: overflow +const _NUSIZE_SHR: usize = 1usize >> BITS; //~ ERROR: overflow +const _NUSIZE_SHR_P: &usize = &(1usize >> BITS); //~ ERROR: overflow // Addition -const _NI8_ADD: i8 = 1i8 + i8::MAX; //~ ERROR: evaluation of constant value failed -const _NI8_ADD_P: &i8 = &(1i8 + i8::MAX); //~ ERROR: evaluation of constant value failed - -const _NI16_ADD: i16 = 1i16 + i16::MAX; //~ ERROR: evaluation of constant value failed -const _NI16_ADD_P: &i16 = &(1i16 + i16::MAX); //~ ERROR: evaluation of constant value failed +const _NI8_ADD: i8 = 1i8 + i8::MAX; //~ ERROR: overflow +const _NI8_ADD_P: &i8 = &(1i8 + i8::MAX); //~ ERROR: overflow -const _NI32_ADD: i32 = 1i32 + i32::MAX; //~ ERROR: evaluation of constant value failed -const _NI32_ADD_P: &i32 = &(1i32 + i32::MAX); //~ ERROR: evaluation of constant value failed +const _NI16_ADD: i16 = 1i16 + i16::MAX; //~ ERROR: overflow +const _NI16_ADD_P: &i16 = &(1i16 + i16::MAX); //~ ERROR: overflow -const _NI64_ADD: i64 = 1i64 + i64::MAX; //~ ERROR: evaluation of constant value failed -const _NI64_ADD_P: &i64 = &(1i64 + i64::MAX); //~ ERROR: evaluation of constant value failed +const _NI32_ADD: i32 = 1i32 + i32::MAX; //~ ERROR: overflow +const _NI32_ADD_P: &i32 = &(1i32 + i32::MAX); //~ ERROR: overflow -const _NI128_ADD: i128 = 1i128 + i128::MAX; //~ ERROR: evaluation of constant value failed -const _NI128_ADD_P: &i128 = &(1i128 + i128::MAX); //~ ERROR: evaluation of constant value failed +const _NI64_ADD: i64 = 1i64 + i64::MAX; //~ ERROR: overflow +const _NI64_ADD_P: &i64 = &(1i64 + i64::MAX); //~ ERROR: overflow -const _NU8_ADD: u8 = 1u8 + u8::MAX; //~ ERROR: evaluation of constant value failed -const _NU8_ADD_P: &u8 = &(1u8 + u8::MAX); //~ ERROR: evaluation of constant value failed +const _NI128_ADD: i128 = 1i128 + i128::MAX; //~ ERROR: overflow +const _NI128_ADD_P: &i128 = &(1i128 + i128::MAX); //~ ERROR: overflow -const _NU16_ADD: u16 = 1u16 + u16::MAX; //~ ERROR: evaluation of constant value failed -const _NU16_ADD_P: &u16 = &(1u16 + u16::MAX); //~ ERROR: evaluation of constant value failed +const _NU8_ADD: u8 = 1u8 + u8::MAX; //~ ERROR: overflow +const _NU8_ADD_P: &u8 = &(1u8 + u8::MAX); //~ ERROR: overflow -const _NU32_ADD: u32 = 1u32 + u32::MAX; //~ ERROR: evaluation of constant value failed -const _NU32_ADD_P: &u32 = &(1u32 + u32::MAX); //~ ERROR: evaluation of constant value failed +const _NU16_ADD: u16 = 1u16 + u16::MAX; //~ ERROR: overflow +const _NU16_ADD_P: &u16 = &(1u16 + u16::MAX); //~ ERROR: overflow -const _NU64_ADD: u64 = 1u64 + u64::MAX; //~ ERROR: evaluation of constant value failed -const _NU64_ADD_P: &u64 = &(1u64 + u64::MAX); //~ ERROR: evaluation of constant value failed +const _NU32_ADD: u32 = 1u32 + u32::MAX; //~ ERROR: overflow +const _NU32_ADD_P: &u32 = &(1u32 + u32::MAX); //~ ERROR: overflow -const _NU128_ADD: u128 = 1u128 + u128::MAX; //~ ERROR: evaluation of constant value failed -const _NU128_ADD_P: &u128 = &(1u128 + u128::MAX); //~ ERROR: evaluation of constant value failed +const _NU64_ADD: u64 = 1u64 + u64::MAX; //~ ERROR: overflow +const _NU64_ADD_P: &u64 = &(1u64 + u64::MAX); //~ ERROR: overflow -const _NISIZE_ADD: isize = 1isize + isize::MAX; //~ ERROR: evaluation of constant value failed -const _NISIZE_ADD_P: &isize = &(1isize + isize::MAX); //~ ERROR: evaluation of constant value failed +const _NU128_ADD: u128 = 1u128 + u128::MAX; //~ ERROR: overflow +const _NU128_ADD_P: &u128 = &(1u128 + u128::MAX); //~ ERROR: overflow -const _NUSIZE_ADD: usize = 1usize + usize::MAX; //~ ERROR: evaluation of constant value failed -const _NUSIZE_ADD_P: &usize = &(1usize + usize::MAX); //~ ERROR: evaluation of constant value failed +const _NISIZE_ADD: isize = 1isize + isize::MAX; //~ ERROR: overflow +const _NISIZE_ADD_P: &isize = &(1isize + isize::MAX); //~ ERROR: overflow +const _NUSIZE_ADD: usize = 1usize + usize::MAX; //~ ERROR: overflow +const _NUSIZE_ADD_P: &usize = &(1usize + usize::MAX); //~ ERROR: overflow // Subtraction -const _NI8_SUB: i8 = -5i8 - i8::MAX; //~ ERROR: evaluation of constant value failed -const _NI8_SUB_P: &i8 = &(-5i8 - i8::MAX); //~ ERROR: evaluation of constant value failed +const _NI8_SUB: i8 = -5i8 - i8::MAX; //~ ERROR: overflow +const _NI8_SUB_P: &i8 = &(-5i8 - i8::MAX); //~ ERROR: overflow -const _NI16_SUB: i16 = -5i16 - i16::MAX; //~ ERROR: evaluation of constant value failed -const _NI16_SUB_P: &i16 = &(-5i16 - i16::MAX); //~ ERROR: evaluation of constant value failed +const _NI16_SUB: i16 = -5i16 - i16::MAX; //~ ERROR: overflow +const _NI16_SUB_P: &i16 = &(-5i16 - i16::MAX); //~ ERROR: overflow -const _NI32_SUB: i32 = -5i32 - i32::MAX; //~ ERROR: evaluation of constant value failed -const _NI32_SUB_P: &i32 = &(-5i32 - i32::MAX); //~ ERROR: evaluation of constant value failed +const _NI32_SUB: i32 = -5i32 - i32::MAX; //~ ERROR: overflow +const _NI32_SUB_P: &i32 = &(-5i32 - i32::MAX); //~ ERROR: overflow -const _NI64_SUB: i64 = -5i64 - i64::MAX; //~ ERROR: evaluation of constant value failed -const _NI64_SUB_P: &i64 = &(-5i64 - i64::MAX); //~ ERROR: evaluation of constant value failed +const _NI64_SUB: i64 = -5i64 - i64::MAX; //~ ERROR: overflow +const _NI64_SUB_P: &i64 = &(-5i64 - i64::MAX); //~ ERROR: overflow -const _NI128_SUB: i128 = -5i128 - i128::MAX; //~ ERROR: evaluation of constant value failed -const _NI128_SUB_P: &i128 = &(-5i128 - i128::MAX); //~ ERROR: evaluation of constant value failed +const _NI128_SUB: i128 = -5i128 - i128::MAX; //~ ERROR: overflow +const _NI128_SUB_P: &i128 = &(-5i128 - i128::MAX); //~ ERROR: overflow -const _NU8_SUB: u8 = 1u8 - 5; //~ ERROR: evaluation of constant value failed -const _NU8_SUB_P: &u8 = &(1u8 - 5); //~ ERROR: evaluation of constant value failed +const _NU8_SUB: u8 = 1u8 - 5; //~ ERROR: overflow +const _NU8_SUB_P: &u8 = &(1u8 - 5); //~ ERROR: overflow -const _NU16_SUB: u16 = 1u16 - 5; //~ ERROR: evaluation of constant value failed -const _NU16_SUB_P: &u16 = &(1u16 - 5); //~ ERROR: evaluation of constant value failed +const _NU16_SUB: u16 = 1u16 - 5; //~ ERROR: overflow +const _NU16_SUB_P: &u16 = &(1u16 - 5); //~ ERROR: overflow -const _NU32_SUB: u32 = 1u32 - 5; //~ ERROR: evaluation of constant value failed -const _NU32_SUB_P: &u32 = &(1u32 - 5); //~ ERROR: evaluation of constant value failed +const _NU32_SUB: u32 = 1u32 - 5; //~ ERROR: overflow +const _NU32_SUB_P: &u32 = &(1u32 - 5); //~ ERROR: overflow -const _NU64_SUB: u64 = 1u64 - 5; //~ ERROR: evaluation of constant value failed -const _NU64_SUB_P: &u64 = &(1u64 - 5); //~ ERROR: evaluation of constant value failed +const _NU64_SUB: u64 = 1u64 - 5; //~ ERROR: overflow +const _NU64_SUB_P: &u64 = &(1u64 - 5); //~ ERROR: overflow -const _NU128_SUB: u128 = 1u128 - 5; //~ ERROR: evaluation of constant value failed -const _NU128_SUB_P: &u128 = &(1u128 - 5); //~ ERROR: evaluation of constant value failed +const _NU128_SUB: u128 = 1u128 - 5; //~ ERROR: overflow +const _NU128_SUB_P: &u128 = &(1u128 - 5); //~ ERROR: overflow -const _NISIZE_SUB: isize = -5isize - isize::MAX; //~ ERROR: evaluation of constant value failed -const _NISIZE_SUB_P: &isize = &(-5isize - isize::MAX); //~ ERROR: evaluation of constant value failed - -const _NUSIZE_SUB: usize = 1usize - 5 ; //~ ERROR: evaluation of constant value failed -const _NUSIZE_SUB_P: &usize = &(1usize - 5 ); //~ ERROR: evaluation of constant value failed +const _NISIZE_SUB: isize = -5isize - isize::MAX; //~ ERROR: overflow +const _NISIZE_SUB_P: &isize = &(-5isize - isize::MAX); //~ ERROR: overflow +const _NUSIZE_SUB: usize = 1usize - 5; //~ ERROR: overflow +const _NUSIZE_SUB_P: &usize = &(1usize - 5); //~ ERROR: overflow // Multiplication -const _NI8_MUL: i8 = i8::MAX * 5; //~ ERROR: evaluation of constant value failed -const _NI8_MUL_P: &i8 = &(i8::MAX * 5); //~ ERROR: evaluation of constant value failed - -const _NI16_MUL: i16 = i16::MAX * 5; //~ ERROR: evaluation of constant value failed -const _NI16_MUL_P: &i16 = &(i16::MAX * 5); //~ ERROR: evaluation of constant value failed +const _NI8_MUL: i8 = i8::MAX * 5; //~ ERROR: overflow +const _NI8_MUL_P: &i8 = &(i8::MAX * 5); //~ ERROR: overflow -const _NI32_MUL: i32 = i32::MAX * 5; //~ ERROR: evaluation of constant value failed -const _NI32_MUL_P: &i32 = &(i32::MAX * 5); //~ ERROR: evaluation of constant value failed +const _NI16_MUL: i16 = i16::MAX * 5; //~ ERROR: overflow +const _NI16_MUL_P: &i16 = &(i16::MAX * 5); //~ ERROR: overflow -const _NI64_MUL: i64 = i64::MAX * 5; //~ ERROR: evaluation of constant value failed -const _NI64_MUL_P: &i64 = &(i64::MAX * 5); //~ ERROR: evaluation of constant value failed +const _NI32_MUL: i32 = i32::MAX * 5; //~ ERROR: overflow +const _NI32_MUL_P: &i32 = &(i32::MAX * 5); //~ ERROR: overflow -const _NI128_MUL: i128 = i128::MAX * 5; //~ ERROR: evaluation of constant value failed -const _NI128_MUL_P: &i128 = &(i128::MAX * 5); //~ ERROR: evaluation of constant value failed +const _NI64_MUL: i64 = i64::MAX * 5; //~ ERROR: overflow +const _NI64_MUL_P: &i64 = &(i64::MAX * 5); //~ ERROR: overflow -const _NU8_MUL: u8 = u8::MAX * 5; //~ ERROR: evaluation of constant value failed -const _NU8_MUL_P: &u8 = &(u8::MAX * 5); //~ ERROR: evaluation of constant value failed +const _NI128_MUL: i128 = i128::MAX * 5; //~ ERROR: overflow +const _NI128_MUL_P: &i128 = &(i128::MAX * 5); //~ ERROR: overflow -const _NU16_MUL: u16 = u16::MAX * 5; //~ ERROR: evaluation of constant value failed -const _NU16_MUL_P: &u16 = &(u16::MAX * 5); //~ ERROR: evaluation of constant value failed +const _NU8_MUL: u8 = u8::MAX * 5; //~ ERROR: overflow +const _NU8_MUL_P: &u8 = &(u8::MAX * 5); //~ ERROR: overflow -const _NU32_MUL: u32 = u32::MAX * 5; //~ ERROR: evaluation of constant value failed -const _NU32_MUL_P: &u32 = &(u32::MAX * 5); //~ ERROR: evaluation of constant value failed +const _NU16_MUL: u16 = u16::MAX * 5; //~ ERROR: overflow +const _NU16_MUL_P: &u16 = &(u16::MAX * 5); //~ ERROR: overflow -const _NU64_MUL: u64 = u64::MAX * 5; //~ ERROR: evaluation of constant value failed -const _NU64_MUL_P: &u64 = &(u64::MAX * 5); //~ ERROR: evaluation of constant value failed +const _NU32_MUL: u32 = u32::MAX * 5; //~ ERROR: overflow +const _NU32_MUL_P: &u32 = &(u32::MAX * 5); //~ ERROR: overflow -const _NU128_MUL: u128 = u128::MAX * 5; //~ ERROR: evaluation of constant value failed -const _NU128_MUL_P: &u128 = &(u128::MAX * 5); //~ ERROR: evaluation of constant value failed +const _NU64_MUL: u64 = u64::MAX * 5; //~ ERROR: overflow +const _NU64_MUL_P: &u64 = &(u64::MAX * 5); //~ ERROR: overflow -const _NISIZE_MUL: isize = isize::MAX * 5; //~ ERROR: evaluation of constant value failed -const _NISIZE_MUL_P: &isize = &(isize::MAX * 5); //~ ERROR: evaluation of constant value failed +const _NU128_MUL: u128 = u128::MAX * 5; //~ ERROR: overflow +const _NU128_MUL_P: &u128 = &(u128::MAX * 5); //~ ERROR: overflow -const _NUSIZE_MUL: usize = usize::MAX * 5; //~ ERROR: evaluation of constant value failed -const _NUSIZE_MUL_P: &usize = &(usize::MAX * 5); //~ ERROR: evaluation of constant value failed +const _NISIZE_MUL: isize = isize::MAX * 5; //~ ERROR: overflow +const _NISIZE_MUL_P: &isize = &(isize::MAX * 5); //~ ERROR: overflow +const _NUSIZE_MUL: usize = usize::MAX * 5; //~ ERROR: overflow +const _NUSIZE_MUL_P: &usize = &(usize::MAX * 5); //~ ERROR: overflow // Division -const _NI8_DIV: i8 = 1i8 / 0; //~ ERROR: evaluation of constant value failed -const _NI8_DIV_P: &i8 = &(1i8 / 0); //~ ERROR: evaluation of constant value failed +const _NI8_DIV: i8 = 1i8 / 0; //~ ERROR: by zero +const _NI8_DIV_P: &i8 = &(1i8 / 0); //~ ERROR: by zero -const _NI16_DIV: i16 = 1i16 / 0; //~ ERROR: evaluation of constant value failed -const _NI16_DIV_P: &i16 = &(1i16 / 0); //~ ERROR: evaluation of constant value failed +const _NI16_DIV: i16 = 1i16 / 0; //~ ERROR: by zero +const _NI16_DIV_P: &i16 = &(1i16 / 0); //~ ERROR: by zero -const _NI32_DIV: i32 = 1i32 / 0; //~ ERROR: evaluation of constant value failed -const _NI32_DIV_P: &i32 = &(1i32 / 0); //~ ERROR: evaluation of constant value failed +const _NI32_DIV: i32 = 1i32 / 0; //~ ERROR: by zero +const _NI32_DIV_P: &i32 = &(1i32 / 0); //~ ERROR: by zero -const _NI64_DIV: i64 = 1i64 / 0; //~ ERROR: evaluation of constant value failed -const _NI64_DIV_P: &i64 = &(1i64 / 0); //~ ERROR: evaluation of constant value failed +const _NI64_DIV: i64 = 1i64 / 0; //~ ERROR: by zero +const _NI64_DIV_P: &i64 = &(1i64 / 0); //~ ERROR: by zero -const _NI128_DIV: i128 = 1i128 / 0; //~ ERROR: evaluation of constant value failed -const _NI128_DIV_P: &i128 = &(1i128 / 0); //~ ERROR: evaluation of constant value failed +const _NI128_DIV: i128 = 1i128 / 0; //~ ERROR: by zero +const _NI128_DIV_P: &i128 = &(1i128 / 0); //~ ERROR: by zero -const _NU8_DIV: u8 = 1u8 / 0; //~ ERROR: evaluation of constant value failed -const _NU8_DIV_P: &u8 = &(1u8 / 0); //~ ERROR: evaluation of constant value failed +const _NU8_DIV: u8 = 1u8 / 0; //~ ERROR: by zero +const _NU8_DIV_P: &u8 = &(1u8 / 0); //~ ERROR: by zero -const _NU16_DIV: u16 = 1u16 / 0; //~ ERROR: evaluation of constant value failed -const _NU16_DIV_P: &u16 = &(1u16 / 0); //~ ERROR: evaluation of constant value failed +const _NU16_DIV: u16 = 1u16 / 0; //~ ERROR: by zero +const _NU16_DIV_P: &u16 = &(1u16 / 0); //~ ERROR: by zero -const _NU32_DIV: u32 = 1u32 / 0; //~ ERROR: evaluation of constant value failed -const _NU32_DIV_P: &u32 = &(1u32 / 0); //~ ERROR: evaluation of constant value failed +const _NU32_DIV: u32 = 1u32 / 0; //~ ERROR: by zero +const _NU32_DIV_P: &u32 = &(1u32 / 0); //~ ERROR: by zero -const _NU64_DIV: u64 = 1u64 / 0; //~ ERROR: evaluation of constant value failed -const _NU64_DIV_P: &u64 = &(1u64 / 0); //~ ERROR: evaluation of constant value failed +const _NU64_DIV: u64 = 1u64 / 0; //~ ERROR: by zero +const _NU64_DIV_P: &u64 = &(1u64 / 0); //~ ERROR: by zero -const _NU128_DIV: u128 = 1u128 / 0; //~ ERROR: evaluation of constant value failed -const _NU128_DIV_P: &u128 = &(1u128 / 0); //~ ERROR: evaluation of constant value failed +const _NU128_DIV: u128 = 1u128 / 0; //~ ERROR: by zero +const _NU128_DIV_P: &u128 = &(1u128 / 0); //~ ERROR: by zero -const _NISIZE_DIV: isize = 1isize / 0; //~ ERROR: evaluation of constant value failed -const _NISIZE_DIV_P: &isize = &(1isize / 0); //~ ERROR: evaluation of constant value failed +const _NISIZE_DIV: isize = 1isize / 0; //~ ERROR: by zero +const _NISIZE_DIV_P: &isize = &(1isize / 0); //~ ERROR: by zero -const _NUSIZE_DIV: usize = 1usize / 0; //~ ERROR: evaluation of constant value failed -const _NUSIZE_DIV_P: &usize = &(1usize / 0); //~ ERROR: evaluation of constant value failed +const _NUSIZE_DIV: usize = 1usize / 0; //~ ERROR: by zero +const _NUSIZE_DIV_P: &usize = &(1usize / 0); //~ ERROR: by zero // Modulus -const _NI8_MOD: i8 = 1i8 % 0; //~ ERROR: evaluation of constant value failed -const _NI8_MOD_P: &i8 = &(1i8 % 0); //~ ERROR: evaluation of constant value failed +const _NI8_MOD: i8 = 1i8 % 0; //~ ERROR: divisor of zero +const _NI8_MOD_P: &i8 = &(1i8 % 0); //~ ERROR: divisor of zero -const _NI16_MOD: i16 = 1i16 % 0; //~ ERROR: evaluation of constant value failed -const _NI16_MOD_P: &i16 = &(1i16 % 0); //~ ERROR: evaluation of constant value failed +const _NI16_MOD: i16 = 1i16 % 0; //~ ERROR: divisor of zero +const _NI16_MOD_P: &i16 = &(1i16 % 0); //~ ERROR: divisor of zero -const _NI32_MOD: i32 = 1i32 % 0; //~ ERROR: evaluation of constant value failed -const _NI32_MOD_P: &i32 = &(1i32 % 0); //~ ERROR: evaluation of constant value failed +const _NI32_MOD: i32 = 1i32 % 0; //~ ERROR: divisor of zero +const _NI32_MOD_P: &i32 = &(1i32 % 0); //~ ERROR: divisor of zero -const _NI64_MOD: i64 = 1i64 % 0; //~ ERROR: evaluation of constant value failed -const _NI64_MOD_P: &i64 = &(1i64 % 0); //~ ERROR: evaluation of constant value failed +const _NI64_MOD: i64 = 1i64 % 0; //~ ERROR: divisor of zero +const _NI64_MOD_P: &i64 = &(1i64 % 0); //~ ERROR: divisor of zero -const _NI128_MOD: i128 = 1i128 % 0; //~ ERROR: evaluation of constant value failed -const _NI128_MOD_P: &i128 = &(1i128 % 0); //~ ERROR: evaluation of constant value failed +const _NI128_MOD: i128 = 1i128 % 0; //~ ERROR: divisor of zero +const _NI128_MOD_P: &i128 = &(1i128 % 0); //~ ERROR: divisor of zero -const _NU8_MOD: u8 = 1u8 % 0; //~ ERROR: evaluation of constant value failed -const _NU8_MOD_P: &u8 = &(1u8 % 0); //~ ERROR: evaluation of constant value failed +const _NU8_MOD: u8 = 1u8 % 0; //~ ERROR: divisor of zero +const _NU8_MOD_P: &u8 = &(1u8 % 0); //~ ERROR: divisor of zero -const _NU16_MOD: u16 = 1u16 % 0; //~ ERROR: evaluation of constant value failed -const _NU16_MOD_P: &u16 = &(1u16 % 0); //~ ERROR: evaluation of constant value failed +const _NU16_MOD: u16 = 1u16 % 0; //~ ERROR: divisor of zero +const _NU16_MOD_P: &u16 = &(1u16 % 0); //~ ERROR: divisor of zero -const _NU32_MOD: u32 = 1u32 % 0; //~ ERROR: evaluation of constant value failed -const _NU32_MOD_P: &u32 = &(1u32 % 0); //~ ERROR: evaluation of constant value failed +const _NU32_MOD: u32 = 1u32 % 0; //~ ERROR: divisor of zero +const _NU32_MOD_P: &u32 = &(1u32 % 0); //~ ERROR: divisor of zero -const _NU64_MOD: u64 = 1u64 % 0; //~ ERROR: evaluation of constant value failed -const _NU64_MOD_P: &u64 = &(1u64 % 0); //~ ERROR: evaluation of constant value failed +const _NU64_MOD: u64 = 1u64 % 0; //~ ERROR: divisor of zero +const _NU64_MOD_P: &u64 = &(1u64 % 0); //~ ERROR: divisor of zero -const _NU128_MOD: u128 = 1u128 % 0; //~ ERROR: evaluation of constant value failed -const _NU128_MOD_P: &u128 = &(1u128 % 0); //~ ERROR: evaluation of constant value failed +const _NU128_MOD: u128 = 1u128 % 0; //~ ERROR: divisor of zero +const _NU128_MOD_P: &u128 = &(1u128 % 0); //~ ERROR: divisor of zero -const _NISIZE_MOD: isize = 1isize % 0; //~ ERROR: evaluation of constant value failed -const _NISIZE_MOD_P: &isize = &(1isize % 0); //~ ERROR: evaluation of constant value failed - -const _NUSIZE_MOD: usize = 1usize % 0; //~ ERROR: evaluation of constant value failed -const _NUSIZE_MOD_P: &usize = &(1usize % 0); //~ ERROR: evaluation of constant value failed +const _NISIZE_MOD: isize = 1isize % 0; //~ ERROR: divisor of zero +const _NISIZE_MOD_P: &isize = &(1isize % 0); //~ ERROR: divisor of zero +const _NUSIZE_MOD: usize = 1usize % 0; //~ ERROR: divisor of zero +const _NUSIZE_MOD_P: &usize = &(1usize % 0); //~ ERROR: divisor of zero // Out of bounds access -const _NI32_OOB: i32 = [1, 2, 3][4]; //~ ERROR: evaluation of constant value failed -const _NI32_OOB_P: &i32 = &([1, 2, 3][4]); //~ ERROR: evaluation of constant value failed - +const _NI32_OOB: i32 = [1, 2, 3][4]; //~ ERROR: the length is 3 but the index is 4 +const _NI32_OOB_P: &i32 = &([1, 2, 3][4]); //~ ERROR: the length is 3 but the index is 4 pub fn main() {} diff --git a/tests/ui/consts/promoted_running_out_of_memory_issue-130687.rs b/tests/ui/consts/promoted_running_out_of_memory_issue-130687.rs index e458a6f98ad..d7977bfba77 100644 --- a/tests/ui/consts/promoted_running_out_of_memory_issue-130687.rs +++ b/tests/ui/consts/promoted_running_out_of_memory_issue-130687.rs @@ -11,7 +11,6 @@ pub struct Data([u8; (1 << 47) - 1]); const _: &'static Data = &Data([0; (1 << 47) - 1]); -//~^ERROR: evaluation of constant value failed -//~| NOTE tried to allocate more memory than available to compiler +//~^ ERROR: tried to allocate more memory than available to compiler fn main() {} diff --git a/tests/ui/consts/promoted_running_out_of_memory_issue-130687.stderr b/tests/ui/consts/promoted_running_out_of_memory_issue-130687.stderr index 02180c1e4c6..a5a50c580d0 100644 --- a/tests/ui/consts/promoted_running_out_of_memory_issue-130687.stderr +++ b/tests/ui/consts/promoted_running_out_of_memory_issue-130687.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: tried to allocate more memory than available to compiler --> $DIR/promoted_running_out_of_memory_issue-130687.rs:13:32 | LL | const _: &'static Data = &Data([0; (1 << 47) - 1]); - | ^^^^^^^^^^^^^^^^^^ tried to allocate more memory than available to compiler + | ^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/promoted_size_overflow.rs b/tests/ui/consts/promoted_size_overflow.rs index ebd5ab06487..232fb76c75b 100644 --- a/tests/ui/consts/promoted_size_overflow.rs +++ b/tests/ui/consts/promoted_size_overflow.rs @@ -1,7 +1,6 @@ //@ only-64bit pub struct Data([u8; usize::MAX >> 2]); const _: &'static [Data] = &[]; -//~^ERROR: evaluation of constant value failed -//~| NOTE too big for the target architecture +//~^ ERROR: too big for the target architecture fn main() {} diff --git a/tests/ui/consts/promoted_size_overflow.stderr b/tests/ui/consts/promoted_size_overflow.stderr index cfb8260bed0..529b232c77c 100644 --- a/tests/ui/consts/promoted_size_overflow.stderr +++ b/tests/ui/consts/promoted_size_overflow.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: values of the type `[u8; 4611686018427387903]` are too big for the target architecture --> $DIR/promoted_size_overflow.rs:3:29 | LL | const _: &'static [Data] = &[]; - | ^^ values of the type `[u8; 4611686018427387903]` are too big for the target architecture + | ^^ evaluation of `_` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/qualif-indirect-mutation-fail.rs b/tests/ui/consts/qualif-indirect-mutation-fail.rs index 4abb231c29f..b70fca7b864 100644 --- a/tests/ui/consts/qualif-indirect-mutation-fail.rs +++ b/tests/ui/consts/qualif-indirect-mutation-fail.rs @@ -15,7 +15,7 @@ pub const A1: () = { let b = &mut y; std::mem::swap(a, b); std::mem::forget(y); -}; //~ ERROR evaluation of constant value failed +}; //~ ERROR calling non-const function `<Vec<u8> as Drop>::drop` // Mutable borrow of a type with drop impl. pub const A2: () = { @@ -26,7 +26,7 @@ pub const A2: () = { std::mem::swap(a, b); std::mem::forget(y); let _z = x; //~ ERROR destructor of -}; //~ ERROR evaluation of constant value failed +}; //~ ERROR calling non-const function `<Vec<u8> as Drop>::drop` // Shared borrow of a type that might be !Freeze and Drop. pub const fn g1<T>() { diff --git a/tests/ui/consts/qualif-indirect-mutation-fail.stderr b/tests/ui/consts/qualif-indirect-mutation-fail.stderr index dd575e07c20..79724ee8d6a 100644 --- a/tests/ui/consts/qualif-indirect-mutation-fail.stderr +++ b/tests/ui/consts/qualif-indirect-mutation-fail.stderr @@ -7,11 +7,11 @@ LL | let mut x = None; LL | }; | - value is dropped here -error[E0080]: evaluation of constant value failed +error[E0080]: calling non-const function `<Vec<u8> as Drop>::drop` --> $DIR/qualif-indirect-mutation-fail.rs:18:1 | LL | }; - | ^ calling non-const function `<Vec<u8> as Drop>::drop` + | ^ evaluation of `A1` failed inside this call | note: inside `drop_in_place::<Option<String>> - shim(Some(Option<String>))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL @@ -28,11 +28,11 @@ LL | let _z = x; LL | }; | - value is dropped here -error[E0080]: evaluation of constant value failed +error[E0080]: calling non-const function `<Vec<u8> as Drop>::drop` --> $DIR/qualif-indirect-mutation-fail.rs:29:1 | LL | }; - | ^ calling non-const function `<Vec<u8> as Drop>::drop` + | ^ evaluation of `A2` failed inside this call | note: inside `drop_in_place::<Option<String>> - shim(Some(Option<String>))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL diff --git a/tests/ui/consts/recursive-zst-static.default.stderr b/tests/ui/consts/recursive-zst-static.default.stderr index dedca16db8d..fee33a892d0 100644 --- a/tests/ui/consts/recursive-zst-static.default.stderr +++ b/tests/ui/consts/recursive-zst-static.default.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: encountered static that tried to initialize itself with itself --> $DIR/recursive-zst-static.rs:10:18 | LL | static FOO: () = FOO; - | ^^^ encountered static that tried to initialize itself with itself + | ^^^ evaluation of `FOO` failed here error[E0391]: cycle detected when evaluating initializer of static `A` --> $DIR/recursive-zst-static.rs:13:16 diff --git a/tests/ui/consts/recursive-zst-static.rs b/tests/ui/consts/recursive-zst-static.rs index a52624fada8..852caae9493 100644 --- a/tests/ui/consts/recursive-zst-static.rs +++ b/tests/ui/consts/recursive-zst-static.rs @@ -8,7 +8,7 @@ // See https://github.com/rust-lang/rust/issues/71078 for more details. static FOO: () = FOO; -//~^ ERROR could not evaluate static initializer +//~^ ERROR encountered static that tried to initialize itself with itself static A: () = B; //~ ERROR cycle detected when evaluating initializer of static `A` static B: () = A; diff --git a/tests/ui/consts/recursive-zst-static.unleash.stderr b/tests/ui/consts/recursive-zst-static.unleash.stderr index dedca16db8d..fee33a892d0 100644 --- a/tests/ui/consts/recursive-zst-static.unleash.stderr +++ b/tests/ui/consts/recursive-zst-static.unleash.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: encountered static that tried to initialize itself with itself --> $DIR/recursive-zst-static.rs:10:18 | LL | static FOO: () = FOO; - | ^^^ encountered static that tried to initialize itself with itself + | ^^^ evaluation of `FOO` failed here error[E0391]: cycle detected when evaluating initializer of static `A` --> $DIR/recursive-zst-static.rs:13:16 diff --git a/tests/ui/consts/recursive.rs b/tests/ui/consts/recursive.rs index b5703d11310..ed23baf0768 100644 --- a/tests/ui/consts/recursive.rs +++ b/tests/ui/consts/recursive.rs @@ -4,6 +4,6 @@ const fn f<T>(x: T) { //~ WARN function cannot return without recursing f(x); } -const X: () = f(1); //~ ERROR evaluation of constant value failed +const X: () = f(1); //~ ERROR reached the configured maximum number of stack frames fn main() {} diff --git a/tests/ui/consts/recursive.stderr b/tests/ui/consts/recursive.stderr index fd38b078b94..a382fabf7b7 100644 --- a/tests/ui/consts/recursive.stderr +++ b/tests/ui/consts/recursive.stderr @@ -9,11 +9,11 @@ LL | f(x); = help: a `loop` may express intention better if this is on purpose = note: `#[warn(unconditional_recursion)]` on by default -error[E0080]: evaluation of constant value failed +error[E0080]: reached the configured maximum number of stack frames --> $DIR/recursive.rs:7:15 | LL | const X: () = f(1); - | ^^^^ reached the configured maximum number of stack frames + | ^^^^ evaluation of `X` failed inside this call | note: [... 126 additional calls inside `f::<i32>` ...] --> $DIR/recursive.rs:4:5 diff --git a/tests/ui/consts/required-consts/collect-in-called-fn.noopt.stderr b/tests/ui/consts/required-consts/collect-in-called-fn.noopt.stderr index 6812b3734ef..7d7bbbc5e36 100644 --- a/tests/ui/consts/required-consts/collect-in-called-fn.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-called-fn.noopt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Fail::<i32>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-called-fn.rs:10:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::<i32>::C` failed here note: erroneous constant encountered --> $DIR/collect-in-called-fn.rs:19:17 diff --git a/tests/ui/consts/required-consts/collect-in-called-fn.opt.stderr b/tests/ui/consts/required-consts/collect-in-called-fn.opt.stderr index 6812b3734ef..7d7bbbc5e36 100644 --- a/tests/ui/consts/required-consts/collect-in-called-fn.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-called-fn.opt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Fail::<i32>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-called-fn.rs:10:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::<i32>::C` failed here note: erroneous constant encountered --> $DIR/collect-in-called-fn.rs:19:17 diff --git a/tests/ui/consts/required-consts/collect-in-called-fn.rs b/tests/ui/consts/required-consts/collect-in-called-fn.rs index 93947950af2..2045b8266c7 100644 --- a/tests/ui/consts/required-consts/collect-in-called-fn.rs +++ b/tests/ui/consts/required-consts/collect-in-called-fn.rs @@ -7,7 +7,7 @@ struct Fail<T>(T); impl<T> Fail<T> { - const C: () = panic!(); //~ERROR evaluation of `Fail::<i32>::C` failed + const C: () = panic!(); //~ERROR evaluation panicked: explicit panic } #[inline(never)] diff --git a/tests/ui/consts/required-consts/collect-in-dead-closure.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-closure.noopt.stderr index 661aea71604..239e9cb1472 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-closure.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-closure.noopt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Fail::<i32>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-closure.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::<i32>::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-closure.rs:17:17 diff --git a/tests/ui/consts/required-consts/collect-in-dead-closure.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-closure.opt.stderr index 661aea71604..239e9cb1472 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-closure.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-closure.opt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Fail::<i32>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-closure.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::<i32>::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-closure.rs:17:17 diff --git a/tests/ui/consts/required-consts/collect-in-dead-closure.rs b/tests/ui/consts/required-consts/collect-in-dead-closure.rs index a00214c62db..5f8b6bbb174 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-closure.rs +++ b/tests/ui/consts/required-consts/collect-in-dead-closure.rs @@ -6,7 +6,7 @@ struct Fail<T>(T); impl<T> Fail<T> { - const C: () = panic!(); //~ERROR evaluation of `Fail::<i32>::C` failed + const C: () = panic!(); //~ERROR evaluation panicked: explicit panic } // This function is not actually called, but it is mentioned in a closure that is coerced to a diff --git a/tests/ui/consts/required-consts/collect-in-dead-drop.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-drop.noopt.stderr index 31e6b2f487f..7c6219ccf93 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-drop.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-drop.noopt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Fail::<i32>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-drop.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::<i32>::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-drop.rs:16:17 diff --git a/tests/ui/consts/required-consts/collect-in-dead-drop.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-drop.opt.stderr index 31e6b2f487f..7c6219ccf93 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-drop.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-drop.opt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Fail::<i32>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-drop.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::<i32>::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-drop.rs:16:17 diff --git a/tests/ui/consts/required-consts/collect-in-dead-drop.rs b/tests/ui/consts/required-consts/collect-in-dead-drop.rs index 389fcf5dfc9..f7293d162df 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-drop.rs +++ b/tests/ui/consts/required-consts/collect-in-dead-drop.rs @@ -6,7 +6,7 @@ struct Fail<T>(T); impl<T> Fail<T> { - const C: () = panic!(); //~ERROR evaluation of `Fail::<i32>::C` failed + const C: () = panic!(); //~ERROR evaluation panicked: explicit panic } // This function is not actually called, but is mentioned implicitly as destructor in dead code in a diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.noopt.stderr index 32dc1cb304b..e1a82fd5231 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.noopt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Fail::<i32>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn-behind-assoc-type.rs:10:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::<i32>::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-fn-behind-assoc-type.rs:16:17 diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.opt.stderr index 32dc1cb304b..e1a82fd5231 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.opt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Fail::<i32>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn-behind-assoc-type.rs:10:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::<i32>::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-fn-behind-assoc-type.rs:16:17 diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.rs b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.rs index 9c36af50bb7..e6be9f56cb7 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.rs +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.rs @@ -7,7 +7,7 @@ struct Fail<T>(T); impl<T> Fail<T> { - const C: () = panic!(); //~ERROR evaluation of `Fail::<i32>::C` failed + const C: () = panic!(); //~ERROR evaluation panicked: explicit panic } #[inline(never)] diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.noopt.stderr index d22cf579448..1d2af342a44 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.noopt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Fail::<i32>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn-behind-generic.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::<i32>::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-fn-behind-generic.rs:15:17 diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.opt.stderr index d22cf579448..1d2af342a44 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.opt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Fail::<i32>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn-behind-generic.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::<i32>::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-fn-behind-generic.rs:15:17 diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.rs b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.rs index 5829d914ee1..a86902af526 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.rs +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.rs @@ -6,7 +6,7 @@ struct Fail<T>(T); impl<T> Fail<T> { - const C: () = panic!(); //~ERROR evaluation of `Fail::<i32>::C` failed + const C: () = panic!(); //~ERROR evaluation panicked: explicit panic } #[inline(never)] diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr index 91daa2f9bc3..a480a8c5a39 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `m::Fail::<i32>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn-behind-opaque-type.rs:11:23 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `m::Fail::<i32>::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-fn-behind-opaque-type.rs:19:21 diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr index 91daa2f9bc3..a480a8c5a39 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `m::Fail::<i32>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn-behind-opaque-type.rs:11:23 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `m::Fail::<i32>::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-fn-behind-opaque-type.rs:19:21 diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.rs b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.rs index f333f3462c7..4cdb2741354 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.rs +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.rs @@ -8,7 +8,7 @@ mod m { struct Fail<T>(T); impl<T> Fail<T> { - const C: () = panic!(); //~ERROR evaluation of `m::Fail::<i32>::C` failed + const C: () = panic!(); //~ERROR: evaluation panicked: explicit panic } pub type NotCalledFn = impl Fn(); diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn.noopt.stderr index d254fc60c0c..f253a7cbbee 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn.noopt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Fail::<i32>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::<i32>::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-fn.rs:19:17 diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn.opt.stderr index d254fc60c0c..f253a7cbbee 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn.opt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Fail::<i32>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::<i32>::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-fn.rs:19:17 diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn.rs b/tests/ui/consts/required-consts/collect-in-dead-fn.rs index 1c95e0c303f..0c479580106 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn.rs +++ b/tests/ui/consts/required-consts/collect-in-dead-fn.rs @@ -6,7 +6,7 @@ struct Fail<T>(T); impl<T> Fail<T> { - const C: () = panic!(); //~ERROR evaluation of `Fail::<i32>::C` failed + const C: () = panic!(); //~ERROR evaluation panicked: explicit panic } // This function is not actually called, but it is mentioned in dead code in a function that is diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.noopt.stderr index c14837ce442..b962630ca01 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.noopt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Late::<i32>::FAIL` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fnptr-in-const.rs:9:22 | LL | const FAIL: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Late::<i32>::FAIL` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-fnptr-in-const.rs:10:28 diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.opt.stderr index c14837ce442..b962630ca01 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.opt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Late::<i32>::FAIL` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fnptr-in-const.rs:9:22 | LL | const FAIL: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Late::<i32>::FAIL` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-fnptr-in-const.rs:10:28 diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.rs b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.rs index 8b6344c93f3..04544cb4139 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.rs +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.rs @@ -6,7 +6,7 @@ struct Late<T>(T); impl<T> Late<T> { - const FAIL: () = panic!(); //~ERROR evaluation of `Late::<i32>::FAIL` failed + const FAIL: () = panic!(); //~ERROR evaluation panicked: explicit panic const FNPTR: fn() = || Self::FAIL; } diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fnptr.noopt.stderr index 284e1a70a20..29e6711153c 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr.noopt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Fail::<i32>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fnptr.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::<i32>::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-fnptr.rs:18:17 diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fnptr.opt.stderr index 284e1a70a20..29e6711153c 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr.opt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Fail::<i32>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fnptr.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::<i32>::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-fnptr.rs:18:17 diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr.rs b/tests/ui/consts/required-consts/collect-in-dead-fnptr.rs index acbe34829e8..4cdb50f4385 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr.rs +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr.rs @@ -6,7 +6,7 @@ struct Fail<T>(T); impl<T> Fail<T> { - const C: () = panic!(); //~ERROR evaluation of `Fail::<i32>::C` failed + const C: () = panic!(); //~ERROR evaluation panicked: explicit panic } // This function is not actually called, but it is mentioned in dead code in a function that is diff --git a/tests/ui/consts/required-consts/collect-in-dead-move.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-move.noopt.stderr index 8b43c67c085..6c8edc00260 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-move.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-move.noopt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Fail::<i32>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-move.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::<i32>::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-move.rs:16:17 diff --git a/tests/ui/consts/required-consts/collect-in-dead-move.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-move.opt.stderr index 8b43c67c085..6c8edc00260 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-move.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-move.opt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Fail::<i32>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-move.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::<i32>::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-move.rs:16:17 diff --git a/tests/ui/consts/required-consts/collect-in-dead-move.rs b/tests/ui/consts/required-consts/collect-in-dead-move.rs index 6a224a375cf..4e2d959db32 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-move.rs +++ b/tests/ui/consts/required-consts/collect-in-dead-move.rs @@ -6,7 +6,7 @@ struct Fail<T>(T); impl<T> Fail<T> { - const C: () = panic!(); //~ERROR evaluation of `Fail::<i32>::C` failed + const C: () = panic!(); //~ERROR evaluation panicked: explicit panic } // This function is not actually called, but is mentioned implicitly as destructor in dead code in a diff --git a/tests/ui/consts/required-consts/collect-in-dead-vtable.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-vtable.noopt.stderr index 4056f28541d..4e35beadbf4 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-vtable.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-vtable.noopt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Fail::<i32>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-vtable.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::<i32>::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-vtable.rs:22:21 diff --git a/tests/ui/consts/required-consts/collect-in-dead-vtable.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-vtable.opt.stderr index 4056f28541d..4e35beadbf4 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-vtable.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-vtable.opt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Fail::<i32>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-vtable.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::<i32>::C` failed here note: erroneous constant encountered --> $DIR/collect-in-dead-vtable.rs:22:21 diff --git a/tests/ui/consts/required-consts/collect-in-dead-vtable.rs b/tests/ui/consts/required-consts/collect-in-dead-vtable.rs index f63207eafec..d4ad7308377 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-vtable.rs +++ b/tests/ui/consts/required-consts/collect-in-dead-vtable.rs @@ -6,7 +6,7 @@ struct Fail<T>(T); impl<T> Fail<T> { - const C: () = panic!(); //~ERROR evaluation of `Fail::<i32>::C` failed + const C: () = panic!(); //~ERROR evaluation panicked: explicit panic } trait MyTrait { diff --git a/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr b/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr index c5f3b0009f5..67f5009c4ff 100644 --- a/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Fail::<i32>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-promoted-const.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::<i32>::C` failed here note: erroneous constant encountered --> $DIR/collect-in-promoted-const.rs:20:21 diff --git a/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr b/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr index 6f36aaf314d..5c3edf68d95 100644 --- a/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Fail::<T>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-promoted-const.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::<T>::C` failed here note: erroneous constant encountered --> $DIR/collect-in-promoted-const.rs:20:21 @@ -10,11 +10,11 @@ note: erroneous constant encountered LL | let _val = &Fail::<T>::C; | ^^^^^^^^^^^^ -error[E0080]: evaluation of `Fail::<i32>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-promoted-const.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::<i32>::C` failed here note: erroneous constant encountered --> $DIR/collect-in-promoted-const.rs:20:21 diff --git a/tests/ui/consts/required-consts/collect-in-promoted-const.rs b/tests/ui/consts/required-consts/collect-in-promoted-const.rs index 4a3ce92e8f9..25c8cb7e804 100644 --- a/tests/ui/consts/required-consts/collect-in-promoted-const.rs +++ b/tests/ui/consts/required-consts/collect-in-promoted-const.rs @@ -6,8 +6,8 @@ struct Fail<T>(T); impl<T> Fail<T> { - const C: () = panic!(); //~ERROR evaluation of `Fail::<i32>::C` failed - //[opt]~^ ERROR evaluation of `Fail::<T>::C` failed + const C: () = panic!(); //~ERROR evaluation panicked: explicit panic + //[opt]~^ ERROR evaluation panicked: explicit panic // (Not sure why optimizations lead to this being emitted twice, but as long as compilation // fails either way it's fine.) } 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 f98e2c17202..c9fd476bd8b 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 @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Fail::<i32>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/interpret-in-const-called-fn.rs:8:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::<i32>::C` failed here note: erroneous constant encountered --> $DIR/interpret-in-const-called-fn.rs:18:9 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 f98e2c17202..c9fd476bd8b 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 @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Fail::<i32>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/interpret-in-const-called-fn.rs:8:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::<i32>::C` failed here note: erroneous constant encountered --> $DIR/interpret-in-const-called-fn.rs:18:9 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 1ed6853f0a4..9309457e22a 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 @@ -5,7 +5,7 @@ struct Fail<T>(T); impl<T> Fail<T> { - const C: () = panic!(); //~ERROR evaluation of `Fail::<i32>::C` failed + const C: () = panic!(); //~ERROR explicit panic //~| NOTE in this expansion of panic! } 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 f70e262ac4c..12c5acd02a4 100644 --- a/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr @@ -1,16 +1,14 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: entering unreachable code --> $DIR/interpret-in-promoted.rs:15:28 | LL | let _x: &'static () = &ub(); - | ^^^^ entering unreachable code + | ^^^^ evaluation of `FOO` failed inside this call | note: inside `ub` --> $DIR/interpret-in-promoted.rs:9:5 | LL | std::hint::unreachable_unchecked(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: inside `unreachable_unchecked` - --> $SRC_DIR/core/src/hint.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here note: erroneous constant encountered --> $DIR/interpret-in-promoted.rs:15:27 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 f70e262ac4c..12c5acd02a4 100644 --- a/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr @@ -1,16 +1,14 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: entering unreachable code --> $DIR/interpret-in-promoted.rs:15:28 | LL | let _x: &'static () = &ub(); - | ^^^^ entering unreachable code + | ^^^^ evaluation of `FOO` failed inside this call | note: inside `ub` --> $DIR/interpret-in-promoted.rs:9:5 | LL | std::hint::unreachable_unchecked(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: inside `unreachable_unchecked` - --> $SRC_DIR/core/src/hint.rs:LL:COL + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here note: erroneous constant encountered --> $DIR/interpret-in-promoted.rs:15:27 diff --git a/tests/ui/consts/required-consts/interpret-in-promoted.rs b/tests/ui/consts/required-consts/interpret-in-promoted.rs index 85d2ea3418c..b223e6d16aa 100644 --- a/tests/ui/consts/required-consts/interpret-in-promoted.rs +++ b/tests/ui/consts/required-consts/interpret-in-promoted.rs @@ -12,7 +12,7 @@ const unsafe fn ub() { pub const FOO: () = unsafe { // Make sure that this gets promoted and then fails to evaluate, and we deal with that // correctly. - let _x: &'static () = &ub(); //~ ERROR evaluation of constant value failed + let _x: &'static () = &ub(); //~ ERROR unreachable code }; fn main() {} 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 28daf265af4..8b8d375250d 100644 --- a/tests/ui/consts/required-consts/interpret-in-static.noopt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-static.noopt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Fail::<i32>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/interpret-in-static.rs:8:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::<i32>::C` failed here note: erroneous constant encountered --> $DIR/interpret-in-static.rs:17:9 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 28daf265af4..8b8d375250d 100644 --- a/tests/ui/consts/required-consts/interpret-in-static.opt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-static.opt.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Fail::<i32>::C` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/interpret-in-static.rs:8:19 | LL | const C: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `Fail::<i32>::C` failed here note: erroneous constant encountered --> $DIR/interpret-in-static.rs:17:9 diff --git a/tests/ui/consts/required-consts/interpret-in-static.rs b/tests/ui/consts/required-consts/interpret-in-static.rs index 7ddf15f9121..19ad6be1c9f 100644 --- a/tests/ui/consts/required-consts/interpret-in-static.rs +++ b/tests/ui/consts/required-consts/interpret-in-static.rs @@ -5,7 +5,7 @@ struct Fail<T>(T); impl<T> Fail<T> { - const C: () = panic!(); //~ERROR evaluation of `Fail::<i32>::C` failed + const C: () = panic!(); //~ERROR explicit panic //~| NOTE in this expansion of panic! } diff --git a/tests/ui/consts/slice-index-overflow-issue-130284.rs b/tests/ui/consts/slice-index-overflow-issue-130284.rs index 6877ebe1476..f5235b0e1f1 100644 --- a/tests/ui/consts/slice-index-overflow-issue-130284.rs +++ b/tests/ui/consts/slice-index-overflow-issue-130284.rs @@ -5,8 +5,7 @@ const C: () = { unsafe { // This used to ICE, but it should just report UB. let _ice = (*fat)[usize::MAX - 1]; - //~^ERROR: constant value failed - //~| NOTE overflow + //~^ERROR: overflow } }; diff --git a/tests/ui/consts/slice-index-overflow-issue-130284.stderr b/tests/ui/consts/slice-index-overflow-issue-130284.stderr index e3e676c8949..63c355b4b0f 100644 --- a/tests/ui/consts/slice-index-overflow-issue-130284.stderr +++ b/tests/ui/consts/slice-index-overflow-issue-130284.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: overflowing pointer arithmetic: the total offset in bytes does not fit in an `isize` --> $DIR/slice-index-overflow-issue-130284.rs:7:20 | LL | let _ice = (*fat)[usize::MAX - 1]; - | ^^^^^^^^^^^^^^^^^^^^^^ overflowing pointer arithmetic: the total offset in bytes does not fit in an `isize` + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `C` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/static_mut_containing_mut_ref2.rs b/tests/ui/consts/static_mut_containing_mut_ref2.rs index 2b1fe55df78..e9910816fc1 100644 --- a/tests/ui/consts/static_mut_containing_mut_ref2.rs +++ b/tests/ui/consts/static_mut_containing_mut_ref2.rs @@ -4,7 +4,7 @@ static mut STDERR_BUFFER_SPACE: u8 = 0; pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; - //~^ ERROR could not evaluate static initializer + //~^ ERROR modifying a static's initial value }; fn main() {} diff --git a/tests/ui/consts/static_mut_containing_mut_ref2.stderr b/tests/ui/consts/static_mut_containing_mut_ref2.stderr index 37cd2b51ad1..556a4d956ed 100644 --- a/tests/ui/consts/static_mut_containing_mut_ref2.stderr +++ b/tests/ui/consts/static_mut_containing_mut_ref2.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: modifying a static's initial value from another static's initializer --> $DIR/static_mut_containing_mut_ref2.rs:6:5 | LL | *(&mut STDERR_BUFFER_SPACE) = 42; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ modifying a static's initial value from another static's initializer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `STDERR_BUFFER` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/static_mut_containing_mut_ref3.rs b/tests/ui/consts/static_mut_containing_mut_ref3.rs index c24c7e27920..42a4d04cde6 100644 --- a/tests/ui/consts/static_mut_containing_mut_ref3.rs +++ b/tests/ui/consts/static_mut_containing_mut_ref3.rs @@ -1,6 +1,6 @@ static mut FOO: (u8, u8) = (42, 43); static mut BAR: () = unsafe { FOO.0 = 99; }; -//~^ ERROR could not evaluate static initializer +//~^ ERROR modifying a static's initial value fn main() {} diff --git a/tests/ui/consts/static_mut_containing_mut_ref3.stderr b/tests/ui/consts/static_mut_containing_mut_ref3.stderr index be84608acf7..b8ad2310a78 100644 --- a/tests/ui/consts/static_mut_containing_mut_ref3.stderr +++ b/tests/ui/consts/static_mut_containing_mut_ref3.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: modifying a static's initial value from another static's initializer --> $DIR/static_mut_containing_mut_ref3.rs:3:31 | LL | static mut BAR: () = unsafe { FOO.0 = 99; }; - | ^^^^^^^^^^ modifying a static's initial value from another static's initializer + | ^^^^^^^^^^ evaluation of `BAR` failed here error: aborting due to 1 previous error diff --git a/tests/ui/consts/uninhabited-const-issue-61744.rs b/tests/ui/consts/uninhabited-const-issue-61744.rs index 802d422888b..56f0939ef18 100644 --- a/tests/ui/consts/uninhabited-const-issue-61744.rs +++ b/tests/ui/consts/uninhabited-const-issue-61744.rs @@ -10,7 +10,8 @@ pub const unsafe fn hint_unreachable() -> ! { } trait Const { - const CONSTANT: i32 = unsafe { fake_type() }; //~ ERROR evaluation of `fake_type::<!>` failed + const CONSTANT: i32 = unsafe { fake_type() }; //~ ERROR reached the configured maximum number of stack frames + //~^ NOTE evaluation of `<i32 as Const>::CONSTANT` failed inside this call } impl<T> Const for T {} diff --git a/tests/ui/consts/uninhabited-const-issue-61744.stderr b/tests/ui/consts/uninhabited-const-issue-61744.stderr index d0e90f9a423..cae4f8c3323 100644 --- a/tests/ui/consts/uninhabited-const-issue-61744.stderr +++ b/tests/ui/consts/uninhabited-const-issue-61744.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `fake_type::<!>` failed +error[E0080]: reached the configured maximum number of stack frames --> $DIR/uninhabited-const-issue-61744.rs:13:36 | LL | const CONSTANT: i32 = unsafe { fake_type() }; - | ^^^^^^^^^^^ reached the configured maximum number of stack frames + | ^^^^^^^^^^^ evaluation of `<i32 as Const>::CONSTANT` failed inside this call | note: inside `fake_type::<i32>` --> $DIR/uninhabited-const-issue-61744.rs:5:5 diff --git a/tests/ui/consts/validate_never_arrays.rs b/tests/ui/consts/validate_never_arrays.rs index 055bb1c69c8..b0ea064188b 100644 --- a/tests/ui/consts/validate_never_arrays.rs +++ b/tests/ui/consts/validate_never_arrays.rs @@ -3,10 +3,10 @@ //@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP" #![feature(never_type)] -const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR undefined behavior +const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR invalid value const _: &[!; 0] = unsafe { &*(1_usize as *const [!; 0]) }; // ok const _: &[!] = unsafe { &*(1_usize as *const [!; 0]) }; // ok -const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR undefined behavior -const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; //~ ERROR undefined behavior +const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR invalid value +const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; //~ ERROR invalid value fn main() {} diff --git a/tests/ui/consts/validate_never_arrays.stderr b/tests/ui/consts/validate_never_arrays.stderr index 12090e483a4..0f503df4060 100644 --- a/tests/ui/consts/validate_never_arrays.stderr +++ b/tests/ui/consts/validate_never_arrays.stderr @@ -1,30 +1,30 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered a reference pointing to uninhabited type [!; 1] --> $DIR/validate_never_arrays.rs:6:1 | LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; - | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type [!; 1] + | ^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>[0]: encountered a value of the never type `!` --> $DIR/validate_never_arrays.rs:9:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; - | ^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a value of the never type `!` + | ^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .<deref>[0]: encountered a value of the never type `!` --> $DIR/validate_never_arrays.rs:10:1 | LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; - | ^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a value of the never type `!` + | ^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { diff --git a/tests/ui/consts/write-to-static-mut-in-static.rs b/tests/ui/consts/write-to-static-mut-in-static.rs index a2985d05a79..ce15d9e912b 100644 --- a/tests/ui/consts/write-to-static-mut-in-static.rs +++ b/tests/ui/consts/write-to-static-mut-in-static.rs @@ -1,10 +1,10 @@ pub static mut A: u32 = 0; pub static mut B: () = unsafe { A = 1; }; -//~^ ERROR could not evaluate static initializer +//~^ ERROR modifying a static's initial value pub static mut C: u32 = unsafe { C = 1; 0 }; pub static D: u32 = D; -//~^ ERROR could not evaluate static initializer +//~^ ERROR static that tried to initialize itself with itself fn main() {} diff --git a/tests/ui/consts/write-to-static-mut-in-static.stderr b/tests/ui/consts/write-to-static-mut-in-static.stderr index 9616f8eeeb7..bb5e217afb9 100644 --- a/tests/ui/consts/write-to-static-mut-in-static.stderr +++ b/tests/ui/consts/write-to-static-mut-in-static.stderr @@ -1,14 +1,14 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: modifying a static's initial value from another static's initializer --> $DIR/write-to-static-mut-in-static.rs:2:33 | LL | pub static mut B: () = unsafe { A = 1; }; - | ^^^^^ modifying a static's initial value from another static's initializer + | ^^^^^ evaluation of `B` failed here -error[E0080]: could not evaluate static initializer +error[E0080]: encountered static that tried to initialize itself with itself --> $DIR/write-to-static-mut-in-static.rs:7:21 | LL | pub static D: u32 = D; - | ^ encountered static that tried to initialize itself with itself + | ^ evaluation of `D` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/coroutine/auxiliary/xcrate.rs b/tests/ui/coroutine/auxiliary/xcrate.rs index 52f188135bd..524eaafc752 100644 --- a/tests/ui/coroutine/auxiliary/xcrate.rs +++ b/tests/ui/coroutine/auxiliary/xcrate.rs @@ -12,7 +12,7 @@ pub fn foo() -> impl Coroutine<(), Yield = (), Return = ()> { } } -pub fn bar<T: 'static>(t: T) -> Box<Coroutine<(), Yield = T, Return = ()> + Unpin> { +pub fn bar<T: 'static>(t: T) -> Box<dyn Coroutine<(), Yield = T, Return = ()> + Unpin> { Box::new( #[coroutine] || { diff --git a/tests/ui/coroutine/const_gen_fn.rs b/tests/ui/coroutine/const_gen_fn.rs index 2701139ffed..b044c185e0f 100644 --- a/tests/ui/coroutine/const_gen_fn.rs +++ b/tests/ui/coroutine/const_gen_fn.rs @@ -4,8 +4,10 @@ const gen fn a() {} //~^ ERROR functions cannot be both `const` and `gen` +//~^^ ERROR `gen` fn bodies are not allowed in constant functions const async gen fn b() {} //~^ ERROR functions cannot be both `const` and `async gen` +//~^^ ERROR `async gen` fn bodies are not allowed in constant functions fn main() {} diff --git a/tests/ui/coroutine/const_gen_fn.stderr b/tests/ui/coroutine/const_gen_fn.stderr index 4f3c73d1678..400ee216d06 100644 --- a/tests/ui/coroutine/const_gen_fn.stderr +++ b/tests/ui/coroutine/const_gen_fn.stderr @@ -8,7 +8,7 @@ LL | const gen fn a() {} | `const` because of this error: functions cannot be both `const` and `async gen` - --> $DIR/const_gen_fn.rs:8:1 + --> $DIR/const_gen_fn.rs:9:1 | LL | const async gen fn b() {} | ^^^^^-^^^^^^^^^---------- @@ -16,5 +16,17 @@ LL | const async gen fn b() {} | | `async gen` because of this | `const` because of this -error: aborting due to 2 previous errors +error: `gen` fn bodies are not allowed in constant functions + --> $DIR/const_gen_fn.rs:5:18 + | +LL | const gen fn a() {} + | ^^ + +error: `async gen` fn bodies are not allowed in constant functions + --> $DIR/const_gen_fn.rs:9:24 + | +LL | const async gen fn b() {} + | ^^ + +error: aborting due to 4 previous errors diff --git a/tests/ui/coroutine/gen_block.none.stderr b/tests/ui/coroutine/gen_block.none.stderr index ed744f2957a..b793033b521 100644 --- a/tests/ui/coroutine/gen_block.none.stderr +++ b/tests/ui/coroutine/gen_block.none.stderr @@ -31,7 +31,7 @@ LL | let _ = || yield true; | ^^^^^^^^^^ | = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information - = help: add `#![feature(coroutines)]` to the crate attributes to enable + = help: add `#![feature(yield_expr)]` 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]: yield syntax is experimental @@ -41,7 +41,7 @@ LL | let _ = #[coroutine] || yield true; | ^^^^^^^^^^ | = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information - = help: add `#![feature(coroutines)]` to the crate attributes to enable + = help: add `#![feature(yield_expr)]` 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]: the `#[coroutine]` attribute is an experimental feature diff --git a/tests/ui/coroutine/unresolved-ct-var.stderr b/tests/ui/coroutine/unresolved-ct-var.stderr index da2ec272f9f..86b73e4b062 100644 --- a/tests/ui/coroutine/unresolved-ct-var.stderr +++ b/tests/ui/coroutine/unresolved-ct-var.stderr @@ -2,15 +2,18 @@ error[E0277]: `[(); _]` is not a future --> $DIR/unresolved-ct-var.rs:6:45 | LL | let s = std::array::from_fn(|_| ()).await; - | ----------------------------^^^^^ - | | || - | | |`[(); _]` is not a future - | | help: remove the `.await` + | --------------------------- ^^^^^ `[(); _]` is not a future + | | | this call returns `[(); _]` | = help: the trait `Future` is not implemented for `[(); _]` = note: [(); _] must be a future or must implement `IntoFuture` to be awaited = note: required for `[(); _]` to implement `IntoFuture` +help: remove the `.await` + | +LL - let s = std::array::from_fn(|_| ()).await; +LL + let s = std::array::from_fn(|_| ()); + | error: aborting due to 1 previous error diff --git a/tests/ui/auxiliary/crate-method-reexport-grrrrrrr2.rs b/tests/ui/cross-crate/auxiliary/method_reexport_aux.rs index d08504005a5..7579f033dc6 100644 --- a/tests/ui/auxiliary/crate-method-reexport-grrrrrrr2.rs +++ b/tests/ui/cross-crate/auxiliary/method_reexport_aux.rs @@ -1,4 +1,6 @@ -#![crate_name="crate_method_reexport_grrrrrrr2"] +//! Used by `tests/ui/cross-crate/cross-crate-method-reexport.rs` + +#![crate_name="method_reexport_aux"] pub use name_pool::add; @@ -16,7 +18,7 @@ pub mod name_pool { } pub mod rust { - pub use name_pool::add; + pub use crate::name_pool::add; pub type rt = Box<()>; diff --git a/tests/ui/cross-crate/auxiliary/static_priv_by_default.rs b/tests/ui/cross-crate/auxiliary/static_priv_by_default.rs index 39f912066ec..fe9aef42feb 100644 --- a/tests/ui/cross-crate/auxiliary/static_priv_by_default.rs +++ b/tests/ui/cross-crate/auxiliary/static_priv_by_default.rs @@ -31,11 +31,11 @@ mod foo { } pub mod bar { - pub use foo::reexported_a as e; - pub use foo::reexported_b as f; - pub use foo::reexported_c as g; - pub use foo::reexported_d as h; - pub use foo::reexported_e as i; + pub use crate::foo::reexported_a as e; + pub use crate::foo::reexported_b as f; + pub use crate::foo::reexported_c as g; + pub use crate::foo::reexported_d as h; + pub use crate::foo::reexported_e as i; } pub static a: isize = 0; diff --git a/tests/ui/crate-method-reexport-grrrrrrr.rs b/tests/ui/cross-crate/cross-crate-method-reexport.rs index aca399f4e20..e9eab99e214 100644 --- a/tests/ui/crate-method-reexport-grrrrrrr.rs +++ b/tests/ui/cross-crate/cross-crate-method-reexport.rs @@ -4,13 +4,13 @@ // name_pool::methods impl in the other crate is reachable from this // crate. -//@ aux-build:crate-method-reexport-grrrrrrr2.rs +//@ aux-build:method_reexport_aux.rs -extern crate crate_method_reexport_grrrrrrr2; +extern crate method_reexport_aux; pub fn main() { - use crate_method_reexport_grrrrrrr2::rust::add; - use crate_method_reexport_grrrrrrr2::rust::cx; + use method_reexport_aux::rust::add; + use method_reexport_aux::rust::cx; let x: Box<_> = Box::new(()); x.cx(); let y = (); diff --git a/tests/ui/default-method-parsing.rs b/tests/ui/default-method-parsing.rs deleted file mode 100644 index 84c3ab747c8..00000000000 --- a/tests/ui/default-method-parsing.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ check-pass - -trait Foo { - fn m(&self, _:isize) { } -} - -pub fn main() { } diff --git a/tests/ui/delegation/bad-resolve.stderr b/tests/ui/delegation/bad-resolve.stderr index 966387e1d61..fc6811292a6 100644 --- a/tests/ui/delegation/bad-resolve.stderr +++ b/tests/ui/delegation/bad-resolve.stderr @@ -44,9 +44,7 @@ error[E0575]: expected method or associated constant, found associated type `Tra --> $DIR/bad-resolve.rs:27:11 | LL | reuse <F as Trait>::Type; - | ^^^^^^^^^^^^^^^^^^ - | - = note: can't use a type alias as a constructor + | ^^^^^^^^^^^^^^^^^^ not a method or associated constant error[E0576]: cannot find method or associated constant `baz` in trait `Trait` --> $DIR/bad-resolve.rs:30:25 diff --git a/tests/ui/delegation/glob-non-fn.stderr b/tests/ui/delegation/glob-non-fn.stderr index 4b918c53b84..f63c8e88c6f 100644 --- a/tests/ui/delegation/glob-non-fn.stderr +++ b/tests/ui/delegation/glob-non-fn.stderr @@ -38,9 +38,7 @@ error[E0423]: expected function, found associated type `Trait::Type` --> $DIR/glob-non-fn.rs:30:11 | LL | reuse Trait::* { &self.0 } - | ^^^^^ - | - = note: can't use a type alias as a constructor + | ^^^^^ not a function error[E0046]: not all trait items implemented, missing: `CONST`, `Type`, `method` --> $DIR/glob-non-fn.rs:29:1 diff --git a/tests/ui/dep-graph/dep-graph-assoc-type-codegen.rs b/tests/ui/dep-graph/dep-graph-assoc-type-codegen.rs index 9525ff2e5ef..9a7a10529fa 100644 --- a/tests/ui/dep-graph/dep-graph-assoc-type-codegen.rs +++ b/tests/ui/dep-graph/dep-graph-assoc-type-codegen.rs @@ -15,7 +15,7 @@ pub trait Foo: Sized { } mod x { - use Foo; + use crate::Foo; #[rustc_if_this_changed] impl Foo for char { type T = char; } @@ -24,7 +24,7 @@ mod x { } mod y { - use Foo; + use crate::Foo; #[rustc_then_this_would_need(typeck)] //~ ERROR OK pub fn use_char_assoc() { diff --git a/tests/ui/dep-graph/dep-graph-caller-callee.rs b/tests/ui/dep-graph/dep-graph-caller-callee.rs index e56cd5202e5..b1318a169d9 100644 --- a/tests/ui/dep-graph/dep-graph-caller-callee.rs +++ b/tests/ui/dep-graph/dep-graph-caller-callee.rs @@ -15,7 +15,7 @@ mod x { } mod y { - use x; + use crate::x; // These dependencies SHOULD exist: #[rustc_then_this_would_need(typeck)] //~ ERROR OK @@ -25,7 +25,7 @@ mod y { } mod z { - use y; + use crate::y; // These are expected to yield errors, because changes to `x` // affect the BODY of `y`, but not its signature. diff --git a/tests/ui/dep-graph/dep-graph-struct-signature.rs b/tests/ui/dep-graph/dep-graph-struct-signature.rs index 5303c6d2e53..eea81b26f9f 100644 --- a/tests/ui/dep-graph/dep-graph-struct-signature.rs +++ b/tests/ui/dep-graph/dep-graph-struct-signature.rs @@ -23,7 +23,7 @@ struct WontChange { // these are valid dependencies mod signatures { - use WillChange; + use crate::WillChange; #[rustc_then_this_would_need(type_of)] //~ ERROR no path #[rustc_then_this_would_need(associated_item)] //~ ERROR no path @@ -70,7 +70,7 @@ mod signatures { } mod invalid_signatures { - use WontChange; + use crate::WontChange; #[rustc_then_this_would_need(type_of)] //~ ERROR no path trait A { diff --git a/tests/ui/dep-graph/dep-graph-trait-impl-two-traits-same-method.rs b/tests/ui/dep-graph/dep-graph-trait-impl-two-traits-same-method.rs index b3e8e9a512e..eab4c792105 100644 --- a/tests/ui/dep-graph/dep-graph-trait-impl-two-traits-same-method.rs +++ b/tests/ui/dep-graph/dep-graph-trait-impl-two-traits-same-method.rs @@ -19,7 +19,7 @@ pub trait Bar: Sized { } mod x { - use {Foo, Bar}; + use crate::{Foo, Bar}; #[rustc_if_this_changed] impl Foo for u32 { } @@ -28,7 +28,7 @@ mod x { } mod y { - use {Foo, Bar}; + use crate::{Foo, Bar}; #[rustc_then_this_would_need(typeck)] //~ ERROR OK pub fn with_char() { @@ -37,7 +37,7 @@ mod y { } mod z { - use y; + use crate::y; #[rustc_then_this_would_need(typeck)] //~ ERROR no path pub fn z() { diff --git a/tests/ui/dep-graph/dep-graph-trait-impl-two-traits.rs b/tests/ui/dep-graph/dep-graph-trait-impl-two-traits.rs index 7c612158bf0..859505a4a7a 100644 --- a/tests/ui/dep-graph/dep-graph-trait-impl-two-traits.rs +++ b/tests/ui/dep-graph/dep-graph-trait-impl-two-traits.rs @@ -18,7 +18,7 @@ pub trait Bar: Sized { } mod x { - use {Foo, Bar}; + use crate::{Foo, Bar}; #[rustc_if_this_changed] impl Foo for char { } @@ -27,7 +27,7 @@ mod x { } mod y { - use {Foo, Bar}; + use crate::{Foo, Bar}; #[rustc_then_this_would_need(typeck)] //~ ERROR no path pub fn call_bar() { @@ -36,7 +36,7 @@ mod y { } mod z { - use y; + use crate::y; #[rustc_then_this_would_need(typeck)] //~ ERROR no path pub fn z() { diff --git a/tests/ui/dep-graph/dep-graph-trait-impl.rs b/tests/ui/dep-graph/dep-graph-trait-impl.rs index 38cc88e567d..5cf0d34e007 100644 --- a/tests/ui/dep-graph/dep-graph-trait-impl.rs +++ b/tests/ui/dep-graph/dep-graph-trait-impl.rs @@ -14,7 +14,7 @@ pub trait Foo: Sized { } mod x { - use Foo; + use crate::Foo; #[rustc_if_this_changed] impl Foo for char { } @@ -23,7 +23,7 @@ mod x { } mod y { - use Foo; + use crate::Foo; #[rustc_then_this_would_need(typeck)] //~ ERROR OK pub fn with_char() { @@ -49,7 +49,7 @@ mod y { } mod z { - use y; + use crate::y; // These are expected to yield errors, because changes to `x` // affect the BODY of `y`, but not its signature. diff --git a/tests/ui/deprecation/deprecation-lint.rs b/tests/ui/deprecation/deprecation-lint.rs index dc11a4d56a2..5eda38732c8 100644 --- a/tests/ui/deprecation/deprecation-lint.rs +++ b/tests/ui/deprecation/deprecation-lint.rs @@ -71,7 +71,7 @@ mod cross_crate { <Foo as Trait>::trait_deprecated_text(&foo); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated_text`: text } - fn test_method_object(foo: &Trait) { + fn test_method_object(foo: &dyn Trait) { foo.trait_deprecated(); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated` foo.trait_deprecated_text(); //~ ERROR use of deprecated method `deprecation_lint::Trait::trait_deprecated_text`: text } @@ -299,7 +299,7 @@ mod this_crate { <Foo as Trait>::trait_deprecated_text(&foo); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated_text`: text } - fn test_method_object(foo: &Trait) { + fn test_method_object(foo: &dyn Trait) { foo.trait_deprecated(); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated` foo.trait_deprecated_text(); //~ ERROR use of deprecated method `this_crate::Trait::trait_deprecated_text`: text } diff --git a/tests/ui/derived-errors/issue-31997.rs b/tests/ui/derived-errors/issue-31997.rs index ff619313afb..59f19e4fde2 100644 --- a/tests/ui/derived-errors/issue-31997.rs +++ b/tests/ui/derived-errors/issue-31997.rs @@ -11,7 +11,7 @@ fn closure<F, T>(x: F) -> Result<T, ()> } fn foo() -> Result<(), ()> { - try!(closure(|| bar(core::ptr::null_mut()))); //~ ERROR cannot find function `bar` in this scope + closure(|| bar(core::ptr::null_mut()))?; //~ ERROR cannot find function `bar` in this scope Ok(()) } diff --git a/tests/ui/derived-errors/issue-31997.stderr b/tests/ui/derived-errors/issue-31997.stderr index 7d6415fef83..f5afb94fbd6 100644 --- a/tests/ui/derived-errors/issue-31997.stderr +++ b/tests/ui/derived-errors/issue-31997.stderr @@ -1,8 +1,8 @@ error[E0425]: cannot find function `bar` in this scope - --> $DIR/issue-31997.rs:14:21 + --> $DIR/issue-31997.rs:14:16 | -LL | try!(closure(|| bar(core::ptr::null_mut()))); - | ^^^ not found in this scope +LL | closure(|| bar(core::ptr::null_mut()))?; + | ^^^ not found in this scope error: aborting due to 1 previous error diff --git a/tests/ui/derives/clone-debug-dead-code.stderr b/tests/ui/derives/clone-debug-dead-code.stderr index 38be486e332..34b7f929ec5 100644 --- a/tests/ui/derives/clone-debug-dead-code.stderr +++ b/tests/ui/derives/clone-debug-dead-code.stderr @@ -40,7 +40,7 @@ LL | struct D { f: () } | | | field in this struct | - = note: `D` has derived impls for the traits `Clone` and `Debug`, but these are intentionally ignored during dead code analysis + = note: `D` has derived impls for the traits `Debug` and `Clone`, but these are intentionally ignored during dead code analysis error: field `f` is never read --> $DIR/clone-debug-dead-code.rs:21:12 diff --git a/tests/ui/deriving/deriving-all-codegen.rs b/tests/ui/deriving/deriving-all-codegen.rs index eab2b4f1f53..e2b6804fbd1 100644 --- a/tests/ui/deriving/deriving-all-codegen.rs +++ b/tests/ui/deriving/deriving-all-codegen.rs @@ -45,6 +45,22 @@ struct Big { b1: u32, b2: u32, b3: u32, b4: u32, b5: u32, b6: u32, b7: u32, b8: u32, } +// It is more efficient to compare scalar types before non-scalar types. +#[derive(PartialEq, PartialOrd)] +struct Reorder { + b1: Option<f32>, + b2: u16, + b3: &'static str, + b4: i8, + b5: u128, + _b: *mut &'static dyn FnMut() -> (), + b6: f64, + b7: &'static mut (), + b8: char, + b9: &'static [i64], + b10: &'static *const bool, +} + // A struct that doesn't impl `Copy`, which means it gets the non-simple // `clone` implemention that clones the fields individually. #[derive(Clone)] @@ -130,6 +146,20 @@ enum Mixed { S { d1: Option<u32>, d2: Option<i32> }, } +// When comparing enum variant it is more efficient to compare scalar types before non-scalar types. +#[derive(PartialEq, PartialOrd)] +enum ReorderEnum { + A(i32), + B, + C(i8), + D, + E, + F, + G(&'static mut str, *const u8, *const dyn Fn() -> ()), + H, + I, +} + // An enum with no fieldless variants. Note that `Default` cannot be derived // for this enum. #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] diff --git a/tests/ui/deriving/deriving-all-codegen.stdout b/tests/ui/deriving/deriving-all-codegen.stdout index 6503c870990..fa8f249373d 100644 --- a/tests/ui/deriving/deriving-all-codegen.stdout +++ b/tests/ui/deriving/deriving-all-codegen.stdout @@ -419,6 +419,100 @@ impl ::core::cmp::Ord for Big { } } +// It is more efficient to compare scalar types before non-scalar types. +struct Reorder { + b1: Option<f32>, + b2: u16, + b3: &'static str, + b4: i8, + b5: u128, + _b: *mut &'static dyn FnMut() -> (), + b6: f64, + b7: &'static mut (), + b8: char, + b9: &'static [i64], + b10: &'static *const bool, +} +#[automatically_derived] +impl ::core::marker::StructuralPartialEq for Reorder { } +#[automatically_derived] +impl ::core::cmp::PartialEq for Reorder { + #[inline] + fn eq(&self, other: &Reorder) -> bool { + self.b2 == other.b2 && self.b4 == other.b4 && self.b5 == other.b5 && + self.b6 == other.b6 && self.b7 == other.b7 && + self.b8 == other.b8 && self.b10 == other.b10 && + self.b1 == other.b1 && self.b3 == other.b3 && + self._b == other._b && self.b9 == other.b9 + } +} +#[automatically_derived] +impl ::core::cmp::PartialOrd for Reorder { + #[inline] + fn partial_cmp(&self, other: &Reorder) + -> ::core::option::Option<::core::cmp::Ordering> { + match ::core::cmp::PartialOrd::partial_cmp(&self.b1, &other.b1) { + ::core::option::Option::Some(::core::cmp::Ordering::Equal) => + match ::core::cmp::PartialOrd::partial_cmp(&self.b2, + &other.b2) { + ::core::option::Option::Some(::core::cmp::Ordering::Equal) + => + match ::core::cmp::PartialOrd::partial_cmp(&self.b3, + &other.b3) { + ::core::option::Option::Some(::core::cmp::Ordering::Equal) + => + match ::core::cmp::PartialOrd::partial_cmp(&self.b4, + &other.b4) { + ::core::option::Option::Some(::core::cmp::Ordering::Equal) + => + match ::core::cmp::PartialOrd::partial_cmp(&self.b5, + &other.b5) { + ::core::option::Option::Some(::core::cmp::Ordering::Equal) + => + match ::core::cmp::PartialOrd::partial_cmp(&self._b, + &other._b) { + ::core::option::Option::Some(::core::cmp::Ordering::Equal) + => + match ::core::cmp::PartialOrd::partial_cmp(&self.b6, + &other.b6) { + ::core::option::Option::Some(::core::cmp::Ordering::Equal) + => + match ::core::cmp::PartialOrd::partial_cmp(&self.b7, + &other.b7) { + ::core::option::Option::Some(::core::cmp::Ordering::Equal) + => + match ::core::cmp::PartialOrd::partial_cmp(&self.b8, + &other.b8) { + ::core::option::Option::Some(::core::cmp::Ordering::Equal) + => + match ::core::cmp::PartialOrd::partial_cmp(&self.b9, + &other.b9) { + ::core::option::Option::Some(::core::cmp::Ordering::Equal) + => + ::core::cmp::PartialOrd::partial_cmp(&self.b10, &other.b10), + cmp => cmp, + }, + cmp => cmp, + }, + cmp => cmp, + }, + cmp => cmp, + }, + cmp => cmp, + }, + cmp => cmp, + }, + cmp => cmp, + }, + cmp => cmp, + }, + cmp => cmp, + }, + cmp => cmp, + } + } +} + // A struct that doesn't impl `Copy`, which means it gets the non-simple // `clone` implemention that clones the fields individually. struct NonCopy(u32); @@ -1167,6 +1261,77 @@ impl ::core::cmp::Ord for Mixed { } } +// When comparing enum variant it is more efficient to compare scalar types before non-scalar types. +enum ReorderEnum { + A(i32), + B, + C(i8), + D, + E, + F, + G(&'static mut str, *const u8, *const dyn Fn() -> ()), + H, + I, +} +#[automatically_derived] +impl ::core::marker::StructuralPartialEq for ReorderEnum { } +#[automatically_derived] +impl ::core::cmp::PartialEq for ReorderEnum { + #[inline] + fn eq(&self, other: &ReorderEnum) -> bool { + let __self_discr = ::core::intrinsics::discriminant_value(self); + let __arg1_discr = ::core::intrinsics::discriminant_value(other); + __self_discr == __arg1_discr && + match (self, other) { + (ReorderEnum::A(__self_0), ReorderEnum::A(__arg1_0)) => + __self_0 == __arg1_0, + (ReorderEnum::C(__self_0), ReorderEnum::C(__arg1_0)) => + __self_0 == __arg1_0, + (ReorderEnum::G(__self_0, __self_1, __self_2), + ReorderEnum::G(__arg1_0, __arg1_1, __arg1_2)) => + __self_1 == __arg1_1 && __self_0 == __arg1_0 && + __self_2 == __arg1_2, + _ => true, + } + } +} +#[automatically_derived] +impl ::core::cmp::PartialOrd for ReorderEnum { + #[inline] + fn partial_cmp(&self, other: &ReorderEnum) + -> ::core::option::Option<::core::cmp::Ordering> { + let __self_discr = ::core::intrinsics::discriminant_value(self); + let __arg1_discr = ::core::intrinsics::discriminant_value(other); + match ::core::cmp::PartialOrd::partial_cmp(&__self_discr, + &__arg1_discr) { + ::core::option::Option::Some(::core::cmp::Ordering::Equal) => + match (self, other) { + (ReorderEnum::A(__self_0), ReorderEnum::A(__arg1_0)) => + ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0), + (ReorderEnum::C(__self_0), ReorderEnum::C(__arg1_0)) => + ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0), + (ReorderEnum::G(__self_0, __self_1, __self_2), + ReorderEnum::G(__arg1_0, __arg1_1, __arg1_2)) => + match ::core::cmp::PartialOrd::partial_cmp(__self_0, + __arg1_0) { + ::core::option::Option::Some(::core::cmp::Ordering::Equal) + => + match ::core::cmp::PartialOrd::partial_cmp(__self_1, + __arg1_1) { + ::core::option::Option::Some(::core::cmp::Ordering::Equal) + => ::core::cmp::PartialOrd::partial_cmp(__self_2, __arg1_2), + cmp => cmp, + }, + cmp => cmp, + }, + _ => + ::core::option::Option::Some(::core::cmp::Ordering::Equal), + }, + cmp => cmp, + } + } +} + // An enum with no fieldless variants. Note that `Default` cannot be derived // for this enum. enum Fielded { X(u32), Y(bool), Z(Option<i32>), } diff --git a/tests/ui/deriving/deriving-in-macro.rs b/tests/ui/deriving/deriving-in-macro.rs index 493c1415c7f..739d9b30682 100644 --- a/tests/ui/deriving/deriving-in-macro.rs +++ b/tests/ui/deriving/deriving-in-macro.rs @@ -1,5 +1,6 @@ -//@ run-pass +//@ check-pass #![allow(non_camel_case_types)] +#![allow(dead_code)] macro_rules! define_vec { () => ( diff --git a/tests/ui/destructuring-assignment/bad-let-in-destructure.rs b/tests/ui/destructuring-assignment/bad-let-in-destructure.rs new file mode 100644 index 00000000000..70a0403fc38 --- /dev/null +++ b/tests/ui/destructuring-assignment/bad-let-in-destructure.rs @@ -0,0 +1,13 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/141844>. + +fn main() { + // The following expression gets desugared into something like: + // ``` + // let (lhs,) = x; (let x = 1) = lhs; + // ``` + // This used to ICE since we haven't yet declared the type for `x` when + // checking the first desugared statement, whose RHS resolved to `x` since + // in the AST, the `let` expression was visited first. + (let x = 1,) = x; + //~^ ERROR expected expression, found `let` statement +} diff --git a/tests/ui/destructuring-assignment/bad-let-in-destructure.stderr b/tests/ui/destructuring-assignment/bad-let-in-destructure.stderr new file mode 100644 index 00000000000..622d714ba2f --- /dev/null +++ b/tests/ui/destructuring-assignment/bad-let-in-destructure.stderr @@ -0,0 +1,10 @@ +error: expected expression, found `let` statement + --> $DIR/bad-let-in-destructure.rs:11:4 + | +LL | (let x = 1,) = x; + | ^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: aborting due to 1 previous error + diff --git a/tests/ui/command-line-diagnostics.rs b/tests/ui/diagnostic-width/command-line-error-format-human.rs index 8a6cf5b8e32..a2cfbbcbeb1 100644 --- a/tests/ui/command-line-diagnostics.rs +++ b/tests/ui/diagnostic-width/command-line-error-format-human.rs @@ -1,4 +1,5 @@ -// This test checks the output format without the intermediate json representation +//! This test checks the output format without the intermediate json representation + //@ compile-flags: --error-format=human pub fn main() { diff --git a/tests/ui/command-line-diagnostics.stderr b/tests/ui/diagnostic-width/command-line-error-format-human.stderr index 6d33fb4172f..b4b78239f88 100644 --- a/tests/ui/command-line-diagnostics.stderr +++ b/tests/ui/diagnostic-width/command-line-error-format-human.stderr @@ -1,5 +1,5 @@ error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/command-line-diagnostics.rs:6:5 + --> $DIR/command-line-error-format-human.rs:7:5 | LL | let x = 42; | - first assignment to `x` diff --git a/tests/ui/conservative_impl_trait.rs b/tests/ui/diagnostic-width/impl-trait-invalid-iterator-error.rs index b7f795eadb7..05588932395 100644 --- a/tests/ui/conservative_impl_trait.rs +++ b/tests/ui/diagnostic-width/impl-trait-invalid-iterator-error.rs @@ -1,4 +1,4 @@ -// #39872, #39553 +//! Test for #39872 and #39553 fn will_ice(something: &u32) -> impl Iterator<Item = &u32> { //~^ ERROR `()` is not an iterator diff --git a/tests/ui/conservative_impl_trait.stderr b/tests/ui/diagnostic-width/impl-trait-invalid-iterator-error.stderr index eecdb6f9266..0146fa7a28b 100644 --- a/tests/ui/conservative_impl_trait.stderr +++ b/tests/ui/diagnostic-width/impl-trait-invalid-iterator-error.stderr @@ -1,5 +1,5 @@ error[E0277]: `()` is not an iterator - --> $DIR/conservative_impl_trait.rs:3:33 + --> $DIR/impl-trait-invalid-iterator-error.rs:3:33 | LL | fn will_ice(something: &u32) -> impl Iterator<Item = &u32> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator diff --git a/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.rs b/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.rs index b76b550fcb2..a0e497fa045 100644 --- a/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.rs +++ b/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.rs @@ -3,7 +3,7 @@ //@ reference: attributes.diagnostic.on_unimplemented.syntax //@ reference: attributes.diagnostic.on_unimplemented.invalid-formats #[diagnostic::on_unimplemented( - on(_Self = "&str"), + on(Self = "&str"), //~^WARN malformed `on_unimplemented` attribute //~|WARN malformed `on_unimplemented` attribute message = "trait has `{Self}` and `{T}` as params", @@ -41,7 +41,7 @@ impl Bar for i32 {} //~|WARN there is no parameter `integral` on trait `Baz` //~|WARN there is no parameter `integer` on trait `Baz` //~|WARN there is no parameter `integer` on trait `Baz` - label = "{float}{_Self}{crate_local}{Trait}{ItemContext}" + label = "{float}{_Self}{crate_local}{Trait}{ItemContext}{This}" //~^WARN there is no parameter `float` on trait `Baz` //~|WARN there is no parameter `float` on trait `Baz` //~|WARN there is no parameter `_Self` on trait `Baz` @@ -52,6 +52,8 @@ impl Bar for i32 {} //~|WARN there is no parameter `Trait` on trait `Baz` //~|WARN there is no parameter `ItemContext` on trait `Baz` //~|WARN there is no parameter `ItemContext` on trait `Baz` + //~|WARN there is no parameter `This` on trait `Baz` + //~|WARN there is no parameter `This` on trait `Baz` )] trait Baz {} diff --git a/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.stderr b/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.stderr index 88816a98dcf..8dace7d9052 100644 --- a/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.stderr +++ b/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.stderr @@ -9,8 +9,8 @@ LL | #[diagnostic::on_unimplemented(message = "Not allowed to apply it on a impl warning: malformed `on_unimplemented` attribute --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:6:5 | -LL | on(_Self = "&str"), - | ^^^^^^^^^^^^^^^^^^ invalid option found here +LL | on(Self = "&str"), + | ^^^^^^^^^^^^^^^^^ invalid option found here | = help: only `message`, `note` and `label` are allowed as options @@ -81,7 +81,7 @@ LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}", warning: there is no parameter `float` on trait `Baz` --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:44:15 | -LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}" +LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}{This}" | ^^^^^ | = help: expect either a generic argument name or `{Self}` as format argument @@ -89,7 +89,7 @@ LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}" warning: there is no parameter `_Self` on trait `Baz` --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:44:22 | -LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}" +LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}{This}" | ^^^^^ | = help: expect either a generic argument name or `{Self}` as format argument @@ -97,7 +97,7 @@ LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}" warning: there is no parameter `crate_local` on trait `Baz` --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:44:29 | -LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}" +LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}{This}" | ^^^^^^^^^^^ | = help: expect either a generic argument name or `{Self}` as format argument @@ -105,7 +105,7 @@ LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}" warning: there is no parameter `Trait` on trait `Baz` --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:44:42 | -LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}" +LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}{This}" | ^^^^^ | = help: expect either a generic argument name or `{Self}` as format argument @@ -113,16 +113,24 @@ LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}" warning: there is no parameter `ItemContext` on trait `Baz` --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:44:49 | -LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}" +LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}{This}" | ^^^^^^^^^^^ | = help: expect either a generic argument name or `{Self}` as format argument +warning: there is no parameter `This` on trait `Baz` + --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:44:62 + | +LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}{This}" + | ^^^^ + | + = help: expect either a generic argument name or `{Self}` as format argument + warning: malformed `on_unimplemented` attribute --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:6:5 | -LL | on(_Self = "&str"), - | ^^^^^^^^^^^^^^^^^^ invalid option found here +LL | on(Self = "&str"), + | ^^^^^^^^^^^^^^^^^ invalid option found here | = help: only `message`, `note` and `label` are allowed as options = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` @@ -146,7 +154,7 @@ LL | append_const_msg = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: trait has `()` and `i32` as params - --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:63:15 + --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:65:15 | LL | takes_foo(()); | --------- ^^ trait has `()` and `i32` as params @@ -161,7 +169,7 @@ help: this trait has no implementations, consider adding one LL | trait Foo<T> {} | ^^^^^^^^^^^^ note: required by a bound in `takes_foo` - --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:58:22 + --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:60:22 | LL | fn takes_foo(_: impl Foo<i32>) {} | ^^^^^^^^ required by this bound in `takes_foo` @@ -176,7 +184,7 @@ LL | #[diagnostic::on_unimplemented = "Message"] = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the trait bound `(): Bar` is not satisfied - --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:65:15 + --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:67:15 | LL | takes_bar(()); | --------- ^^ the trait `Bar` is not implemented for `()` @@ -185,7 +193,7 @@ LL | takes_bar(()); | = help: the trait `Bar` is implemented for `i32` note: required by a bound in `takes_bar` - --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:59:22 + --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:61:22 | LL | fn takes_bar(_: impl Bar) {} | ^^^ required by this bound in `takes_bar` @@ -238,7 +246,7 @@ LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}", warning: there is no parameter `float` on trait `Baz` --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:44:15 | -LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}" +LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}{This}" | ^^^^^ | = help: expect either a generic argument name or `{Self}` as format argument @@ -247,7 +255,7 @@ LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}" warning: there is no parameter `_Self` on trait `Baz` --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:44:22 | -LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}" +LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}{This}" | ^^^^^ | = help: expect either a generic argument name or `{Self}` as format argument @@ -256,7 +264,7 @@ LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}" warning: there is no parameter `crate_local` on trait `Baz` --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:44:29 | -LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}" +LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}{This}" | ^^^^^^^^^^^ | = help: expect either a generic argument name or `{Self}` as format argument @@ -265,7 +273,7 @@ LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}" warning: there is no parameter `Trait` on trait `Baz` --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:44:42 | -LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}" +LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}{This}" | ^^^^^ | = help: expect either a generic argument name or `{Self}` as format argument @@ -274,32 +282,41 @@ LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}" warning: there is no parameter `ItemContext` on trait `Baz` --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:44:49 | -LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}" +LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}{This}" | ^^^^^^^^^^^ | = help: expect either a generic argument name or `{Self}` as format argument = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +warning: there is no parameter `This` on trait `Baz` + --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:44:62 + | +LL | label = "{float}{_Self}{crate_local}{Trait}{ItemContext}{This}" + | ^^^^ + | + = help: expect either a generic argument name or `{Self}` as format argument + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0277]: {from_desugaring}{direct}{cause}{integral}{integer} - --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:67:15 + --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:69:15 | LL | takes_baz(()); - | --------- ^^ {float}{_Self}{crate_local}{Trait}{ItemContext} + | --------- ^^ {float}{_Self}{crate_local}{Trait}{ItemContext}{This} | | | required by a bound introduced by this call | = help: the trait `Baz` is not implemented for `()` help: this trait has no implementations, consider adding one - --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:56:1 + --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:58:1 | LL | trait Baz {} | ^^^^^^^^^ note: required by a bound in `takes_baz` - --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:60:22 + --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:62:22 | LL | fn takes_baz(_: impl Baz) {} | ^^^ required by this bound in `takes_baz` -error: aborting due to 3 previous errors; 29 warnings emitted +error: aborting due to 3 previous errors; 31 warnings emitted For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/diagnostic_namespace/on_unimplemented/do_not_fail_parsing_on_invalid_options_1.rs b/tests/ui/diagnostic_namespace/on_unimplemented/do_not_fail_parsing_on_invalid_options_1.rs index 8328c10d2a0..08eb5707e90 100644 --- a/tests/ui/diagnostic_namespace/on_unimplemented/do_not_fail_parsing_on_invalid_options_1.rs +++ b/tests/ui/diagnostic_namespace/on_unimplemented/do_not_fail_parsing_on_invalid_options_1.rs @@ -14,11 +14,15 @@ struct Bar {} //~|WARN malformed `on_unimplemented` attribute trait Baz {} -#[diagnostic::on_unimplemented(message = "Boom", on(_Self = "i32", message = "whatever"))] +#[diagnostic::on_unimplemented(message = "Boom", on(Self = "i32", message = "whatever"))] //~^WARN malformed `on_unimplemented` attribute //~|WARN malformed `on_unimplemented` attribute trait Boom {} +#[diagnostic::on_unimplemented(message = "Boom", on(_Self = "i32", message = "whatever"))] +//~^WARN malformed `on_unimplemented` attribute +trait _Self {} + #[diagnostic::on_unimplemented = "boom"] //~^WARN malformed `on_unimplemented` attribute trait Doom {} diff --git a/tests/ui/diagnostic_namespace/on_unimplemented/do_not_fail_parsing_on_invalid_options_1.stderr b/tests/ui/diagnostic_namespace/on_unimplemented/do_not_fail_parsing_on_invalid_options_1.stderr index 4dd8c1afca0..80790dc3f79 100644 --- a/tests/ui/diagnostic_namespace/on_unimplemented/do_not_fail_parsing_on_invalid_options_1.stderr +++ b/tests/ui/diagnostic_namespace/on_unimplemented/do_not_fail_parsing_on_invalid_options_1.stderr @@ -25,13 +25,21 @@ LL | #[diagnostic::on_unimplemented(message = "Boom", unsupported = "Bar")] warning: malformed `on_unimplemented` attribute --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:17:50 | +LL | #[diagnostic::on_unimplemented(message = "Boom", on(Self = "i32", message = "whatever"))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here + | + = help: only `message`, `note` and `label` are allowed as options + +warning: malformed `on_unimplemented` attribute + --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:22:50 + | LL | #[diagnostic::on_unimplemented(message = "Boom", on(_Self = "i32", message = "whatever"))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here | = help: only `message`, `note` and `label` are allowed as options warning: malformed `on_unimplemented` attribute - --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:22:32 + --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:26:32 | LL | #[diagnostic::on_unimplemented = "boom"] | ^^^^^^^^ invalid option found here @@ -39,7 +47,7 @@ LL | #[diagnostic::on_unimplemented = "boom"] = help: only `message`, `note` and `label` are allowed as options warning: missing options for `on_unimplemented` attribute - --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:26:1 + --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:30:1 | LL | #[diagnostic::on_unimplemented] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -47,7 +55,7 @@ LL | #[diagnostic::on_unimplemented] = help: at least one of the `message`, `note` and `label` options are expected warning: there is no parameter `DoesNotExist` on trait `Test` - --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:31:44 + --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:35:44 | LL | #[diagnostic::on_unimplemented(message = "{DoesNotExist}")] | ^^^^^^^^^^^^ @@ -64,7 +72,7 @@ LL | #[diagnostic::on_unimplemented(unsupported = "foo")] = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the trait bound `i32: Foo` is not satisfied - --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:43:14 + --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:47:14 | LL | take_foo(1_i32); | -------- ^^^^^ the trait `Foo` is not implemented for `i32` @@ -77,7 +85,7 @@ help: this trait has no implementations, consider adding one LL | trait Foo {} | ^^^^^^^^^ note: required by a bound in `take_foo` - --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:36:21 + --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:40:21 | LL | fn take_foo(_: impl Foo) {} | ^^^ required by this bound in `take_foo` @@ -92,7 +100,7 @@ LL | #[diagnostic::on_unimplemented(message = "Boom", unsupported = "Bar")] = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: Boom - --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:45:14 + --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:49:14 | LL | take_baz(1_i32); | -------- ^^^^^ the trait `Baz` is not implemented for `i32` @@ -105,7 +113,7 @@ help: this trait has no implementations, consider adding one LL | trait Baz {} | ^^^^^^^^^ note: required by a bound in `take_baz` - --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:37:21 + --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:41:21 | LL | fn take_baz(_: impl Baz) {} | ^^^ required by this bound in `take_baz` @@ -113,14 +121,14 @@ LL | fn take_baz(_: impl Baz) {} warning: malformed `on_unimplemented` attribute --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:17:50 | -LL | #[diagnostic::on_unimplemented(message = "Boom", on(_Self = "i32", message = "whatever"))] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here +LL | #[diagnostic::on_unimplemented(message = "Boom", on(Self = "i32", message = "whatever"))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here | = help: only `message`, `note` and `label` are allowed as options = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: Boom - --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:47:15 + --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:51:15 | LL | take_boom(1_i32); | --------- ^^^^^ the trait `Boom` is not implemented for `i32` @@ -133,13 +141,13 @@ help: this trait has no implementations, consider adding one LL | trait Boom {} | ^^^^^^^^^^ note: required by a bound in `take_boom` - --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:38:22 + --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:42:22 | LL | fn take_boom(_: impl Boom) {} | ^^^^ required by this bound in `take_boom` warning: missing options for `on_unimplemented` attribute - --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:26:1 + --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:30:1 | LL | #[diagnostic::on_unimplemented] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -148,7 +156,7 @@ LL | #[diagnostic::on_unimplemented] = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the trait bound `i32: Whatever` is not satisfied - --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:49:19 + --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:53:19 | LL | take_whatever(1_i32); | ------------- ^^^^^ the trait `Whatever` is not implemented for `i32` @@ -156,18 +164,18 @@ LL | take_whatever(1_i32); | required by a bound introduced by this call | help: this trait has no implementations, consider adding one - --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:29:1 + --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:33:1 | LL | trait Whatever {} | ^^^^^^^^^^^^^^ note: required by a bound in `take_whatever` - --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:39:26 + --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:43:26 | LL | fn take_whatever(_: impl Whatever) {} | ^^^^^^^^ required by this bound in `take_whatever` warning: there is no parameter `DoesNotExist` on trait `Test` - --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:31:44 + --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:35:44 | LL | #[diagnostic::on_unimplemented(message = "{DoesNotExist}")] | ^^^^^^^^^^^^ @@ -176,7 +184,7 @@ LL | #[diagnostic::on_unimplemented(message = "{DoesNotExist}")] = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: {DoesNotExist} - --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:51:15 + --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:55:15 | LL | take_test(()); | --------- ^^ the trait `Test` is not implemented for `()` @@ -184,16 +192,16 @@ LL | take_test(()); | required by a bound introduced by this call | help: this trait has no implementations, consider adding one - --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:34:1 + --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:38:1 | LL | trait Test {} | ^^^^^^^^^^ note: required by a bound in `take_test` - --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:40:22 + --> $DIR/do_not_fail_parsing_on_invalid_options_1.rs:44:22 | LL | fn take_test(_: impl Test) {} | ^^^^ required by this bound in `take_test` -error: aborting due to 5 previous errors; 12 warnings emitted +error: aborting due to 5 previous errors; 13 warnings emitted For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/did_you_mean/E0178.rs b/tests/ui/did_you_mean/E0178.rs index 095df640c38..cdaddac35a3 100644 --- a/tests/ui/did_you_mean/E0178.rs +++ b/tests/ui/did_you_mean/E0178.rs @@ -1,3 +1,4 @@ +//@ edition:2015 #![allow(bare_trait_objects)] trait Foo {} diff --git a/tests/ui/did_you_mean/E0178.stderr b/tests/ui/did_you_mean/E0178.stderr index 36e4dbdf7c4..7b69f860381 100644 --- a/tests/ui/did_you_mean/E0178.stderr +++ b/tests/ui/did_you_mean/E0178.stderr @@ -1,5 +1,5 @@ error[E0178]: expected a path on the left-hand side of `+` - --> $DIR/E0178.rs:6:8 + --> $DIR/E0178.rs:7:8 | LL | w: &'a Foo + Copy, | ^^^^^^^ @@ -10,7 +10,7 @@ LL | w: &'a (Foo + Copy), | + + error[E0178]: expected a path on the left-hand side of `+` - --> $DIR/E0178.rs:7:8 + --> $DIR/E0178.rs:8:8 | LL | x: &'a Foo + 'a, | ^^^^^^^ @@ -21,7 +21,7 @@ LL | x: &'a (Foo + 'a), | + + error[E0178]: expected a path on the left-hand side of `+` - --> $DIR/E0178.rs:8:8 + --> $DIR/E0178.rs:9:8 | LL | y: &'a mut Foo + 'a, | ^^^^^^^^^^^ @@ -32,7 +32,7 @@ LL | y: &'a mut (Foo + 'a), | + + error[E0178]: expected a path on the left-hand side of `+` - --> $DIR/E0178.rs:9:8 + --> $DIR/E0178.rs:10:8 | LL | z: fn() -> Foo + 'a, | ^^^^^^^^^^^----- diff --git a/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.rs b/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.rs index 9cd32ffeb6d..eff431f4665 100644 --- a/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.rs +++ b/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.rs @@ -1,7 +1,9 @@ +//@ edition: 2015 #![allow(bare_trait_objects)] fn main() { let _: &Copy + 'static; //~ ERROR expected a path //~^ ERROR is not dyn compatible let _: &'static Copy + 'static; //~ ERROR expected a path + //~^ ERROR is not dyn compatible } diff --git a/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr b/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr index 762b37b9e9d..b051d181ad8 100644 --- a/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr +++ b/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr @@ -1,5 +1,5 @@ error[E0178]: expected a path on the left-hand side of `+` - --> $DIR/trait-object-reference-without-parens-suggestion.rs:4:12 + --> $DIR/trait-object-reference-without-parens-suggestion.rs:5:12 | LL | let _: &Copy + 'static; | ^^^^^ @@ -10,7 +10,7 @@ LL | let _: &(Copy + 'static); | + + error[E0178]: expected a path on the left-hand side of `+` - --> $DIR/trait-object-reference-without-parens-suggestion.rs:6:12 + --> $DIR/trait-object-reference-without-parens-suggestion.rs:7:12 | LL | let _: &'static Copy + 'static; | ^^^^^^^^^^^^^ @@ -21,16 +21,26 @@ LL | let _: &'static (Copy + 'static); | + + error[E0038]: the trait `Copy` is not dyn compatible - --> $DIR/trait-object-reference-without-parens-suggestion.rs:4:12 + --> $DIR/trait-object-reference-without-parens-suggestion.rs:5:13 | LL | let _: &Copy + 'static; - | ^^^^^ `Copy` is not dyn compatible + | ^^^^ `Copy` is not dyn compatible | = note: the trait is not dyn compatible because it requires `Self: Sized` = 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> -error: aborting due to 3 previous errors +error[E0038]: the trait `Copy` is not dyn compatible + --> $DIR/trait-object-reference-without-parens-suggestion.rs:7:21 + | +LL | let _: &'static Copy + 'static; + | ^^^^ `Copy` is not dyn compatible + | + = note: the trait is not dyn compatible because it requires `Self: Sized` + = 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> + +error: aborting due to 4 previous errors Some errors have detailed explanations: E0038, E0178. For more information about an error, try `rustc --explain E0038`. diff --git a/tests/ui/drop/drop-order-comparisons.e2021.fixed b/tests/ui/drop/drop-order-comparisons.e2021.fixed index 71158cb8062..42f805923ec 100644 --- a/tests/ui/drop/drop-order-comparisons.e2021.fixed +++ b/tests/ui/drop/drop-order-comparisons.e2021.fixed @@ -24,6 +24,7 @@ //@ [e2024] edition: 2024 //@ run-pass +#![feature(if_let_guard)] #![cfg_attr(e2021, feature(let_chains))] #![cfg_attr(e2021, warn(rust_2024_compatibility))] @@ -344,6 +345,25 @@ fn t_if_let_chains_then() { e.assert(9); } +#[rustfmt::skip] +fn t_guard_if_let_chains_then() { + let e = Events::new(); + _ = match () { + () if e.ok(1).is_ok() + && let true = e.ok(9).is_ok() + && let Ok(_v) = e.ok(8) + && let Ok(_) = e.ok(7) + && let Ok(_) = e.ok(6).as_ref() + && e.ok(2).is_ok() + && let Ok(_v) = e.ok(5) + && let Ok(_) = e.ok(4).as_ref() => { + e.mark(3); + } + _ => {} + }; + e.assert(9); +} + #[cfg(e2021)] #[rustfmt::skip] fn t_if_let_nested_else() { @@ -484,6 +504,25 @@ fn t_if_let_chains_then_else() { e.assert(9); } +#[rustfmt::skip] +fn t_guard_if_let_chains_then_else() { + let e = Events::new(); + _ = match () { + () if e.ok(1).is_ok() + && let true = e.ok(8).is_ok() + && let Ok(_v) = e.ok(7) + && let Ok(_) = e.ok(6) + && let Ok(_) = e.ok(5).as_ref() + && e.ok(2).is_ok() + && let Ok(_v) = e.ok(4) + && let Ok(_) = e.err(3) => {} + _ => { + e.mark(9); + } + }; + e.assert(9); +} + fn main() { t_bindings(); t_tuples(); @@ -502,10 +541,12 @@ fn main() { t_if_let_nested_then(); t_let_else_chained_then(); t_if_let_chains_then(); + t_guard_if_let_chains_then(); t_if_let_nested_else(); t_if_let_nested_then_else(); t_let_else_chained_then_else(); t_if_let_chains_then_else(); + t_guard_if_let_chains_then_else(); } // # Test scaffolding @@ -548,7 +589,7 @@ impl Events { Ok(LogDrop(self, m)) } /// Return an `Err` value that logs its drop. - fn err(&self, m: u64) -> Result<LogDrop, LogDrop> { + fn err(&self, m: u64) -> Result<LogDrop<'_>, LogDrop<'_>> { Err(LogDrop(self, m)) } /// Log an event. diff --git a/tests/ui/drop/drop-order-comparisons.e2021.stderr b/tests/ui/drop/drop-order-comparisons.e2021.stderr index 0717a8c1b9b..8b93376cc0d 100644 --- a/tests/ui/drop/drop-order-comparisons.e2021.stderr +++ b/tests/ui/drop/drop-order-comparisons.e2021.stderr @@ -1,5 +1,5 @@ warning: relative drop order changing in Rust 2024 - --> $DIR/drop-order-comparisons.rs:76:9 + --> $DIR/drop-order-comparisons.rs:77:9 | LL | _ = ({ | _________- @@ -29,35 +29,35 @@ LL | | }, e.mark(3), e.ok(4)); = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html> note: `#3` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:571:1 + --> $DIR/drop-order-comparisons.rs:612:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: `#1` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:571:1 + --> $DIR/drop-order-comparisons.rs:612:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: `_v` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:571:1 + --> $DIR/drop-order-comparisons.rs:612:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: `#2` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:571:1 + --> $DIR/drop-order-comparisons.rs:612:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages note: the lint level is defined here - --> $DIR/drop-order-comparisons.rs:28:25 + --> $DIR/drop-order-comparisons.rs:29:25 | LL | #![cfg_attr(e2021, warn(rust_2024_compatibility))] | ^^^^^^^^^^^^^^^^^^^^^^^ = note: `#[warn(tail_expr_drop_order)]` implied by `#[warn(rust_2024_compatibility)]` warning: relative drop order changing in Rust 2024 - --> $DIR/drop-order-comparisons.rs:100:45 + --> $DIR/drop-order-comparisons.rs:101:45 | LL | _ = ({ | _________- @@ -77,19 +77,19 @@ LL | | }, e.mark(1), e.ok(4)); = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html> note: `#2` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:571:1 + --> $DIR/drop-order-comparisons.rs:612:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: `#1` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:571:1 + --> $DIR/drop-order-comparisons.rs:612:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages warning: relative drop order changing in Rust 2024 - --> $DIR/drop-order-comparisons.rs:100:19 + --> $DIR/drop-order-comparisons.rs:101:19 | LL | _ = ({ | _________- @@ -109,19 +109,19 @@ LL | | }, e.mark(1), e.ok(4)); = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html> note: `#2` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:571:1 + --> $DIR/drop-order-comparisons.rs:612:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: `#1` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:571:1 + --> $DIR/drop-order-comparisons.rs:612:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages warning: relative drop order changing in Rust 2024 - --> $DIR/drop-order-comparisons.rs:221:24 + --> $DIR/drop-order-comparisons.rs:222:24 | LL | _ = ({ | _________- @@ -141,19 +141,19 @@ LL | | }, e.mark(2), e.ok(3)); = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html> note: `#2` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:571:1 + --> $DIR/drop-order-comparisons.rs:612:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: `#1` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:571:1 + --> $DIR/drop-order-comparisons.rs:612:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages warning: relative drop order changing in Rust 2024 - --> $DIR/drop-order-comparisons.rs:247:24 + --> $DIR/drop-order-comparisons.rs:248:24 | LL | _ = ({ | _________- @@ -173,19 +173,19 @@ LL | | }, e.mark(2), e.ok(3)); = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html> note: `#2` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:571:1 + --> $DIR/drop-order-comparisons.rs:612:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: `#1` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:571:1 + --> $DIR/drop-order-comparisons.rs:612:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:123:13 + --> $DIR/drop-order-comparisons.rs:124:13 | LL | _ = (if let Ok(_) = e.ok(4).as_ref() { | ^^^^^^^^^^^^-------^^^^^^^^^ @@ -195,12 +195,12 @@ LL | _ = (if let Ok(_) = e.ok(4).as_ref() { = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-if-let-scope.html> note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:571:1 + --> $DIR/drop-order-comparisons.rs:612:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:127:5 + --> $DIR/drop-order-comparisons.rs:128:5 | LL | }, e.mark(2), e.ok(3)); | ^ @@ -215,7 +215,7 @@ LL ~ } _ => {}}, e.mark(2), e.ok(3)); | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:145:13 + --> $DIR/drop-order-comparisons.rs:146:13 | LL | _ = (if let Ok(_) = e.err(4).as_ref() {} else { | ^^^^^^^^^^^^--------^^^^^^^^^ @@ -225,12 +225,12 @@ LL | _ = (if let Ok(_) = e.err(4).as_ref() {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-if-let-scope.html> note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:571:1 + --> $DIR/drop-order-comparisons.rs:612:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:145:44 + --> $DIR/drop-order-comparisons.rs:146:44 | LL | _ = (if let Ok(_) = e.err(4).as_ref() {} else { | ^ @@ -244,7 +244,7 @@ LL ~ }}, e.mark(2), e.ok(3)); | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:247:12 + --> $DIR/drop-order-comparisons.rs:248:12 | LL | if let Ok(_) = e.err(4).as_ref() {} else { | ^^^^^^^^^^^^--------^^^^^^^^^ @@ -254,12 +254,12 @@ LL | if let Ok(_) = e.err(4).as_ref() {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-if-let-scope.html> note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:571:1 + --> $DIR/drop-order-comparisons.rs:612:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:247:43 + --> $DIR/drop-order-comparisons.rs:248:43 | LL | if let Ok(_) = e.err(4).as_ref() {} else { | ^ @@ -273,7 +273,7 @@ LL ~ }} | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:352:12 + --> $DIR/drop-order-comparisons.rs:372:12 | LL | if let true = e.err(9).is_ok() {} else { | ^^^^^^^^^^^--------^^^^^^^^ @@ -283,12 +283,12 @@ LL | if let true = e.err(9).is_ok() {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-if-let-scope.html> note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:571:1 + --> $DIR/drop-order-comparisons.rs:612:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:352:41 + --> $DIR/drop-order-comparisons.rs:372:41 | LL | if let true = e.err(9).is_ok() {} else { | ^ @@ -302,7 +302,7 @@ LL ~ }}}}}}}}}; | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:355:12 + --> $DIR/drop-order-comparisons.rs:375:12 | LL | if let Ok(_v) = e.err(8) {} else { | ^^^^^^^^^^^^^-------- @@ -312,12 +312,12 @@ LL | if let Ok(_v) = e.err(8) {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-if-let-scope.html> note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:571:1 + --> $DIR/drop-order-comparisons.rs:612:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:355:35 + --> $DIR/drop-order-comparisons.rs:375:35 | LL | if let Ok(_v) = e.err(8) {} else { | ^ @@ -331,7 +331,7 @@ LL ~ }}}}}}}}}; | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:358:12 + --> $DIR/drop-order-comparisons.rs:378:12 | LL | if let Ok(_) = e.err(7) {} else { | ^^^^^^^^^^^^-------- @@ -341,12 +341,12 @@ LL | if let Ok(_) = e.err(7) {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-if-let-scope.html> note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:571:1 + --> $DIR/drop-order-comparisons.rs:612:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:358:34 + --> $DIR/drop-order-comparisons.rs:378:34 | LL | if let Ok(_) = e.err(7) {} else { | ^ @@ -360,7 +360,7 @@ LL ~ }}}}}}}}}; | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:361:12 + --> $DIR/drop-order-comparisons.rs:381:12 | LL | if let Ok(_) = e.err(6).as_ref() {} else { | ^^^^^^^^^^^^--------^^^^^^^^^ @@ -370,12 +370,12 @@ LL | if let Ok(_) = e.err(6).as_ref() {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-if-let-scope.html> note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:571:1 + --> $DIR/drop-order-comparisons.rs:612:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:361:43 + --> $DIR/drop-order-comparisons.rs:381:43 | LL | if let Ok(_) = e.err(6).as_ref() {} else { | ^ @@ -389,7 +389,7 @@ LL ~ }}}}}}}}}; | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:365:12 + --> $DIR/drop-order-comparisons.rs:385:12 | LL | if let Ok(_v) = e.err(5) {} else { | ^^^^^^^^^^^^^-------- @@ -399,12 +399,12 @@ LL | if let Ok(_v) = e.err(5) {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-if-let-scope.html> note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:571:1 + --> $DIR/drop-order-comparisons.rs:612:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:365:35 + --> $DIR/drop-order-comparisons.rs:385:35 | LL | if let Ok(_v) = e.err(5) {} else { | ^ @@ -418,7 +418,7 @@ LL ~ }}}}}}}}}; | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:368:12 + --> $DIR/drop-order-comparisons.rs:388:12 | LL | if let Ok(_) = e.err(4) {} else { | ^^^^^^^^^^^^-------- @@ -428,12 +428,12 @@ LL | if let Ok(_) = e.err(4) {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-if-let-scope.html> note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:571:1 + --> $DIR/drop-order-comparisons.rs:612:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:368:34 + --> $DIR/drop-order-comparisons.rs:388:34 | LL | if let Ok(_) = e.err(4) {} else { | ^ @@ -447,7 +447,7 @@ LL ~ }}}}}}}}}; | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:404:12 + --> $DIR/drop-order-comparisons.rs:424:12 | LL | if let Ok(_) = e.err(4).as_ref() {} else { | ^^^^^^^^^^^^--------^^^^^^^^^ @@ -457,12 +457,12 @@ LL | if let Ok(_) = e.err(4).as_ref() {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-if-let-scope.html> note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:571:1 + --> $DIR/drop-order-comparisons.rs:612:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:404:43 + --> $DIR/drop-order-comparisons.rs:424:43 | LL | if let Ok(_) = e.err(4).as_ref() {} else { | ^ diff --git a/tests/ui/drop/drop-order-comparisons.rs b/tests/ui/drop/drop-order-comparisons.rs index 0492b3a4db7..e7425159aa2 100644 --- a/tests/ui/drop/drop-order-comparisons.rs +++ b/tests/ui/drop/drop-order-comparisons.rs @@ -24,6 +24,7 @@ //@ [e2024] edition: 2024 //@ run-pass +#![feature(if_let_guard)] #![cfg_attr(e2021, feature(let_chains))] #![cfg_attr(e2021, warn(rust_2024_compatibility))] @@ -344,6 +345,25 @@ fn t_if_let_chains_then() { e.assert(9); } +#[rustfmt::skip] +fn t_guard_if_let_chains_then() { + let e = Events::new(); + _ = match () { + () if e.ok(1).is_ok() + && let true = e.ok(9).is_ok() + && let Ok(_v) = e.ok(8) + && let Ok(_) = e.ok(7) + && let Ok(_) = e.ok(6).as_ref() + && e.ok(2).is_ok() + && let Ok(_v) = e.ok(5) + && let Ok(_) = e.ok(4).as_ref() => { + e.mark(3); + } + _ => {} + }; + e.assert(9); +} + #[cfg(e2021)] #[rustfmt::skip] fn t_if_let_nested_else() { @@ -484,6 +504,25 @@ fn t_if_let_chains_then_else() { e.assert(9); } +#[rustfmt::skip] +fn t_guard_if_let_chains_then_else() { + let e = Events::new(); + _ = match () { + () if e.ok(1).is_ok() + && let true = e.ok(8).is_ok() + && let Ok(_v) = e.ok(7) + && let Ok(_) = e.ok(6) + && let Ok(_) = e.ok(5).as_ref() + && e.ok(2).is_ok() + && let Ok(_v) = e.ok(4) + && let Ok(_) = e.err(3) => {} + _ => { + e.mark(9); + } + }; + e.assert(9); +} + fn main() { t_bindings(); t_tuples(); @@ -502,10 +541,12 @@ fn main() { t_if_let_nested_then(); t_let_else_chained_then(); t_if_let_chains_then(); + t_guard_if_let_chains_then(); t_if_let_nested_else(); t_if_let_nested_then_else(); t_let_else_chained_then_else(); t_if_let_chains_then_else(); + t_guard_if_let_chains_then_else(); } // # Test scaffolding @@ -548,7 +589,7 @@ impl Events { Ok(LogDrop(self, m)) } /// Return an `Err` value that logs its drop. - fn err(&self, m: u64) -> Result<LogDrop, LogDrop> { + fn err(&self, m: u64) -> Result<LogDrop<'_>, LogDrop<'_>> { Err(LogDrop(self, m)) } /// Log an event. diff --git a/tests/ui/drop/drop_order.rs b/tests/ui/drop/drop_order.rs index b96e55a2535..34b1a0e8f75 100644 --- a/tests/ui/drop/drop_order.rs +++ b/tests/ui/drop/drop_order.rs @@ -23,11 +23,11 @@ impl Drop for LoudDrop<'_> { } impl DropOrderCollector { - fn option_loud_drop(&self, n: u32) -> Option<LoudDrop> { + fn option_loud_drop(&self, n: u32) -> Option<LoudDrop<'_>> { Some(LoudDrop(self, n)) } - fn loud_drop(&self, n: u32) -> LoudDrop { + fn loud_drop(&self, n: u32) -> LoudDrop<'_> { LoudDrop(self, n) } diff --git a/tests/ui/drop/drop_order_if_let_rescope.rs b/tests/ui/drop/drop_order_if_let_rescope.rs index 27bced5fa62..e96ceedd5cb 100644 --- a/tests/ui/drop/drop_order_if_let_rescope.rs +++ b/tests/ui/drop/drop_order_if_let_rescope.rs @@ -18,7 +18,7 @@ impl Drop for LoudDrop<'_> { } impl DropOrderCollector { - fn option_loud_drop(&self, n: u32) -> Option<LoudDrop> { + fn option_loud_drop(&self, n: u32) -> Option<LoudDrop<'_>> { Some(LoudDrop(self, n)) } diff --git a/tests/ui/drop/for-expr-temporary-drop-scope.rs b/tests/ui/drop/for-expr-temporary-drop-scope.rs new file mode 100644 index 00000000000..c6f80842ee6 --- /dev/null +++ b/tests/ui/drop/for-expr-temporary-drop-scope.rs @@ -0,0 +1,33 @@ +//! Check that temporaries in the for into-iterable expr are not dropped +//! until the end of the for expr. + +//@ run-pass + +static mut FLAGS: u64 = 0; + +struct AddFlags { + bits: u64, +} + +impl Drop for AddFlags { + fn drop(&mut self) { + unsafe { + FLAGS += self.bits; + } + } +} + +fn check_flags(expected: u64) { + unsafe { + let actual = FLAGS; + FLAGS = 0; + assert_eq!(actual, expected, "flags {}, expected {}", actual, expected); + } +} + +fn main() { + for _ in &[AddFlags { bits: 1 }] { + check_flags(0); + } + check_flags(1); +} diff --git a/tests/ui/drop/issue-23338-ensure-param-drop-order.rs b/tests/ui/drop/issue-23338-ensure-param-drop-order.rs index 6fee4520cbc..54a9d3324b9 100644 --- a/tests/ui/drop/issue-23338-ensure-param-drop-order.rs +++ b/tests/ui/drop/issue-23338-ensure-param-drop-order.rs @@ -163,7 +163,7 @@ pub mod d { }; self.log.borrow_mut().push(self.uid); indent_println(self.trail, &format!("+-- Drop {}", self)); - indent_println(::PREF_INDENT, ""); + indent_println(super::PREF_INDENT, ""); } } } diff --git a/tests/ui/drop/issue-23611-enum-swap-in-drop.rs b/tests/ui/drop/issue-23611-enum-swap-in-drop.rs index 410b07b16fc..208c6e2ada3 100644 --- a/tests/ui/drop/issue-23611-enum-swap-in-drop.rs +++ b/tests/ui/drop/issue-23611-enum-swap-in-drop.rs @@ -256,7 +256,7 @@ pub mod d { }; self.log.borrow_mut().push(self.uid); indent_println(self.trail, &format!("+-- Drop {}", self)); - indent_println(::PREF_INDENT, ""); + indent_println(super::PREF_INDENT, ""); } } } diff --git a/tests/ui/drop/issue-2735-2.rs b/tests/ui/drop/issue-2735-2.rs index 7a6ed6ea2f8..43fbafe7a0e 100644 --- a/tests/ui/drop/issue-2735-2.rs +++ b/tests/ui/drop/issue-2735-2.rs @@ -1,27 +1,24 @@ //@ run-pass -#![allow(non_camel_case_types)] use std::cell::Cell; // This test should behave exactly like issue-2735-3 -struct defer<'a> { +struct Defer<'a> { b: &'a Cell<bool>, } -impl<'a> Drop for defer<'a> { +impl<'a> Drop for Defer<'a> { fn drop(&mut self) { self.b.set(true); } } -fn defer(b: &Cell<bool>) -> defer { - defer { - b: b - } +fn defer(b: &Cell<bool>) -> Defer<'_> { + Defer { b } } pub fn main() { let dtor_ran = &Cell::new(false); - let _ = defer(dtor_ran); + let _ = defer(dtor_ran); assert!(dtor_ran.get()); } diff --git a/tests/ui/drop/issue-2735-3.rs b/tests/ui/drop/issue-2735-3.rs index 3bb4536537c..cc28f96d2b0 100644 --- a/tests/ui/drop/issue-2735-3.rs +++ b/tests/ui/drop/issue-2735-3.rs @@ -1,23 +1,20 @@ //@ run-pass -#![allow(non_camel_case_types)] use std::cell::Cell; // This test should behave exactly like issue-2735-2 -struct defer<'a> { +struct Defer<'a> { b: &'a Cell<bool>, } -impl<'a> Drop for defer<'a> { +impl<'a> Drop for Defer<'a> { fn drop(&mut self) { self.b.set(true); } } -fn defer(b: &Cell<bool>) -> defer { - defer { - b: b - } +fn defer(b: &Cell<bool>) -> Defer<'_> { + Defer { b } } pub fn main() { diff --git a/tests/ui/drop/issue-2735.rs b/tests/ui/drop/issue-2735.rs index cd7e0b8f461..838b9da109b 100644 --- a/tests/ui/drop/issue-2735.rs +++ b/tests/ui/drop/issue-2735.rs @@ -1,15 +1,13 @@ //@ run-pass #![allow(dead_code)] -#![allow(non_camel_case_types)] - -trait hax { - fn dummy(&self) { } +trait Hax { + fn dummy(&self) {} } -impl<A> hax for A { } +impl<A> Hax for A {} -fn perform_hax<T: 'static>(x: Box<T>) -> Box<dyn hax+'static> { - Box::new(x) as Box<dyn hax+'static> +fn perform_hax<T: 'static>(x: Box<T>) -> Box<dyn Hax + 'static> { + Box::new(x) as Box<dyn Hax + 'static> } fn deadcode() { diff --git a/tests/ui/drop/issue-979.rs b/tests/ui/drop/issue-979.rs index 8d98ac4df23..abbcc71de18 100644 --- a/tests/ui/drop/issue-979.rs +++ b/tests/ui/drop/issue-979.rs @@ -1,22 +1,19 @@ //@ run-pass -#![allow(non_camel_case_types)] use std::cell::Cell; -struct r<'a> { +struct R<'a> { b: &'a Cell<isize>, } -impl<'a> Drop for r<'a> { +impl<'a> Drop for R<'a> { fn drop(&mut self) { self.b.set(self.b.get() + 1); } } -fn r(b: &Cell<isize>) -> r { - r { - b: b - } +fn r(b: &Cell<isize>) -> R<'_> { + R { b } } pub fn main() { diff --git a/tests/ui/drop/tail-expr-drop-order.rs b/tests/ui/drop/tail-expr-drop-order.rs index f74530fce1e..a6807b16b50 100644 --- a/tests/ui/drop/tail-expr-drop-order.rs +++ b/tests/ui/drop/tail-expr-drop-order.rs @@ -28,11 +28,11 @@ impl Drop for LoudDrop<'_> { } impl DropOrderCollector { - fn option_loud_drop(&self, n: u32) -> Option<LoudDrop> { + fn option_loud_drop(&self, n: u32) -> Option<LoudDrop<'_>> { Some(LoudDrop(self, n)) } - fn loud_drop(&self, n: u32) -> LoudDrop { + fn loud_drop(&self, n: u32) -> LoudDrop<'_> { LoudDrop(self, n) } diff --git a/tests/ui/dropck/dropck_trait_cycle_checked.rs b/tests/ui/dropck/dropck_trait_cycle_checked.rs index be6ec3e4ed1..ffe43480b12 100644 --- a/tests/ui/dropck/dropck_trait_cycle_checked.rs +++ b/tests/ui/dropck/dropck_trait_cycle_checked.rs @@ -17,7 +17,7 @@ mod s { } mod id { - use s; + use crate::s; #[derive(Debug)] pub struct Id { orig_count: usize, diff --git a/tests/ui/dyn-compatibility/almost-supertrait-associated-type.rs b/tests/ui/dyn-compatibility/almost-supertrait-associated-type.rs index 1b1b8bcf03d..d73b67dc080 100644 --- a/tests/ui/dyn-compatibility/almost-supertrait-associated-type.rs +++ b/tests/ui/dyn-compatibility/almost-supertrait-associated-type.rs @@ -6,7 +6,6 @@ use std::marker::PhantomData; fn transmute<T, U>(t: T) -> U { (&PhantomData::<T> as &dyn Foo<T, U>).transmute(t) //~^ ERROR the trait `Foo` is not dyn compatible - //~| ERROR the trait `Foo` is not dyn compatible } struct ActuallySuper; diff --git a/tests/ui/dyn-compatibility/almost-supertrait-associated-type.stderr b/tests/ui/dyn-compatibility/almost-supertrait-associated-type.stderr index a384697ee08..acd6dbe7b2c 100644 --- a/tests/ui/dyn-compatibility/almost-supertrait-associated-type.stderr +++ b/tests/ui/dyn-compatibility/almost-supertrait-associated-type.stderr @@ -1,12 +1,12 @@ error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/almost-supertrait-associated-type.rs:21:20 + --> $DIR/almost-supertrait-associated-type.rs:20:20 | LL | impl<T, U> Dyn for dyn Foo<T, U> + '_ { | ^^^^^^^^^^^^^^^^^^ `Foo` 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/almost-supertrait-associated-type.rs:33:34 + --> $DIR/almost-supertrait-associated-type.rs:32:34 | LL | trait Foo<T, U>: Super<ActuallySuper, Assoc = T> | --- this trait is not dyn compatible... @@ -16,14 +16,14 @@ LL | fn transmute(&self, t: T) -> <Self as Super<NotActuallySuper>>::Assoc; = help: consider moving `transmute` to another trait error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/almost-supertrait-associated-type.rs:7:27 + --> $DIR/almost-supertrait-associated-type.rs:7:32 | LL | (&PhantomData::<T> as &dyn Foo<T, U>).transmute(t) - | ^^^^^^^^^^^^^^ `Foo` is not dyn compatible + | ^^^^^^^^^ `Foo` 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/almost-supertrait-associated-type.rs:33:34 + --> $DIR/almost-supertrait-associated-type.rs:32:34 | LL | trait Foo<T, U>: Super<ActuallySuper, Assoc = T> | --- this trait is not dyn compatible... @@ -32,24 +32,6 @@ LL | fn transmute(&self, t: T) -> <Self as Super<NotActuallySuper>>::Assoc; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...because method `transmute` references the `Self` type in its return type = help: consider moving `transmute` to another trait -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/almost-supertrait-associated-type.rs:7:6 - | -LL | (&PhantomData::<T> as &dyn Foo<T, U>).transmute(t) - | ^^^^^^^^^^^^^^^^^ `Foo` 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/almost-supertrait-associated-type.rs:33:34 - | -LL | trait Foo<T, U>: Super<ActuallySuper, Assoc = T> - | --- this trait is not dyn compatible... -... -LL | fn transmute(&self, t: T) -> <Self as Super<NotActuallySuper>>::Assoc; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...because method `transmute` references the `Self` type in its return type - = help: consider moving `transmute` to another trait - = note: required for the cast from `&PhantomData<T>` to `&dyn Foo<T, U>` - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/dyn-compatibility/associated-consts.rs b/tests/ui/dyn-compatibility/associated-consts.rs index 10d151d9a8b..69fff81b281 100644 --- a/tests/ui/dyn-compatibility/associated-consts.rs +++ b/tests/ui/dyn-compatibility/associated-consts.rs @@ -8,7 +8,6 @@ trait Bar { fn make_bar<T:Bar>(t: &T) -> &dyn Bar { //~^ ERROR E0038 t - //~^ ERROR E0038 } fn main() { diff --git a/tests/ui/dyn-compatibility/associated-consts.stderr b/tests/ui/dyn-compatibility/associated-consts.stderr index beaf263af07..dc64c93a577 100644 --- a/tests/ui/dyn-compatibility/associated-consts.stderr +++ b/tests/ui/dyn-compatibility/associated-consts.stderr @@ -14,23 +14,6 @@ LL | const X: usize; | ^ ...because it contains this associated `const` = help: consider moving `X` to another trait -error[E0038]: the trait `Bar` is not dyn compatible - --> $DIR/associated-consts.rs:10:5 - | -LL | t - | ^ `Bar` 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/associated-consts.rs:5:11 - | -LL | trait Bar { - | --- this trait is not dyn compatible... -LL | const X: usize; - | ^ ...because it contains this associated `const` - = help: consider moving `X` to another trait - = note: required for the cast from `&T` to `&dyn Bar` - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/dyn-compatibility/generics.rs b/tests/ui/dyn-compatibility/generics.rs index dcce17f925b..c25bdab361b 100644 --- a/tests/ui/dyn-compatibility/generics.rs +++ b/tests/ui/dyn-compatibility/generics.rs @@ -15,14 +15,12 @@ trait Quux { fn make_bar<T:Bar>(t: &T) -> &dyn Bar { //~^ ERROR E0038 t - //~^ ERROR E0038 } fn make_bar_explicit<T:Bar>(t: &T) -> &dyn Bar { //~^ ERROR E0038 t as &dyn Bar //~^ ERROR E0038 - //~| ERROR E0038 } fn make_quux<T:Quux>(t: &T) -> &dyn Quux { diff --git a/tests/ui/dyn-compatibility/generics.stderr b/tests/ui/dyn-compatibility/generics.stderr index c0193010541..79dccc42244 100644 --- a/tests/ui/dyn-compatibility/generics.stderr +++ b/tests/ui/dyn-compatibility/generics.stderr @@ -15,7 +15,7 @@ LL | fn bar<T>(&self, t: T); = help: consider moving `bar` to another trait error[E0038]: the trait `Bar` is not dyn compatible - --> $DIR/generics.rs:21:40 + --> $DIR/generics.rs:20:40 | LL | fn make_bar_explicit<T:Bar>(t: &T) -> &dyn Bar { | ^^^^^^^ `Bar` is not dyn compatible @@ -31,43 +31,10 @@ LL | fn bar<T>(&self, t: T); = help: consider moving `bar` to another trait error[E0038]: the trait `Bar` is not dyn compatible - --> $DIR/generics.rs:17:5 - | -LL | t - | ^ `Bar` 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/generics.rs:7:8 - | -LL | trait Bar { - | --- this trait is not dyn compatible... -LL | fn bar<T>(&self, t: T); - | ^^^ ...because method `bar` has generic type parameters - = help: consider moving `bar` to another trait - = note: required for the cast from `&T` to `&dyn Bar` - -error[E0038]: the trait `Bar` is not dyn compatible - --> $DIR/generics.rs:23:10 - | -LL | t as &dyn Bar - | ^^^^^^^^ `Bar` 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/generics.rs:7:8 - | -LL | trait Bar { - | --- this trait is not dyn compatible... -LL | fn bar<T>(&self, t: T); - | ^^^ ...because method `bar` has generic type parameters - = help: consider moving `bar` to another trait - -error[E0038]: the trait `Bar` is not dyn compatible - --> $DIR/generics.rs:23:5 + --> $DIR/generics.rs:22:15 | LL | t as &dyn Bar - | ^ `Bar` is not dyn compatible + | ^^^ `Bar` 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> @@ -78,8 +45,7 @@ LL | trait Bar { LL | fn bar<T>(&self, t: T); | ^^^ ...because method `bar` has generic type parameters = help: consider moving `bar` to another trait - = note: required for the cast from `&T` to `&dyn Bar` -error: aborting due to 5 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/dyn-compatibility/mention-correct-dyn-incompatible-trait.rs b/tests/ui/dyn-compatibility/mention-correct-dyn-incompatible-trait.rs index 1289d2d7874..d8b1bc5b717 100644 --- a/tests/ui/dyn-compatibility/mention-correct-dyn-incompatible-trait.rs +++ b/tests/ui/dyn-compatibility/mention-correct-dyn-incompatible-trait.rs @@ -18,5 +18,4 @@ fn main() { let mut thing = Thing; let test: &mut dyn Bar = &mut thing; //~^ ERROR E0038 - //~| ERROR E0038 } diff --git a/tests/ui/dyn-compatibility/mention-correct-dyn-incompatible-trait.stderr b/tests/ui/dyn-compatibility/mention-correct-dyn-incompatible-trait.stderr index c1e93ccb83c..dd7b31a70c5 100644 --- a/tests/ui/dyn-compatibility/mention-correct-dyn-incompatible-trait.stderr +++ b/tests/ui/dyn-compatibility/mention-correct-dyn-incompatible-trait.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Bar` is not dyn compatible - --> $DIR/mention-correct-dyn-incompatible-trait.rs:19:30 + --> $DIR/mention-correct-dyn-incompatible-trait.rs:19:24 | LL | let test: &mut dyn Bar = &mut thing; - | ^^^^^^^^^^ `Bar` is not dyn compatible + | ^^^ `Bar` 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> @@ -15,26 +15,7 @@ LL | trait Bar: Foo { } | --- this trait is not dyn compatible... = help: consider moving `foo` to another trait = help: only type `Thing` implements `Bar`; consider using it directly instead. - = note: required for the cast from `&mut Thing` to `&mut dyn Bar` -error[E0038]: the trait `Bar` is not dyn compatible - --> $DIR/mention-correct-dyn-incompatible-trait.rs:19:15 - | -LL | let test: &mut dyn Bar = &mut thing; - | ^^^^^^^^^^^^ `Bar` 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/mention-correct-dyn-incompatible-trait.rs:4:8 - | -LL | fn foo<T>(&self, val: T); - | ^^^ ...because method `foo` has generic type parameters -... -LL | trait Bar: Foo { } - | --- this trait is not dyn compatible... - = help: consider moving `foo` to another trait - = help: only type `Thing` implements `Bar`; consider using it directly instead. - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/dyn-compatibility/mentions-Self.rs b/tests/ui/dyn-compatibility/mentions-Self.rs index ce210f4776f..8b0d5ec6604 100644 --- a/tests/ui/dyn-compatibility/mentions-Self.rs +++ b/tests/ui/dyn-compatibility/mentions-Self.rs @@ -18,13 +18,11 @@ trait Quux { fn make_bar<T:Bar>(t: &T) -> &dyn Bar { //~^ ERROR E0038 t - //~^ ERROR E0038 } fn make_baz<T:Baz>(t: &T) -> &dyn Baz { //~^ ERROR E0038 t - //~^ ERROR E0038 } fn make_quux<T:Quux>(t: &T) -> &dyn Quux { diff --git a/tests/ui/dyn-compatibility/mentions-Self.stderr b/tests/ui/dyn-compatibility/mentions-Self.stderr index 6d1ae90152e..9d41e1d92dd 100644 --- a/tests/ui/dyn-compatibility/mentions-Self.stderr +++ b/tests/ui/dyn-compatibility/mentions-Self.stderr @@ -15,7 +15,7 @@ LL | fn bar(&self, x: &Self); = help: consider moving `bar` to another trait error[E0038]: the trait `Baz` is not dyn compatible - --> $DIR/mentions-Self.rs:24:31 + --> $DIR/mentions-Self.rs:23:31 | LL | fn make_baz<T:Baz>(t: &T) -> &dyn Baz { | ^^^^^^^ `Baz` is not dyn compatible @@ -30,40 +30,6 @@ LL | fn baz(&self) -> Self; | ^^^^ ...because method `baz` references the `Self` type in its return type = help: consider moving `baz` to another trait -error[E0038]: the trait `Bar` is not dyn compatible - --> $DIR/mentions-Self.rs:20:5 - | -LL | t - | ^ `Bar` 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/mentions-Self.rs:7:22 - | -LL | trait Bar { - | --- this trait is not dyn compatible... -LL | fn bar(&self, x: &Self); - | ^^^^^ ...because method `bar` references the `Self` type in this parameter - = help: consider moving `bar` to another trait - = note: required for the cast from `&T` to `&dyn Bar` - -error[E0038]: the trait `Baz` is not dyn compatible - --> $DIR/mentions-Self.rs:26:5 - | -LL | t - | ^ `Baz` 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/mentions-Self.rs:11:22 - | -LL | trait Baz { - | --- this trait is not dyn compatible... -LL | fn baz(&self) -> Self; - | ^^^^ ...because method `baz` references the `Self` type in its return type - = help: consider moving `baz` to another trait - = note: required for the cast from `&T` to `&dyn Baz` - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/dyn-compatibility/no-static.rs b/tests/ui/dyn-compatibility/no-static.rs index 9bd87161972..2d5954afffd 100644 --- a/tests/ui/dyn-compatibility/no-static.rs +++ b/tests/ui/dyn-compatibility/no-static.rs @@ -17,5 +17,4 @@ impl Foo for Bar {} fn main() { let b: Box<dyn Foo> = Box::new(Bar); //~^ ERROR E0038 - //~| ERROR E0038 } diff --git a/tests/ui/dyn-compatibility/no-static.stderr b/tests/ui/dyn-compatibility/no-static.stderr index 814ab0d53c3..c1d5dd6f562 100644 --- a/tests/ui/dyn-compatibility/no-static.stderr +++ b/tests/ui/dyn-compatibility/no-static.stderr @@ -23,10 +23,10 @@ LL | fn foo() where Self: Sized {} | +++++++++++++++++ error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/no-static.rs:18:12 + --> $DIR/no-static.rs:18:20 | LL | let b: Box<dyn Foo> = Box::new(Bar); - | ^^^^^^^^^^^^ `Foo` is not dyn compatible + | ^^^ `Foo` 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> @@ -46,31 +46,6 @@ help: alternatively, consider constraining `foo` so it does not apply to trait o LL | fn foo() where Self: Sized {} | +++++++++++++++++ -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/no-static.rs:18:27 - | -LL | let b: Box<dyn Foo> = Box::new(Bar); - | ^^^^^^^^^^^^^ `Foo` 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/no-static.rs:5:8 - | -LL | trait Foo { - | --- this trait is not dyn compatible... -LL | fn foo() {} - | ^^^ ...because associated function `foo` has no `self` parameter - = help: only type `Bar` implements `Foo`; consider using it directly instead. - = note: required for the cast from `Box<Bar>` to `Box<dyn Foo>` -help: consider turning `foo` into a method by giving it a `&self` argument - | -LL | fn foo(&self) {} - | +++++ -help: alternatively, consider constraining `foo` so it does not apply to trait objects - | -LL | fn foo() where Self: Sized {} - | +++++++++++++++++ - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/dyn-compatibility/sized-2.rs b/tests/ui/dyn-compatibility/sized-2.rs index f61d49ee8df..c99dcce46b2 100644 --- a/tests/ui/dyn-compatibility/sized-2.rs +++ b/tests/ui/dyn-compatibility/sized-2.rs @@ -10,7 +10,6 @@ trait Bar fn make_bar<T:Bar>(t: &T) -> &dyn Bar { //~^ ERROR E0038 t - //~^ ERROR E0038 } fn main() { diff --git a/tests/ui/dyn-compatibility/sized-2.stderr b/tests/ui/dyn-compatibility/sized-2.stderr index 1834d906bb8..70bd5f6dd36 100644 --- a/tests/ui/dyn-compatibility/sized-2.stderr +++ b/tests/ui/dyn-compatibility/sized-2.stderr @@ -13,22 +13,6 @@ LL | trait Bar LL | where Self : Sized | ^^^^^ ...because it requires `Self: Sized` -error[E0038]: the trait `Bar` is not dyn compatible - --> $DIR/sized-2.rs:12:5 - | -LL | t - | ^ `Bar` 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/sized-2.rs:5:18 - | -LL | trait Bar - | --- this trait is not dyn compatible... -LL | where Self : Sized - | ^^^^^ ...because it requires `Self: Sized` - = note: required for the cast from `&T` to `&dyn Bar` - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/dyn-compatibility/sized.rs b/tests/ui/dyn-compatibility/sized.rs index eb5279c17e6..b5a8a4be766 100644 --- a/tests/ui/dyn-compatibility/sized.rs +++ b/tests/ui/dyn-compatibility/sized.rs @@ -8,7 +8,6 @@ trait Bar: Sized { fn make_bar<T: Bar>(t: &T) -> &dyn Bar { //~^ ERROR E0038 t - //~^ ERROR E0038 } fn main() {} diff --git a/tests/ui/dyn-compatibility/sized.stderr b/tests/ui/dyn-compatibility/sized.stderr index c66e299cf6f..0cc41179d9a 100644 --- a/tests/ui/dyn-compatibility/sized.stderr +++ b/tests/ui/dyn-compatibility/sized.stderr @@ -13,22 +13,6 @@ LL | trait Bar: Sized { | | | this trait is not dyn compatible... -error[E0038]: the trait `Bar` is not dyn compatible - --> $DIR/sized.rs:10:5 - | -LL | t - | ^ `Bar` 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/sized.rs:4:12 - | -LL | trait Bar: Sized { - | --- ^^^^^ ...because it requires `Self: Sized` - | | - | this trait is not dyn compatible... - = note: required for the cast from `&T` to `&dyn Bar` - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/dyn-compatibility/taint-const-eval.rs b/tests/ui/dyn-compatibility/taint-const-eval.rs index 64c4df611e6..a5c01e1791e 100644 --- a/tests/ui/dyn-compatibility/taint-const-eval.rs +++ b/tests/ui/dyn-compatibility/taint-const-eval.rs @@ -7,6 +7,5 @@ trait Qux { static FOO: &(dyn Qux + Sync) = "desc"; //~^ ERROR the trait `Qux` is not dyn compatible //~| ERROR the trait `Qux` is not dyn compatible -//~| ERROR the trait `Qux` is not dyn compatible fn main() {} diff --git a/tests/ui/dyn-compatibility/taint-const-eval.stderr b/tests/ui/dyn-compatibility/taint-const-eval.stderr index 942c20db6ce..585c1f012c7 100644 --- a/tests/ui/dyn-compatibility/taint-const-eval.stderr +++ b/tests/ui/dyn-compatibility/taint-const-eval.stderr @@ -22,30 +22,6 @@ LL | fn bar() where Self: Sized; | +++++++++++++++++ error[E0038]: the trait `Qux` is not dyn compatible - --> $DIR/taint-const-eval.rs:7:33 - | -LL | static FOO: &(dyn Qux + Sync) = "desc"; - | ^^^^^^ `Qux` 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/taint-const-eval.rs:4:8 - | -LL | trait Qux { - | --- this trait is not dyn compatible... -LL | fn bar(); - | ^^^ ...because associated function `bar` has no `self` parameter - = note: required for the cast from `&'static str` to `&'static (dyn Qux + Sync + 'static)` -help: consider turning `bar` into a method by giving it a `&self` argument - | -LL | fn bar(&self); - | +++++ -help: alternatively, consider constraining `bar` so it does not apply to trait objects - | -LL | fn bar() where Self: Sized; - | +++++++++++++++++ - -error[E0038]: the trait `Qux` is not dyn compatible --> $DIR/taint-const-eval.rs:7:15 | LL | static FOO: &(dyn Qux + Sync) = "desc"; @@ -69,6 +45,6 @@ help: alternatively, consider constraining `bar` so it does not apply to trait o LL | fn bar() where Self: Sized; | +++++++++++++++++ -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/dyn-compatibility/undispatchable-receiver-and-wc-references-Self.rs b/tests/ui/dyn-compatibility/undispatchable-receiver-and-wc-references-Self.rs index ec32bec7785..ac3c2aadf29 100644 --- a/tests/ui/dyn-compatibility/undispatchable-receiver-and-wc-references-Self.rs +++ b/tests/ui/dyn-compatibility/undispatchable-receiver-and-wc-references-Self.rs @@ -25,5 +25,4 @@ pub fn foo() { let fetcher = fetcher(); //~^ ERROR the trait `Fetcher` is not dyn compatible let _ = fetcher.get(); - //~^ ERROR the trait `Fetcher` is not dyn compatible } diff --git a/tests/ui/dyn-compatibility/undispatchable-receiver-and-wc-references-Self.stderr b/tests/ui/dyn-compatibility/undispatchable-receiver-and-wc-references-Self.stderr index 1299167159e..867a719e2eb 100644 --- a/tests/ui/dyn-compatibility/undispatchable-receiver-and-wc-references-Self.stderr +++ b/tests/ui/dyn-compatibility/undispatchable-receiver-and-wc-references-Self.stderr @@ -34,24 +34,6 @@ LL | pub trait Fetcher: Send + Sync { LL | fn get<'a>(self: &'a Box<Self>) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>> | ^^^^^^^^^^^^^ ...because method `get`'s `self` parameter cannot be dispatched on -error[E0038]: the trait `Fetcher` is not dyn compatible - --> $DIR/undispatchable-receiver-and-wc-references-Self.rs:27:13 - | -LL | fn get<'a>(self: &'a Box<Self>) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>> - | ------------- help: consider changing method `get`'s `self` parameter to be `&self`: `&Self` -... -LL | let _ = fetcher.get(); - | ^^^^^^^^^^^^^ `Fetcher` 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/undispatchable-receiver-and-wc-references-Self.rs:11:22 - | -LL | pub trait Fetcher: Send + Sync { - | ------- this trait is not dyn compatible... -LL | fn get<'a>(self: &'a Box<Self>) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>> - | ^^^^^^^^^^^^^ ...because method `get`'s `self` parameter cannot be dispatched on - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/dyn-drop/dyn-drop.rs b/tests/ui/dyn-drop/dyn-drop.rs index e1668a3f188..f336949d2cb 100644 --- a/tests/ui/dyn-drop/dyn-drop.rs +++ b/tests/ui/dyn-drop/dyn-drop.rs @@ -1,8 +1,7 @@ #![deny(dyn_drop)] -#![allow(bare_trait_objects)] fn foo(_: Box<dyn Drop>) {} //~ ERROR fn bar(_: &dyn Drop) {} //~ERROR -fn baz(_: *mut Drop) {} //~ ERROR +fn baz(_: *mut dyn Drop) {} //~ ERROR struct Foo { _x: Box<dyn Drop> //~ ERROR } diff --git a/tests/ui/dyn-drop/dyn-drop.stderr b/tests/ui/dyn-drop/dyn-drop.stderr index 1b1dbc4d12d..8210d8a4c48 100644 --- a/tests/ui/dyn-drop/dyn-drop.stderr +++ b/tests/ui/dyn-drop/dyn-drop.stderr @@ -1,5 +1,5 @@ error: types that do not implement `Drop` can still have drop glue, consider instead using `std::mem::needs_drop` to detect whether a type is trivially dropped - --> $DIR/dyn-drop.rs:3:19 + --> $DIR/dyn-drop.rs:2:19 | LL | fn foo(_: Box<dyn Drop>) {} | ^^^^ @@ -11,25 +11,25 @@ LL | #![deny(dyn_drop)] | ^^^^^^^^ error: types that do not implement `Drop` can still have drop glue, consider instead using `std::mem::needs_drop` to detect whether a type is trivially dropped - --> $DIR/dyn-drop.rs:4:16 + --> $DIR/dyn-drop.rs:3:16 | LL | fn bar(_: &dyn Drop) {} | ^^^^ error: types that do not implement `Drop` can still have drop glue, consider instead using `std::mem::needs_drop` to detect whether a type is trivially dropped - --> $DIR/dyn-drop.rs:5:16 + --> $DIR/dyn-drop.rs:4:20 | -LL | fn baz(_: *mut Drop) {} - | ^^^^ +LL | fn baz(_: *mut dyn Drop) {} + | ^^^^ error: types that do not implement `Drop` can still have drop glue, consider instead using `std::mem::needs_drop` to detect whether a type is trivially dropped - --> $DIR/dyn-drop.rs:7:15 + --> $DIR/dyn-drop.rs:6:15 | LL | _x: Box<dyn Drop> | ^^^^ error: types that do not implement `Drop` can still have drop glue, consider instead using `std::mem::needs_drop` to detect whether a type is trivially dropped - --> $DIR/dyn-drop.rs:14:16 + --> $DIR/dyn-drop.rs:13:16 | LL | type T = dyn Drop; | ^^^^ diff --git a/tests/ui/editions/async-block-2015.rs b/tests/ui/editions/async-block-2015.rs index a079b4aad91..21549f059de 100644 --- a/tests/ui/editions/async-block-2015.rs +++ b/tests/ui/editions/async-block-2015.rs @@ -1,3 +1,4 @@ +//@ edition:2015 async fn foo() { //~^ ERROR `async fn` is not permitted in Rust 2015 //~| NOTE to use `async fn`, switch to Rust 2018 or later diff --git a/tests/ui/editions/async-block-2015.stderr b/tests/ui/editions/async-block-2015.stderr index 574bcacc1cf..139df1758cc 100644 --- a/tests/ui/editions/async-block-2015.stderr +++ b/tests/ui/editions/async-block-2015.stderr @@ -1,5 +1,5 @@ error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/async-block-2015.rs:1:1 + --> $DIR/async-block-2015.rs:2:1 | LL | async fn foo() { | ^^^^^ to use `async fn`, switch to Rust 2018 or later @@ -8,7 +8,7 @@ LL | async fn foo() { = note: for more on editions, read https://doc.rust-lang.org/edition-guide error: expected identifier, found keyword `let` - --> $DIR/async-block-2015.rs:11:9 + --> $DIR/async-block-2015.rs:12:9 | LL | let y = async { | ----- `async` blocks are only allowed in Rust 2018 or later @@ -19,7 +19,7 @@ LL | let x = 42; = note: for more on editions, read https://doc.rust-lang.org/edition-guide error: expected identifier, found `42` - --> $DIR/async-block-2015.rs:19:9 + --> $DIR/async-block-2015.rs:20:9 | LL | let z = async { | ----- `async` blocks are only allowed in Rust 2018 or later @@ -30,7 +30,7 @@ LL | 42 = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0422]: cannot find struct, variant or union type `async` in this scope - --> $DIR/async-block-2015.rs:7:13 + --> $DIR/async-block-2015.rs:8:13 | LL | let x = async {}; | ^^^^^ `async` blocks are only allowed in Rust 2018 or later diff --git a/tests/ui/editions/edition-extern-crate-allowed.stderr b/tests/ui/editions/edition-extern-crate-allowed.stderr index dde774c520d..4444ab79b38 100644 --- a/tests/ui/editions/edition-extern-crate-allowed.stderr +++ b/tests/ui/editions/edition-extern-crate-allowed.stderr @@ -2,7 +2,7 @@ warning: unused extern crate --> $DIR/edition-extern-crate-allowed.rs:7:1 | LL | extern crate edition_extern_crate_allowed; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused | note: the lint level is defined here --> $DIR/edition-extern-crate-allowed.rs:5:9 @@ -10,6 +10,10 @@ note: the lint level is defined here LL | #![warn(rust_2018_idioms)] | ^^^^^^^^^^^^^^^^ = note: `#[warn(unused_extern_crates)]` implied by `#[warn(rust_2018_idioms)]` +help: remove the unused `extern crate` + | +LL - extern crate edition_extern_crate_allowed; + | warning: 1 warning emitted diff --git a/tests/ui/empty/empty-struct-braces-expr.stderr b/tests/ui/empty/empty-struct-braces-expr.stderr index 8ec8ecf46bf..a176107a06e 100644 --- a/tests/ui/empty/empty-struct-braces-expr.stderr +++ b/tests/ui/empty/empty-struct-braces-expr.stderr @@ -121,7 +121,7 @@ error[E0599]: no variant or associated item named `Empty3` found for enum `empty --> $DIR/empty-struct-braces-expr.rs:25:19 | LL | let xe3 = XE::Empty3; - | ^^^^^^ variant or associated item not found in `XE` + | ^^^^^^ variant or associated item not found in `empty_struct::XE` | help: there is a variant with a similar name | @@ -132,7 +132,7 @@ error[E0599]: no variant or associated item named `Empty3` found for enum `empty --> $DIR/empty-struct-braces-expr.rs:26:19 | LL | let xe3 = XE::Empty3(); - | ^^^^^^ variant or associated item not found in `XE` + | ^^^^^^ variant or associated item not found in `empty_struct::XE` | help: there is a variant with a similar name | diff --git a/tests/ui/enum-discriminant/discriminant_size.rs b/tests/ui/enum-discriminant/discriminant_size.rs index a3ec1b28e5c..b1feff3c59e 100644 --- a/tests/ui/enum-discriminant/discriminant_size.rs +++ b/tests/ui/enum-discriminant/discriminant_size.rs @@ -1,6 +1,5 @@ //@ run-pass -#![feature(core_intrinsics, repr128)] -//~^ WARN the feature `repr128` is incomplete +#![feature(core_intrinsics)] use std::intrinsics::discriminant_value; diff --git a/tests/ui/enum-discriminant/discriminant_size.stderr b/tests/ui/enum-discriminant/discriminant_size.stderr deleted file mode 100644 index 9b1505b5c46..00000000000 --- a/tests/ui/enum-discriminant/discriminant_size.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `repr128` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/discriminant_size.rs:2:29 - | -LL | #![feature(core_intrinsics, repr128)] - | ^^^^^^^ - | - = note: see issue #56071 <https://github.com/rust-lang/rust/issues/56071> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/enum-discriminant/eval-error.rs b/tests/ui/enum-discriminant/eval-error.rs index 08b71d52a8b..45ac9472a4b 100644 --- a/tests/ui/enum-discriminant/eval-error.rs +++ b/tests/ui/enum-discriminant/eval-error.rs @@ -6,7 +6,7 @@ union Foo { enum Bar { Boo = { - let _: Option<Foo> = None; //~ ERROR evaluation of constant value failed + let _: Option<Foo> = None; //~ ERROR `Foo` has an unknown layout 0 }, } diff --git a/tests/ui/enum-discriminant/eval-error.stderr b/tests/ui/enum-discriminant/eval-error.stderr index 6bec2c8b420..c29d258a90b 100644 --- a/tests/ui/enum-discriminant/eval-error.stderr +++ b/tests/ui/enum-discriminant/eval-error.stderr @@ -45,11 +45,11 @@ help: wrap the field type in `ManuallyDrop<...>` LL | a: std::mem::ManuallyDrop<str>, | +++++++++++++++++++++++ + -error[E0080]: evaluation of constant value failed +error[E0080]: the type `Foo` has an unknown layout --> $DIR/eval-error.rs:9:30 | LL | let _: Option<Foo> = None; - | ^^^^ the type `Foo` has an unknown layout + | ^^^^ evaluation of `Bar::Boo::{constant#0}` failed here error: aborting due to 5 previous errors diff --git a/tests/ui/enum-discriminant/issue-43398.stderr b/tests/ui/enum-discriminant/issue-43398.stderr deleted file mode 100644 index fc7bbd06284..00000000000 --- a/tests/ui/enum-discriminant/issue-43398.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `repr128` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-43398.rs:4:12 - | -LL | #![feature(repr128)] - | ^^^^^^^ - | - = note: see issue #56071 <https://github.com/rust-lang/rust/issues/56071> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/enum-discriminant/issue-70509-partial_eq.rs b/tests/ui/enum-discriminant/issue-70509-partial_eq.rs index e98532c1207..5e71972c280 100644 --- a/tests/ui/enum-discriminant/issue-70509-partial_eq.rs +++ b/tests/ui/enum-discriminant/issue-70509-partial_eq.rs @@ -1,6 +1,4 @@ //@ run-pass -#![feature(repr128)] -//~^ WARN the feature `repr128` is incomplete #[derive(PartialEq, Debug)] #[repr(i128)] diff --git a/tests/ui/enum-discriminant/issue-70509-partial_eq.stderr b/tests/ui/enum-discriminant/issue-70509-partial_eq.stderr deleted file mode 100644 index 2eef930c394..00000000000 --- a/tests/ui/enum-discriminant/issue-70509-partial_eq.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `repr128` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-70509-partial_eq.rs:2:12 - | -LL | #![feature(repr128)] - | ^^^^^^^ - | - = note: see issue #56071 <https://github.com/rust-lang/rust/issues/56071> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/enum-discriminant/issue-43398.rs b/tests/ui/enum-discriminant/repr128-get-discriminant-issue-43398.rs index 574a4b3ad5a..2bb9725fb77 100644 --- a/tests/ui/enum-discriminant/issue-43398.rs +++ b/tests/ui/enum-discriminant/repr128-get-discriminant-issue-43398.rs @@ -1,8 +1,6 @@ //@ run-pass #![feature(core_intrinsics)] -#![feature(repr128)] -//~^ WARN the feature `repr128` is incomplete #[repr(i128)] enum Big { A, B } diff --git a/tests/ui/enum-discriminant/repr128.rs b/tests/ui/enum-discriminant/repr128.rs index 075ff7a7676..d59a5b3e256 100644 --- a/tests/ui/enum-discriminant/repr128.rs +++ b/tests/ui/enum-discriminant/repr128.rs @@ -1,6 +1,5 @@ //@ run-pass -#![feature(repr128, core_intrinsics, discriminant_kind)] -//~^ WARN the feature `repr128` is incomplete +#![feature(core_intrinsics, discriminant_kind)] use std::intrinsics::discriminant_value; use std::marker::DiscriminantKind; diff --git a/tests/ui/enum-discriminant/repr128.stderr b/tests/ui/enum-discriminant/repr128.stderr deleted file mode 100644 index da8d75c11af..00000000000 --- a/tests/ui/enum-discriminant/repr128.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `repr128` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/repr128.rs:2:12 - | -LL | #![feature(repr128, core_intrinsics, discriminant_kind)] - | ^^^^^^^ - | - = note: see issue #56071 <https://github.com/rust-lang/rust/issues/56071> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/cenum_impl_drop_cast.rs b/tests/ui/enum/enum-drop-cast-error.rs index f681434dd86..36101573624 100644 --- a/tests/ui/cenum_impl_drop_cast.rs +++ b/tests/ui/enum/enum-drop-cast-error.rs @@ -1,3 +1,7 @@ +//! Check that trying to cast an enum with a Drop impl to an integer is rejected. +//! +//! Issue: <https://github.com/rust-lang/rust/issues/35941> + enum E { A = 0, } diff --git a/tests/ui/cenum_impl_drop_cast.stderr b/tests/ui/enum/enum-drop-cast-error.stderr index 35c69f4b4b7..b58abbd39d3 100644 --- a/tests/ui/cenum_impl_drop_cast.stderr +++ b/tests/ui/enum/enum-drop-cast-error.stderr @@ -1,5 +1,5 @@ error: cannot cast enum `E` into integer `u32` because it implements `Drop` - --> $DIR/cenum_impl_drop_cast.rs:13:13 + --> $DIR/enum-drop-cast-error.rs:17:13 | LL | let i = e as u32; | ^^^^^^^^ diff --git a/tests/ui/ergonomic-clones/async/edition-2015.rs b/tests/ui/ergonomic-clones/async/edition-2015.rs index d3b2071b9f9..78831249429 100644 --- a/tests/ui/ergonomic-clones/async/edition-2015.rs +++ b/tests/ui/ergonomic-clones/async/edition-2015.rs @@ -1,3 +1,4 @@ +//@ edition:2015 #![feature(ergonomic_clones)] #![allow(incomplete_features)] diff --git a/tests/ui/ergonomic-clones/async/edition-2015.stderr b/tests/ui/ergonomic-clones/async/edition-2015.stderr index b218e6b242e..8de90f4bfd3 100644 --- a/tests/ui/ergonomic-clones/async/edition-2015.stderr +++ b/tests/ui/ergonomic-clones/async/edition-2015.stderr @@ -1,5 +1,5 @@ error: `async use` blocks are only allowed in Rust 2018 or later - --> $DIR/edition-2015.rs:5:5 + --> $DIR/edition-2015.rs:6:5 | LL | async use {}; | ^^^^^^^^^ diff --git a/tests/ui/error-codes/E0038.rs b/tests/ui/error-codes/E0038.rs index a467767c3fa..9757e2ab10c 100644 --- a/tests/ui/error-codes/E0038.rs +++ b/tests/ui/error-codes/E0038.rs @@ -5,8 +5,6 @@ trait Trait { fn call_foo(x: Box<dyn Trait>) { //~^ ERROR E0038 let y = x.foo(); - //~^ ERROR E0038 - //~| ERROR E0277 } fn main() { diff --git a/tests/ui/error-codes/E0038.stderr b/tests/ui/error-codes/E0038.stderr index 63a5249a386..e09aefaa0dd 100644 --- a/tests/ui/error-codes/E0038.stderr +++ b/tests/ui/error-codes/E0038.stderr @@ -14,33 +14,6 @@ LL | fn foo(&self) -> Self; | ^^^^ ...because method `foo` references the `Self` type in its return type = help: consider moving `foo` to another trait -error[E0038]: the trait `Trait` is not dyn compatible - --> $DIR/E0038.rs:7:13 - | -LL | let y = x.foo(); - | ^^^^^^^ `Trait` 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/E0038.rs:2:22 - | -LL | trait Trait { - | ----- this trait is not dyn compatible... -LL | fn foo(&self) -> Self; - | ^^^^ ...because method `foo` references the `Self` type in its return type - = help: consider moving `foo` to another trait - -error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time - --> $DIR/E0038.rs:7:9 - | -LL | let y = x.foo(); - | ^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `dyn Trait` - = note: all local variables must have a statically known size - = help: unsized locals are gated as an unstable feature - -error: aborting due to 3 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0038, E0277. -For more information about an error, try `rustc --explain E0038`. +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/error-codes/E0080.rs b/tests/ui/error-codes/E0080.rs index 55f45055f01..0d19f02a9f1 100644 --- a/tests/ui/error-codes/E0080.rs +++ b/tests/ui/error-codes/E0080.rs @@ -1,9 +1,6 @@ enum Enum { - X = (1 << 500), //~ ERROR E0080 - //~| NOTE attempt to shift left by `500_i32`, which would overflow - Y = (1 / 0) //~ ERROR E0080 - //~| NOTE attempt to divide `1_isize` by zero + X = (1 << 500), //~ ERROR attempt to shift left by `500_i32`, which would overflow + Y = (1 / 0), //~ ERROR attempt to divide `1_isize` by zero } -fn main() { -} +fn main() {} diff --git a/tests/ui/error-codes/E0080.stderr b/tests/ui/error-codes/E0080.stderr index 60ed9a4358f..c78454620d1 100644 --- a/tests/ui/error-codes/E0080.stderr +++ b/tests/ui/error-codes/E0080.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: attempt to shift left by `500_i32`, which would overflow --> $DIR/E0080.rs:2:9 | LL | X = (1 << 500), - | ^^^^^^^^^^ attempt to shift left by `500_i32`, which would overflow + | ^^^^^^^^^^ evaluation of `Enum::X::{constant#0}` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/E0080.rs:4:9 +error[E0080]: attempt to divide `1_isize` by zero + --> $DIR/E0080.rs:3:9 | -LL | Y = (1 / 0) - | ^^^^^^^ attempt to divide `1_isize` by zero +LL | Y = (1 / 0), + | ^^^^^^^ evaluation of `Enum::Y::{constant#0}` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/error-codes/E0092.rs b/tests/ui/error-codes/E0092.rs deleted file mode 100644 index 19a7c65a48e..00000000000 --- a/tests/ui/error-codes/E0092.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![feature(intrinsics)] - -#[rustc_intrinsic] -unsafe fn atomic_foo(); //~ ERROR E0092 - -fn main() {} diff --git a/tests/ui/error-codes/E0092.stderr b/tests/ui/error-codes/E0092.stderr deleted file mode 100644 index 003c989fd59..00000000000 --- a/tests/ui/error-codes/E0092.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0092]: unrecognized atomic operation function: `foo` - --> $DIR/E0092.rs:4:11 - | -LL | unsafe fn atomic_foo(); - | ^^^^^^^^^^ unrecognized atomic operation - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0092`. diff --git a/tests/ui/error-codes/E0223.stderr b/tests/ui/error-codes/E0223.stderr index e985a4c9bf0..fbfdce5689a 100644 --- a/tests/ui/error-codes/E0223.stderr +++ b/tests/ui/error-codes/E0223.stderr @@ -2,7 +2,13 @@ error[E0223]: ambiguous associated type --> $DIR/E0223.rs:8:14 | LL | let foo: MyTrait::X; - | ^^^^^^^^^^ help: use fully-qualified syntax: `<MyStruct as MyTrait>::X` + | ^^^^^^^^^^ + | +help: use fully-qualified syntax + | +LL - let foo: MyTrait::X; +LL + let foo: <MyStruct as MyTrait>::X; + | error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0604.stderr b/tests/ui/error-codes/E0604.stderr index e91f74d6b3f..67bbb25958f 100644 --- a/tests/ui/error-codes/E0604.stderr +++ b/tests/ui/error-codes/E0604.stderr @@ -2,10 +2,13 @@ error[E0604]: only `u8` can be cast as `char`, not `u32` --> $DIR/E0604.rs:2:5 | LL | 1u32 as char; - | ^^^^^^^^^^^^ - | | - | invalid cast - | help: try `char::from_u32` instead: `char::from_u32(1u32)` + | ^^^^^^^^^^^^ invalid cast + | +help: consider using `char::from_u32` instead + | +LL - 1u32 as char; +LL + char::from_u32(1u32); + | error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0620.stderr b/tests/ui/error-codes/E0620.stderr index 644ba813c96..696407c6f7e 100644 --- a/tests/ui/error-codes/E0620.stderr +++ b/tests/ui/error-codes/E0620.stderr @@ -2,9 +2,12 @@ error[E0620]: cast to unsized type: `&[usize; 2]` as `[usize]` --> $DIR/E0620.rs:2:16 | LL | let _foo = &[1_usize, 2] as [usize]; - | ^^^^^^^^^^^^^^^^^------- - | | - | help: try casting to a reference instead: `&[usize]` + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: consider casting to a reference instead + | +LL | let _foo = &[1_usize, 2] as &[usize]; + | + error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0657.rs b/tests/ui/error-codes/E0657.rs index 212c1d9e581..f046788153d 100644 --- a/tests/ui/error-codes/E0657.rs +++ b/tests/ui/error-codes/E0657.rs @@ -7,7 +7,7 @@ impl<'a> Lt<'a> for () {} impl<T> Id<T> for T {} fn free_fn_capture_hrtb_in_impl_trait() - -> Box<for<'a> Id<impl Lt<'a>>> + -> Box<dyn for<'a> Id<impl Lt<'a>>> //~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from `dyn` type { Box::new(()) @@ -16,7 +16,7 @@ fn free_fn_capture_hrtb_in_impl_trait() struct Foo; impl Foo { fn impl_fn_capture_hrtb_in_impl_trait() - -> Box<for<'a> Id<impl Lt<'a>>> + -> Box<dyn for<'a> Id<impl Lt<'a>>> //~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from `dyn` type { Box::new(()) diff --git a/tests/ui/error-codes/E0657.stderr b/tests/ui/error-codes/E0657.stderr index c539007cdcf..c9dfc9eb906 100644 --- a/tests/ui/error-codes/E0657.stderr +++ b/tests/ui/error-codes/E0657.stderr @@ -1,26 +1,26 @@ error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from `dyn` type - --> $DIR/E0657.rs:10:31 + --> $DIR/E0657.rs:10:35 | -LL | -> Box<for<'a> Id<impl Lt<'a>>> - | ^^ +LL | -> Box<dyn for<'a> Id<impl Lt<'a>>> + | ^^ | note: lifetime declared here - --> $DIR/E0657.rs:10:16 + --> $DIR/E0657.rs:10:20 | -LL | -> Box<for<'a> Id<impl Lt<'a>>> - | ^^ +LL | -> Box<dyn for<'a> Id<impl Lt<'a>>> + | ^^ error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from `dyn` type - --> $DIR/E0657.rs:19:35 + --> $DIR/E0657.rs:19:39 | -LL | -> Box<for<'a> Id<impl Lt<'a>>> - | ^^ +LL | -> Box<dyn for<'a> Id<impl Lt<'a>>> + | ^^ | note: lifetime declared here - --> $DIR/E0657.rs:19:20 + --> $DIR/E0657.rs:19:24 | -LL | -> Box<for<'a> Id<impl Lt<'a>>> - | ^^ +LL | -> Box<dyn for<'a> Id<impl Lt<'a>>> + | ^^ error: aborting due to 2 previous errors diff --git a/tests/ui/error-codes/E0658.rs b/tests/ui/error-codes/E0658.rs index 9c9b95d70a7..e51674cdf92 100644 --- a/tests/ui/error-codes/E0658.rs +++ b/tests/ui/error-codes/E0658.rs @@ -1,6 +1,3 @@ -#[repr(u128)] -enum Foo { //~ ERROR E0658 - Bar(u64), -} +use std::intrinsics; //~ ERROR E0658 fn main() {} diff --git a/tests/ui/error-codes/E0658.stderr b/tests/ui/error-codes/E0658.stderr index e1e812940ec..ae7ecbbc5cb 100644 --- a/tests/ui/error-codes/E0658.stderr +++ b/tests/ui/error-codes/E0658.stderr @@ -1,11 +1,10 @@ -error[E0658]: repr with 128-bit type is unstable - --> $DIR/E0658.rs:2:1 +error[E0658]: use of unstable library feature `core_intrinsics`: intrinsics are unlikely to ever be stabilized, instead they should be used through stabilized interfaces in the rest of the standard library + --> $DIR/E0658.rs:1:5 | -LL | enum Foo { - | ^^^^^^^^ +LL | use std::intrinsics; + | ^^^^^^^^^^^^^^^ | - = note: see issue #56071 <https://github.com/rust-lang/rust/issues/56071> for more information - = help: add `#![feature(repr128)]` to the crate attributes to enable + = help: add `#![feature(core_intrinsics)]` 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 diff --git a/tests/ui/error-codes/E0659.rs b/tests/ui/error-codes/E0659.rs index c00026bb7a7..d056f1d96dd 100644 --- a/tests/ui/error-codes/E0659.rs +++ b/tests/ui/error-codes/E0659.rs @@ -7,8 +7,8 @@ mod earth { } mod collider { - pub use moon::*; - pub use earth::*; + pub use crate::moon::*; + pub use crate::earth::*; } fn main() { diff --git a/tests/ui/error-codes/E0659.stderr b/tests/ui/error-codes/E0659.stderr index dbb72bb6759..371250b811b 100644 --- a/tests/ui/error-codes/E0659.stderr +++ b/tests/ui/error-codes/E0659.stderr @@ -8,14 +8,14 @@ LL | collider::foo(); note: `foo` could refer to the function imported here --> $DIR/E0659.rs:10:13 | -LL | pub use moon::*; - | ^^^^^^^ +LL | pub use crate::moon::*; + | ^^^^^^^^^^^^^^ = help: consider adding an explicit import of `foo` to disambiguate note: `foo` could also refer to the function imported here --> $DIR/E0659.rs:11:13 | -LL | pub use earth::*; - | ^^^^^^^^ +LL | pub use crate::earth::*; + | ^^^^^^^^^^^^^^^ = help: consider adding an explicit import of `foo` to disambiguate error: aborting due to 1 previous error diff --git a/tests/ui/error-emitter/error-festival.stderr b/tests/ui/error-emitter/error-festival.stderr index be484bc8094..6c661eb17a8 100644 --- a/tests/ui/error-emitter/error-festival.stderr +++ b/tests/ui/error-emitter/error-festival.stderr @@ -58,10 +58,13 @@ error[E0604]: only `u8` can be cast as `char`, not `u32` --> $DIR/error-festival.rs:27:5 | LL | 0u32 as char; - | ^^^^^^^^^^^^ - | | - | invalid cast - | help: try `char::from_u32` instead: `char::from_u32(0u32)` + | ^^^^^^^^^^^^ invalid cast + | +help: consider using `char::from_u32` instead + | +LL - 0u32 as char; +LL + char::from_u32(0u32); + | error[E0605]: non-primitive cast: `u8` as `Vec<u8>` --> $DIR/error-festival.rs:31:5 diff --git a/tests/ui/error-emitter/multiline-removal-suggestion.svg b/tests/ui/error-emitter/multiline-removal-suggestion.svg index 95c7740f699..9c9bd163ecd 100644 --- a/tests/ui/error-emitter/multiline-removal-suggestion.svg +++ b/tests/ui/error-emitter/multiline-removal-suggestion.svg @@ -1,4 +1,4 @@ -<svg width="1902px" height="4322px" xmlns="http://www.w3.org/2000/svg"> +<svg width="2322px" height="4322px" xmlns="http://www.w3.org/2000/svg"> <style> .fg { fill: #AAAAAA } .bg { background: #000000 } @@ -99,7 +99,7 @@ </tspan> <tspan x="10px" y="712px"> </tspan> - <tspan x="10px" y="730px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: the method `collect` exists for struct `Flatten<Map<IntoIter<bool, Vec<HashSet<u8>>>, {closure@multiline-removal-suggestion.rs:14:8}>>`, but its trait bounds were not satisfied</tspan> + <tspan x="10px" y="730px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: the method `collect` exists for struct `Flatten<Map<std::collections::hash_map::IntoIter<bool, Vec<HashSet<u8>>>, {closure@$DIR/multiline-removal-suggestion.rs:14:8: 14:23}>>`, but its trait bounds were not satisfied</tspan> </tspan> <tspan x="10px" y="748px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/multiline-removal-suggestion.rs:24:4</tspan> </tspan> @@ -213,7 +213,7 @@ </tspan> <tspan x="10px" y="1738px"> </tspan> - <tspan x="10px" y="1756px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: the method `collect` exists for struct `Flatten<Map<IntoIter<bool, Vec<HashSet<u8>>>, {closure@multiline-removal-suggestion.rs:29:8}>>`, but its trait bounds were not satisfied</tspan> + <tspan x="10px" y="1756px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: the method `collect` exists for struct `Flatten<Map<std::collections::hash_map::IntoIter<bool, Vec<HashSet<u8>>>, {closure@$DIR/multiline-removal-suggestion.rs:29:8: 29:23}>>`, but its trait bounds were not satisfied</tspan> </tspan> <tspan x="10px" y="1774px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/multiline-removal-suggestion.rs:35:4</tspan> </tspan> @@ -329,7 +329,7 @@ </tspan> <tspan x="10px" y="2782px"> </tspan> - <tspan x="10px" y="2800px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: the method `collect` exists for struct `Flatten<Map<IntoIter<bool, Vec<HashSet<u8>>>, {closure@multiline-removal-suggestion.rs:40:8}>>`, but its trait bounds were not satisfied</tspan> + <tspan x="10px" y="2800px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: the method `collect` exists for struct `Flatten<Map<std::collections::hash_map::IntoIter<bool, Vec<HashSet<u8>>>, {closure@$DIR/multiline-removal-suggestion.rs:40:8: 40:23}>>`, but its trait bounds were not satisfied</tspan> </tspan> <tspan x="10px" y="2818px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/multiline-removal-suggestion.rs:46:4</tspan> </tspan> @@ -441,7 +441,7 @@ </tspan> <tspan x="10px" y="3790px"> </tspan> - <tspan x="10px" y="3808px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: the method `collect` exists for struct `Flatten<Map<IntoIter<bool, Vec<HashSet<u8>>>, {closure@multiline-removal-suggestion.rs:51:8}>>`, but its trait bounds were not satisfied</tspan> + <tspan x="10px" y="3808px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: the method `collect` exists for struct `Flatten<Map<std::collections::hash_map::IntoIter<bool, Vec<HashSet<u8>>>, {closure@$DIR/multiline-removal-suggestion.rs:51:8: 51:23}>>`, but its trait bounds were not satisfied</tspan> </tspan> <tspan x="10px" y="3826px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/multiline-removal-suggestion.rs:56:4</tspan> </tspan> diff --git a/tests/ui/errors/dynless-turbofish-e0191-issue-91997.rs b/tests/ui/errors/dynless-turbofish-e0191-issue-91997.rs index 69a4c13530b..d6bb6466227 100644 --- a/tests/ui/errors/dynless-turbofish-e0191-issue-91997.rs +++ b/tests/ui/errors/dynless-turbofish-e0191-issue-91997.rs @@ -1,3 +1,4 @@ +//@ edition:2015 trait MyIterator : Iterator {} fn main() { diff --git a/tests/ui/errors/dynless-turbofish-e0191-issue-91997.stderr b/tests/ui/errors/dynless-turbofish-e0191-issue-91997.stderr index 24f00cfa6be..7f3022c2923 100644 --- a/tests/ui/errors/dynless-turbofish-e0191-issue-91997.stderr +++ b/tests/ui/errors/dynless-turbofish-e0191-issue-91997.stderr @@ -1,5 +1,5 @@ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/dynless-turbofish-e0191-issue-91997.rs:4:13 + --> $DIR/dynless-turbofish-e0191-issue-91997.rs:5:13 | LL | let _ = MyIterator::next; | ^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | let _ = <dyn MyIterator>::next; | ++++ + error[E0191]: the value of the associated type `Item` in `Iterator` must be specified - --> $DIR/dynless-turbofish-e0191-issue-91997.rs:4:13 + --> $DIR/dynless-turbofish-e0191-issue-91997.rs:5:13 | LL | let _ = MyIterator::next; | ^^^^^^^^^^ help: specify the associated type: `MyIterator::<Item = Type>` diff --git a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return.stderr b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return.stderr index 8fb51f5b637..25e30397c83 100644 --- a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return.stderr +++ b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: reached the configured maximum number of stack frames --> $DIR/ctfe-id-unlimited.rs:28:20 | LL | const ID_ED: u32 = rec_id(ORIGINAL); - | ^^^^^^^^^^^^^^^^ reached the configured maximum number of stack frames + | ^^^^^^^^^^^^^^^^ evaluation of `ID_ED` failed inside this call | note: inside `rec_id` --> $DIR/ctfe-id-unlimited.rs:21:5 diff --git a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.rs b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.rs index 9e89f4066bb..53cccb38e2b 100644 --- a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.rs +++ b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.rs @@ -25,7 +25,7 @@ const fn rec_id(n: u32) -> u32 { const ORIGINAL: u32 = 12345; // Original number, but with identity function applied // (this is the same, but requires execution of the recursion) -const ID_ED: u32 = rec_id(ORIGINAL); //[return]~ error: evaluation of constant value failed +const ID_ED: u32 = rec_id(ORIGINAL); //[return]~ ERROR: reached the configured maximum number of stack frames // Assert to make absolutely sure the computation actually happens const ASSERT: () = assert!(ORIGINAL == ID_ED); diff --git a/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.rs b/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.rs index e7038a01d2d..26fb7b16a55 100644 --- a/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.rs +++ b/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.rs @@ -10,7 +10,7 @@ const fn g() { //~^ NOTE in this expansion of panic! } -const _: () = f(); //~ ERROR evaluation of constant value failed -//~^ NOTE explicit panic +const _: () = f(); //~ NOTE failed inside this call +//~^ ERROR explicit panic fn main() {} diff --git a/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.stderr b/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.stderr index 3bdd09e9683..380c2bfb98c 100644 --- a/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.stderr +++ b/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/ctfe-tail-call-panic.rs:13:15 | LL | const _: () = f(); - | ^^^ evaluation panicked: explicit panic + | ^^^ evaluation of `_` failed inside this call | note: inside `g` --> $DIR/ctfe-tail-call-panic.rs:9:5 diff --git a/tests/ui/explore-issue-38412.stderr b/tests/ui/explore-issue-38412.stderr index 884184ec16e..fca5c738d27 100644 --- a/tests/ui/explore-issue-38412.stderr +++ b/tests/ui/explore-issue-38412.stderr @@ -103,8 +103,8 @@ LL | r.pub_mod(); | ::: $DIR/auxiliary/pub-and-stability.rs:116:9 | -LL | pub(in m) fn pub_mod(&self) -> i32 { self.d_priv } - | ---------------------------------- private method defined here +LL | pub(in crate::m) fn pub_mod(&self) -> i32 { self.d_priv } + | ----------------------------------------- private method defined here error[E0624]: method `private` is private --> $DIR/explore-issue-38412.rs:50:7 @@ -156,8 +156,8 @@ LL | t.pub_mod(); | ::: $DIR/auxiliary/pub-and-stability.rs:130:9 | -LL | pub(in m) fn pub_mod(&self) -> i32 { self.0 } - | ---------------------------------- private method defined here +LL | pub(in crate::m) fn pub_mod(&self) -> i32 { self.0 } + | ----------------------------------------- private method defined here error[E0624]: method `private` is private --> $DIR/explore-issue-38412.rs:63:7 diff --git a/tests/ui/expr/scope.rs b/tests/ui/expr/scope.rs index 3a1c8b87da8..b059e43de9e 100644 --- a/tests/ui/expr/scope.rs +++ b/tests/ui/expr/scope.rs @@ -1,3 +1,4 @@ +//@ edition:2015 //@ run-pass // Regression test for issue #762 diff --git a/tests/ui/extern/extern-empty-string-issue-140884.rs b/tests/ui/extern/extern-empty-string-issue-140884.rs new file mode 100644 index 00000000000..10291513d34 --- /dev/null +++ b/tests/ui/extern/extern-empty-string-issue-140884.rs @@ -0,0 +1,3 @@ +extern "" {} //~ ERROR invalid ABI: found `` + +fn main() {} diff --git a/tests/ui/extern/extern-empty-string-issue-140884.stderr b/tests/ui/extern/extern-empty-string-issue-140884.stderr new file mode 100644 index 00000000000..accae0c0f7c --- /dev/null +++ b/tests/ui/extern/extern-empty-string-issue-140884.stderr @@ -0,0 +1,15 @@ +error[E0703]: invalid ABI: found `` + --> $DIR/extern-empty-string-issue-140884.rs:1:8 + | +LL | extern "" {} + | ^^ invalid ABI + | + = note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions +help: there's a similarly named valid ABI `C` + | +LL | extern "C" {} + | + + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0703`. diff --git a/tests/ui/extern/issue-28324.rs b/tests/ui/extern/issue-28324.rs index a5e240fa283..4af400d823b 100644 --- a/tests/ui/extern/issue-28324.rs +++ b/tests/ui/extern/issue-28324.rs @@ -4,6 +4,6 @@ extern "C" { pub static BAZ: u32 = *&error_message_count; //~^ ERROR use of extern static is unsafe and requires -//~| ERROR could not evaluate static initializer +//~| ERROR cannot access extern static fn main() {} diff --git a/tests/ui/extern/issue-28324.stderr b/tests/ui/extern/issue-28324.stderr index 93eb6ff8174..4637163bc5c 100644 --- a/tests/ui/extern/issue-28324.stderr +++ b/tests/ui/extern/issue-28324.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: cannot access extern static `error_message_count` --> $DIR/issue-28324.rs:5:23 | LL | pub static BAZ: u32 = *&error_message_count; - | ^^^^^^^^^^^^^^^^^^^^^ cannot access extern static `error_message_count` + | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAZ` failed here error[E0133]: use of extern static is unsafe and requires unsafe function or block --> $DIR/issue-28324.rs:5:25 diff --git a/tests/ui/feature-gates/feature-gate-asm_cfg.rs b/tests/ui/feature-gates/feature-gate-asm_cfg.rs new file mode 100644 index 00000000000..ef8bf75b692 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-asm_cfg.rs @@ -0,0 +1,48 @@ +//@ only-x86_64 +#![crate_type = "lib"] + +use std::arch::{asm, global_asm, naked_asm}; + +global_asm!( + "nop", + #[cfg(false)] + //~^ ERROR the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable + "nop" +); + +#[unsafe(naked)] +#[no_mangle] +extern "C" fn naked() { + naked_asm!( + "mov rax, 5", + #[cfg(false)] + //~^ ERROR the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable + "mov rax, {a}", + "ret", + #[cfg(false)] + //~^ ERROR the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable + a = const 10, + ) +} + +fn asm() { + unsafe { + asm!( + "nop", + #[cfg(false)] + //~^ ERROR the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable + clobber_abi("C"), + clobber_abi("C"), //~ ERROR `C` ABI specified multiple times + ); + } +} + +fn bad_attribute() { + unsafe { + asm!( + #[inline] + //~^ ERROR this attribute is not supported on assembly + "nop" + ) + }; +} diff --git a/tests/ui/feature-gates/feature-gate-asm_cfg.stderr b/tests/ui/feature-gates/feature-gate-asm_cfg.stderr new file mode 100644 index 00000000000..e92d1e8c487 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-asm_cfg.stderr @@ -0,0 +1,57 @@ +error[E0658]: the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable + --> $DIR/feature-gate-asm_cfg.rs:8:5 + | +LL | #[cfg(false)] + | ^^^^^^^^^^^^^ + | + = note: see issue #140364 <https://github.com/rust-lang/rust/issues/140364> for more information + = help: add `#![feature(asm_cfg)]` 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]: the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable + --> $DIR/feature-gate-asm_cfg.rs:18:9 + | +LL | #[cfg(false)] + | ^^^^^^^^^^^^^ + | + = note: see issue #140364 <https://github.com/rust-lang/rust/issues/140364> for more information + = help: add `#![feature(asm_cfg)]` 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]: the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable + --> $DIR/feature-gate-asm_cfg.rs:22:9 + | +LL | #[cfg(false)] + | ^^^^^^^^^^^^^ + | + = note: see issue #140364 <https://github.com/rust-lang/rust/issues/140364> for more information + = help: add `#![feature(asm_cfg)]` 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]: the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable + --> $DIR/feature-gate-asm_cfg.rs:32:13 + | +LL | #[cfg(false)] + | ^^^^^^^^^^^^^ + | + = note: see issue #140364 <https://github.com/rust-lang/rust/issues/140364> for more information + = help: add `#![feature(asm_cfg)]` 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: this attribute is not supported on assembly + --> $DIR/feature-gate-asm_cfg.rs:43:13 + | +LL | #[inline] + | ^^^^^^^^^ + +error: `C` ABI specified multiple times + --> $DIR/feature-gate-asm_cfg.rs:35:13 + | +LL | clobber_abi("C"), + | ---------------- previously specified here +LL | clobber_abi("C"), + | ^^^^^^^^^^^^^^^^ + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-async-fn-in-dyn-trait.rs b/tests/ui/feature-gates/feature-gate-async-fn-in-dyn-trait.rs index 278a5451e84..50e5fd1ab7a 100644 --- a/tests/ui/feature-gates/feature-gate-async-fn-in-dyn-trait.rs +++ b/tests/ui/feature-gates/feature-gate-async-fn-in-dyn-trait.rs @@ -7,8 +7,6 @@ trait Foo { async fn takes_dyn_trait(x: &dyn Foo) { //~^ ERROR the trait `Foo` is not dyn compatible x.bar().await; - //~^ ERROR the trait `Foo` is not dyn compatible - //~| ERROR the trait `Foo` is not dyn compatible } fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-async-fn-in-dyn-trait.stderr b/tests/ui/feature-gates/feature-gate-async-fn-in-dyn-trait.stderr index ab8c092a826..fd94b0babdb 100644 --- a/tests/ui/feature-gates/feature-gate-async-fn-in-dyn-trait.stderr +++ b/tests/ui/feature-gates/feature-gate-async-fn-in-dyn-trait.stderr @@ -14,38 +14,6 @@ LL | async fn bar(&self); | ^^^ ...because method `bar` is `async` = help: consider moving `bar` to another trait -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/feature-gate-async-fn-in-dyn-trait.rs:9:7 - | -LL | x.bar().await; - | ^^^ `Foo` 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/feature-gate-async-fn-in-dyn-trait.rs:4:14 - | -LL | trait Foo { - | --- this trait is not dyn compatible... -LL | async fn bar(&self); - | ^^^ ...because method `bar` is `async` - = help: consider moving `bar` to another trait - -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/feature-gate-async-fn-in-dyn-trait.rs:9:5 - | -LL | x.bar().await; - | ^^^^^^^ `Foo` 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/feature-gate-async-fn-in-dyn-trait.rs:4:14 - | -LL | trait Foo { - | --- this trait is not dyn compatible... -LL | async fn bar(&self); - | ^^^ ...because method `bar` is `async` - = help: consider moving `bar` to another trait - -error: aborting due to 3 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/feature-gates/feature-gate-autodiff-use.has_support.stderr b/tests/ui/feature-gates/feature-gate-autodiff-use.has_support.stderr index 15ef257fbd8..e5edd8e45e6 100644 --- a/tests/ui/feature-gates/feature-gate-autodiff-use.has_support.stderr +++ b/tests/ui/feature-gates/feature-gate-autodiff-use.has_support.stderr @@ -1,8 +1,8 @@ error[E0658]: use of unstable library feature `autodiff` --> $DIR/feature-gate-autodiff-use.rs:13:3 | -LL | #[autodiff(dfoo, Reverse)] - | ^^^^^^^^ +LL | #[autodiff_reverse(dfoo)] + | ^^^^^^^^^^^^^^^^ | = note: see issue #124509 <https://github.com/rust-lang/rust/issues/124509> for more information = help: add `#![feature(autodiff)]` to the crate attributes to enable @@ -11,8 +11,8 @@ LL | #[autodiff(dfoo, Reverse)] error[E0658]: use of unstable library feature `autodiff` --> $DIR/feature-gate-autodiff-use.rs:9:5 | -LL | use std::autodiff::autodiff; - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | use std::autodiff::autodiff_reverse; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #124509 <https://github.com/rust-lang/rust/issues/124509> for more information = help: add `#![feature(autodiff)]` to the crate attributes to enable diff --git a/tests/ui/feature-gates/feature-gate-autodiff-use.no_support.stderr b/tests/ui/feature-gates/feature-gate-autodiff-use.no_support.stderr index f59e4955452..65ba033b358 100644 --- a/tests/ui/feature-gates/feature-gate-autodiff-use.no_support.stderr +++ b/tests/ui/feature-gates/feature-gate-autodiff-use.no_support.stderr @@ -1,8 +1,8 @@ error[E0658]: use of unstable library feature `autodiff` --> $DIR/feature-gate-autodiff-use.rs:13:3 | -LL | #[autodiff(dfoo, Reverse)] - | ^^^^^^^^ +LL | #[autodiff_reverse(dfoo)] + | ^^^^^^^^^^^^^^^^ | = note: see issue #124509 <https://github.com/rust-lang/rust/issues/124509> for more information = help: add `#![feature(autodiff)]` to the crate attributes to enable @@ -11,14 +11,14 @@ LL | #[autodiff(dfoo, Reverse)] error: this rustc version does not support autodiff --> $DIR/feature-gate-autodiff-use.rs:13:1 | -LL | #[autodiff(dfoo, Reverse)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[autodiff_reverse(dfoo)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0658]: use of unstable library feature `autodiff` --> $DIR/feature-gate-autodiff-use.rs:9:5 | -LL | use std::autodiff::autodiff; - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | use std::autodiff::autodiff_reverse; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #124509 <https://github.com/rust-lang/rust/issues/124509> for more information = help: add `#![feature(autodiff)]` to the crate attributes to enable diff --git a/tests/ui/feature-gates/feature-gate-autodiff-use.rs b/tests/ui/feature-gates/feature-gate-autodiff-use.rs index 602e830b0b2..2864b786c12 100644 --- a/tests/ui/feature-gates/feature-gate-autodiff-use.rs +++ b/tests/ui/feature-gates/feature-gate-autodiff-use.rs @@ -6,11 +6,11 @@ #![crate_type = "lib"] -use std::autodiff::autodiff; +use std::autodiff::autodiff_reverse; //[has_support]~^ ERROR use of unstable library feature `autodiff` //[no_support]~^^ ERROR use of unstable library feature `autodiff` -#[autodiff(dfoo, Reverse)] +#[autodiff_reverse(dfoo)] //[has_support]~^ ERROR use of unstable library feature `autodiff` [E0658] //[no_support]~^^ ERROR use of unstable library feature `autodiff` [E0658] //[no_support]~| ERROR this rustc version does not support autodiff diff --git a/tests/ui/feature-gates/feature-gate-autodiff.has_support.stderr b/tests/ui/feature-gates/feature-gate-autodiff.has_support.stderr index c25cf7d3373..dcbaba71645 100644 --- a/tests/ui/feature-gates/feature-gate-autodiff.has_support.stderr +++ b/tests/ui/feature-gates/feature-gate-autodiff.has_support.stderr @@ -1,12 +1,12 @@ -error: cannot find attribute `autodiff` in this scope +error: cannot find attribute `autodiff_reverse` in this scope --> $DIR/feature-gate-autodiff.rs:9:3 | -LL | #[autodiff(dfoo, Reverse)] - | ^^^^^^^^ +LL | #[autodiff_reverse(dfoo)] + | ^^^^^^^^^^^^^^^^ | help: consider importing this attribute macro | -LL + use std::autodiff::autodiff; +LL + use std::autodiff::autodiff_reverse; | error: aborting due to 1 previous error diff --git a/tests/ui/feature-gates/feature-gate-autodiff.no_support.stderr b/tests/ui/feature-gates/feature-gate-autodiff.no_support.stderr index c25cf7d3373..dcbaba71645 100644 --- a/tests/ui/feature-gates/feature-gate-autodiff.no_support.stderr +++ b/tests/ui/feature-gates/feature-gate-autodiff.no_support.stderr @@ -1,12 +1,12 @@ -error: cannot find attribute `autodiff` in this scope +error: cannot find attribute `autodiff_reverse` in this scope --> $DIR/feature-gate-autodiff.rs:9:3 | -LL | #[autodiff(dfoo, Reverse)] - | ^^^^^^^^ +LL | #[autodiff_reverse(dfoo)] + | ^^^^^^^^^^^^^^^^ | help: consider importing this attribute macro | -LL + use std::autodiff::autodiff; +LL + use std::autodiff::autodiff_reverse; | error: aborting due to 1 previous error diff --git a/tests/ui/feature-gates/feature-gate-autodiff.rs b/tests/ui/feature-gates/feature-gate-autodiff.rs index 4249b229a69..adb35cb8e33 100644 --- a/tests/ui/feature-gates/feature-gate-autodiff.rs +++ b/tests/ui/feature-gates/feature-gate-autodiff.rs @@ -6,7 +6,7 @@ // This checks that without the autodiff feature enabled, we can't use it. -#[autodiff(dfoo, Reverse)] -//[has_support]~^ ERROR cannot find attribute `autodiff` in this scope -//[no_support]~^^ ERROR cannot find attribute `autodiff` in this scope +#[autodiff_reverse(dfoo)] +//[has_support]~^ ERROR cannot find attribute `autodiff_reverse` in this scope +//[no_support]~^^ ERROR cannot find attribute `autodiff_reverse` in this scope fn foo() {} diff --git a/tests/ui/feature-gates/feature-gate-cfg-version.rs b/tests/ui/feature-gates/feature-gate-cfg-version.rs index e35784a68d1..ec2446cc146 100644 --- a/tests/ui/feature-gates/feature-gate-cfg-version.rs +++ b/tests/ui/feature-gates/feature-gate-cfg-version.rs @@ -1,49 +1,12 @@ -#[cfg(version(42))] //~ ERROR: expected a version literal -//~^ ERROR `cfg(version)` is experimental and subject to change -fn foo() {} -#[cfg(version(1.20))] //~ ERROR: expected a version literal -//~^ ERROR `cfg(version)` is experimental and subject to change -fn foo() -> bool { true } -#[cfg(version("1.44"))] -//~^ ERROR `cfg(version)` is experimental and subject to change -fn foo() -> bool { true } -#[cfg(not(version("1.44")))] -//~^ ERROR `cfg(version)` is experimental and subject to change -fn foo() -> bool { false } +//! Feature gate test for `cfg_version`. +//! +//! Tracking issue: #64796. -#[cfg(version("1.43", "1.44", "1.45"))] //~ ERROR: expected single version literal -//~^ ERROR `cfg(version)` is experimental and subject to change -fn bar() -> bool { false } -#[cfg(version(false))] //~ ERROR: expected a version literal -//~^ ERROR `cfg(version)` is experimental and subject to change -fn bar() -> bool { false } -#[cfg(version("foo"))] //~ WARNING: unknown version literal format -//~^ ERROR `cfg(version)` is experimental and subject to change -fn bar() -> bool { false } -#[cfg(version("999"))] //~ WARNING: unknown version literal format -//~^ ERROR `cfg(version)` is experimental and subject to change -fn bar() -> bool { false } -#[cfg(version("-1"))] //~ WARNING: unknown version literal format -//~^ ERROR `cfg(version)` is experimental and subject to change -fn bar() -> bool { false } -#[cfg(version("65536"))] //~ WARNING: unknown version literal format -//~^ ERROR `cfg(version)` is experimental and subject to change -fn bar() -> bool { false } -#[cfg(version("0"))] //~ WARNING: unknown version literal format -//~^ ERROR `cfg(version)` is experimental and subject to change -fn bar() -> bool { true } -#[cfg(version("1.0"))] -//~^ ERROR `cfg(version)` is experimental and subject to change -fn bar() -> bool { true } -#[cfg(version("1.65536.2"))] //~ WARNING: unknown version literal format -//~^ ERROR `cfg(version)` is experimental and subject to change -fn bar() -> bool { false } -#[cfg(version("1.20.0-stable"))] //~ WARNING: unknown version literal format +#[cfg(version("1.42"))] //~^ ERROR `cfg(version)` is experimental and subject to change fn bar() {} fn main() { - assert!(foo()); - assert!(bar()); - assert!(cfg!(version("1.42"))); //~ ERROR `cfg(version)` is experimental and subject to change + assert!(cfg!(version("1.42"))); + //~^ ERROR `cfg(version)` is experimental and subject to change } diff --git a/tests/ui/feature-gates/feature-gate-cfg-version.stderr b/tests/ui/feature-gates/feature-gate-cfg-version.stderr index c1c3e8e5897..7cb2f1e07af 100644 --- a/tests/ui/feature-gates/feature-gate-cfg-version.stderr +++ b/tests/ui/feature-gates/feature-gate-cfg-version.stderr @@ -1,39 +1,7 @@ error[E0658]: `cfg(version)` is experimental and subject to change - --> $DIR/feature-gate-cfg-version.rs:1:7 + --> $DIR/feature-gate-cfg-version.rs:5:7 | -LL | #[cfg(version(42))] - | ^^^^^^^^^^^ - | - = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information - = help: add `#![feature(cfg_version)]` 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: expected a version literal - --> $DIR/feature-gate-cfg-version.rs:1:15 - | -LL | #[cfg(version(42))] - | ^^ - -error[E0658]: `cfg(version)` is experimental and subject to change - --> $DIR/feature-gate-cfg-version.rs:4:7 - | -LL | #[cfg(version(1.20))] - | ^^^^^^^^^^^^^ - | - = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information - = help: add `#![feature(cfg_version)]` 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: expected a version literal - --> $DIR/feature-gate-cfg-version.rs:4:15 - | -LL | #[cfg(version(1.20))] - | ^^^^ - -error[E0658]: `cfg(version)` is experimental and subject to change - --> $DIR/feature-gate-cfg-version.rs:7:7 - | -LL | #[cfg(version("1.44"))] +LL | #[cfg(version("1.42"))] | ^^^^^^^^^^^^^^^ | = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information @@ -41,171 +9,7 @@ LL | #[cfg(version("1.44"))] = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `cfg(version)` is experimental and subject to change - --> $DIR/feature-gate-cfg-version.rs:10:11 - | -LL | #[cfg(not(version("1.44")))] - | ^^^^^^^^^^^^^^^ - | - = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information - = help: add `#![feature(cfg_version)]` 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(version)` is experimental and subject to change - --> $DIR/feature-gate-cfg-version.rs:14:7 - | -LL | #[cfg(version("1.43", "1.44", "1.45"))] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information - = help: add `#![feature(cfg_version)]` 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: expected single version literal - --> $DIR/feature-gate-cfg-version.rs:14:7 - | -LL | #[cfg(version("1.43", "1.44", "1.45"))] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0658]: `cfg(version)` is experimental and subject to change - --> $DIR/feature-gate-cfg-version.rs:17:7 - | -LL | #[cfg(version(false))] - | ^^^^^^^^^^^^^^ - | - = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information - = help: add `#![feature(cfg_version)]` 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: expected a version literal - --> $DIR/feature-gate-cfg-version.rs:17:15 - | -LL | #[cfg(version(false))] - | ^^^^^ - -error[E0658]: `cfg(version)` is experimental and subject to change - --> $DIR/feature-gate-cfg-version.rs:20:7 - | -LL | #[cfg(version("foo"))] - | ^^^^^^^^^^^^^^ - | - = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information - = help: add `#![feature(cfg_version)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -warning: unknown version literal format, assuming it refers to a future version - --> $DIR/feature-gate-cfg-version.rs:20:15 - | -LL | #[cfg(version("foo"))] - | ^^^^^ - -error[E0658]: `cfg(version)` is experimental and subject to change - --> $DIR/feature-gate-cfg-version.rs:23:7 - | -LL | #[cfg(version("999"))] - | ^^^^^^^^^^^^^^ - | - = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information - = help: add `#![feature(cfg_version)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -warning: unknown version literal format, assuming it refers to a future version - --> $DIR/feature-gate-cfg-version.rs:23:15 - | -LL | #[cfg(version("999"))] - | ^^^^^ - -error[E0658]: `cfg(version)` is experimental and subject to change - --> $DIR/feature-gate-cfg-version.rs:26:7 - | -LL | #[cfg(version("-1"))] - | ^^^^^^^^^^^^^ - | - = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information - = help: add `#![feature(cfg_version)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -warning: unknown version literal format, assuming it refers to a future version - --> $DIR/feature-gate-cfg-version.rs:26:15 - | -LL | #[cfg(version("-1"))] - | ^^^^ - -error[E0658]: `cfg(version)` is experimental and subject to change - --> $DIR/feature-gate-cfg-version.rs:29:7 - | -LL | #[cfg(version("65536"))] - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information - = help: add `#![feature(cfg_version)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -warning: unknown version literal format, assuming it refers to a future version - --> $DIR/feature-gate-cfg-version.rs:29:15 - | -LL | #[cfg(version("65536"))] - | ^^^^^^^ - -error[E0658]: `cfg(version)` is experimental and subject to change - --> $DIR/feature-gate-cfg-version.rs:32:7 - | -LL | #[cfg(version("0"))] - | ^^^^^^^^^^^^ - | - = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information - = help: add `#![feature(cfg_version)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -warning: unknown version literal format, assuming it refers to a future version - --> $DIR/feature-gate-cfg-version.rs:32:15 - | -LL | #[cfg(version("0"))] - | ^^^ - -error[E0658]: `cfg(version)` is experimental and subject to change - --> $DIR/feature-gate-cfg-version.rs:35:7 - | -LL | #[cfg(version("1.0"))] - | ^^^^^^^^^^^^^^ - | - = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information - = help: add `#![feature(cfg_version)]` 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(version)` is experimental and subject to change - --> $DIR/feature-gate-cfg-version.rs:38:7 - | -LL | #[cfg(version("1.65536.2"))] - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information - = help: add `#![feature(cfg_version)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -warning: unknown version literal format, assuming it refers to a future version - --> $DIR/feature-gate-cfg-version.rs:38:15 - | -LL | #[cfg(version("1.65536.2"))] - | ^^^^^^^^^^^ - -error[E0658]: `cfg(version)` is experimental and subject to change - --> $DIR/feature-gate-cfg-version.rs:41:7 - | -LL | #[cfg(version("1.20.0-stable"))] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information - = help: add `#![feature(cfg_version)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -warning: unknown version literal format, assuming it refers to a future version - --> $DIR/feature-gate-cfg-version.rs:41:15 - | -LL | #[cfg(version("1.20.0-stable"))] - | ^^^^^^^^^^^^^^^ - -error[E0658]: `cfg(version)` is experimental and subject to change - --> $DIR/feature-gate-cfg-version.rs:48:18 + --> $DIR/feature-gate-cfg-version.rs:10:18 | LL | assert!(cfg!(version("1.42"))); | ^^^^^^^^^^^^^^^ @@ -214,6 +18,6 @@ LL | assert!(cfg!(version("1.42"))); = help: add `#![feature(cfg_version)]` 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 19 previous errors; 7 warnings emitted +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-coroutines.e2024.stderr b/tests/ui/feature-gates/feature-gate-coroutines.e2024.stderr index 381e7a210be..c29c328ac14 100644 --- a/tests/ui/feature-gates/feature-gate-coroutines.e2024.stderr +++ b/tests/ui/feature-gates/feature-gate-coroutines.e2024.stderr @@ -5,7 +5,7 @@ LL | yield true; | ^^^^^^^^^^ | = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information - = help: add `#![feature(coroutines)]` to the crate attributes to enable + = help: add `#![feature(yield_expr)]` 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]: yield syntax is experimental @@ -15,7 +15,7 @@ LL | let _ = || yield true; | ^^^^^^^^^^ | = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information - = help: add `#![feature(coroutines)]` to the crate attributes to enable + = help: add `#![feature(yield_expr)]` 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]: yield syntax is experimental @@ -25,7 +25,7 @@ LL | yield; | ^^^^^ | = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information - = help: add `#![feature(coroutines)]` to the crate attributes to enable + = help: add `#![feature(yield_expr)]` 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]: yield syntax is experimental @@ -35,7 +35,7 @@ LL | yield 0; | ^^^^^^^ | = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information - = help: add `#![feature(coroutines)]` to the crate attributes to enable + = help: add `#![feature(yield_expr)]` 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]: yield syntax is experimental diff --git a/tests/ui/feature-gates/feature-gate-coroutines.none.stderr b/tests/ui/feature-gates/feature-gate-coroutines.none.stderr index 381e7a210be..c29c328ac14 100644 --- a/tests/ui/feature-gates/feature-gate-coroutines.none.stderr +++ b/tests/ui/feature-gates/feature-gate-coroutines.none.stderr @@ -5,7 +5,7 @@ LL | yield true; | ^^^^^^^^^^ | = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information - = help: add `#![feature(coroutines)]` to the crate attributes to enable + = help: add `#![feature(yield_expr)]` 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]: yield syntax is experimental @@ -15,7 +15,7 @@ LL | let _ = || yield true; | ^^^^^^^^^^ | = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information - = help: add `#![feature(coroutines)]` to the crate attributes to enable + = help: add `#![feature(yield_expr)]` 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]: yield syntax is experimental @@ -25,7 +25,7 @@ LL | yield; | ^^^^^ | = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information - = help: add `#![feature(coroutines)]` to the crate attributes to enable + = help: add `#![feature(yield_expr)]` 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]: yield syntax is experimental @@ -35,7 +35,7 @@ LL | yield 0; | ^^^^^^^ | = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information - = help: add `#![feature(coroutines)]` to the crate attributes to enable + = help: add `#![feature(yield_expr)]` 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]: yield syntax is experimental diff --git a/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.rs b/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.rs index 37eabbf1602..8d7ccea9e64 100644 --- a/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.rs +++ b/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.rs @@ -31,5 +31,4 @@ impl Trait for i32 { fn main() { Ptr(Box::new(4)) as Ptr<dyn Trait>; //~^ ERROR the trait `Trait` is not dyn compatible - //~^^ ERROR the trait `Trait` is not dyn compatible } diff --git a/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.stderr b/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.stderr index 6634ce12118..c70ab65aa90 100644 --- a/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.stderr +++ b/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.stderr @@ -1,11 +1,11 @@ error[E0038]: the trait `Trait` is not dyn compatible - --> $DIR/feature-gate-dispatch-from-dyn-missing-impl.rs:32:25 + --> $DIR/feature-gate-dispatch-from-dyn-missing-impl.rs:32:33 | LL | fn ptr(self: Ptr<Self>); | --------- help: consider changing method `ptr`'s `self` parameter to be `&self`: `&Self` ... LL | Ptr(Box::new(4)) as Ptr<dyn Trait>; - | ^^^^^^^^^^^^^^ `Trait` is not dyn compatible + | ^^^^^ `Trait` 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> @@ -17,26 +17,6 @@ LL | fn ptr(self: Ptr<Self>); | ^^^^^^^^^ ...because method `ptr`'s `self` parameter cannot be dispatched on = help: only type `i32` implements `Trait`; consider using it directly instead. -error[E0038]: the trait `Trait` is not dyn compatible - --> $DIR/feature-gate-dispatch-from-dyn-missing-impl.rs:32:5 - | -LL | fn ptr(self: Ptr<Self>); - | --------- help: consider changing method `ptr`'s `self` parameter to be `&self`: `&Self` -... -LL | Ptr(Box::new(4)) as Ptr<dyn Trait>; - | ^^^^^^^^^^^^^^^^ `Trait` 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/feature-gate-dispatch-from-dyn-missing-impl.rs:25:18 - | -LL | trait Trait { - | ----- this trait is not dyn compatible... -LL | fn ptr(self: Ptr<Self>); - | ^^^^^^^^^ ...because method `ptr`'s `self` parameter cannot be dispatched on - = help: only type `i32` implements `Trait`; consider using it directly instead. - = note: required for the cast from `Ptr<{integer}>` to `Ptr<dyn Trait>` - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/feature-gates/feature-gate-repr128.rs b/tests/ui/feature-gates/feature-gate-repr128.rs deleted file mode 100644 index 0290874dd27..00000000000 --- a/tests/ui/feature-gates/feature-gate-repr128.rs +++ /dev/null @@ -1,6 +0,0 @@ -#[repr(u128)] -enum A { //~ ERROR repr with 128-bit type is unstable - A(u64) -} - -fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-repr128.stderr b/tests/ui/feature-gates/feature-gate-repr128.stderr deleted file mode 100644 index 2607032447b..00000000000 --- a/tests/ui/feature-gates/feature-gate-repr128.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: repr with 128-bit type is unstable - --> $DIR/feature-gate-repr128.rs:2:1 - | -LL | enum A { - | ^^^^^^ - | - = note: see issue #56071 <https://github.com/rust-lang/rust/issues/56071> for more information - = help: add `#![feature(repr128)]` 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-yield-expr.stderr b/tests/ui/feature-gates/feature-gate-yield-expr.stderr index ad8a15a0f36..bfac9e49803 100644 --- a/tests/ui/feature-gates/feature-gate-yield-expr.stderr +++ b/tests/ui/feature-gates/feature-gate-yield-expr.stderr @@ -5,7 +5,7 @@ LL | yield (); | ^^^^^^^^ | = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information - = help: add `#![feature(coroutines)]` to the crate attributes to enable + = help: add `#![feature(yield_expr)]` 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]: yield syntax is experimental diff --git a/tests/ui/feature-gates/feature-gated-feature-in-macro-arg.stderr b/tests/ui/feature-gates/feature-gated-feature-in-macro-arg.stderr index aaaaeece67a..fb05273b6ff 100644 --- a/tests/ui/feature-gates/feature-gated-feature-in-macro-arg.stderr +++ b/tests/ui/feature-gates/feature-gated-feature-in-macro-arg.stderr @@ -7,7 +7,7 @@ LL | #[rustc_intrinsic] = help: add `#![feature(intrinsics)]` 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[E0133]: call to unsafe function `atomic_fence` is unsafe and requires unsafe function or block +error[E0133]: call to unsafe function `main::atomic_fence` is unsafe and requires unsafe function or block --> $DIR/feature-gated-feature-in-macro-arg.rs:11:9 | LL | atomic_fence(); diff --git a/tests/ui/feature-gates/version_check.rs b/tests/ui/feature-gates/version_check.rs deleted file mode 100644 index e212dc74fd1..00000000000 --- a/tests/ui/feature-gates/version_check.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ run-pass -//@ only-linux -//@ only-x86 -// FIXME: this should be more like //@ needs-subprocesses -use std::process::Command; - -fn main() { - let signalled_version = "Ceci n'est pas une rustc"; - let version = Command::new(std::env::var_os("RUSTC").unwrap()) - .env("RUSTC_OVERRIDE_VERSION_STRING", signalled_version) - .arg("--version") - .output() - .unwrap() - .stdout; - let version = std::str::from_utf8(&version).unwrap().strip_prefix("rustc ").unwrap().trim_end(); - assert_eq!(version, signalled_version); -} diff --git a/tests/ui/fn/coerce-suggestion-infer-region.rs b/tests/ui/fn/coerce-suggestion-infer-region.rs new file mode 100644 index 00000000000..7edb828c973 --- /dev/null +++ b/tests/ui/fn/coerce-suggestion-infer-region.rs @@ -0,0 +1,26 @@ +//! Functions with a mismatch between the expected and found type where the difference is a +//! reference may trigger analysis for additional help. In this test the expected type will be +//! &'a Container<&'a u8> and the found type will be Container<&'?0 u8>. +//! +//! This test exercises a scenario where the found type being analyzed contains an inference region +//! variable ('?0). This cannot be used in comparisons because the variable no longer exists by the +//! time the later analysis is performed. +//! +//! This is a regression test of #140823 + +trait MyFn<P> {} + +struct Container<T> { + data: T, +} + +struct Desugared { + callback: Box<dyn for<'a> MyFn<&'a Container<&'a u8>>>, +} + +fn test(callback: Box<dyn for<'a> MyFn<Container<&'a u8>>>) -> Desugared { + Desugared { callback } + //~^ ERROR mismatched types +} + +fn main() {} diff --git a/tests/ui/fn/coerce-suggestion-infer-region.stderr b/tests/ui/fn/coerce-suggestion-infer-region.stderr new file mode 100644 index 00000000000..9dd0fcf76ce --- /dev/null +++ b/tests/ui/fn/coerce-suggestion-infer-region.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/coerce-suggestion-infer-region.rs:22:17 + | +LL | Desugared { callback } + | ^^^^^^^^ expected `Box<dyn MyFn<&Container<&u8>>>`, found `Box<dyn MyFn<Container<&u8>>>` + | + = note: expected struct `Box<(dyn for<'a> MyFn<&'a Container<&'a u8>> + 'static)>` + found struct `Box<(dyn for<'a> MyFn<Container<&'a u8>> + 'static)>` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/frontmatter/frontmatter-inner-hyphens-1.rs b/tests/ui/frontmatter/frontmatter-inner-hyphens-1.rs new file mode 100644 index 00000000000..985b1cfe988 --- /dev/null +++ b/tests/ui/frontmatter/frontmatter-inner-hyphens-1.rs @@ -0,0 +1,10 @@ +--- +x ---🚧️ +--- + +// Regression test for #141483 +//@check-pass + +#![feature(frontmatter)] + +fn main() {} diff --git a/tests/ui/frontmatter/frontmatter-inner-hyphens-2.rs b/tests/ui/frontmatter/frontmatter-inner-hyphens-2.rs new file mode 100644 index 00000000000..3d5fb453872 --- /dev/null +++ b/tests/ui/frontmatter/frontmatter-inner-hyphens-2.rs @@ -0,0 +1,11 @@ +--- +x ---y +--- + +// Test that hypens are allowed inside frontmatters if there is some +// non-whitespace character preceding them. +//@check-pass + +#![feature(frontmatter)] + +fn main() {} diff --git a/tests/ui/bare-fn-implements-fn-mut.rs b/tests/ui/functions-closures/bare-fn-implements-fn-mut.rs index 49b31f28f8a..52d5ad3d0f7 100644 --- a/tests/ui/bare-fn-implements-fn-mut.rs +++ b/tests/ui/functions-closures/bare-fn-implements-fn-mut.rs @@ -1,3 +1,7 @@ +//! Tests that bare functions implement the `FnMut` trait. +//! +//! See <https://github.com/rust-lang/rust/issues/15448>. + //@ run-pass fn call_f<F:FnMut()>(mut f: F) { diff --git a/tests/ui/functions-closures/fn-help-with-err.stderr b/tests/ui/functions-closures/fn-help-with-err.stderr index e5fe4611434..9dc56c3652a 100644 --- a/tests/ui/functions-closures/fn-help-with-err.stderr +++ b/tests/ui/functions-closures/fn-help-with-err.stderr @@ -8,7 +8,7 @@ error[E0599]: no method named `bar` found for struct `Arc<{closure@$DIR/fn-help- --> $DIR/fn-help-with-err.rs:19:10 | LL | arc2.bar(); - | ^^^ method not found in `Arc<{closure@fn-help-with-err.rs:18:36}>` + | ^^^ method not found in `Arc<{closure@$DIR/fn-help-with-err.rs:18:36: 18:38}>` | = help: items from traits can only be used if the trait is implemented and in scope note: `Bar` defines an item `bar`, perhaps you need to implement it diff --git a/tests/ui/future-incompatible-lint-group.rs b/tests/ui/future-incompatible-lint-group.rs index c84538318f7..ed2c47bb609 100644 --- a/tests/ui/future-incompatible-lint-group.rs +++ b/tests/ui/future-incompatible-lint-group.rs @@ -2,16 +2,14 @@ // lints for changes that are not tied to an edition #![deny(future_incompatible)] +// Error since this is a `future_incompatible` lint +macro_rules! m { ($i) => {} } //~ ERROR missing fragment specifier + //~| WARN this was previously accepted + trait Tr { // Warn only since this is not a `future_incompatible` lint fn f(u8) {} //~ WARN anonymous parameters are deprecated //~| WARN this is accepted in the current edition } -pub mod submodule { - // Error since this is a `future_incompatible` lint - #![doc(test(some_test))] - //~^ ERROR this attribute can only be applied at the crate level -} - fn main() {} diff --git a/tests/ui/future-incompatible-lint-group.stderr b/tests/ui/future-incompatible-lint-group.stderr index 4e6c434fa29..4c867e0aab3 100644 --- a/tests/ui/future-incompatible-lint-group.stderr +++ b/tests/ui/future-incompatible-lint-group.stderr @@ -1,5 +1,20 @@ +error: missing fragment specifier + --> $DIR/future-incompatible-lint-group.rs:6:19 + | +LL | macro_rules! m { ($i) => {} } + | ^^ + | + = 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 #40107 <https://github.com/rust-lang/rust/issues/40107> +note: the lint level is defined here + --> $DIR/future-incompatible-lint-group.rs:3:9 + | +LL | #![deny(future_incompatible)] + | ^^^^^^^^^^^^^^^^^^^ + = note: `#[deny(missing_fragment_specifier)]` implied by `#[deny(future_incompatible)]` + warning: anonymous parameters are deprecated and will be removed in the next edition - --> $DIR/future-incompatible-lint-group.rs:7:10 + --> $DIR/future-incompatible-lint-group.rs:11:10 | LL | fn f(u8) {} | ^^ help: try naming the parameter or explicitly ignoring it: `_: u8` @@ -8,14 +23,21 @@ LL | fn f(u8) {} = note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686> = note: `#[warn(anonymous_parameters)]` on by default -error: this attribute can only be applied at the crate level - --> $DIR/future-incompatible-lint-group.rs:13:12 +error: aborting due to 1 previous error; 1 warning emitted + +Future incompatibility report: Future breakage diagnostic: +error: missing fragment specifier + --> $DIR/future-incompatible-lint-group.rs:6:19 | -LL | #![doc(test(some_test))] - | ^^^^^^^^^^^^^^^ +LL | macro_rules! m { ($i) => {} } + | ^^ | - = note: read <https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#at-the-crate-level> for more information - = note: `#[deny(invalid_doc_attributes)]` on by default - -error: aborting due to 1 previous error; 1 warning emitted + = 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 #40107 <https://github.com/rust-lang/rust/issues/40107> +note: the lint level is defined here + --> $DIR/future-incompatible-lint-group.rs:3:9 + | +LL | #![deny(future_incompatible)] + | ^^^^^^^^^^^^^^^^^^^ + = note: `#[deny(missing_fragment_specifier)]` implied by `#[deny(future_incompatible)]` diff --git a/tests/ui/generic-associated-types/gat-in-trait-path.rs b/tests/ui/generic-associated-types/gat-in-trait-path.rs index 7523803eacf..774e16d84c5 100644 --- a/tests/ui/generic-associated-types/gat-in-trait-path.rs +++ b/tests/ui/generic-associated-types/gat-in-trait-path.rs @@ -26,5 +26,4 @@ fn main() { let foo = Fooer(5); f(Box::new(foo)); //~^ ERROR the trait `Foo` is not dyn compatible - //~| ERROR the trait `Foo` is not dyn compatible } diff --git a/tests/ui/generic-associated-types/gat-in-trait-path.stderr b/tests/ui/generic-associated-types/gat-in-trait-path.stderr index e57f6b48401..d4ccd80f146 100644 --- a/tests/ui/generic-associated-types/gat-in-trait-path.stderr +++ b/tests/ui/generic-associated-types/gat-in-trait-path.stderr @@ -30,23 +30,6 @@ LL | type A<'a> where Self: 'a; | ^ ...because it contains the generic associated type `A` = help: consider moving `A` to another trait -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/gat-in-trait-path.rs:27:5 - | -LL | f(Box::new(foo)); - | ^^^^^^^^^^^^^ `Foo` 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/gat-in-trait-path.rs:6:10 - | -LL | trait Foo { - | --- this trait is not dyn compatible... -LL | type A<'a> where Self: 'a; - | ^ ...because it contains the generic associated type `A` - = help: consider moving `A` to another trait - = note: required for the cast from `Box<Fooer<{integer}>>` to `Box<(dyn Foo<A<'a> = &'a ()> + 'static)>` - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/generic-associated-types/issue-71176.rs b/tests/ui/generic-associated-types/issue-71176.rs index d3a0caffec1..8ecfa93750d 100644 --- a/tests/ui/generic-associated-types/issue-71176.rs +++ b/tests/ui/generic-associated-types/issue-71176.rs @@ -18,6 +18,5 @@ fn main() { Holder { inner: Box::new(()), //~^ ERROR: the trait `Provider` is not dyn compatible - //~| ERROR: the trait `Provider` is not dyn compatible }; } diff --git a/tests/ui/generic-associated-types/issue-71176.stderr b/tests/ui/generic-associated-types/issue-71176.stderr index 56439f6dfea..f231056a2ee 100644 --- a/tests/ui/generic-associated-types/issue-71176.stderr +++ b/tests/ui/generic-associated-types/issue-71176.stderr @@ -82,25 +82,7 @@ LL | type A<'a>; = help: consider moving `A` to another trait = help: only type `()` implements `Provider`; consider using it directly instead. -error[E0038]: the trait `Provider` is not dyn compatible - --> $DIR/issue-71176.rs:19:16 - | -LL | inner: Box::new(()), - | ^^^^^^^^^^^^ `Provider` 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/issue-71176.rs:2:10 - | -LL | trait Provider { - | -------- this trait is not dyn compatible... -LL | type A<'a>; - | ^ ...because it contains the generic associated type `A` - = help: consider moving `A` to another trait - = help: only type `()` implements `Provider`; consider using it directly instead. - = note: required for the cast from `Box<()>` to `Box<(dyn Provider<A<'_> = _> + 'static), {type error}>` - -error: aborting due to 6 previous errors +error: aborting due to 5 previous errors Some errors have detailed explanations: E0038, E0107. For more information about an error, try `rustc --explain E0038`. diff --git a/tests/ui/generic-associated-types/issue-76535.rs b/tests/ui/generic-associated-types/issue-76535.rs index 9e18c82c7f1..dc697401a58 100644 --- a/tests/ui/generic-associated-types/issue-76535.rs +++ b/tests/ui/generic-associated-types/issue-76535.rs @@ -33,6 +33,5 @@ impl SuperTrait for SuperStruct { fn main() { let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0)); //~^ ERROR missing generics for associated type - //~^^ ERROR the trait //~| ERROR the trait } diff --git a/tests/ui/generic-associated-types/issue-76535.stderr b/tests/ui/generic-associated-types/issue-76535.stderr index b828234afa1..2daf9d817bb 100644 --- a/tests/ui/generic-associated-types/issue-76535.stderr +++ b/tests/ui/generic-associated-types/issue-76535.stderr @@ -15,10 +15,10 @@ LL | let sub: Box<dyn SuperTrait<SubType<'a> = SubStruct>> = Box::new(SuperS | ++++ error[E0038]: the trait `SuperTrait` is not dyn compatible - --> $DIR/issue-76535.rs:34:14 + --> $DIR/issue-76535.rs:34:22 | LL | let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` is not dyn compatible + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` 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> @@ -32,26 +32,7 @@ LL | type SubType<'a>: SubTrait where Self: 'a; = help: only type `SuperStruct` implements `SuperTrait` within this crate; consider using it directly instead. = note: `SuperTrait` may be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type -error[E0038]: the trait `SuperTrait` is not dyn compatible - --> $DIR/issue-76535.rs:34:57 - | -LL | let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` 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/issue-76535.rs:4:10 - | -LL | pub trait SuperTrait { - | ---------- this trait is not dyn compatible... -LL | type SubType<'a>: SubTrait where Self: 'a; - | ^^^^^^^ ...because it contains the generic associated type `SubType` - = help: consider moving `SubType` to another trait - = help: only type `SuperStruct` implements `SuperTrait` within this crate; consider using it directly instead. - = note: `SuperTrait` may be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type - = note: required for the cast from `Box<SuperStruct>` to `Box<dyn SuperTrait<SubType<'_> = SubStruct<'_>>>` - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0038, E0107. For more information about an error, try `rustc --explain E0038`. diff --git a/tests/ui/generic-associated-types/issue-78671.stderr b/tests/ui/generic-associated-types/issue-78671.stderr index c6da137672d..fff061a8ada 100644 --- a/tests/ui/generic-associated-types/issue-78671.stderr +++ b/tests/ui/generic-associated-types/issue-78671.stderr @@ -15,10 +15,10 @@ LL | Box::new(Family) as &dyn CollectionFamily<Member<T>=usize> | +++ error[E0038]: the trait `CollectionFamily` is not dyn compatible - --> $DIR/issue-78671.rs:5:25 + --> $DIR/issue-78671.rs:5:30 | LL | Box::new(Family) as &dyn CollectionFamily<Member=usize> - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `CollectionFamily` is not dyn compatible + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `CollectionFamily` 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> diff --git a/tests/ui/generic-associated-types/issue-79422.rs b/tests/ui/generic-associated-types/issue-79422.rs index fba7a86990e..462614b3612 100644 --- a/tests/ui/generic-associated-types/issue-79422.rs +++ b/tests/ui/generic-associated-types/issue-79422.rs @@ -15,12 +15,17 @@ impl<'a, T> RefCont<'a, T> for Box<T> { } trait MapLike<K, V> { - type VRefCont<'a>: RefCont<'a, V> where Self: 'a; + type VRefCont<'a>: RefCont<'a, V> + where + Self: 'a; fn get<'a>(&'a self, key: &K) -> Option<Self::VRefCont<'a>>; } impl<K: Ord, V: 'static> MapLike<K, V> for std::collections::BTreeMap<K, V> { - type VRefCont<'a> = &'a V where Self: 'a; + type VRefCont<'a> + = &'a V + where + Self: 'a; fn get<'a>(&'a self, key: &K) -> Option<&'a V> { std::collections::BTreeMap::get(self, key) } @@ -37,8 +42,7 @@ impl<K, V: Default> MapLike<K, V> for Source { fn main() { let m = Box::new(std::collections::BTreeMap::<u8, u8>::new()) - //~^ ERROR the trait as Box<dyn MapLike<u8, u8, VRefCont = dyn RefCont<'_, u8>>>; - //~^ ERROR missing generics for associated type - //~| ERROR the trait + //~^ ERROR the trait + //~| ERROR missing generics for associated type } diff --git a/tests/ui/generic-associated-types/issue-79422.stderr b/tests/ui/generic-associated-types/issue-79422.stderr index 6311e4de272..dcf3a9008de 100644 --- a/tests/ui/generic-associated-types/issue-79422.stderr +++ b/tests/ui/generic-associated-types/issue-79422.stderr @@ -1,5 +1,5 @@ error[E0107]: missing generics for associated type `MapLike::VRefCont` - --> $DIR/issue-79422.rs:41:36 + --> $DIR/issue-79422.rs:45:36 | LL | as Box<dyn MapLike<u8, u8, VRefCont = dyn RefCont<'_, u8>>>; | ^^^^^^^^ expected 1 lifetime argument @@ -7,7 +7,7 @@ LL | as Box<dyn MapLike<u8, u8, VRefCont = dyn RefCont<'_, u8>>>; note: associated type defined here, with 1 lifetime parameter: `'a` --> $DIR/issue-79422.rs:18:10 | -LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a; +LL | type VRefCont<'a>: RefCont<'a, V> | ^^^^^^^^ -- help: add missing lifetime argument | @@ -15,10 +15,10 @@ LL | as Box<dyn MapLike<u8, u8, VRefCont<'a> = dyn RefCont<'_, u8>>>; | ++++ error[E0038]: the trait `MapLike` is not dyn compatible - --> $DIR/issue-79422.rs:41:12 + --> $DIR/issue-79422.rs:45:20 | LL | as Box<dyn MapLike<u8, u8, VRefCont = dyn RefCont<'_, u8>>>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` is not dyn compatible + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` 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> @@ -26,28 +26,11 @@ note: for a trait to be dyn compatible it needs to allow building a vtable | LL | trait MapLike<K, V> { | ------- this trait is not dyn compatible... -LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a; +LL | type VRefCont<'a>: RefCont<'a, V> | ^^^^^^^^ ...because it contains the generic associated type `VRefCont` = help: consider moving `VRefCont` to another trait -error[E0038]: the trait `MapLike` is not dyn compatible - --> $DIR/issue-79422.rs:39:13 - | -LL | let m = Box::new(std::collections::BTreeMap::<u8, u8>::new()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` 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/issue-79422.rs:18:10 - | -LL | trait MapLike<K, V> { - | ------- this trait is not dyn compatible... -LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a; - | ^^^^^^^^ ...because it contains the generic associated type `VRefCont` - = help: consider moving `VRefCont` to another trait - = note: required for the cast from `Box<BTreeMap<u8, u8>>` to `Box<dyn MapLike<u8, u8, VRefCont<'_> = (dyn RefCont<'_, u8> + 'static)>>` - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0038, E0107. For more information about an error, try `rustc --explain E0038`. diff --git a/tests/ui/generic-associated-types/trait-objects.rs b/tests/ui/generic-associated-types/trait-objects.rs index 256cfee4c80..87817111b54 100644 --- a/tests/ui/generic-associated-types/trait-objects.rs +++ b/tests/ui/generic-associated-types/trait-objects.rs @@ -8,8 +8,6 @@ trait StreamingIterator { fn min_size(x: &mut dyn for<'a> StreamingIterator<Item<'a> = &'a i32>) -> usize { //~^ ERROR the trait `StreamingIterator` is not dyn compatible x.size_hint().0 - //~^ ERROR the trait `StreamingIterator` is not dyn compatible - //~| ERROR the trait `StreamingIterator` is not dyn compatible } fn main() {} diff --git a/tests/ui/generic-associated-types/trait-objects.stderr b/tests/ui/generic-associated-types/trait-objects.stderr index 7d95718ec87..8c3af6b654a 100644 --- a/tests/ui/generic-associated-types/trait-objects.stderr +++ b/tests/ui/generic-associated-types/trait-objects.stderr @@ -14,38 +14,6 @@ LL | type Item<'a> where Self: 'a; | ^^^^ ...because it contains the generic associated type `Item` = help: consider moving `Item` to another trait -error[E0038]: the trait `StreamingIterator` is not dyn compatible - --> $DIR/trait-objects.rs:10:7 - | -LL | x.size_hint().0 - | ^^^^^^^^^ `StreamingIterator` 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/trait-objects.rs:2:10 - | -LL | trait StreamingIterator { - | ----------------- this trait is not dyn compatible... -LL | type Item<'a> where Self: 'a; - | ^^^^ ...because it contains the generic associated type `Item` - = help: consider moving `Item` to another trait - -error[E0038]: the trait `StreamingIterator` is not dyn compatible - --> $DIR/trait-objects.rs:10:5 - | -LL | x.size_hint().0 - | ^^^^^^^^^^^^^ `StreamingIterator` 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/trait-objects.rs:2:10 - | -LL | trait StreamingIterator { - | ----------------- this trait is not dyn compatible... -LL | type Item<'a> where Self: 'a; - | ^^^^ ...because it contains the generic associated type `Item` - = help: consider moving `Item` to another trait - -error: aborting due to 3 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/generic-const-items/def-site-eval.fail.stderr b/tests/ui/generic-const-items/def-site-eval.fail.stderr index fa07f385522..e39fbdf7802 100644 --- a/tests/ui/generic-const-items/def-site-eval.fail.stderr +++ b/tests/ui/generic-const-items/def-site-eval.fail.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `_::<'_>` failed - --> $DIR/def-site-eval.rs:14:20 +error[E0080]: evaluation panicked: explicit panic + --> $DIR/def-site-eval.rs:13:20 | LL | const _<'_a>: () = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `_` failed here error: aborting due to 1 previous error diff --git a/tests/ui/generic-const-items/def-site-eval.rs b/tests/ui/generic-const-items/def-site-eval.rs index 3ed7f96aed0..fa3ef5907b2 100644 --- a/tests/ui/generic-const-items/def-site-eval.rs +++ b/tests/ui/generic-const-items/def-site-eval.rs @@ -1,16 +1,15 @@ //! Test that we only evaluate free const items (their def site to be clear) //! whose generics don't require monomorphization. #![feature(generic_const_items)] -#![allow(incomplete_features)] +#![expect(incomplete_features)] //@ revisions: fail pass -//@[fail] build-fail (we require monomorphization) -//@[pass] build-pass (we require monomorphization) +//@[pass] check-pass const _<_T>: () = panic!(); const _<const _N: usize>: () = panic!(); #[cfg(fail)] -const _<'_a>: () = panic!(); //[fail]~ ERROR evaluation of `_::<'_>` failed +const _<'_a>: () = panic!(); //[fail]~ ERROR evaluation panicked: explicit panic fn main() {} diff --git a/tests/ui/generic-const-items/def-site-predicates-wf.rs b/tests/ui/generic-const-items/def-site-predicates-wf.rs new file mode 100644 index 00000000000..39cdcc304f3 --- /dev/null +++ b/tests/ui/generic-const-items/def-site-predicates-wf.rs @@ -0,0 +1,9 @@ +//! Ensure that we check the predicates for well-formedness at the definition site. +#![feature(generic_const_items)] +#![expect(incomplete_features)] + +const _: () = () +where + Vec<str>: Sized; //~ ERROR the size for values of type `str` cannot be known at compilation time + +fn main() {} diff --git a/tests/ui/generic-const-items/def-site-predicates-wf.stderr b/tests/ui/generic-const-items/def-site-predicates-wf.stderr new file mode 100644 index 00000000000..62db089fd55 --- /dev/null +++ b/tests/ui/generic-const-items/def-site-predicates-wf.stderr @@ -0,0 +1,13 @@ +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/def-site-predicates-wf.rs:7:15 + | +LL | Vec<str>: Sized; + | ^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` +note: required by an implicit `Sized` bound in `Vec` + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.rs b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.rs index 93f01c9577c..102c7b1e5f9 100644 --- a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.rs +++ b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.rs @@ -3,7 +3,7 @@ // Ensure that we check if trivial bounds on const items hold or not. -const UNUSABLE: () = () //~ ERROR evaluation of constant value failed +const UNUSABLE: () = () //~ ERROR entering unreachable code where String: Copy; diff --git a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.stderr b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.stderr index 407682fee56..e5c3bbb0c7d 100644 --- a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.stderr +++ b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.stderr @@ -1,10 +1,10 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: entering unreachable code --> $DIR/trivially-unsatisfied-bounds-0.rs:6:1 | LL | / const UNUSABLE: () = () LL | | where LL | | String: Copy; - | |_________________^ entering unreachable code + | |_________________^ evaluation of `UNUSABLE` failed here error[E0277]: the trait bound `String: Copy` is not satisfied --> $DIR/trivially-unsatisfied-bounds-0.rs:11:13 diff --git a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.rs b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.rs index 9243deac870..ebe97a65bbf 100644 --- a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.rs +++ b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.rs @@ -7,6 +7,6 @@ const UNUSED: () = () where String: Copy; -//~^^^ ERROR evaluation of constant value failed +//~^^^ ERROR unreachable code fn main() {} diff --git a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.stderr b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.stderr index b8438a0589c..a5f6dd980bd 100644 --- a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.stderr +++ b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.stderr @@ -1,10 +1,10 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: entering unreachable code --> $DIR/trivially-unsatisfied-bounds-1.rs:7:1 | LL | / const UNUSED: () = () LL | | where LL | | String: Copy; - | |_________________^ entering unreachable code + | |_________________^ evaluation of `UNUSED` failed here error: aborting due to 1 previous error diff --git a/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.rs b/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.rs index 961e5b4aeeb..13ce1f7de5b 100644 --- a/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.rs +++ b/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.rs @@ -5,7 +5,7 @@ const POSITIVE<const N: usize>: usize = N where - [(); N - 1]:; //~ ERROR evaluation of `POSITIVE::<0>::{constant#0}` failed + [(); N - 1]:; //~ ERROR overflow fn main() { let _ = POSITIVE::<0>; diff --git a/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.stderr b/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.stderr index f522190e8aa..a9f11ac31c3 100644 --- a/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.stderr +++ b/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `POSITIVE::<0>::{constant#0}` failed +error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow --> $DIR/unsatisfied-evaluatable-bounds.rs:8:10 | LL | [(); N - 1]:; - | ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow + | ^^^^^ evaluation of `POSITIVE::<0>::{constant#0}` failed here error: aborting due to 1 previous error diff --git a/tests/ui/generics/export-name-on-generics.fixed b/tests/ui/generics/export-name-on-generics.fixed index 4430cd9a299..c8a3fd5798f 100644 --- a/tests/ui/generics/export-name-on-generics.fixed +++ b/tests/ui/generics/export-name-on-generics.fixed @@ -1,5 +1,5 @@ //@ run-rustfix -#![allow(dead_code, elided_named_lifetimes)] +#![allow(dead_code, mismatched_lifetime_syntaxes)] #![deny(no_mangle_generic_items)] pub fn foo<T>() {} //~ ERROR functions generic over types or consts must be mangled diff --git a/tests/ui/generics/export-name-on-generics.rs b/tests/ui/generics/export-name-on-generics.rs index cbf11021960..8b38037fe12 100644 --- a/tests/ui/generics/export-name-on-generics.rs +++ b/tests/ui/generics/export-name-on-generics.rs @@ -1,5 +1,5 @@ //@ run-rustfix -#![allow(dead_code, elided_named_lifetimes)] +#![allow(dead_code, mismatched_lifetime_syntaxes)] #![deny(no_mangle_generic_items)] #[export_name = "foo"] diff --git a/tests/ui/generics/generic-no-mangle.fixed b/tests/ui/generics/generic-no-mangle.fixed index 2776848c45f..e3e41eb9d0d 100644 --- a/tests/ui/generics/generic-no-mangle.fixed +++ b/tests/ui/generics/generic-no-mangle.fixed @@ -1,5 +1,5 @@ //@ run-rustfix -#![allow(dead_code, elided_named_lifetimes)] +#![allow(dead_code, mismatched_lifetime_syntaxes)] #![deny(no_mangle_generic_items)] pub fn foo<T>() {} //~ ERROR functions generic over types or consts must be mangled diff --git a/tests/ui/generics/generic-no-mangle.rs b/tests/ui/generics/generic-no-mangle.rs index 5314005d31f..085f8610a54 100644 --- a/tests/ui/generics/generic-no-mangle.rs +++ b/tests/ui/generics/generic-no-mangle.rs @@ -1,5 +1,5 @@ //@ run-rustfix -#![allow(dead_code, elided_named_lifetimes)] +#![allow(dead_code, mismatched_lifetime_syntaxes)] #![deny(no_mangle_generic_items)] #[no_mangle] diff --git a/tests/ui/generics/post_monomorphization_error_backtrace.rs b/tests/ui/generics/post_monomorphization_error_backtrace.rs index f5f36ef03ae..9f53751584b 100644 --- a/tests/ui/generics/post_monomorphization_error_backtrace.rs +++ b/tests/ui/generics/post_monomorphization_error_backtrace.rs @@ -4,12 +4,12 @@ fn assert_zst<T>() { struct F<T>(T); impl<T> F<T> { const V: () = assert!(std::mem::size_of::<T>() == 0); - //~^ ERROR: evaluation of `assert_zst::F::<u32>::V` failed [E0080] + //~^ NOTE: evaluation of `assert_zst::F::<u32>::V` failed //~| NOTE: in this expansion of assert! - //~| NOTE: assertion failed - //~| ERROR: evaluation of `assert_zst::F::<i32>::V` failed [E0080] + //~| ERROR: assertion failed + //~| NOTE: evaluation of `assert_zst::F::<i32>::V` failed //~| NOTE: in this expansion of assert! - //~| NOTE: assertion failed + //~| ERROR: assertion failed } F::<T>::V; //~^NOTE: erroneous constant @@ -23,7 +23,6 @@ fn foo<U>() { //~| NOTE: the above error was encountered while instantiating `fn assert_zst::<i32>` } - fn bar<V>() { foo::<V>() } diff --git a/tests/ui/generics/post_monomorphization_error_backtrace.stderr b/tests/ui/generics/post_monomorphization_error_backtrace.stderr index 96aa04ee359..6953414f0c2 100644 --- a/tests/ui/generics/post_monomorphization_error_backtrace.stderr +++ b/tests/ui/generics/post_monomorphization_error_backtrace.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `assert_zst::F::<u32>::V` failed +error[E0080]: evaluation panicked: assertion failed: std::mem::size_of::<T>() == 0 --> $DIR/post_monomorphization_error_backtrace.rs:6:23 | LL | const V: () = assert!(std::mem::size_of::<T>() == 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: assertion failed: std::mem::size_of::<T>() == 0 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `assert_zst::F::<u32>::V` failed here note: erroneous constant encountered --> $DIR/post_monomorphization_error_backtrace.rs:14:5 @@ -16,11 +16,11 @@ note: the above error was encountered while instantiating `fn assert_zst::<u32>` LL | assert_zst::<U>() | ^^^^^^^^^^^^^^^^^ -error[E0080]: evaluation of `assert_zst::F::<i32>::V` failed +error[E0080]: evaluation panicked: assertion failed: std::mem::size_of::<T>() == 0 --> $DIR/post_monomorphization_error_backtrace.rs:6:23 | LL | const V: () = assert!(std::mem::size_of::<T>() == 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: assertion failed: std::mem::size_of::<T>() == 0 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `assert_zst::F::<i32>::V` failed here note: erroneous constant encountered --> $DIR/post_monomorphization_error_backtrace.rs:14:5 diff --git a/tests/ui/bounds-lifetime.rs b/tests/ui/higher-ranked/higher-ranked-invalid-bounds.rs index f26976066ac..be161aeb53d 100644 --- a/tests/ui/bounds-lifetime.rs +++ b/tests/ui/higher-ranked/higher-ranked-invalid-bounds.rs @@ -1,3 +1,5 @@ +//! Tests invalid lifetime bounds and generic parameters in higher-ranked types. + type A = for<'b, 'a: 'b> fn(); //~ ERROR bounds cannot be used in this context type B = for<'b, 'a: 'b,> fn(); //~ ERROR bounds cannot be used in this context type C = for<'b, 'a: 'b +> fn(); //~ ERROR bounds cannot be used in this context diff --git a/tests/ui/bounds-lifetime.stderr b/tests/ui/higher-ranked/higher-ranked-invalid-bounds.stderr index 01b314f3d1b..60ee7a7cf76 100644 --- a/tests/ui/bounds-lifetime.stderr +++ b/tests/ui/higher-ranked/higher-ranked-invalid-bounds.stderr @@ -1,23 +1,23 @@ error: bounds cannot be used in this context - --> $DIR/bounds-lifetime.rs:1:22 + --> $DIR/higher-ranked-invalid-bounds.rs:3:22 | LL | type A = for<'b, 'a: 'b> fn(); | ^^ error: bounds cannot be used in this context - --> $DIR/bounds-lifetime.rs:2:22 + --> $DIR/higher-ranked-invalid-bounds.rs:4:22 | LL | type B = for<'b, 'a: 'b,> fn(); | ^^ error: bounds cannot be used in this context - --> $DIR/bounds-lifetime.rs:3:22 + --> $DIR/higher-ranked-invalid-bounds.rs:5:22 | LL | type C = for<'b, 'a: 'b +> fn(); | ^^ error[E0658]: only lifetime parameters can be used in this context - --> $DIR/bounds-lifetime.rs:4:18 + --> $DIR/higher-ranked-invalid-bounds.rs:6:18 | LL | type D = for<'a, T> fn(); | ^ @@ -27,7 +27,7 @@ LL | type D = for<'a, T> fn(); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: only lifetime parameters can be used in this context - --> $DIR/bounds-lifetime.rs:5:18 + --> $DIR/higher-ranked-invalid-bounds.rs:7:18 | LL | type E = dyn for<T, U> Fn(); | ^ ^ diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-1.stderr b/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-1.stderr index 240e1c3dde1..21dc5c66adf 100644 --- a/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-1.stderr +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-1.stderr @@ -1,4 +1,4 @@ -error[E0599]: the method `filterx` exists for struct `Map<Repeat, {closure@hrtb-doesnt-borrow-self-1.rs:113:27}>`, but its trait bounds were not satisfied +error[E0599]: the method `filterx` exists for struct `Map<Repeat, {closure@$DIR/hrtb-doesnt-borrow-self-1.rs:113:27: 113:34}>`, but its trait bounds were not satisfied --> $DIR/hrtb-doesnt-borrow-self-1.rs:114:22 | LL | pub struct Map<S, F> { diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.stderr b/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.stderr index 13041ea2bb0..23b979e2ef0 100644 --- a/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.stderr +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.stderr @@ -1,4 +1,4 @@ -error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, fn(&u64) -> &u64 {identity::<u64>}>, {closure@hrtb-doesnt-borrow-self-2.rs:109:30}>`, but its trait bounds were not satisfied +error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:109:30: 109:37}>`, but its trait bounds were not satisfied --> $DIR/hrtb-doesnt-borrow-self-2.rs:110:24 | LL | pub struct Filter<S, F> { diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-1.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-1.rs index c368f265062..e00a31e26aa 100644 --- a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-1.rs +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-1.rs @@ -25,7 +25,7 @@ where impl<T: 'static> Inject for RefMutFamily<T> { type I = Self; - fn inject(_: &()) -> <Self::I as FamilyLt>::Out { + fn inject(_: &()) -> <Self::I as FamilyLt<'_>>::Out { unimplemented!() } } diff --git a/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.rs b/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.rs index 5d039cd5dc6..cc813430468 100644 --- a/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.rs +++ b/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.rs @@ -13,8 +13,6 @@ fn needs_bar(_: *mut Type2) {} fn main() { let x: &dyn Foo = &(); //~^ ERROR the trait `Foo` is not dyn compatible - //~| ERROR the trait `Foo` is not dyn compatible needs_bar(x); - //~^ ERROR mismatched types } diff --git a/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.stderr b/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.stderr index 183ee678d7a..d35394a4f66 100644 --- a/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.stderr +++ b/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/span-bug-issue-121597.rs:14:23 + --> $DIR/span-bug-issue-121597.rs:14:17 | LL | let x: &dyn Foo = &(); - | ^^^ `Foo` is not dyn compatible + | ^^^ `Foo` 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> @@ -12,40 +12,7 @@ LL | trait Foo: for<T> Bar<T> {} | --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables | | | this trait is not dyn compatible... - = note: required for the cast from `&()` to `&dyn Foo` -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/span-bug-issue-121597.rs:14:12 - | -LL | let x: &dyn Foo = &(); - | ^^^^^^^^ `Foo` 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/span-bug-issue-121597.rs:4:12 - | -LL | trait Foo: for<T> Bar<T> {} - | --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables - | | - | this trait is not dyn compatible... - -error[E0308]: mismatched types - --> $DIR/span-bug-issue-121597.rs:18:15 - | -LL | needs_bar(x); - | --------- ^ types differ in mutability - | | - | arguments to this function are incorrect - | - = note: expected raw pointer `*mut Type2` - found reference `&dyn Foo` -note: function defined here - --> $DIR/span-bug-issue-121597.rs:11:4 - | -LL | fn needs_bar(_: *mut Type2) {} - | ^^^^^^^^^ ------------- - -error: aborting due to 3 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0038, E0308. -For more information about an error, try `rustc --explain E0038`. +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.rs b/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.rs index 901d4b39cf3..accd173ce23 100644 --- a/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.rs +++ b/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.rs @@ -21,6 +21,8 @@ impl DynIncompatible for B { fn car() -> dyn DynIncompatible { //~ ERROR the trait `DynIncompatible` is not dyn compatible //~^ ERROR return type cannot be a trait object without pointer indirection +//~| ERROR the trait `DynIncompatible` is not dyn compatible +//~| ERROR the trait `DynIncompatible` is not dyn compatible if true { return A; } @@ -29,9 +31,9 @@ fn car() -> dyn DynIncompatible { //~ ERROR the trait `DynIncompatible` is not d fn cat() -> Box<dyn DynIncompatible> { //~ ERROR the trait `DynIncompatible` is not dyn compatible if true { - return Box::new(A); //~ ERROR is not dyn compatible + return Box::new(A); } - Box::new(B) //~ ERROR is not dyn compatible + Box::new(B) } fn main() {} diff --git a/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.stderr b/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.stderr index 2c314b07bce..a8787a01a6f 100644 --- a/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.stderr +++ b/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.stderr @@ -41,6 +41,7 @@ help: alternatively, box the return type, and wrap all of the returned values in | LL ~ fn car() -> Box<dyn DynIncompatible> { LL | +... LL | if true { LL ~ return Box::new(A); LL | } @@ -48,7 +49,7 @@ LL ~ Box::new(B) | error[E0038]: the trait `DynIncompatible` is not dyn compatible - --> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:30:17 + --> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:32:17 | LL | fn cat() -> Box<dyn DynIncompatible> { | ^^^^^^^^^^^^^^^^^^^ `DynIncompatible` is not dyn compatible @@ -76,10 +77,10 @@ LL | fn foo() -> Self where Self: Sized; | +++++++++++++++++ error[E0038]: the trait `DynIncompatible` is not dyn compatible - --> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:32:16 + --> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:22:17 | -LL | return Box::new(A); - | ^^^^^^^^^^^ `DynIncompatible` is not dyn compatible +LL | fn car() -> dyn DynIncompatible { + | ^^^^^^^^^^^^^^^ `DynIncompatible` 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> @@ -94,7 +95,11 @@ LL | fn foo() -> Self; B consider defining an enum where each variant holds one of these types, implementing `DynIncompatible` for this new enum and using it instead - = note: required for the cast from `Box<A>` to `Box<(dyn DynIncompatible + 'static)>` +help: consider using an opaque type instead + | +LL - fn car() -> dyn DynIncompatible { +LL + fn car() -> impl DynIncompatible { + | help: consider turning `foo` into a method by giving it a `&self` argument | LL | fn foo(&self) -> Self; @@ -105,10 +110,10 @@ LL | fn foo() -> Self where Self: Sized; | +++++++++++++++++ error[E0038]: the trait `DynIncompatible` is not dyn compatible - --> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:34:5 + --> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:22:17 | -LL | Box::new(B) - | ^^^^^^^^^^^ `DynIncompatible` is not dyn compatible +LL | fn car() -> dyn DynIncompatible { + | ^^^^^^^^^^^^^^^ `DynIncompatible` 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> @@ -123,7 +128,12 @@ LL | fn foo() -> Self; B consider defining an enum where each variant holds one of these types, implementing `DynIncompatible` for this new enum and using it instead - = note: required for the cast from `Box<B>` to `Box<(dyn DynIncompatible + 'static)>` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: consider using an opaque type instead + | +LL - fn car() -> dyn DynIncompatible { +LL + fn car() -> impl DynIncompatible { + | help: consider turning `foo` into a method by giving it a `&self` argument | LL | fn foo(&self) -> Self; diff --git a/tests/ui/impl-trait/impl-fn-hrtb-bounds.rs b/tests/ui/impl-trait/impl-fn-hrtb-bounds.rs index a7f38b5c16a..da7530b4e7a 100644 --- a/tests/ui/impl-trait/impl-fn-hrtb-bounds.rs +++ b/tests/ui/impl-trait/impl-fn-hrtb-bounds.rs @@ -13,7 +13,6 @@ fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) { fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) { //~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` - //~| WARNING elided lifetime has a name |x| x } diff --git a/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr b/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr index 31f39eb9004..40cb6b647d1 100644 --- a/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr +++ b/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr @@ -1,5 +1,5 @@ error[E0106]: missing lifetime specifier - --> $DIR/impl-fn-hrtb-bounds.rs:20:38 + --> $DIR/impl-fn-hrtb-bounds.rs:19:38 | LL | fn d() -> impl Fn() -> (impl Debug + '_) { | ^^ expected named lifetime parameter @@ -11,14 +11,6 @@ LL - fn d() -> impl Fn() -> (impl Debug + '_) { LL + fn d() -> impl Fn() -> (impl Debug + 'static) { | -warning: elided lifetime has a name - --> $DIR/impl-fn-hrtb-bounds.rs:14:52 - | -LL | fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) { - | -- lifetime `'a` declared here ^^ this elided lifetime gets resolved as `'a` - | - = note: `#[warn(elided_named_lifetimes)]` on by default - error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` --> $DIR/impl-fn-hrtb-bounds.rs:4:41 | @@ -55,7 +47,7 @@ note: lifetime declared here LL | fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) { | ^^ -error: aborting due to 4 previous errors; 1 warning emitted +error: aborting due to 4 previous errors Some errors have detailed explanations: E0106, E0657. For more information about an error, try `rustc --explain E0106`. diff --git a/tests/ui/impl-trait/impl-fn-predefined-lifetimes.rs b/tests/ui/impl-trait/impl-fn-predefined-lifetimes.rs index 776bb7278ce..199cbbf4fcc 100644 --- a/tests/ui/impl-trait/impl-fn-predefined-lifetimes.rs +++ b/tests/ui/impl-trait/impl-fn-predefined-lifetimes.rs @@ -2,7 +2,6 @@ use std::fmt::Debug; fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) { - //~^ WARNING elided lifetime has a name |x| x //~^ ERROR expected generic lifetime parameter, found `'_` } diff --git a/tests/ui/impl-trait/impl-fn-predefined-lifetimes.stderr b/tests/ui/impl-trait/impl-fn-predefined-lifetimes.stderr index 209186db4cc..6064b09ef09 100644 --- a/tests/ui/impl-trait/impl-fn-predefined-lifetimes.stderr +++ b/tests/ui/impl-trait/impl-fn-predefined-lifetimes.stderr @@ -1,20 +1,11 @@ -warning: elided lifetime has a name - --> $DIR/impl-fn-predefined-lifetimes.rs:4:48 - | -LL | fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) { - | -- lifetime `'a` declared here ^^ this elided lifetime gets resolved as `'a` - | - = note: `#[warn(elided_named_lifetimes)]` on by default - error[E0792]: expected generic lifetime parameter, found `'_` - --> $DIR/impl-fn-predefined-lifetimes.rs:6:9 + --> $DIR/impl-fn-predefined-lifetimes.rs:5:9 | LL | fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) { | -- this generic parameter must be used with a generic lifetime parameter -LL | LL | |x| x | ^ -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr b/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr index c9e657b87d5..2f417d57752 100644 --- a/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr +++ b/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr @@ -12,14 +12,6 @@ note: required by a bound in `compare_ty::Trait::Ty` LL | type Ty: IntoIterator<Item = ()>; | ^^^^^^^^^ required by this bound in `Trait::Ty` -error: unconstrained opaque type - --> $DIR/in-assoc-type-unconstrained.rs:8:26 - | -LL | type Ty = Option<impl Sized>; - | ^^^^^^^^^^ - | - = note: `Ty` must be used in combination with a concrete type within the same impl - error[E0053]: method `method` has an incompatible type for trait --> $DIR/in-assoc-type-unconstrained.rs:22:24 | @@ -43,6 +35,14 @@ LL + fn method() -> <() as compare_method::Trait>::Ty {} | error: unconstrained opaque type + --> $DIR/in-assoc-type-unconstrained.rs:8:26 + | +LL | type Ty = Option<impl Sized>; + | ^^^^^^^^^^ + | + = note: `Ty` must be used in combination with a concrete type within the same impl + +error: unconstrained opaque type --> $DIR/in-assoc-type-unconstrained.rs:20:19 | LL | type Ty = impl Sized; diff --git a/tests/ui/impl-trait/in-trait/dyn-compatibility.rs b/tests/ui/impl-trait/in-trait/dyn-compatibility.rs index 85b1ba269fc..45b431f6d30 100644 --- a/tests/ui/impl-trait/in-trait/dyn-compatibility.rs +++ b/tests/ui/impl-trait/in-trait/dyn-compatibility.rs @@ -13,8 +13,5 @@ impl Foo for u32 { fn main() { let i = Box::new(42_u32) as Box<dyn Foo>; //~^ ERROR the trait `Foo` is not dyn compatible - //~| ERROR the trait `Foo` is not dyn compatible let s = i.baz(); - //~^ ERROR the trait `Foo` is not dyn compatible - //~| ERROR the trait `Foo` is not dyn compatible } diff --git a/tests/ui/impl-trait/in-trait/dyn-compatibility.stderr b/tests/ui/impl-trait/in-trait/dyn-compatibility.stderr index 840c27e183f..8cdb3808533 100644 --- a/tests/ui/impl-trait/in-trait/dyn-compatibility.stderr +++ b/tests/ui/impl-trait/in-trait/dyn-compatibility.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/dyn-compatibility.rs:14:33 + --> $DIR/dyn-compatibility.rs:14:41 | LL | let i = Box::new(42_u32) as Box<dyn Foo>; - | ^^^^^^^^^^^^ `Foo` is not dyn compatible + | ^^^ `Foo` 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> @@ -15,58 +15,6 @@ LL | fn baz(&self) -> impl Debug; = help: consider moving `baz` to another trait = help: only type `u32` implements `Foo`; consider using it directly instead. -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/dyn-compatibility.rs:17:15 - | -LL | let s = i.baz(); - | ^^^ `Foo` 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/dyn-compatibility.rs:4:22 - | -LL | trait Foo { - | --- this trait is not dyn compatible... -LL | fn baz(&self) -> impl Debug; - | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type - = help: consider moving `baz` to another trait - = help: only type `u32` implements `Foo`; consider using it directly instead. - -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/dyn-compatibility.rs:17:13 - | -LL | let s = i.baz(); - | ^^^^^^^ `Foo` 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/dyn-compatibility.rs:4:22 - | -LL | trait Foo { - | --- this trait is not dyn compatible... -LL | fn baz(&self) -> impl Debug; - | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type - = help: consider moving `baz` to another trait - = help: only type `u32` implements `Foo`; consider using it directly instead. - -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/dyn-compatibility.rs:14:13 - | -LL | let i = Box::new(42_u32) as Box<dyn Foo>; - | ^^^^^^^^^^^^^^^^ `Foo` 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/dyn-compatibility.rs:4:22 - | -LL | trait Foo { - | --- this trait is not dyn compatible... -LL | fn baz(&self) -> impl Debug; - | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type - = help: consider moving `baz` to another trait - = help: only type `u32` implements `Foo`; consider using it directly instead. - = note: required for the cast from `Box<u32>` to `Box<dyn Foo>` - -error: aborting due to 4 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr b/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr index 29235ca78a5..68ac765a3c1 100644 --- a/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr +++ b/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/foreign-dyn-error.rs:6:12 + --> $DIR/foreign-dyn-error.rs:6:17 | LL | let _: &dyn rpitit::Foo = todo!(); - | ^^^^^^^^^^^^^^^^ `Foo` is not dyn compatible + | ^^^^^^^^^^^ `Foo` 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> diff --git a/tests/crashes/141143.rs b/tests/ui/impl-trait/in-trait/not-inferred-generic.rs index a4aa2f19a6c..3879ea0e626 100644 --- a/tests/crashes/141143.rs +++ b/tests/ui/impl-trait/in-trait/not-inferred-generic.rs @@ -1,4 +1,3 @@ -//@ known-bug: #141143 trait TypedClient { fn publish_typed<F>(&self) -> impl Sized where @@ -10,4 +9,5 @@ impl TypedClient for () { fn main() { ().publish_typed(); + //~^ ERROR type annotations needed [E0283] } diff --git a/tests/ui/impl-trait/in-trait/not-inferred-generic.stderr b/tests/ui/impl-trait/in-trait/not-inferred-generic.stderr new file mode 100644 index 00000000000..07f029d3bb7 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/not-inferred-generic.stderr @@ -0,0 +1,21 @@ +error[E0283]: type annotations needed + --> $DIR/not-inferred-generic.rs:11:8 + | +LL | ().publish_typed(); + | ^^^^^^^^^^^^^ cannot infer type of the type parameter `F` declared on the method `publish_typed` + | + = note: cannot satisfy `_: Clone` + = note: associated types cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` +note: required by a bound in `TypedClient::publish_typed::{anon_assoc#0}` + --> $DIR/not-inferred-generic.rs:4:12 + | +LL | F: Clone; + | ^^^^^ required by this bound in `TypedClient::publish_typed::{anon_assoc#0}` +help: consider specifying the generic argument + | +LL | ().publish_typed::<F>(); + | +++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0283`. diff --git a/tests/ui/impl-trait/issues/issue-100075-2.stderr b/tests/ui/impl-trait/issues/issue-100075-2.stderr index b3b69677507..554c3ea3433 100644 --- a/tests/ui/impl-trait/issues/issue-100075-2.stderr +++ b/tests/ui/impl-trait/issues/issue-100075-2.stderr @@ -1,3 +1,9 @@ +error[E0720]: cannot resolve opaque type + --> $DIR/issue-100075-2.rs:1:23 + | +LL | fn opaque<T>(t: T) -> impl Sized { + | ^^^^^^^^^^ + warning: function cannot return without recursing --> $DIR/issue-100075-2.rs:1:1 | @@ -10,15 +16,6 @@ LL | opaque(Some(t)) = help: a `loop` may express intention better if this is on purpose = note: `#[warn(unconditional_recursion)]` on by default -error[E0720]: cannot resolve opaque type - --> $DIR/issue-100075-2.rs:1:23 - | -LL | fn opaque<T>(t: T) -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -... -LL | opaque(Some(t)) - | --------------- returning here with type `impl Sized` - error: aborting due to 1 previous error; 1 warning emitted For more information about this error, try `rustc --explain E0720`. diff --git a/tests/ui/impl-trait/issues/issue-100075.stderr b/tests/ui/impl-trait/issues/issue-100075.stderr index 75963489236..bca2874b2b4 100644 --- a/tests/ui/impl-trait/issues/issue-100075.stderr +++ b/tests/ui/impl-trait/issues/issue-100075.stderr @@ -2,10 +2,7 @@ error[E0720]: cannot resolve opaque type --> $DIR/issue-100075.rs:13:37 | LL | fn _g<T>(t: &'static T) -> &'static impl Marker { - | ^^^^^^^^^^^ recursive opaque type -... -LL | return _g(t); - | ----- returning here with type `&impl Marker` + | ^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/issues/issue-103599.rs b/tests/ui/impl-trait/issues/issue-103599.rs index 62741a7454c..e674ce3cbdf 100644 --- a/tests/ui/impl-trait/issues/issue-103599.rs +++ b/tests/ui/impl-trait/issues/issue-103599.rs @@ -1,9 +1,8 @@ -//@ check-pass - trait T {} fn wrap(x: impl T) -> impl T { - //~^ WARN function cannot return without recursing + //~^ ERROR cannot resolve opaque type + //~| WARN function cannot return without recursing wrap(wrap(x)) } diff --git a/tests/ui/impl-trait/issues/issue-103599.stderr b/tests/ui/impl-trait/issues/issue-103599.stderr index 82038c1dceb..9878b12044f 100644 --- a/tests/ui/impl-trait/issues/issue-103599.stderr +++ b/tests/ui/impl-trait/issues/issue-103599.stderr @@ -1,14 +1,21 @@ +error[E0720]: cannot resolve opaque type + --> $DIR/issue-103599.rs:3:23 + | +LL | fn wrap(x: impl T) -> impl T { + | ^^^^^^ + warning: function cannot return without recursing - --> $DIR/issue-103599.rs:5:1 + --> $DIR/issue-103599.rs:3:1 | LL | fn wrap(x: impl T) -> impl T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing -LL | +... LL | wrap(wrap(x)) | ------- recursive call site | = help: a `loop` may express intention better if this is on purpose = note: `#[warn(unconditional_recursion)]` on by default -warning: 1 warning emitted +error: aborting due to 1 previous error; 1 warning emitted +For more information about this error, try `rustc --explain E0720`. diff --git a/tests/ui/impl-trait/issues/issue-87450.rs b/tests/ui/impl-trait/issues/issue-87450.rs index 983ef7cfbe0..5a7759af111 100644 --- a/tests/ui/impl-trait/issues/issue-87450.rs +++ b/tests/ui/impl-trait/issues/issue-87450.rs @@ -3,8 +3,8 @@ fn bar() -> impl Fn() { } fn foo() -> impl Fn() { - //~^ WARNING 5:1: 5:22: function cannot return without recursing [unconditional_recursion] - //~| ERROR 5:13: 5:22: cannot resolve opaque type [E0720] + //~^ WARN function cannot return without recursing + //~| ERROR cannot resolve opaque type wrap(wrap(wrap(wrap(wrap(wrap(wrap(foo()))))))) } diff --git a/tests/ui/impl-trait/issues/issue-87450.stderr b/tests/ui/impl-trait/issues/issue-87450.stderr index 9567e09651d..f0f8b5859c0 100644 --- a/tests/ui/impl-trait/issues/issue-87450.stderr +++ b/tests/ui/impl-trait/issues/issue-87450.stderr @@ -1,3 +1,9 @@ +error[E0720]: cannot resolve opaque type + --> $DIR/issue-87450.rs:5:13 + | +LL | fn foo() -> impl Fn() { + | ^^^^^^^^^ + warning: function cannot return without recursing --> $DIR/issue-87450.rs:5:1 | @@ -10,18 +16,6 @@ LL | wrap(wrap(wrap(wrap(wrap(wrap(wrap(foo()))))))) = help: a `loop` may express intention better if this is on purpose = note: `#[warn(unconditional_recursion)]` on by default -error[E0720]: cannot resolve opaque type - --> $DIR/issue-87450.rs:5:13 - | -LL | fn foo() -> impl Fn() { - | ^^^^^^^^^ recursive opaque type -... -LL | wrap(wrap(wrap(wrap(wrap(wrap(wrap(foo()))))))) - | ----------------------------------------------- returning here with type `impl Fn()` -... -LL | fn wrap(f: impl Fn()) -> impl Fn() { - | --------- returning this opaque type `impl Fn()` - error: aborting due to 1 previous error; 1 warning emitted For more information about this error, try `rustc --explain E0720`. diff --git a/tests/ui/impl-trait/no-method-suggested-traits.stderr b/tests/ui/impl-trait/no-method-suggested-traits.stderr index 64202513ae2..061c9bd8f35 100644 --- a/tests/ui/impl-trait/no-method-suggested-traits.stderr +++ b/tests/ui/impl-trait/no-method-suggested-traits.stderr @@ -173,7 +173,7 @@ error[E0599]: no method named `method2` found for struct `no_method_suggested_tr --> $DIR/no-method-suggested-traits.rs:52:37 | LL | no_method_suggested_traits::Foo.method2(); - | ^^^^^^^ method not found in `Foo` + | ^^^^^^^ method not found in `no_method_suggested_traits::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 @@ -186,7 +186,7 @@ error[E0599]: no method named `method2` found for struct `Rc<&mut Box<&no_method --> $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>>` + | ^^^^^^^ method not found in `Rc<&mut Box<&no_method_suggested_traits::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 @@ -199,7 +199,7 @@ error[E0599]: no method named `method2` found for enum `no_method_suggested_trai --> $DIR/no-method-suggested-traits.rs:56:40 | LL | no_method_suggested_traits::Bar::X.method2(); - | ^^^^^^^ method not found in `Bar` + | ^^^^^^^ method not found in `no_method_suggested_traits::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 @@ -212,7 +212,7 @@ error[E0599]: no method named `method2` found for struct `Rc<&mut Box<&no_method --> $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>>` + | ^^^^^^^ method not found in `Rc<&mut Box<&no_method_suggested_traits::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 @@ -283,25 +283,25 @@ error[E0599]: no method named `method3` found for struct `no_method_suggested_tr --> $DIR/no-method-suggested-traits.rs:73:37 | LL | no_method_suggested_traits::Foo.method3(); - | ^^^^^^^ method not found in `Foo` + | ^^^^^^^ method not found in `no_method_suggested_traits::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:74:71 | LL | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Foo)).method3(); - | ^^^^^^^ method not found in `Rc<&mut Box<&Foo>>` + | ^^^^^^^ method not found in `Rc<&mut Box<&no_method_suggested_traits::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:76:40 | LL | no_method_suggested_traits::Bar::X.method3(); - | ^^^^^^^ method not found in `Bar` + | ^^^^^^^ method not found in `no_method_suggested_traits::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: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>>` + | ^^^^^^^ method not found in `Rc<&mut Box<&no_method_suggested_traits::Bar>>` error: aborting due to 24 previous errors diff --git a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.stderr b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.stderr index 2d2731e4368..af84375c747 100644 --- a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.stderr +++ b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.stderr @@ -2,112 +2,67 @@ error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:6:22 | LL | fn option(i: i32) -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | if i < 0 { None } else { Some((option(i - 1), i)) } - | ---- ------------------------ returning here with type `Option<(impl Sized, i32)>` - | | - | returning here with type `Option<(impl Sized, i32)>` + | ^^^^^^^^^^ error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:11:15 | LL | fn tuple() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | (tuple(),) - | ---------- returning here with type `(impl Sized,)` + | ^^^^^^^^^^ error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:16:15 | LL | fn array() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | [array()] - | --------- returning here with type `[impl Sized; 1]` + | ^^^^^^^^^^ error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:21:13 | LL | fn ptr() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | &ptr() as *const _ - | ------------------ returning here with type `*const impl Sized` + | ^^^^^^^^^^ error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:26:16 | LL | fn fn_ptr() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | fn_ptr as fn() -> _ - | ------------------- returning here with type `fn() -> impl Sized` + | ^^^^^^^^^^ error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:31:25 | -LL | fn closure_capture() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -... -LL | / move || { -LL | | x; - | | - closure captures itself here -LL | | } - | |_____- returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:34:5: 34:12}` +LL | fn closure_capture() -> impl Sized { + | ^^^^^^^^^^ error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:39:29 | -LL | fn closure_ref_capture() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -... -LL | / move || { -LL | | &x; - | | - closure captures itself here -LL | | } - | |_____- returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:42:5: 42:12}` +LL | fn closure_ref_capture() -> impl Sized { + | ^^^^^^^^^^ error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:47:21 | LL | fn closure_sig() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | || closure_sig() - | ---------------- returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:49:5: 49:7}` + | ^^^^^^^^^^ error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:52:23 | LL | fn coroutine_sig() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | || coroutine_sig() - | ------------------ returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:54:5: 54:7}` + | ^^^^^^^^^^ error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:57:27 | -LL | fn coroutine_capture() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -... -LL | / move || { -LL | | yield; -LL | | x; - | | - coroutine captures itself here -LL | | } - | |_____- returning here with type `{coroutine@$DIR/recursive-impl-trait-type-indirect.rs:62:5: 62:12}` +LL | fn coroutine_capture() -> impl Sized { + | ^^^^^^^^^^ error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:68:35 | LL | fn substs_change<T: 'static>() -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -LL | -LL | (substs_change::<&T>(),) - | ------------------------ returning here with type `(impl Sized,)` + | ^^^^^^^^^^ error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:78:26 diff --git a/tests/ui/impl-trait/recursive-in-exhaustiveness.current.stderr b/tests/ui/impl-trait/recursive-in-exhaustiveness.current.stderr index 42dbc7c9160..080c3284641 100644 --- a/tests/ui/impl-trait/recursive-in-exhaustiveness.current.stderr +++ b/tests/ui/impl-trait/recursive-in-exhaustiveness.current.stderr @@ -1,56 +1,21 @@ -warning: function cannot return without recursing - --> $DIR/recursive-in-exhaustiveness.rs:17:1 +error[E0720]: cannot resolve opaque type + --> $DIR/recursive-in-exhaustiveness.rs:17:22 | LL | fn build<T>(x: T) -> impl Sized { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing -LL | -LL | let (x,) = (build(x),); - | -------- recursive call site - | - = help: a `loop` may express intention better if this is on purpose - = note: `#[warn(unconditional_recursion)]` on by default - -warning: function cannot return without recursing - --> $DIR/recursive-in-exhaustiveness.rs:27:1 - | -LL | fn build2<T>(x: T) -> impl Sized { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing -... -LL | let (x,) = (build2(x),); - | --------- recursive call site - | - = help: a `loop` may express intention better if this is on purpose + | ^^^^^^^^^^ error[E0720]: cannot resolve opaque type --> $DIR/recursive-in-exhaustiveness.rs:27:23 | LL | fn build2<T>(x: T) -> impl Sized { - | ^^^^^^^^^^ recursive opaque type -... -LL | (build2(x),) - | ------------ returning here with type `(impl Sized,)` + | ^^^^^^^^^^ -warning: function cannot return without recursing - --> $DIR/recursive-in-exhaustiveness.rs:40:1 - | -LL | fn build3<T>(x: T) -> impl Sized { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing -LL | -LL | let (x,) = (build3((x,)),); - | ------------ recursive call site - | - = help: a `loop` may express intention better if this is on purpose - -error[E0792]: expected generic type parameter, found `(T,)` - --> $DIR/recursive-in-exhaustiveness.rs:49:5 +error[E0720]: cannot resolve opaque type + --> $DIR/recursive-in-exhaustiveness.rs:39:23 | LL | fn build3<T>(x: T) -> impl Sized { - | - this generic parameter must be used with a generic type parameter -... -LL | build3(x) - | ^^^^^^^^^ + | ^^^^^^^^^^ -error: aborting due to 2 previous errors; 3 warnings emitted +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0720, E0792. -For more information about an error, try `rustc --explain E0720`. +For more information about this error, try `rustc --explain E0720`. diff --git a/tests/ui/impl-trait/recursive-in-exhaustiveness.next.stderr b/tests/ui/impl-trait/recursive-in-exhaustiveness.next.stderr index 4c3d5aa8fb8..a3609b93cb3 100644 --- a/tests/ui/impl-trait/recursive-in-exhaustiveness.next.stderr +++ b/tests/ui/impl-trait/recursive-in-exhaustiveness.next.stderr @@ -5,19 +5,19 @@ LL | let (x,) = (build(x),); | ^^^^^^^^ cannot satisfy `impl Sized == _` error[E0271]: type mismatch resolving `build2<(_,)>::{opaque#0} normalizes-to _` - --> $DIR/recursive-in-exhaustiveness.rs:31:6 + --> $DIR/recursive-in-exhaustiveness.rs:30:6 | LL | (build2(x),) | ^^^^^^^^^ types differ error[E0271]: type mismatch resolving `build2<(_,)>::{opaque#0} normalizes-to _` - --> $DIR/recursive-in-exhaustiveness.rs:31:5 + --> $DIR/recursive-in-exhaustiveness.rs:30:5 | LL | (build2(x),) | ^^^^^^^^^^^^ types differ error[E0277]: the size for values of type `(impl Sized,)` cannot be known at compilation time - --> $DIR/recursive-in-exhaustiveness.rs:31:5 + --> $DIR/recursive-in-exhaustiveness.rs:30:5 | LL | (build2(x),) | ^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -26,13 +26,13 @@ LL | (build2(x),) = note: tuples must have a statically known size to be initialized error[E0271]: type mismatch resolving `build3<(T,)>::{opaque#0} normalizes-to _` - --> $DIR/recursive-in-exhaustiveness.rs:42:17 + --> $DIR/recursive-in-exhaustiveness.rs:41:17 | LL | let (x,) = (build3((x,)),); | ^^^^^^^^^^^^ types differ error[E0277]: the size for values of type `(impl Sized,)` cannot be known at compilation time - --> $DIR/recursive-in-exhaustiveness.rs:42:16 + --> $DIR/recursive-in-exhaustiveness.rs:41:16 | LL | let (x,) = (build3((x,)),); | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -41,7 +41,7 @@ LL | let (x,) = (build3((x,)),); = note: tuples must have a statically known size to be initialized error[E0308]: mismatched types - --> $DIR/recursive-in-exhaustiveness.rs:42:16 + --> $DIR/recursive-in-exhaustiveness.rs:41:16 | LL | fn build3<T>(x: T) -> impl Sized { | ---------- the found opaque type @@ -53,7 +53,7 @@ LL | let (x,) = (build3((x,)),); found tuple `(impl Sized,)` error[E0271]: type mismatch resolving `build3<(T,)>::{opaque#0} normalizes-to _` - --> $DIR/recursive-in-exhaustiveness.rs:42:17 + --> $DIR/recursive-in-exhaustiveness.rs:41:17 | LL | let (x,) = (build3((x,)),); | ^^^^^^^^^^^^ types differ @@ -61,13 +61,13 @@ LL | let (x,) = (build3((x,)),); = note: the return type of a function must have a statically known size error[E0271]: type mismatch resolving `build3<(T,)>::{opaque#0} normalizes-to _` - --> $DIR/recursive-in-exhaustiveness.rs:42:16 + --> $DIR/recursive-in-exhaustiveness.rs:41:16 | LL | let (x,) = (build3((x,)),); | ^^^^^^^^^^^^^^^ types differ error[E0271]: type mismatch resolving `build3<(T,)>::{opaque#0} normalizes-to _` - --> $DIR/recursive-in-exhaustiveness.rs:42:17 + --> $DIR/recursive-in-exhaustiveness.rs:41:17 | LL | let (x,) = (build3((x,)),); | ^^^^^^^^^^^^ types differ diff --git a/tests/ui/impl-trait/recursive-in-exhaustiveness.rs b/tests/ui/impl-trait/recursive-in-exhaustiveness.rs index 58944533686..fa8fa0e8174 100644 --- a/tests/ui/impl-trait/recursive-in-exhaustiveness.rs +++ b/tests/ui/impl-trait/recursive-in-exhaustiveness.rs @@ -15,7 +15,7 @@ // We unfortunately accept this today, and due to how opaque type relating is implemented // in the NLL type relation, this defines `Opaque<T> = T`. fn build<T>(x: T) -> impl Sized { - //[current]~^ WARN function cannot return without recursing + //[current]~^ ERROR cannot resolve opaque type let (x,) = (build(x),); //[next]~^ ERROR type annotations needed build(x) @@ -26,7 +26,6 @@ fn build<T>(x: T) -> impl Sized { // Not allowed today. Detected as recursive. fn build2<T>(x: T) -> impl Sized { //[current]~^ ERROR cannot resolve opaque type - //[current]~| WARN function cannot return without recursing let (x,) = (build2(x),); (build2(x),) //[next]~^ ERROR type mismatch resolving @@ -38,7 +37,7 @@ fn build2<T>(x: T) -> impl Sized { // // Not allowed today. Detected as not defining. fn build3<T>(x: T) -> impl Sized { - //[current]~^ WARN function cannot return without recursing + //[current]~^ ERROR cannot resolve opaque type let (x,) = (build3((x,)),); //[next]~^ ERROR type mismatch resolving //[next]~| ERROR type mismatch resolving @@ -47,7 +46,6 @@ fn build3<T>(x: T) -> impl Sized { //[next]~| ERROR the size for values of type //[next]~| ERROR mismatched types build3(x) - //[current]~^ ERROR expected generic type parameter, found `(T,)` } fn main() {} diff --git a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr index 7f642fa1bed..ce6f68f535b 100644 --- a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr +++ b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr @@ -15,19 +15,6 @@ LL - fn eq(&self, _other: &(Foo, i32)) -> bool { LL + fn eq(&self, _other: &(a::Bar, i32)) -> bool { | -error: item does not constrain `a::Foo::{opaque#0}` - --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:10:12 - | -LL | fn eq(&self, _other: &(Foo, i32)) -> bool { - | ^^ - | - = note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]` -note: this opaque type is supposed to be constrained - --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:4:16 - | -LL | type Foo = impl PartialEq<(Foo, i32)>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - error[E0053]: method `eq` has an incompatible type for trait --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:25:30 | @@ -50,6 +37,19 @@ LL - fn eq(&self, _other: &(Bar, i32)) -> bool { LL + fn eq(&self, _other: &(b::Foo, i32)) -> bool { | +error: item does not constrain `a::Foo::{opaque#0}` + --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:10:12 + | +LL | fn eq(&self, _other: &(Foo, i32)) -> bool { + | ^^ + | + = note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]` +note: this opaque type is supposed to be constrained + --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:4:16 + | +LL | type Foo = impl PartialEq<(Foo, i32)>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: unconstrained opaque type --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:19:16 | diff --git a/tests/ui/impl-trait/rpit-assoc-pair-with-lifetime.rs b/tests/ui/impl-trait/rpit-assoc-pair-with-lifetime.rs index e48441f533d..1ac3c593dbe 100644 --- a/tests/ui/impl-trait/rpit-assoc-pair-with-lifetime.rs +++ b/tests/ui/impl-trait/rpit-assoc-pair-with-lifetime.rs @@ -1,7 +1,7 @@ //@ check-pass pub fn iter<'a>(v: Vec<(u32, &'a u32)>) -> impl DoubleEndedIterator<Item = (u32, &u32)> { - //~^ WARNING elided lifetime has a name + //~^ WARNING lifetime flowing from input to output with different syntax v.into_iter() } diff --git a/tests/ui/impl-trait/rpit-assoc-pair-with-lifetime.stderr b/tests/ui/impl-trait/rpit-assoc-pair-with-lifetime.stderr index bff3ffd934a..b9d8674992c 100644 --- a/tests/ui/impl-trait/rpit-assoc-pair-with-lifetime.stderr +++ b/tests/ui/impl-trait/rpit-assoc-pair-with-lifetime.stderr @@ -1,10 +1,14 @@ -warning: elided lifetime has a name - --> $DIR/rpit-assoc-pair-with-lifetime.rs:3:82 +warning: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/rpit-assoc-pair-with-lifetime.rs:3:31 | LL | pub fn iter<'a>(v: Vec<(u32, &'a u32)>) -> impl DoubleEndedIterator<Item = (u32, &u32)> { - | -- lifetime `'a` declared here ^ this elided lifetime gets resolved as `'a` + | ^^ this lifetime flows to the output ---- the lifetime gets resolved as `'a` | - = note: `#[warn(elided_named_lifetimes)]` on by default + = note: `#[warn(mismatched_lifetime_syntaxes)]` on by default +help: one option is to consistently use `'a` + | +LL | pub fn iter<'a>(v: Vec<(u32, &'a u32)>) -> impl DoubleEndedIterator<Item = (u32, &'a u32)> { + | ++ warning: 1 warning emitted diff --git a/tests/ui/imports/duplicate.rs b/tests/ui/imports/duplicate.rs index 0c5a376da38..69ec82aafbd 100644 --- a/tests/ui/imports/duplicate.rs +++ b/tests/ui/imports/duplicate.rs @@ -7,27 +7,27 @@ mod b { } mod c { - pub use a::foo; + pub use crate::a::foo; } mod d { - use a::foo; - use a::foo; //~ ERROR the name `foo` is defined multiple times + use crate::a::foo; + use crate::a::foo; //~ ERROR the name `foo` is defined multiple times } mod e { - pub use a::*; - pub use c::*; // ok + pub use crate::a::*; + pub use crate::c::*; // ok } mod f { - pub use a::*; - pub use b::*; + pub use crate::a::*; + pub use crate::b::*; } mod g { - pub use a::*; - pub use f::*; + pub use crate::a::*; + pub use crate::f::*; } fn main() { diff --git a/tests/ui/imports/duplicate.stderr b/tests/ui/imports/duplicate.stderr index d7a7dfce921..f7dc7312b9d 100644 --- a/tests/ui/imports/duplicate.stderr +++ b/tests/ui/imports/duplicate.stderr @@ -1,10 +1,10 @@ error[E0252]: the name `foo` is defined multiple times --> $DIR/duplicate.rs:15:9 | -LL | use a::foo; - | ------ previous import of the value `foo` here -LL | use a::foo; - | ^^^^^^ `foo` reimported here +LL | use crate::a::foo; + | ------------- previous import of the value `foo` here +LL | use crate::a::foo; + | ^^^^^^^^^^^^^ `foo` reimported here | = note: `foo` must be defined only once in the value namespace of this module @@ -38,14 +38,14 @@ LL | f::foo(); note: `foo` could refer to the function imported here --> $DIR/duplicate.rs:24:13 | -LL | pub use a::*; - | ^^^^ +LL | pub use crate::a::*; + | ^^^^^^^^^^^ = help: consider adding an explicit import of `foo` to disambiguate note: `foo` could also refer to the function imported here --> $DIR/duplicate.rs:25:13 | -LL | pub use b::*; - | ^^^^ +LL | pub use crate::b::*; + | ^^^^^^^^^^^ = help: consider adding an explicit import of `foo` to disambiguate error[E0659]: `foo` is ambiguous @@ -80,14 +80,14 @@ LL | g::foo(); note: `foo` could refer to the function imported here --> $DIR/duplicate.rs:24:13 | -LL | pub use a::*; - | ^^^^ +LL | pub use crate::a::*; + | ^^^^^^^^^^^ = help: consider adding an explicit import of `foo` to disambiguate note: `foo` could also refer to the function imported here --> $DIR/duplicate.rs:25:13 | -LL | pub use b::*; - | ^^^^ +LL | pub use crate::b::*; + | ^^^^^^^^^^^ = help: consider adding an explicit import of `foo` to disambiguate = note: `#[warn(ambiguous_glob_imports)]` on by default diff --git a/tests/ui/imports/export-glob-imports-target.rs b/tests/ui/imports/export-glob-imports-target.rs index 6fde9fef0b6..84b9ffa83ff 100644 --- a/tests/ui/imports/export-glob-imports-target.rs +++ b/tests/ui/imports/export-glob-imports-target.rs @@ -9,7 +9,7 @@ mod foo { - use foo::bar::*; + use crate::foo::bar::*; pub mod bar { pub static a : isize = 10; } diff --git a/tests/ui/imports/extern-crate-used.stderr b/tests/ui/imports/extern-crate-used.stderr index 982da0c913e..08bee391414 100644 --- a/tests/ui/imports/extern-crate-used.stderr +++ b/tests/ui/imports/extern-crate-used.stderr @@ -2,13 +2,18 @@ error: unused extern crate --> $DIR/extern-crate-used.rs:18:1 | LL | extern crate core; - | ^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^ unused | note: the lint level is defined here --> $DIR/extern-crate-used.rs:6:9 | LL | #![deny(unused_extern_crates)] | ^^^^^^^^^^^^^^^^^^^^ +help: remove the unused `extern crate` + | +LL - extern crate core; +LL + + | error: aborting due to 1 previous error diff --git a/tests/ui/imports/glob-cycles.rs b/tests/ui/imports/glob-cycles.rs index 066aa3b53ea..d9850bec4ca 100644 --- a/tests/ui/imports/glob-cycles.rs +++ b/tests/ui/imports/glob-cycles.rs @@ -1,12 +1,12 @@ //@ check-pass mod foo { - pub use bar::*; - pub use main as f; + pub use crate::bar::*; + pub use crate::main as f; } mod bar { - pub use foo::*; + pub use crate::foo::*; } pub use foo::*; diff --git a/tests/ui/imports/glob-shadowing.rs b/tests/ui/imports/glob-shadowing.rs index 3a33b592b00..72848aac511 100644 --- a/tests/ui/imports/glob-shadowing.rs +++ b/tests/ui/imports/glob-shadowing.rs @@ -6,7 +6,7 @@ mod m { } mod glob_in_normal_module { - use m::*; + use crate::m::*; fn check() { let x = env!("PATH"); //~ ERROR `env` is ambiguous } @@ -14,7 +14,7 @@ mod glob_in_normal_module { mod glob_in_block_module { fn block() { - use m::*; + use crate::m::*; fn check() { let x = env!("PATH"); //~ ERROR `env` is ambiguous } @@ -24,7 +24,7 @@ mod glob_in_block_module { mod glob_shadows_item { pub macro fenv($e: expr) { $e } fn block() { - use m::*; + use crate::m::*; fn check() { let x = fenv!(); //~ ERROR `fenv` is ambiguous } diff --git a/tests/ui/imports/glob-shadowing.stderr b/tests/ui/imports/glob-shadowing.stderr index aff2eff68ac..0ce8d4f54f8 100644 --- a/tests/ui/imports/glob-shadowing.stderr +++ b/tests/ui/imports/glob-shadowing.stderr @@ -9,8 +9,8 @@ LL | let x = env!("PATH"); note: `env` could also refer to the macro imported here --> $DIR/glob-shadowing.rs:9:9 | -LL | use m::*; - | ^^^^ +LL | use crate::m::*; + | ^^^^^^^^^^^ = help: consider adding an explicit import of `env` to disambiguate = help: or use `self::env` to refer to this macro unambiguously @@ -25,8 +25,8 @@ LL | let x = env!("PATH"); note: `env` could also refer to the macro imported here --> $DIR/glob-shadowing.rs:17:13 | -LL | use m::*; - | ^^^^ +LL | use crate::m::*; + | ^^^^^^^^^^^ = help: consider adding an explicit import of `env` to disambiguate error[E0659]: `fenv` is ambiguous @@ -39,8 +39,8 @@ LL | let x = fenv!(); note: `fenv` could refer to the macro imported here --> $DIR/glob-shadowing.rs:27:13 | -LL | use m::*; - | ^^^^ +LL | use crate::m::*; + | ^^^^^^^^^^^ = help: consider adding an explicit import of `fenv` to disambiguate note: `fenv` could also refer to the macro defined here --> $DIR/glob-shadowing.rs:25:5 diff --git a/tests/ui/crate-leading-sep.rs b/tests/ui/imports/global-path-resolution-drop.rs index 6f4dd0bcfd7..29a6afa10c9 100644 --- a/tests/ui/crate-leading-sep.rs +++ b/tests/ui/imports/global-path-resolution-drop.rs @@ -1,3 +1,5 @@ +//! Checks global path resolution of `mem::drop` using a leading `::`. + //@ run-pass #![allow(dropping_copy_types)] diff --git a/tests/ui/imports/import-glob-1.rs b/tests/ui/imports/import-glob-1.rs index 510f3814567..8beec4ce469 100644 --- a/tests/ui/imports/import-glob-1.rs +++ b/tests/ui/imports/import-glob-1.rs @@ -21,7 +21,7 @@ mod bar { } mod foo { - use bar::Baz::{Baz1, Baz2}; + use crate::bar::Baz::{Baz1, Baz2}; } fn main() {} diff --git a/tests/ui/imports/import-glob-circular.rs b/tests/ui/imports/import-glob-circular.rs index e47fa870c06..2dcfc7721fa 100644 --- a/tests/ui/imports/import-glob-circular.rs +++ b/tests/ui/imports/import-glob-circular.rs @@ -1,17 +1,17 @@ mod circ1 { - pub use circ2::f2; + pub use crate::circ2::f2; pub fn f1() { println!("f1"); } pub fn common() -> usize { return 0; } } mod circ2 { - pub use circ1::f1; + pub use crate::circ1::f1; pub fn f2() { println!("f2"); } pub fn common() -> usize { return 1; } } mod test { - use circ1::*; + use crate::circ1::*; fn test() { f1066(); } //~ ERROR cannot find function `f1066` in this scope } diff --git a/tests/ui/imports/import-glob-crate.rs b/tests/ui/imports/import-glob-crate.rs index 0a2ca6ef2c3..ee067931876 100644 --- a/tests/ui/imports/import-glob-crate.rs +++ b/tests/ui/imports/import-glob-crate.rs @@ -1,3 +1,4 @@ +//@ edition: 2015 //@ run-pass use std::mem::*; diff --git a/tests/ui/imports/import-loop-2.rs b/tests/ui/imports/import-loop-2.rs index 1bd0f06c671..42f9a07fff3 100644 --- a/tests/ui/imports/import-loop-2.rs +++ b/tests/ui/imports/import-loop-2.rs @@ -1,9 +1,9 @@ mod a { - pub use b::x; + pub use crate::b::x; } mod b { - pub use a::x; //~ ERROR unresolved import `a::x` + pub use crate::a::x; //~ ERROR unresolved import `crate::a::x` fn main() { let y = x; } } diff --git a/tests/ui/imports/import-loop-2.stderr b/tests/ui/imports/import-loop-2.stderr index 2521b6e7c04..2ef40c4e218 100644 --- a/tests/ui/imports/import-loop-2.stderr +++ b/tests/ui/imports/import-loop-2.stderr @@ -1,8 +1,8 @@ -error[E0432]: unresolved import `a::x` +error[E0432]: unresolved import `crate::a::x` --> $DIR/import-loop-2.rs:6:13 | -LL | pub use a::x; - | ^^^^ no `x` in `a` +LL | pub use crate::a::x; + | ^^^^^^^^^^^ no `x` in `a` error: aborting due to 1 previous error diff --git a/tests/ui/imports/import-loop.rs b/tests/ui/imports/import-loop.rs index fc5bd32adee..92483770711 100644 --- a/tests/ui/imports/import-loop.rs +++ b/tests/ui/imports/import-loop.rs @@ -1,7 +1,7 @@ use y::x; mod y { - pub use y::x; //~ ERROR unresolved import `y::x` + pub use crate::y::x; //~ ERROR unresolved import `crate::y::x` } fn main() { } diff --git a/tests/ui/imports/import-loop.stderr b/tests/ui/imports/import-loop.stderr index 801fc2552b6..888ca11293c 100644 --- a/tests/ui/imports/import-loop.stderr +++ b/tests/ui/imports/import-loop.stderr @@ -1,8 +1,8 @@ -error[E0432]: unresolved import `y::x` +error[E0432]: unresolved import `crate::y::x` --> $DIR/import-loop.rs:4:13 | -LL | pub use y::x; - | ^^^^ no `x` in `y` +LL | pub use crate::y::x; + | ^^^^^^^^^^^ no `x` in `y` error: aborting due to 1 previous error diff --git a/tests/ui/imports/import-rpass.rs b/tests/ui/imports/import-rpass.rs index 97c64fd9c63..f03f974d573 100644 --- a/tests/ui/imports/import-rpass.rs +++ b/tests/ui/imports/import-rpass.rs @@ -4,8 +4,8 @@ mod foo { } mod bar { - use foo::x; - use foo::x as z; + use crate::foo::x; + use crate::foo::x as z; pub fn thing() { x(10); z(10); } } diff --git a/tests/ui/imports/import4.rs b/tests/ui/imports/import4.rs index 01535fc6f45..f670cc06201 100644 --- a/tests/ui/imports/import4.rs +++ b/tests/ui/imports/import4.rs @@ -1,4 +1,4 @@ -mod a { pub use b::foo; } -mod b { pub use a::foo; } //~ ERROR unresolved import `a::foo` +mod a { pub use crate::b::foo; } +mod b { pub use crate::a::foo; } //~ ERROR unresolved import `crate::a::foo` fn main() { println!("loop"); } diff --git a/tests/ui/imports/import4.stderr b/tests/ui/imports/import4.stderr index c979d6c9ae2..4faa5f0520a 100644 --- a/tests/ui/imports/import4.stderr +++ b/tests/ui/imports/import4.stderr @@ -1,8 +1,8 @@ -error[E0432]: unresolved import `a::foo` +error[E0432]: unresolved import `crate::a::foo` --> $DIR/import4.rs:2:17 | -LL | mod b { pub use a::foo; } - | ^^^^^^ no `foo` in `a` +LL | mod b { pub use crate::a::foo; } + | ^^^^^^^^^^^^^ no `foo` in `a` error: aborting due to 1 previous error diff --git a/tests/ui/imports/import5.rs b/tests/ui/imports/import5.rs index 96d6c62d48a..7c7d99d7175 100644 --- a/tests/ui/imports/import5.rs +++ b/tests/ui/imports/import5.rs @@ -1,7 +1,7 @@ //@ run-pass use foo::bar; mod foo { - pub use foo::zed::bar; + pub use crate::foo::zed::bar; pub mod zed { pub fn bar() { println!("foo"); } } diff --git a/tests/ui/imports/import6.rs b/tests/ui/imports/import6.rs index 8632c21e5f7..1677003c0ec 100644 --- a/tests/ui/imports/import6.rs +++ b/tests/ui/imports/import6.rs @@ -10,6 +10,6 @@ mod foo { } } mod bar { - pub use foo::zed::baz; + pub use crate::foo::zed::baz; } pub fn main() { baz(); } diff --git a/tests/ui/imports/imports.rs b/tests/ui/imports/imports.rs index a770103c212..b5c25eb0447 100644 --- a/tests/ui/imports/imports.rs +++ b/tests/ui/imports/imports.rs @@ -3,7 +3,7 @@ // Like other items, private imports can be imported and used non-lexically in paths. mod a { - use a as foo; + use crate::a as foo; use self::foo::foo as bar; mod b { @@ -18,22 +18,22 @@ pub fn f() -> bool { true } // Items and explicit imports shadow globs. fn g() { - use foo::*; - use bar::*; + use crate::foo::*; + use crate::bar::*; fn f() -> bool { true } let _: bool = f(); } fn h() { - use foo::*; - use bar::*; - use f; + use crate::foo::*; + use crate::bar::*; + use crate::f; let _: bool = f(); } // Here, there appears to be shadowing but isn't because of namespaces. mod b { - use foo::*; // This imports `f` in the value namespace. + use crate::foo::*; // This imports `f` in the value namespace. use super::b as f; // This imports `f` only in the type namespace, fn test() { self::f(); } // so the glob isn't shadowed. } @@ -55,12 +55,13 @@ mod c { // Unused names can be ambiguous. mod d { - pub use foo::*; // This imports `f` in the value namespace. - pub use bar::*; // This also imports `f` in the value namespace. + pub use crate::foo::*; // This imports `f` in the value namespace. + pub use crate::bar::*; // This also imports `f` in the value namespace. } mod e { - pub use d::*; // n.b. Since `e::f` is not used, this is not considered to be a use of `d::f`. + pub use crate::d::*; // n.b. Since `e::f` is not used, + // this is not considered to be a use of `d::f`. } fn main() {} diff --git a/tests/ui/imports/issue-18083.rs b/tests/ui/imports/issue-18083.rs index 97c0bc83ad5..c111c9b5aa8 100644 --- a/tests/ui/imports/issue-18083.rs +++ b/tests/ui/imports/issue-18083.rs @@ -5,7 +5,7 @@ // each other and be reported as unresolved. mod a { - use b::{B}; + use crate::b::{B}; pub use self::inner::A; mod inner { @@ -14,7 +14,7 @@ mod a { } mod b { - use a::{A}; + use crate::a::{A}; pub use self::inner::B; mod inner { diff --git a/tests/ui/imports/issue-19498.rs b/tests/ui/imports/issue-19498.rs index 5b9ce85fd8b..ae4e5fd35e5 100644 --- a/tests/ui/imports/issue-19498.rs +++ b/tests/ui/imports/issue-19498.rs @@ -7,7 +7,7 @@ mod A {} //~ ERROR the name `A` is defined multiple times pub mod B {} //~ ERROR the name `B` is defined multiple times //~| NOTE `B` redefined here mod C { - use C::D; + use crate::C::D; mod D {} //~ ERROR the name `D` is defined multiple times //~| NOTE `D` redefined here } diff --git a/tests/ui/imports/issue-19498.stderr b/tests/ui/imports/issue-19498.stderr index eb0d68a24c9..a4ddff3ed99 100644 --- a/tests/ui/imports/issue-19498.stderr +++ b/tests/ui/imports/issue-19498.stderr @@ -31,16 +31,16 @@ LL | use self::B as OtherB; error[E0255]: the name `D` is defined multiple times --> $DIR/issue-19498.rs:11:5 | -LL | use C::D; - | ---- previous import of the module `D` here +LL | use crate::C::D; + | ----------- previous import of the module `D` here LL | mod D {} | ^^^^^ `D` redefined here | = note: `D` must be defined only once in the type namespace of this module help: you can use `as` to change the binding name of the import | -LL | use C::D as OtherD; - | +++++++++ +LL | use crate::C::D as OtherD; + | +++++++++ error: aborting due to 3 previous errors diff --git a/tests/ui/imports/issue-32222.rs b/tests/ui/imports/issue-32222.rs index 8c528bc0a1e..6f5530a065c 100644 --- a/tests/ui/imports/issue-32222.rs +++ b/tests/ui/imports/issue-32222.rs @@ -16,7 +16,7 @@ mod a { } mod b { - pub use a::bar; + pub use crate::a::bar; } fn main() {} diff --git a/tests/ui/imports/issue-4366-2.rs b/tests/ui/imports/issue-4366-2.rs index c777b750252..e92d964f889 100644 --- a/tests/ui/imports/issue-4366-2.rs +++ b/tests/ui/imports/issue-4366-2.rs @@ -7,11 +7,11 @@ mod foo { } mod a { pub mod b { - use foo::foo; + use crate::foo::foo; type Bar = isize; } pub mod sub { - use a::b::*; + use crate::a::b::*; fn sub() -> Bar { 1 } //~^ ERROR cannot find type `Bar` in this scope } diff --git a/tests/ui/imports/issue-4366.rs b/tests/ui/imports/issue-4366.rs index 9ec2e58ecad..e2d89fdaff3 100644 --- a/tests/ui/imports/issue-4366.rs +++ b/tests/ui/imports/issue-4366.rs @@ -10,11 +10,11 @@ mod foo { } mod a { pub mod b { - use foo::foo; + use crate::foo::foo; type Bar = isize; } pub mod sub { - use a::b::*; + use crate::a::b::*; fn sub() -> isize { foo(); 1 } //~ ERROR cannot find function `foo` in this scope } } diff --git a/tests/ui/imports/issue-4865-1.rs b/tests/ui/imports/issue-4865-1.rs index 1a72b1b5e3f..7c34d105550 100644 --- a/tests/ui/imports/issue-4865-1.rs +++ b/tests/ui/imports/issue-4865-1.rs @@ -6,16 +6,16 @@ // because these previous imports were not resolved. pub mod a { - use b::fn_b; - use c::*; + use crate::b::fn_b; + use crate::c::*; pub fn fn_a(){ } } pub mod b { - use a::fn_a; - use c::*; + use crate::a::fn_a; + use crate::c::*; pub fn fn_b(){ } diff --git a/tests/ui/imports/issue-4865-2.rs b/tests/ui/imports/issue-4865-2.rs index 746a74658dd..60ce2a468d9 100644 --- a/tests/ui/imports/issue-4865-2.rs +++ b/tests/ui/imports/issue-4865-2.rs @@ -12,7 +12,7 @@ pub mod say { } pub mod hello { - use say; + use crate::say; pub fn hello() { say::hello(); diff --git a/tests/ui/imports/issue-4865-3.rs b/tests/ui/imports/issue-4865-3.rs index 130223558cb..d9d17f4dd47 100644 --- a/tests/ui/imports/issue-4865-3.rs +++ b/tests/ui/imports/issue-4865-3.rs @@ -4,11 +4,11 @@ // they are not `pub`. pub mod a { - use b::*; + use crate::b::*; } pub mod b { - use a::*; + use crate::a::*; } use a::*; diff --git a/tests/ui/imports/issue-8208.rs b/tests/ui/imports/issue-8208.rs index 997d4d227b3..f6d88f830f2 100644 --- a/tests/ui/imports/issue-8208.rs +++ b/tests/ui/imports/issue-8208.rs @@ -2,7 +2,7 @@ use self::*; //~ ERROR: unresolved import `self::*` [E0432] //~^ NOTE cannot glob-import a module into itself mod foo { - use foo::*; //~ ERROR: unresolved import `foo::*` [E0432] + use crate::foo::*; //~ ERROR: unresolved import `crate::foo::*` [E0432] //~^ NOTE cannot glob-import a module into itself mod bar { diff --git a/tests/ui/imports/issue-8208.stderr b/tests/ui/imports/issue-8208.stderr index e59aea12cda..0fbe4d35fab 100644 --- a/tests/ui/imports/issue-8208.stderr +++ b/tests/ui/imports/issue-8208.stderr @@ -4,11 +4,11 @@ error[E0432]: unresolved import `self::*` LL | use self::*; | ^^^^^^^ cannot glob-import a module into itself -error[E0432]: unresolved import `foo::*` +error[E0432]: unresolved import `crate::foo::*` --> $DIR/issue-8208.rs:5:9 | -LL | use foo::*; - | ^^^^^^ cannot glob-import a module into itself +LL | use crate::foo::*; + | ^^^^^^^^^^^^^ cannot glob-import a module into itself error[E0432]: unresolved import `super::bar::*` --> $DIR/issue-8208.rs:9:13 diff --git a/tests/ui/imports/issue-8640.rs b/tests/ui/imports/issue-8640.rs index 51a02a32ec8..7cf73d0e93e 100644 --- a/tests/ui/imports/issue-8640.rs +++ b/tests/ui/imports/issue-8640.rs @@ -1,7 +1,7 @@ #[allow(unused_imports)] mod foo { - use baz::bar; + use crate::baz::bar; mod bar {} //~^ ERROR the name `bar` is defined multiple times } diff --git a/tests/ui/imports/issue-8640.stderr b/tests/ui/imports/issue-8640.stderr index d22fddb1a69..3ce57e3a44a 100644 --- a/tests/ui/imports/issue-8640.stderr +++ b/tests/ui/imports/issue-8640.stderr @@ -1,16 +1,16 @@ error[E0255]: the name `bar` is defined multiple times --> $DIR/issue-8640.rs:5:5 | -LL | use baz::bar; - | -------- previous import of the module `bar` here +LL | use crate::baz::bar; + | --------------- previous import of the module `bar` here LL | mod bar {} | ^^^^^^^ `bar` redefined here | = note: `bar` must be defined only once in the type namespace of this module help: you can use `as` to change the binding name of the import | -LL | use baz::bar as other_bar; - | ++++++++++++ +LL | use crate::baz::bar as other_bar; + | ++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/imports/local-modularized-tricky-fail-2.rs b/tests/ui/imports/local-modularized-tricky-fail-2.rs index 386de88bc3d..80b242b456c 100644 --- a/tests/ui/imports/local-modularized-tricky-fail-2.rs +++ b/tests/ui/imports/local-modularized-tricky-fail-2.rs @@ -10,13 +10,13 @@ macro_rules! define_exported { () => { define_exported!(); mod m { - use exported; + use crate::exported; //~^ ERROR macro-expanded `macro_export` macros from the current crate cannot //~| WARN this was previously accepted } fn main() { - ::exported!(); + crate::exported!(); //~^ ERROR macro-expanded `macro_export` macros from the current crate cannot //~| WARN this was previously accepted } diff --git a/tests/ui/imports/local-modularized-tricky-fail-2.stderr b/tests/ui/imports/local-modularized-tricky-fail-2.stderr index 2c1965ac0a4..49f5c72947f 100644 --- a/tests/ui/imports/local-modularized-tricky-fail-2.stderr +++ b/tests/ui/imports/local-modularized-tricky-fail-2.stderr @@ -1,8 +1,8 @@ error: macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths --> $DIR/local-modularized-tricky-fail-2.rs:13:9 | -LL | use exported; - | ^^^^^^^^ +LL | use crate::exported; + | ^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #52234 <https://github.com/rust-lang/rust/issues/52234> @@ -22,8 +22,8 @@ LL | define_exported!(); error: macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths --> $DIR/local-modularized-tricky-fail-2.rs:19:5 | -LL | ::exported!(); - | ^^^^^^^^^^ +LL | crate::exported!(); + | ^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #52234 <https://github.com/rust-lang/rust/issues/52234> diff --git a/tests/ui/imports/macros.rs b/tests/ui/imports/macros.rs index 7f479571e5e..cf67e08c87a 100644 --- a/tests/ui/imports/macros.rs +++ b/tests/ui/imports/macros.rs @@ -8,13 +8,13 @@ mod foo { mod m1 { m!(use two_macros::*;); - use foo::m; // This shadows the glob import + use crate::foo::m; // This shadows the glob import } mod m2 { use two_macros::*; m! { //~ ERROR ambiguous - use foo::m; + use crate::foo::m; } } diff --git a/tests/ui/imports/macros.stderr b/tests/ui/imports/macros.stderr index e34e5359b48..25a678c6b37 100644 --- a/tests/ui/imports/macros.stderr +++ b/tests/ui/imports/macros.stderr @@ -8,8 +8,8 @@ LL | m! { note: `m` could refer to the macro imported here --> $DIR/macros.rs:17:13 | -LL | use foo::m; - | ^^^^^^ +LL | use crate::foo::m; + | ^^^^^^^^^^^^^ note: `m` could also refer to the macro imported here --> $DIR/macros.rs:15:9 | diff --git a/tests/ui/imports/reexport-star.rs b/tests/ui/imports/reexport-star.rs index 461dc23b4dc..9bf4a6ce0c4 100644 --- a/tests/ui/imports/reexport-star.rs +++ b/tests/ui/imports/reexport-star.rs @@ -6,7 +6,7 @@ mod a { } mod b { - pub use a::*; + pub use crate::a::*; } pub fn main() { diff --git a/tests/ui/imports/reexports.rs b/tests/ui/imports/reexports.rs index 2a1a62834ce..6ad704b53fc 100644 --- a/tests/ui/imports/reexports.rs +++ b/tests/ui/imports/reexports.rs @@ -33,8 +33,8 @@ mod b { mod c { // Test that `foo` is not re-exported. - use b::a::foo::S; //~ ERROR `foo` - use b::b::foo::S as T; //~ ERROR `foo` + use crate::b::a::foo::S; //~ ERROR `foo` + use crate::b::b::foo::S as T; //~ ERROR `foo` } fn main() {} diff --git a/tests/ui/imports/reexports.stderr b/tests/ui/imports/reexports.stderr index fa05c0c0f8e..0ebcf8e58d6 100644 --- a/tests/ui/imports/reexports.stderr +++ b/tests/ui/imports/reexports.stderr @@ -11,10 +11,10 @@ LL | pub use super::foo; | ^^^^^^^^^^ error[E0603]: module import `foo` is private - --> $DIR/reexports.rs:36:15 + --> $DIR/reexports.rs:36:22 | -LL | use b::a::foo::S; - | ^^^ private module import +LL | use crate::b::a::foo::S; + | ^^^ private module import | note: the module import `foo` is defined here... --> $DIR/reexports.rs:24:17 @@ -28,10 +28,10 @@ LL | mod foo { | ^^^^^^^ error[E0603]: module import `foo` is private - --> $DIR/reexports.rs:37:15 + --> $DIR/reexports.rs:37:22 | -LL | use b::b::foo::S as T; - | ^^^ private module import +LL | use crate::b::b::foo::S as T; + | ^^^ private module import | note: the module import `foo` is defined here... --> $DIR/reexports.rs:29:17 diff --git a/tests/ui/imports/shadow_builtin_macros.rs b/tests/ui/imports/shadow_builtin_macros.rs index 5a149067408..7d318dfdb43 100644 --- a/tests/ui/imports/shadow_builtin_macros.rs +++ b/tests/ui/imports/shadow_builtin_macros.rs @@ -6,17 +6,17 @@ mod foo { } mod m1 { - use foo::panic; // ok + use crate::foo::panic; // ok fn f() { panic!(); } } mod m2 { - use foo::*; + use crate::foo::*; fn f() { panic!(); } //~ ERROR ambiguous } mod m3 { - ::two_macros::m!(use foo::panic;); + ::two_macros::m!(use crate::foo::panic;); fn f() { panic!(); } //~ ERROR ambiguous } @@ -40,12 +40,12 @@ mod bar { } mod m6 { - use bar::n; // ok + use crate::bar::n; // ok n!(); } mod m7 { - use bar::*; + use crate::bar::*; n!(); //~ ERROR ambiguous } diff --git a/tests/ui/imports/shadow_builtin_macros.stderr b/tests/ui/imports/shadow_builtin_macros.stderr index 6ffb31c20e6..c828b1193d8 100644 --- a/tests/ui/imports/shadow_builtin_macros.stderr +++ b/tests/ui/imports/shadow_builtin_macros.stderr @@ -9,8 +9,8 @@ LL | fn f() { panic!(); } note: `panic` could also refer to the macro imported here --> $DIR/shadow_builtin_macros.rs:14:9 | -LL | use foo::*; - | ^^^^^^ +LL | use crate::foo::*; + | ^^^^^^^^^^^^^ = help: consider adding an explicit import of `panic` to disambiguate = help: or use `self::panic` to refer to this macro unambiguously @@ -42,8 +42,8 @@ LL | n!(); note: `n` could refer to the macro imported here --> $DIR/shadow_builtin_macros.rs:48:9 | -LL | use bar::*; - | ^^^^^^ +LL | use crate::bar::*; + | ^^^^^^^^^^^^^ = help: consider adding an explicit import of `n` to disambiguate = help: or use `self::n` to refer to this macro unambiguously note: `n` could also refer to the macro imported here @@ -63,8 +63,8 @@ LL | fn f() { panic!(); } note: `panic` could also refer to the macro imported here --> $DIR/shadow_builtin_macros.rs:19:26 | -LL | ::two_macros::m!(use foo::panic;); - | ^^^^^^^^^^ +LL | ::two_macros::m!(use crate::foo::panic;); + | ^^^^^^^^^^^^^^^^^ = help: use `self::panic` to refer to this macro unambiguously error: aborting due to 4 previous errors diff --git a/tests/ui/infinite/infinite-recursion-const-fn.rs b/tests/ui/infinite/infinite-recursion-const-fn.rs index 7b7f6fafab5..3c0b3b9741b 100644 --- a/tests/ui/infinite/infinite-recursion-const-fn.rs +++ b/tests/ui/infinite/infinite-recursion-const-fn.rs @@ -6,6 +6,6 @@ const fn a() -> usize { const fn b() -> usize { a() } -const ARR: [i32; a()] = [5; 6]; //~ ERROR evaluation of constant value failed [E0080] +const ARR: [i32; a()] = [5; 6]; //~ ERROR reached the configured maximum number of stack frames fn main() {} diff --git a/tests/ui/infinite/infinite-recursion-const-fn.stderr b/tests/ui/infinite/infinite-recursion-const-fn.stderr index 524abdf4d7a..f5f6e2a58fd 100644 --- a/tests/ui/infinite/infinite-recursion-const-fn.stderr +++ b/tests/ui/infinite/infinite-recursion-const-fn.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: reached the configured maximum number of stack frames --> $DIR/infinite-recursion-const-fn.rs:9:18 | LL | const ARR: [i32; a()] = [5; 6]; - | ^^^ reached the configured maximum number of stack frames + | ^^^ evaluation of `ARR::{constant#0}` failed inside this call | note: inside `a` --> $DIR/infinite-recursion-const-fn.rs:4:5 diff --git a/tests/ui/inline-const/const-expr-generic-err.stderr b/tests/ui/inline-const/const-expr-generic-err.stderr index a40e8bceb36..26039ba6d44 100644 --- a/tests/ui/inline-const/const-expr-generic-err.stderr +++ b/tests/ui/inline-const/const-expr-generic-err.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `foo::<i32>::{constant#0}` failed +error[E0080]: evaluation panicked: assertion failed: std::mem::size_of::<T>() == 0 --> $DIR/const-expr-generic-err.rs:4:13 | LL | const { assert!(std::mem::size_of::<T>() == 0); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: assertion failed: std::mem::size_of::<T>() == 0 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `foo::<i32>::{constant#0}` failed here note: erroneous constant encountered --> $DIR/const-expr-generic-err.rs:4:5 @@ -16,11 +16,11 @@ note: the above error was encountered while instantiating `fn foo::<i32>` LL | foo::<i32>(); | ^^^^^^^^^^^^ -error[E0080]: evaluation of `bar::<0>::{constant#0}` failed +error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow --> $DIR/const-expr-generic-err.rs:8:13 | LL | const { N - 1 } - | ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow + | ^^^^^ evaluation of `bar::<0>::{constant#0}` failed here note: erroneous constant encountered --> $DIR/const-expr-generic-err.rs:8:5 diff --git a/tests/ui/inline-const/required-const.stderr b/tests/ui/inline-const/required-const.stderr index 2f618e54ed3..a517ea2fec0 100644 --- a/tests/ui/inline-const/required-const.stderr +++ b/tests/ui/inline-const/required-const.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `foo::<i32>::{constant#0}` failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/required-const.rs:6:17 | LL | const { panic!() } - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `foo::<i32>::{constant#0}` failed here note: erroneous constant encountered --> $DIR/required-const.rs:6:9 diff --git a/tests/ui/instrument-xray/platform-support.rs b/tests/ui/instrument-xray/platform-support.rs new file mode 100644 index 00000000000..238018b348d --- /dev/null +++ b/tests/ui/instrument-xray/platform-support.rs @@ -0,0 +1,27 @@ +//@ only-nightly (flag is still unstable) +//@ needs-xray + +//@ revisions: unsupported +//@[unsupported] needs-llvm-components: x86 +//@[unsupported] compile-flags: -Z instrument-xray --target=x86_64-pc-windows-msvc + +//@ revisions: x86_64-linux +//@[x86_64-linux] needs-llvm-components: x86 +//@[x86_64-linux] compile-flags: -Z instrument-xray --target=x86_64-unknown-linux-gnu +//@[x86_64-linux] check-pass + +//@ revisions: x86_64-darwin +//@[x86_64-darwin] needs-llvm-components: x86 +//@[x86_64-darwin] compile-flags: -Z instrument-xray --target=x86_64-apple-darwin +//@[x86_64-darwin] check-pass + +//@ revisions: aarch64-darwin +//@[aarch64-darwin] needs-llvm-components: aarch64 +//@[aarch64-darwin] compile-flags: -Z instrument-xray --target=aarch64-apple-darwin +//@[aarch64-darwin] check-pass + +#![feature(no_core)] +#![no_core] +#![no_main] + +//[unsupported]~? ERROR XRay instrumentation is not supported for this target diff --git a/tests/ui/instrument-xray/target-not-supported.stderr b/tests/ui/instrument-xray/platform-support.unsupported.stderr index 119094bfc4c..119094bfc4c 100644 --- a/tests/ui/instrument-xray/target-not-supported.stderr +++ b/tests/ui/instrument-xray/platform-support.unsupported.stderr diff --git a/tests/ui/instrument-xray/target-not-supported.rs b/tests/ui/instrument-xray/target-not-supported.rs deleted file mode 100644 index 2045913b186..00000000000 --- a/tests/ui/instrument-xray/target-not-supported.rs +++ /dev/null @@ -1,10 +0,0 @@ -// Verifies that `-Z instrument-xray` cannot be used with unsupported targets, -// -//@ needs-llvm-components: x86 -//@ compile-flags: -Z instrument-xray --target x86_64-apple-darwin - -#![feature(no_core)] -#![no_core] -#![no_main] - -//~? ERROR XRay instrumentation is not supported for this target diff --git a/tests/ui/intrinsics/auxiliary/cci_intrinsic.rs b/tests/ui/intrinsics/auxiliary/cci_intrinsic.rs index 1014ac6f560..95fc673f434 100644 --- a/tests/ui/intrinsics/auxiliary/cci_intrinsic.rs +++ b/tests/ui/intrinsics/auxiliary/cci_intrinsic.rs @@ -1,11 +1,12 @@ -#![feature(intrinsics)] +#![feature(intrinsics, adt_const_params)] -pub mod rusti { +mod rusti { #[rustc_intrinsic] - pub unsafe fn atomic_xchg_seqcst<T>(dst: *mut T, src: T) -> T; + pub unsafe fn size_of_val<T: ?Sized>(ptr: *const T) -> usize; } +// A monomorphic function, inlined cross-crate, referencing an intrinsic. #[inline(always)] -pub fn atomic_xchg_seqcst(dst: *mut isize, src: isize) -> isize { - unsafe { rusti::atomic_xchg_seqcst(dst, src) } +pub fn size_of_val(val: &[u8]) -> usize { + unsafe { rusti::size_of_val(val) } } diff --git a/tests/ui/intrinsics/const-eval-select-stability.stderr b/tests/ui/intrinsics/const-eval-select-stability.stderr index 5f443b1d4ff..513c19cbb5b 100644 --- a/tests/ui/intrinsics/const-eval-select-stability.stderr +++ b/tests/ui/intrinsics/const-eval-select-stability.stderr @@ -4,16 +4,11 @@ error: const function that might be (indirectly) exposed to stable cannot use `# LL | const_eval_select((), nothing, log); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the function is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | pub const fn hey() { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(const_eval_select)] -LL | pub const fn hey() { - | error: aborting due to 1 previous error diff --git a/tests/ui/intrinsics/intrinsic-alignment.rs b/tests/ui/intrinsics/intrinsic-alignment.rs index c42a4b94e29..30a523f364c 100644 --- a/tests/ui/intrinsics/intrinsic-alignment.rs +++ b/tests/ui/intrinsics/intrinsic-alignment.rs @@ -23,18 +23,12 @@ use std::intrinsics as rusti; mod m { #[cfg(target_arch = "x86")] pub fn main() { - unsafe { - assert_eq!(::rusti::pref_align_of::<u64>(), 8); - assert_eq!(::rusti::min_align_of::<u64>(), 4); - } + assert_eq!(crate::rusti::min_align_of::<u64>(), 4); } #[cfg(not(target_arch = "x86"))] pub fn main() { - unsafe { - assert_eq!(::rusti::pref_align_of::<u64>(), 8); - assert_eq!(::rusti::min_align_of::<u64>(), 8); - } + assert_eq!(crate::rusti::min_align_of::<u64>(), 8); } } @@ -42,30 +36,21 @@ mod m { mod m { #[cfg(target_arch = "x86_64")] pub fn main() { - unsafe { - assert_eq!(::rusti::pref_align_of::<u64>(), 8); - assert_eq!(::rusti::min_align_of::<u64>(), 8); - } + assert_eq!(crate::rusti::min_align_of::<u64>(), 8); } } #[cfg(target_os = "windows")] mod m { pub fn main() { - unsafe { - assert_eq!(::rusti::pref_align_of::<u64>(), 8); - assert_eq!(::rusti::min_align_of::<u64>(), 8); - } + assert_eq!(crate::rusti::min_align_of::<u64>(), 8); } } #[cfg(target_family = "wasm")] mod m { pub fn main() { - unsafe { - assert_eq!(::rusti::pref_align_of::<u64>(), 8); - assert_eq!(::rusti::min_align_of::<u64>(), 8); - } + assert_eq!(crate::rusti::min_align_of::<u64>(), 8); } } diff --git a/tests/ui/intrinsics/intrinsic-atomics-cc.rs b/tests/ui/intrinsics/intrinsic-atomics-cc.rs deleted file mode 100644 index 612a21a47cf..00000000000 --- a/tests/ui/intrinsics/intrinsic-atomics-cc.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ run-pass -//@ aux-build:cci_intrinsic.rs - - -extern crate cci_intrinsic; -use cci_intrinsic::atomic_xchg_seqcst; - -pub fn main() { - let mut x = 1; - atomic_xchg_seqcst(&mut x, 5); - assert_eq!(x, 5); -} diff --git a/tests/ui/intrinsics/intrinsic-atomics.rs b/tests/ui/intrinsics/intrinsic-atomics.rs index 9127cc649e6..2275aafff83 100644 --- a/tests/ui/intrinsics/intrinsic-atomics.rs +++ b/tests/ui/intrinsics/intrinsic-atomics.rs @@ -1,50 +1,50 @@ //@ run-pass #![feature(core_intrinsics)] -use std::intrinsics as rusti; +use std::intrinsics::{self as rusti, AtomicOrdering::*}; pub fn main() { unsafe { let mut x: Box<_> = Box::new(1); - assert_eq!(rusti::atomic_load_seqcst(&*x), 1); + assert_eq!(rusti::atomic_load::<_, { SeqCst }>(&*x), 1); *x = 5; - assert_eq!(rusti::atomic_load_acquire(&*x), 5); + assert_eq!(rusti::atomic_load::<_, { Acquire }>(&*x), 5); - rusti::atomic_store_seqcst(&mut *x, 3); + rusti::atomic_store::<_, { SeqCst }>(&mut *x, 3); assert_eq!(*x, 3); - rusti::atomic_store_release(&mut *x, 1); + rusti::atomic_store::<_, { Release }>(&mut *x, 1); assert_eq!(*x, 1); - assert_eq!(rusti::atomic_cxchg_seqcst_seqcst(&mut *x, 1, 2), (1, true)); + assert_eq!(rusti::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(&mut *x, 1, 2), (1, true)); assert_eq!(*x, 2); - assert_eq!(rusti::atomic_cxchg_acquire_acquire(&mut *x, 1, 3), (2, false)); + assert_eq!(rusti::atomic_cxchg::<_, { Acquire }, { Acquire }>(&mut *x, 1, 3), (2, false)); assert_eq!(*x, 2); - assert_eq!(rusti::atomic_cxchg_release_relaxed(&mut *x, 2, 1), (2, true)); + assert_eq!(rusti::atomic_cxchg::<_, { Release }, { Relaxed }>(&mut *x, 2, 1), (2, true)); assert_eq!(*x, 1); - assert_eq!(rusti::atomic_xchg_seqcst(&mut *x, 0), 1); + assert_eq!(rusti::atomic_xchg::<_, { SeqCst }>(&mut *x, 0), 1); assert_eq!(*x, 0); - assert_eq!(rusti::atomic_xchg_acquire(&mut *x, 1), 0); + assert_eq!(rusti::atomic_xchg::<_, { Acquire }>(&mut *x, 1), 0); assert_eq!(*x, 1); - assert_eq!(rusti::atomic_xchg_release(&mut *x, 0), 1); + assert_eq!(rusti::atomic_xchg::<_, { Release }>(&mut *x, 0), 1); assert_eq!(*x, 0); - assert_eq!(rusti::atomic_xadd_seqcst(&mut *x, 1), 0); - assert_eq!(rusti::atomic_xadd_acquire(&mut *x, 1), 1); - assert_eq!(rusti::atomic_xadd_release(&mut *x, 1), 2); + assert_eq!(rusti::atomic_xadd::<_, { SeqCst }>(&mut *x, 1), 0); + assert_eq!(rusti::atomic_xadd::<_, { Acquire }>(&mut *x, 1), 1); + assert_eq!(rusti::atomic_xadd::<_, { Release }>(&mut *x, 1), 2); assert_eq!(*x, 3); - assert_eq!(rusti::atomic_xsub_seqcst(&mut *x, 1), 3); - assert_eq!(rusti::atomic_xsub_acquire(&mut *x, 1), 2); - assert_eq!(rusti::atomic_xsub_release(&mut *x, 1), 1); + assert_eq!(rusti::atomic_xsub::<_, { SeqCst }>(&mut *x, 1), 3); + assert_eq!(rusti::atomic_xsub::<_, { Acquire }>(&mut *x, 1), 2); + assert_eq!(rusti::atomic_xsub::<_, { Release }>(&mut *x, 1), 1); assert_eq!(*x, 0); loop { - let res = rusti::atomic_cxchgweak_seqcst_seqcst(&mut *x, 0, 1); + let res = rusti::atomic_cxchgweak::<_, { SeqCst }, { SeqCst }>(&mut *x, 0, 1); assert_eq!(res.0, 0); if res.1 { break; @@ -53,7 +53,7 @@ pub fn main() { assert_eq!(*x, 1); loop { - let res = rusti::atomic_cxchgweak_acquire_acquire(&mut *x, 1, 2); + let res = rusti::atomic_cxchgweak::<_, { Acquire }, { Acquire }>(&mut *x, 1, 2); assert_eq!(res.0, 1); if res.1 { break; @@ -62,7 +62,7 @@ pub fn main() { assert_eq!(*x, 2); loop { - let res = rusti::atomic_cxchgweak_release_relaxed(&mut *x, 2, 3); + let res = rusti::atomic_cxchgweak::<_, { Release }, { Relaxed }>(&mut *x, 2, 3); assert_eq!(res.0, 2); if res.1 { break; diff --git a/tests/ui/intrinsics/intrinsic-inline-cc.rs b/tests/ui/intrinsics/intrinsic-inline-cc.rs new file mode 100644 index 00000000000..f2b961a760b --- /dev/null +++ b/tests/ui/intrinsics/intrinsic-inline-cc.rs @@ -0,0 +1,9 @@ +//@ run-pass +//@ aux-build:cci_intrinsic.rs + +extern crate cci_intrinsic; + +pub fn main() { + let val = cci_intrinsic::size_of_val(&[1u8, 2, 3]); + assert_eq!(val, 3); +} diff --git a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs index fdb25a3ae3f..15f4a9a778e 100644 --- a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs +++ b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.rs @@ -2,22 +2,19 @@ const RAW_EQ_PADDING: bool = unsafe { std::intrinsics::raw_eq(&(1_u8, 2_u16), &(1_u8, 2_u16)) -//~^ ERROR evaluation of constant value failed -//~| NOTE requires initialized memory +//~^ ERROR requires initialized memory }; const RAW_EQ_PTR: bool = unsafe { std::intrinsics::raw_eq(&(&0), &(&1)) -//~^ ERROR evaluation of constant value failed -//~| NOTE unable to turn pointer into integer +//~^ ERROR unable to turn pointer into integer }; const RAW_EQ_NOT_ALIGNED: bool = unsafe { let arr = [0u8; 4]; let aref = &*arr.as_ptr().cast::<i32>(); std::intrinsics::raw_eq(aref, aref) -//~^ ERROR evaluation of constant value failed -//~| NOTE alignment +//~^ ERROR alignment }; pub fn main() { diff --git a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr index b8fdfe7bef3..10f4d8d1a71 100644 --- a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr +++ b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr @@ -1,23 +1,23 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory --> $DIR/intrinsic-raw_eq-const-bad.rs:4:5 | LL | std::intrinsics::raw_eq(&(1_u8, 2_u16), &(1_u8, 2_u16)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `RAW_EQ_PADDING` failed here -error[E0080]: evaluation of constant value failed - --> $DIR/intrinsic-raw_eq-const-bad.rs:10:5 +error[E0080]: unable to turn pointer into integer + --> $DIR/intrinsic-raw_eq-const-bad.rs:9:5 | LL | std::intrinsics::raw_eq(&(&0), &(&1)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `RAW_EQ_PTR` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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/intrinsic-raw_eq-const-bad.rs:18:5 +error[E0080]: accessing memory with alignment 1, but alignment 4 is required + --> $DIR/intrinsic-raw_eq-const-bad.rs:16:5 | LL | std::intrinsics::raw_eq(aref, aref) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ accessing memory with alignment 1, but alignment 4 is required + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `RAW_EQ_NOT_ALIGNED` failed here error: aborting due to 3 previous errors diff --git a/tests/ui/intrinsics/non-integer-atomic.rs b/tests/ui/intrinsics/non-integer-atomic.rs index 2d1d0882084..853c163710f 100644 --- a/tests/ui/intrinsics/non-integer-atomic.rs +++ b/tests/ui/intrinsics/non-integer-atomic.rs @@ -4,89 +4,89 @@ #![allow(warnings)] #![crate_type = "rlib"] -use std::intrinsics; +use std::intrinsics::{self, AtomicOrdering::*}; #[derive(Copy, Clone)] pub struct Foo(i64); -pub type Bar = &'static Fn(); +pub type Bar = &'static dyn Fn(); pub type Quux = [u8; 100]; pub unsafe fn test_bool_load(p: &mut bool, v: bool) { - intrinsics::atomic_load_seqcst(p); - //~^ ERROR `atomic_load_seqcst` intrinsic: expected basic integer type, found `bool` + intrinsics::atomic_load::<_, { SeqCst }>(p); + //~^ ERROR `atomic_load` intrinsic: expected basic integer type, found `bool` } pub unsafe fn test_bool_store(p: &mut bool, v: bool) { - intrinsics::atomic_store_seqcst(p, v); - //~^ ERROR `atomic_store_seqcst` intrinsic: expected basic integer type, found `bool` + intrinsics::atomic_store::<_, { SeqCst }>(p, v); + //~^ ERROR `atomic_store` intrinsic: expected basic integer type, found `bool` } pub unsafe fn test_bool_xchg(p: &mut bool, v: bool) { - intrinsics::atomic_xchg_seqcst(p, v); - //~^ ERROR `atomic_xchg_seqcst` intrinsic: expected basic integer type, found `bool` + intrinsics::atomic_xchg::<_, { SeqCst }>(p, v); + //~^ ERROR `atomic_xchg` intrinsic: expected basic integer type, found `bool` } pub unsafe fn test_bool_cxchg(p: &mut bool, v: bool) { - intrinsics::atomic_cxchg_seqcst_seqcst(p, v, v); - //~^ ERROR `atomic_cxchg_seqcst_seqcst` intrinsic: expected basic integer type, found `bool` + intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v); + //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer type, found `bool` } pub unsafe fn test_Foo_load(p: &mut Foo, v: Foo) { - intrinsics::atomic_load_seqcst(p); - //~^ ERROR `atomic_load_seqcst` intrinsic: expected basic integer type, found `Foo` + intrinsics::atomic_load::<_, { SeqCst }>(p); + //~^ ERROR `atomic_load` intrinsic: expected basic integer type, found `Foo` } pub unsafe fn test_Foo_store(p: &mut Foo, v: Foo) { - intrinsics::atomic_store_seqcst(p, v); - //~^ ERROR `atomic_store_seqcst` intrinsic: expected basic integer type, found `Foo` + intrinsics::atomic_store::<_, { SeqCst }>(p, v); + //~^ ERROR `atomic_store` intrinsic: expected basic integer type, found `Foo` } pub unsafe fn test_Foo_xchg(p: &mut Foo, v: Foo) { - intrinsics::atomic_xchg_seqcst(p, v); - //~^ ERROR `atomic_xchg_seqcst` intrinsic: expected basic integer type, found `Foo` + intrinsics::atomic_xchg::<_, { SeqCst }>(p, v); + //~^ ERROR `atomic_xchg` intrinsic: expected basic integer type, found `Foo` } pub unsafe fn test_Foo_cxchg(p: &mut Foo, v: Foo) { - intrinsics::atomic_cxchg_seqcst_seqcst(p, v, v); - //~^ ERROR `atomic_cxchg_seqcst_seqcst` intrinsic: expected basic integer type, found `Foo` + intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v); + //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer type, found `Foo` } pub unsafe fn test_Bar_load(p: &mut Bar, v: Bar) { - intrinsics::atomic_load_seqcst(p); + intrinsics::atomic_load::<_, { SeqCst }>(p); //~^ ERROR expected basic integer type, found `&dyn Fn()` } pub unsafe fn test_Bar_store(p: &mut Bar, v: Bar) { - intrinsics::atomic_store_seqcst(p, v); + intrinsics::atomic_store::<_, { SeqCst }>(p, v); //~^ ERROR expected basic integer type, found `&dyn Fn()` } pub unsafe fn test_Bar_xchg(p: &mut Bar, v: Bar) { - intrinsics::atomic_xchg_seqcst(p, v); + intrinsics::atomic_xchg::<_, { SeqCst }>(p, v); //~^ ERROR expected basic integer type, found `&dyn Fn()` } pub unsafe fn test_Bar_cxchg(p: &mut Bar, v: Bar) { - intrinsics::atomic_cxchg_seqcst_seqcst(p, v, v); + intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v); //~^ ERROR expected basic integer type, found `&dyn Fn()` } pub unsafe fn test_Quux_load(p: &mut Quux, v: Quux) { - intrinsics::atomic_load_seqcst(p); - //~^ ERROR `atomic_load_seqcst` intrinsic: expected basic integer type, found `[u8; 100]` + intrinsics::atomic_load::<_, { SeqCst }>(p); + //~^ ERROR `atomic_load` intrinsic: expected basic integer type, found `[u8; 100]` } pub unsafe fn test_Quux_store(p: &mut Quux, v: Quux) { - intrinsics::atomic_store_seqcst(p, v); - //~^ ERROR `atomic_store_seqcst` intrinsic: expected basic integer type, found `[u8; 100]` + intrinsics::atomic_store::<_, { SeqCst }>(p, v); + //~^ ERROR `atomic_store` intrinsic: expected basic integer type, found `[u8; 100]` } pub unsafe fn test_Quux_xchg(p: &mut Quux, v: Quux) { - intrinsics::atomic_xchg_seqcst(p, v); - //~^ ERROR `atomic_xchg_seqcst` intrinsic: expected basic integer type, found `[u8; 100]` + intrinsics::atomic_xchg::<_, { SeqCst }>(p, v); + //~^ ERROR `atomic_xchg` intrinsic: expected basic integer type, found `[u8; 100]` } pub unsafe fn test_Quux_cxchg(p: &mut Quux, v: Quux) { - intrinsics::atomic_cxchg_seqcst_seqcst(p, v, v); - //~^ ERROR `atomic_cxchg_seqcst_seqcst` intrinsic: expected basic integer type, found `[u8; 100]` + intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v); + //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer type, found `[u8; 100]` } diff --git a/tests/ui/intrinsics/non-integer-atomic.stderr b/tests/ui/intrinsics/non-integer-atomic.stderr index 32791a8e8b7..e539d99b8ae 100644 --- a/tests/ui/intrinsics/non-integer-atomic.stderr +++ b/tests/ui/intrinsics/non-integer-atomic.stderr @@ -1,98 +1,98 @@ -error[E0511]: invalid monomorphization of `atomic_load_seqcst` intrinsic: expected basic integer type, found `bool` +error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer type, found `bool` --> $DIR/non-integer-atomic.rs:15:5 | -LL | intrinsics::atomic_load_seqcst(p); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | intrinsics::atomic_load::<_, { SeqCst }>(p); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_store_seqcst` intrinsic: expected basic integer type, found `bool` +error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer type, found `bool` --> $DIR/non-integer-atomic.rs:20:5 | -LL | intrinsics::atomic_store_seqcst(p, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | intrinsics::atomic_store::<_, { SeqCst }>(p, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_xchg_seqcst` intrinsic: expected basic integer type, found `bool` +error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer type, found `bool` --> $DIR/non-integer-atomic.rs:25:5 | -LL | intrinsics::atomic_xchg_seqcst(p, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | intrinsics::atomic_xchg::<_, { SeqCst }>(p, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_cxchg_seqcst_seqcst` intrinsic: expected basic integer type, found `bool` +error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer type, found `bool` --> $DIR/non-integer-atomic.rs:30:5 | -LL | intrinsics::atomic_cxchg_seqcst_seqcst(p, v, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_load_seqcst` intrinsic: expected basic integer type, found `Foo` +error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer type, found `Foo` --> $DIR/non-integer-atomic.rs:35:5 | -LL | intrinsics::atomic_load_seqcst(p); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | intrinsics::atomic_load::<_, { SeqCst }>(p); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_store_seqcst` intrinsic: expected basic integer type, found `Foo` +error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer type, found `Foo` --> $DIR/non-integer-atomic.rs:40:5 | -LL | intrinsics::atomic_store_seqcst(p, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | intrinsics::atomic_store::<_, { SeqCst }>(p, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_xchg_seqcst` intrinsic: expected basic integer type, found `Foo` +error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer type, found `Foo` --> $DIR/non-integer-atomic.rs:45:5 | -LL | intrinsics::atomic_xchg_seqcst(p, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | intrinsics::atomic_xchg::<_, { SeqCst }>(p, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_cxchg_seqcst_seqcst` intrinsic: expected basic integer type, found `Foo` +error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer type, found `Foo` --> $DIR/non-integer-atomic.rs:50:5 | -LL | intrinsics::atomic_cxchg_seqcst_seqcst(p, v, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_load_seqcst` intrinsic: expected basic integer type, found `&dyn Fn()` +error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer type, found `&dyn Fn()` --> $DIR/non-integer-atomic.rs:55:5 | -LL | intrinsics::atomic_load_seqcst(p); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | intrinsics::atomic_load::<_, { SeqCst }>(p); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_store_seqcst` intrinsic: expected basic integer type, found `&dyn Fn()` +error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer type, found `&dyn Fn()` --> $DIR/non-integer-atomic.rs:60:5 | -LL | intrinsics::atomic_store_seqcst(p, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | intrinsics::atomic_store::<_, { SeqCst }>(p, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_xchg_seqcst` intrinsic: expected basic integer type, found `&dyn Fn()` +error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer type, found `&dyn Fn()` --> $DIR/non-integer-atomic.rs:65:5 | -LL | intrinsics::atomic_xchg_seqcst(p, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | intrinsics::atomic_xchg::<_, { SeqCst }>(p, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_cxchg_seqcst_seqcst` intrinsic: expected basic integer type, found `&dyn Fn()` +error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer type, found `&dyn Fn()` --> $DIR/non-integer-atomic.rs:70:5 | -LL | intrinsics::atomic_cxchg_seqcst_seqcst(p, v, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_load_seqcst` intrinsic: expected basic integer type, found `[u8; 100]` +error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer type, found `[u8; 100]` --> $DIR/non-integer-atomic.rs:75:5 | -LL | intrinsics::atomic_load_seqcst(p); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | intrinsics::atomic_load::<_, { SeqCst }>(p); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_store_seqcst` intrinsic: expected basic integer type, found `[u8; 100]` +error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer type, found `[u8; 100]` --> $DIR/non-integer-atomic.rs:80:5 | -LL | intrinsics::atomic_store_seqcst(p, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | intrinsics::atomic_store::<_, { SeqCst }>(p, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_xchg_seqcst` intrinsic: expected basic integer type, found `[u8; 100]` +error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer type, found `[u8; 100]` --> $DIR/non-integer-atomic.rs:85:5 | -LL | intrinsics::atomic_xchg_seqcst(p, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | intrinsics::atomic_xchg::<_, { SeqCst }>(p, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `atomic_cxchg_seqcst_seqcst` intrinsic: expected basic integer type, found `[u8; 100]` +error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer type, found `[u8; 100]` --> $DIR/non-integer-atomic.rs:90:5 | -LL | intrinsics::atomic_cxchg_seqcst_seqcst(p, v, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 16 previous errors diff --git a/tests/ui/issues/auxiliary/issue-11224.rs b/tests/ui/issues/auxiliary/issue-11224.rs index 63543621a80..94fb1f3abd5 100644 --- a/tests/ui/issues/auxiliary/issue-11224.rs +++ b/tests/ui/issues/auxiliary/issue-11224.rs @@ -11,6 +11,6 @@ mod inner { } pub fn foo() { - let a = &1isize as &inner::Trait; + let a = &1isize as &dyn inner::Trait; a.f(); } diff --git a/tests/ui/issues/auxiliary/issue-13507.rs b/tests/ui/issues/auxiliary/issue-13507.rs index c91013043eb..4160cf99f53 100644 --- a/tests/ui/issues/auxiliary/issue-13507.rs +++ b/tests/ui/issues/auxiliary/issue-13507.rs @@ -16,7 +16,7 @@ pub mod testtypes { TypeId::of::<FooFnPtr>(), TypeId::of::<FooNil>(), TypeId::of::<FooTuple>(), - TypeId::of::<FooTrait>(), + TypeId::of::<dyn FooTrait>(), TypeId::of::<FooStruct>(), TypeId::of::<FooEnum>() ] diff --git a/tests/ui/issues/auxiliary/issue-17662.rs b/tests/ui/issues/auxiliary/issue-17662.rs index 75efe110cdf..5ecec31deb0 100644 --- a/tests/ui/issues/auxiliary/issue-17662.rs +++ b/tests/ui/issues/auxiliary/issue-17662.rs @@ -4,9 +4,9 @@ pub trait Foo<'a, T> { fn foo(&'a self) -> T; } -pub fn foo<'a, T>(x: &'a Foo<'a, T>) -> T { - let x: &'a Foo<T> = x; - // ^ the lifetime parameter of Foo is left to be inferred. +pub fn foo<'a, T>(x: &'a dyn Foo<'a, T>) -> T { + let x: &'a dyn Foo<T> = x; + // ^ the lifetime parameter of Foo is left to be inferred. x.foo() // ^ encoding this method call in metadata triggers an ICE. } diff --git a/tests/ui/issues/auxiliary/issue-2380.rs b/tests/ui/issues/auxiliary/issue-2380.rs index 79fd62d1633..9ec829b417f 100644 --- a/tests/ui/issues/auxiliary/issue-2380.rs +++ b/tests/ui/issues/auxiliary/issue-2380.rs @@ -6,8 +6,8 @@ pub trait i<T> fn dummy(&self, t: T) -> T { panic!() } } -pub fn f<T>() -> Box<i<T>+'static> { +pub fn f<T>() -> Box<dyn i<T>+'static> { impl<T> i<T> for () { } - Box::new(()) as Box<i<T>+'static> + Box::new(()) as Box<dyn i<T>+'static> } diff --git a/tests/ui/issues/auxiliary/issue-25467.rs b/tests/ui/issues/auxiliary/issue-25467.rs index ca9b3097c83..16c2869dc75 100644 --- a/tests/ui/issues/auxiliary/issue-25467.rs +++ b/tests/ui/issues/auxiliary/issue-25467.rs @@ -7,4 +7,4 @@ pub trait Trait { type Issue25467BarT; } -pub type Object = Option<Box<Trait<Issue25467FooT=(),Issue25467BarT=()>>>; +pub type Object = Option<Box<dyn Trait<Issue25467FooT=(),Issue25467BarT=()>>>; diff --git a/tests/ui/issues/auxiliary/issue-34796-aux.rs b/tests/ui/issues/auxiliary/issue-34796-aux.rs index 09c69b90329..0e91bb4bcdc 100644 --- a/tests/ui/issues/auxiliary/issue-34796-aux.rs +++ b/tests/ui/issues/auxiliary/issue-34796-aux.rs @@ -9,7 +9,7 @@ impl Future for u32 { type Error = Box<()>; } -fn foo() -> Box<Future<Item=(), Error=Box<()>>> { +fn foo() -> Box<dyn Future<Item=(), Error=Box<()>>> { Box::new(0u32) } diff --git a/tests/ui/issues/auxiliary/issue-38226-aux.rs b/tests/ui/issues/auxiliary/issue-38226-aux.rs index f968017199f..a8e964e016f 100644 --- a/tests/ui/issues/auxiliary/issue-38226-aux.rs +++ b/tests/ui/issues/auxiliary/issue-38226-aux.rs @@ -2,7 +2,7 @@ #[inline(never)] pub fn foo<T>() { - let _: Box<SomeTrait> = Box::new(SomeTraitImpl); + let _: Box<dyn SomeTrait> = Box::new(SomeTraitImpl); } pub fn bar() { diff --git a/tests/ui/issues/auxiliary/issue-8401.rs b/tests/ui/issues/auxiliary/issue-8401.rs index e35dbbfabfc..7d0eb5cd876 100644 --- a/tests/ui/issues/auxiliary/issue-8401.rs +++ b/tests/ui/issues/auxiliary/issue-8401.rs @@ -8,9 +8,9 @@ trait A { struct B; impl A for B {} -fn bar<T>(_: &mut A, _: &T) {} +fn bar<T>(_: &mut dyn A, _: &T) {} fn foo<T>(t: &T) { let mut b = B; - bar(&mut b as &mut A, t) + bar(&mut b as &mut dyn A, t) } diff --git a/tests/ui/issues/issue-10806.rs b/tests/ui/issues/issue-10806.rs index 72d99ae3a79..31315dc7c93 100644 --- a/tests/ui/issues/issue-10806.rs +++ b/tests/ui/issues/issue-10806.rs @@ -1,3 +1,4 @@ +//@ edition: 2015 //@ run-pass #![allow(unused_imports)] diff --git a/tests/ui/issues/issue-12729.rs b/tests/ui/issues/issue-12729.rs index 74014981df5..4d45846bc60 100644 --- a/tests/ui/issues/issue-12729.rs +++ b/tests/ui/issues/issue-12729.rs @@ -1,3 +1,4 @@ +//@ edition: 2015 //@ check-pass #![allow(dead_code)] diff --git a/tests/ui/issues/issue-13105.rs b/tests/ui/issues/issue-13105.rs index 0dd78372a26..d119aa9c788 100644 --- a/tests/ui/issues/issue-13105.rs +++ b/tests/ui/issues/issue-13105.rs @@ -1,3 +1,4 @@ +//@ edition: 2015 //@ check-pass trait Foo { diff --git a/tests/ui/issues/issue-13775.rs b/tests/ui/issues/issue-13775.rs index 500ec6782a8..1477dab9e21 100644 --- a/tests/ui/issues/issue-13775.rs +++ b/tests/ui/issues/issue-13775.rs @@ -1,3 +1,4 @@ +//@ edition: 2015 //@ check-pass trait Foo { diff --git a/tests/ui/issues/issue-15774.rs b/tests/ui/issues/issue-15774.rs index 8eb327a0d5e..dadd59cc077 100644 --- a/tests/ui/issues/issue-15774.rs +++ b/tests/ui/issues/issue-15774.rs @@ -1,3 +1,4 @@ +//@ edition: 2015 //@ run-pass #![deny(warnings)] diff --git a/tests/ui/issues/issue-16048.stderr b/tests/ui/issues/issue-16048.stderr index 73610942d7a..f97f13152bc 100644 --- a/tests/ui/issues/issue-16048.stderr +++ b/tests/ui/issues/issue-16048.stderr @@ -11,9 +11,13 @@ error[E0605]: non-primitive cast: `Foo<'a>` as `T` --> $DIR/issue-16048.rs:24:16 | LL | return *self as T; - | ^^^^^^^^^^ help: consider using the `From` trait instead: `T::from(*self)` + | ^^^^^^^^^^ 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 - return *self as T; +LL + return T::from(*self); | - = note: an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object error: aborting due to 2 previous errors diff --git a/tests/ui/issues/issue-17441.stderr b/tests/ui/issues/issue-17441.stderr index 29e50b91c7c..96aad879e24 100644 --- a/tests/ui/issues/issue-17441.stderr +++ b/tests/ui/issues/issue-17441.stderr @@ -2,17 +2,23 @@ error[E0620]: cast to unsized type: `&[usize; 2]` as `[usize]` --> $DIR/issue-17441.rs:2:16 | LL | let _foo = &[1_usize, 2] as [usize]; - | ^^^^^^^^^^^^^^^^^------- - | | - | help: try casting to a reference instead: `&[usize]` + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: consider casting to a reference instead + | +LL | let _foo = &[1_usize, 2] as &[usize]; + | + error[E0620]: cast to unsized type: `Box<usize>` as `dyn Debug` --> $DIR/issue-17441.rs:5:16 | LL | let _bar = Box::new(1_usize) as dyn std::fmt::Debug; - | ^^^^^^^^^^^^^^^^^^^^^------------------- - | | - | help: you can cast to a `Box` instead: `Box<dyn std::fmt::Debug>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: you can cast to a `Box` instead + | +LL | let _bar = Box::new(1_usize) as Box<dyn std::fmt::Debug>; + | ++++ + error[E0620]: cast to unsized type: `usize` as `dyn Debug` --> $DIR/issue-17441.rs:8:16 diff --git a/tests/ui/issues/issue-18959.rs b/tests/ui/issues/issue-18959.rs index 6aeb34879ea..415fe818f53 100644 --- a/tests/ui/issues/issue-18959.rs +++ b/tests/ui/issues/issue-18959.rs @@ -11,13 +11,12 @@ impl Foo for Thing { fn foo(b: &dyn Bar) { //~^ ERROR E0038 b.foo(&0) - //~^ ERROR E0038 } fn main() { let mut thing = Thing; let test: &dyn Bar = &mut thing; //~^ ERROR E0038 - //~| ERROR E0038 foo(test); + //~^ ERROR E0038 } diff --git a/tests/ui/issues/issue-18959.stderr b/tests/ui/issues/issue-18959.stderr index 1e050b115e5..df47d50a019 100644 --- a/tests/ui/issues/issue-18959.stderr +++ b/tests/ui/issues/issue-18959.stderr @@ -15,26 +15,10 @@ LL | pub trait Bar: Foo { } = help: consider moving `foo` to another trait error[E0038]: the trait `Bar` is not dyn compatible - --> $DIR/issue-18959.rs:13:5 - | -LL | b.foo(&0) - | ^^^^^^^^^ `Bar` 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/issue-18959.rs:1:20 - | -LL | pub trait Foo { fn foo<T>(&self, ext_thing: &T); } - | ^^^ ...because method `foo` has generic type parameters -LL | pub trait Bar: Foo { } - | --- this trait is not dyn compatible... - = help: consider moving `foo` to another trait - -error[E0038]: the trait `Bar` is not dyn compatible - --> $DIR/issue-18959.rs:19:26 + --> $DIR/issue-18959.rs:18:20 | LL | let test: &dyn Bar = &mut thing; - | ^^^^^^^^^^ `Bar` is not dyn compatible + | ^^^ `Bar` 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> @@ -45,13 +29,12 @@ LL | pub trait Foo { fn foo<T>(&self, ext_thing: &T); } LL | pub trait Bar: Foo { } | --- this trait is not dyn compatible... = help: consider moving `foo` to another trait - = note: required for the cast from `&mut Thing` to `&dyn Bar` error[E0038]: the trait `Bar` is not dyn compatible - --> $DIR/issue-18959.rs:19:15 + --> $DIR/issue-18959.rs:20:9 | -LL | let test: &dyn Bar = &mut thing; - | ^^^^^^^^ `Bar` is not dyn compatible +LL | foo(test); + | ^^^^ `Bar` 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> @@ -63,6 +46,6 @@ LL | pub trait Bar: Foo { } | --- this trait is not dyn compatible... = help: consider moving `foo` to another trait -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/issues/issue-19380.rs b/tests/ui/issues/issue-19380.rs index 8b3fe4d2b09..fce737cba18 100644 --- a/tests/ui/issues/issue-19380.rs +++ b/tests/ui/issues/issue-19380.rs @@ -15,6 +15,5 @@ struct Bar { const FOO : Foo = Foo; const BAR : Bar = Bar { foos: &[&FOO]}; //~^ ERROR E0038 -//~| ERROR E0038 fn main() { } diff --git a/tests/ui/issues/issue-19380.stderr b/tests/ui/issues/issue-19380.stderr index f8509891d3a..4c41d41ae37 100644 --- a/tests/ui/issues/issue-19380.stderr +++ b/tests/ui/issues/issue-19380.stderr @@ -23,31 +23,6 @@ LL | fn qiz() where Self: Sized; | +++++++++++++++++ error[E0038]: the trait `Qiz` is not dyn compatible - --> $DIR/issue-19380.rs:16:33 - | -LL | const BAR : Bar = Bar { foos: &[&FOO]}; - | ^^^^ `Qiz` 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/issue-19380.rs:2:6 - | -LL | trait Qiz { - | --- this trait is not dyn compatible... -LL | fn qiz(); - | ^^^ ...because associated function `qiz` has no `self` parameter - = help: only type `Foo` implements `Qiz`; consider using it directly instead. - = note: required for the cast from `&Foo` to `&'static (dyn Qiz + 'static)` -help: consider turning `qiz` into a method by giving it a `&self` argument - | -LL | fn qiz(&self); - | +++++ -help: alternatively, consider constraining `qiz` so it does not apply to trait objects - | -LL | fn qiz() where Self: Sized; - | +++++++++++++++++ - -error[E0038]: the trait `Qiz` is not dyn compatible --> $DIR/issue-19380.rs:16:31 | LL | const BAR : Bar = Bar { foos: &[&FOO]}; @@ -71,6 +46,6 @@ help: alternatively, consider constraining `qiz` so it does not apply to trait o LL | fn qiz() where Self: Sized; | +++++++++++++++++ -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/issues/issue-20427.rs b/tests/ui/issues/issue-20427.rs index ff84023ebf2..4018043c371 100644 --- a/tests/ui/issues/issue-20427.rs +++ b/tests/ui/issues/issue-20427.rs @@ -59,7 +59,7 @@ mod reuse { pub fn check<u16>() { assert_eq!(size_of::<u8>(), 8); - assert_eq!(size_of::<::u64>(), 0); + assert_eq!(size_of::<crate::u64>(), 0); assert_eq!(size_of::<i16>(), 3 * size_of::<*const ()>()); assert_eq!(size_of::<u16>(), 0); } diff --git a/tests/ui/issues/issue-2502.rs b/tests/ui/issues/issue-2502.rs index dfc0995104e..98a52a3b5a7 100644 --- a/tests/ui/issues/issue-2502.rs +++ b/tests/ui/issues/issue-2502.rs @@ -14,7 +14,7 @@ impl<'a> font<'a> { } } -fn font(fontbuf: &Vec<u8> ) -> font { +fn font(fontbuf: &Vec<u8> ) -> font<'_> { font { fontbuf: fontbuf } diff --git a/tests/ui/issues/issue-28983.rs b/tests/ui/issues/issue-28983.rs index 5273dab16c1..90a4793787d 100644 --- a/tests/ui/issues/issue-28983.rs +++ b/tests/ui/issues/issue-28983.rs @@ -7,7 +7,7 @@ impl Test for u32 { pub mod export { #[no_mangle] - pub extern "C" fn issue_28983(t: <u32 as ::Test>::T) -> i32 { t*3 } + pub extern "C" fn issue_28983(t: <u32 as crate::Test>::T) -> i32 { t*3 } } // to test both exporting and importing functions, import diff --git a/tests/ui/issues/issue-30123.stderr b/tests/ui/issues/issue-30123.stderr index c086b45ac9b..3ed1f34c44a 100644 --- a/tests/ui/issues/issue-30123.stderr +++ b/tests/ui/issues/issue-30123.stderr @@ -2,7 +2,7 @@ error[E0599]: no function or associated item named `new_undirected` found for st --> $DIR/issue-30123.rs:7:33 | LL | let ug = Graph::<i32, i32>::new_undirected(); - | ^^^^^^^^^^^^^^ function or associated item not found in `Graph<i32, i32>` + | ^^^^^^^^^^^^^^ function or associated item not found in `issue_30123_aux::Graph<i32, i32>` | note: if you're trying to build a new `issue_30123_aux::Graph<i32, i32>`, consider using `issue_30123_aux::Graph::<N, E>::new` which returns `issue_30123_aux::Graph<_, _>` --> $DIR/auxiliary/issue-30123-aux.rs:14:5 diff --git a/tests/ui/issues/issue-31776.rs b/tests/ui/issues/issue-31776.rs index 4b342a0e3b2..abe6c7ecee5 100644 --- a/tests/ui/issues/issue-31776.rs +++ b/tests/ui/issues/issue-31776.rs @@ -8,7 +8,7 @@ struct S; mod m { fn f() { - impl ::S { + impl crate::S { pub fn s(&self) {} } } @@ -24,7 +24,7 @@ pub struct S1; fn f() { pub struct Z; - impl ::Tr for ::S1 { + impl crate::Tr for crate::S1 { type A = Z; // Private-in-public error unless `struct Z` is pub } } @@ -43,7 +43,7 @@ mod m1 { pub field: u8 } - impl ::Tr1 for ::S2 { + impl crate::Tr1 for crate::S2 { type A = Z; fn pull(&self) -> Self::A { Z{field: 10} } } diff --git a/tests/ui/issues/issue-32797.rs b/tests/ui/issues/issue-32797.rs index 6711a8f9fe5..470d661cb28 100644 --- a/tests/ui/issues/issue-32797.rs +++ b/tests/ui/issues/issue-32797.rs @@ -7,7 +7,7 @@ mod bar { pub use baz::*; mod baz { - pub use main as f; + pub use crate::main as f; } pub fn main() {} diff --git a/tests/ui/issues/issue-34074.rs b/tests/ui/issues/issue-34074.rs index 9b3dee11d9b..d642c74d412 100644 --- a/tests/ui/issues/issue-34074.rs +++ b/tests/ui/issues/issue-34074.rs @@ -1,3 +1,4 @@ +//@ edition: 2015 //@ check-pass // Make sure several unnamed function parameters don't conflict with each other diff --git a/tests/ui/issues/issue-34373.rs b/tests/ui/issues/issue-34373.rs index 707aa8cf338..5b05811a4eb 100644 --- a/tests/ui/issues/issue-34373.rs +++ b/tests/ui/issues/issue-34373.rs @@ -4,7 +4,7 @@ trait Trait<T> { fn foo(_: T) {} } -pub struct Foo<T = Box<Trait<DefaultFoo>>>; //~ ERROR cycle detected +pub struct Foo<T = Box<dyn Trait<DefaultFoo>>>; //~ ERROR cycle detected //~^ ERROR `T` is never used type DefaultFoo = Foo; diff --git a/tests/ui/issues/issue-34373.stderr b/tests/ui/issues/issue-34373.stderr index 06365558217..03d77193134 100644 --- a/tests/ui/issues/issue-34373.stderr +++ b/tests/ui/issues/issue-34373.stderr @@ -1,8 +1,8 @@ error[E0391]: cycle detected when computing type of `Foo::T` - --> $DIR/issue-34373.rs:7:30 + --> $DIR/issue-34373.rs:7:34 | -LL | pub struct Foo<T = Box<Trait<DefaultFoo>>>; - | ^^^^^^^^^^ +LL | pub struct Foo<T = Box<dyn Trait<DefaultFoo>>>; + | ^^^^^^^^^^ | note: ...which requires expanding type alias `DefaultFoo`... --> $DIR/issue-34373.rs:9:19 @@ -13,15 +13,15 @@ LL | type DefaultFoo = Foo; note: cycle used when checking that `Foo` is well-formed --> $DIR/issue-34373.rs:7:1 | -LL | pub struct Foo<T = Box<Trait<DefaultFoo>>>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | pub struct Foo<T = Box<dyn Trait<DefaultFoo>>>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = 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[E0392]: type parameter `T` is never used --> $DIR/issue-34373.rs:7:16 | -LL | pub struct Foo<T = Box<Trait<DefaultFoo>>>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unused type parameter +LL | pub struct Foo<T = Box<dyn Trait<DefaultFoo>>>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused type parameter | = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` = help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead diff --git a/tests/ui/issues/issue-41053.rs b/tests/ui/issues/issue-41053.rs index 18f9e209c33..42b0b008ce9 100644 --- a/tests/ui/issues/issue-41053.rs +++ b/tests/ui/issues/issue-41053.rs @@ -11,7 +11,7 @@ impl Iterator for Foo { type Item = Box<dyn Trait>; fn next(&mut self) -> Option<Box<dyn Trait>> { extern crate issue_41053; - impl ::Trait for issue_41053::Test { + impl crate::Trait for issue_41053::Test { fn foo(&self) {} } Some(Box::new(issue_41053::Test)) diff --git a/tests/ui/issues/issue-41880.stderr b/tests/ui/issues/issue-41880.stderr index 9d09be66305..1936c0aebd4 100644 --- a/tests/ui/issues/issue-41880.stderr +++ b/tests/ui/issues/issue-41880.stderr @@ -5,7 +5,7 @@ LL | pub struct Iterate<T, F> { | ------------------------ method `iter` not found for this struct ... LL | println!("{:?}", a.iter().take(10).collect::<Vec<usize>>()); - | ^^^^ method not found in `Iterate<{integer}, {closure@issue-41880.rs:26:24}>` + | ^^^^ method not found in `Iterate<{integer}, {closure@$DIR/issue-41880.rs:26:24: 26:27}>` error: aborting due to 1 previous error diff --git a/tests/ui/issues/issue-42552.rs b/tests/ui/issues/issue-42552.rs index 998cde44be0..734921d9b01 100644 --- a/tests/ui/issues/issue-42552.rs +++ b/tests/ui/issues/issue-42552.rs @@ -1,7 +1,7 @@ //@ run-pass // Regression test for an obscure issue with the projection cache. -fn into_iter<I: Iterator>(a: &I) -> Groups<I> { +fn into_iter<I: Iterator>(a: &I) -> Groups<'_, I> { Groups { _a: a } } diff --git a/tests/ui/issues/issue-47364.rs b/tests/ui/issues/issue-47364.rs index b657b3d3bde..79cd5ed92a8 100644 --- a/tests/ui/issues/issue-47364.rs +++ b/tests/ui/issues/issue-47364.rs @@ -18,18 +18,18 @@ pub enum IResult<I,O> { Incomplete(u32, u64) } -pub fn multispace<T: Copy>(input: T) -> ::IResult<i8, i8> { - ::IResult::Done(0, 0) +pub fn multispace<T: Copy>(input: T) -> crate::IResult<i8, i8> { + crate::IResult::Done(0, 0) } mod nom_sql { - fn where_clause(i: &[u8]) -> ::IResult<&[u8], Option<String>> { - let X = match ::multispace(i) { - ::IResult::Done(..) => ::IResult::Done(i, None::<String>), - _ => ::IResult::Error(::Err::NodePosition(0)), + fn where_clause(i: &[u8]) -> crate::IResult<&[u8], Option<String>> { + let X = match crate::multispace(i) { + crate::IResult::Done(..) => crate::IResult::Done(i, None::<String>), + _ => crate::IResult::Error(crate::Err::NodePosition(0)), }; match X { - ::IResult::Done(_, _) => ::IResult::Done(i, None), + crate::IResult::Done(_, _) => crate::IResult::Done(i, None), _ => X } } @@ -39,16 +39,16 @@ mod nom_sql { match { where_clause(i) } { - ::IResult::Done(_, o) => ::IResult::Done(i, Some(o)), - ::IResult::Error(_) => ::IResult::Done(i, None), - _ => ::IResult::Incomplete(0, 0), + crate::IResult::Done(_, o) => crate::IResult::Done(i, Some(o)), + crate::IResult::Error(_) => crate::IResult::Done(i, None), + _ => crate::IResult::Incomplete(0, 0), } } { - ::IResult::Done(z, _) => ::IResult::Done(z, None::<String>), + crate::IResult::Done(z, _) => crate::IResult::Done(z, None::<String>), _ => return () }; match Y { - ::IResult::Done(x, _) => { + crate::IResult::Done(x, _) => { let bytes = b"; "; let len = x.len(); bytes[len]; diff --git a/tests/ui/issues/issue-50187.rs b/tests/ui/issues/issue-50187.rs index 7304903b954..478416f86dc 100644 --- a/tests/ui/issues/issue-50187.rs +++ b/tests/ui/issues/issue-50187.rs @@ -13,20 +13,20 @@ mod macro_ns { } mod merge2 { - pub use type_ns::A; - pub use value_ns::A; + pub use crate::type_ns::A; + pub use crate::value_ns::A; } mod merge3 { - pub use type_ns::A; - pub use value_ns::A; - pub use macro_ns::A; + pub use crate::type_ns::A; + pub use crate::value_ns::A; + pub use crate::macro_ns::A; } mod use2 { - pub use merge2::A; + pub use crate::merge2::A; } mod use3 { - pub use merge3::A; + pub use crate::merge3::A; } fn main() { diff --git a/tests/ui/issues/issue-50571.fixed b/tests/ui/issues/issue-50571.fixed index 37ed729be81..6d73f17cca4 100644 --- a/tests/ui/issues/issue-50571.fixed +++ b/tests/ui/issues/issue-50571.fixed @@ -1,3 +1,4 @@ +//@ edition: 2015 //@ run-rustfix #![allow(dead_code)] diff --git a/tests/ui/issues/issue-50571.rs b/tests/ui/issues/issue-50571.rs index 97a042d3ec1..dd840ffe4d1 100644 --- a/tests/ui/issues/issue-50571.rs +++ b/tests/ui/issues/issue-50571.rs @@ -1,3 +1,4 @@ +//@ edition: 2015 //@ run-rustfix #![allow(dead_code)] diff --git a/tests/ui/issues/issue-50571.stderr b/tests/ui/issues/issue-50571.stderr index 86709410670..9b00fe0f5db 100644 --- a/tests/ui/issues/issue-50571.stderr +++ b/tests/ui/issues/issue-50571.stderr @@ -1,5 +1,5 @@ error[E0642]: patterns aren't allowed in methods without bodies - --> $DIR/issue-50571.rs:5:12 + --> $DIR/issue-50571.rs:6:12 | LL | fn foo([a, b]: [i32; 2]) {} | ^^^^^^ diff --git a/tests/ui/issues/issue-50761.rs b/tests/ui/issues/issue-50761.rs index 6911bfa0265..8f5a32e0a00 100644 --- a/tests/ui/issues/issue-50761.rs +++ b/tests/ui/issues/issue-50761.rs @@ -14,7 +14,7 @@ mod b { } impl Builder { - pub fn with_a(&mut self, _a: fn() -> dyn (::a::A)) {} + pub fn with_a(&mut self, _a: fn() -> dyn (crate::a::A)) {} } } diff --git a/tests/ui/issues/issue-50781.rs b/tests/ui/issues/issue-50781.rs index ab90db1cadc..d837b848591 100644 --- a/tests/ui/issues/issue-50781.rs +++ b/tests/ui/issues/issue-50781.rs @@ -15,5 +15,4 @@ pub fn main() { // Check that this does not segfault. <dyn X as X>::foo(&()); //~^ ERROR the trait `X` is not dyn compatible - //~| ERROR the trait `X` is not dyn compatible } diff --git a/tests/ui/issues/issue-50781.stderr b/tests/ui/issues/issue-50781.stderr index 88b83a83e0c..4ba3166b6c5 100644 --- a/tests/ui/issues/issue-50781.stderr +++ b/tests/ui/issues/issue-50781.stderr @@ -16,10 +16,10 @@ LL | fn foo(&self) where Self: Trait; = help: only type `()` implements `X`; consider using it directly instead. error[E0038]: the trait `X` is not dyn compatible - --> $DIR/issue-50781.rs:16:23 + --> $DIR/issue-50781.rs:16:10 | LL | <dyn X as X>::foo(&()); - | ^^^ `X` is not dyn compatible + | ^ `X` 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> @@ -31,25 +31,7 @@ LL | fn foo(&self) where Self: Trait; | ^^^ ...because method `foo` references the `Self` type in its `where` clause = help: consider moving `foo` to another trait = help: only type `()` implements `X`; consider using it directly instead. - = note: required for the cast from `&()` to `&dyn X` -error[E0038]: the trait `X` is not dyn compatible - --> $DIR/issue-50781.rs:16:6 - | -LL | <dyn X as X>::foo(&()); - | ^^^^^ `X` 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/issue-50781.rs:4:8 - | -LL | trait X { - | - this trait is not dyn compatible... -LL | fn foo(&self) where Self: Trait; - | ^^^ ...because method `foo` references the `Self` type in its `where` clause - = help: consider moving `foo` to another trait - = help: only type `()` implements `X`; consider using it directly instead. - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/issues/issue-5708.rs b/tests/ui/issues/issue-5708.rs index ce9ef78ffcd..6fa3cfa4724 100644 --- a/tests/ui/issues/issue-5708.rs +++ b/tests/ui/issues/issue-5708.rs @@ -25,7 +25,7 @@ struct Outer<'a> { } impl<'a> Outer<'a> { - fn new(inner: &dyn Inner) -> Outer { + fn new(inner: &dyn Inner) -> Outer<'_> { Outer { inner: inner } diff --git a/tests/ui/issues/issue-58734.rs b/tests/ui/issues/issue-58734.rs index ee23be87b6b..e5b371f5530 100644 --- a/tests/ui/issues/issue-58734.rs +++ b/tests/ui/issues/issue-58734.rs @@ -18,8 +18,7 @@ fn main() { Trait::exists(()); // no dyn-compatibility error Trait::nonexistent(()); - //~^ ERROR no function or associated item named `nonexistent` found - //~| WARN trait objects without an explicit `dyn` are deprecated + //~^ WARN trait objects without an explicit `dyn` are deprecated //~| WARN this is accepted in the current edition //~| ERROR the trait `Trait` is not dyn compatible } diff --git a/tests/ui/issues/issue-58734.stderr b/tests/ui/issues/issue-58734.stderr index c4624cecc62..e5dad000b51 100644 --- a/tests/ui/issues/issue-58734.stderr +++ b/tests/ui/issues/issue-58734.stderr @@ -37,13 +37,6 @@ help: alternatively, consider constraining `dyn_incompatible` so it does not app LL | fn dyn_incompatible() -> Self where Self: Sized; | +++++++++++++++++ -error[E0599]: no function or associated item named `nonexistent` found for trait object `dyn Trait` in the current scope - --> $DIR/issue-58734.rs:20:12 - | -LL | Trait::nonexistent(()); - | ^^^^^^^^^^^ function or associated item not found in `dyn Trait` - -error: aborting due to 2 previous errors; 1 warning emitted +error: aborting due to 1 previous error; 1 warning emitted -Some errors have detailed explanations: E0038, E0599. -For more information about an error, try `rustc --explain E0038`. +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/issues/issue-6936.rs b/tests/ui/issues/issue-6936.rs index 26531bba9ec..e9aa80b4eb3 100644 --- a/tests/ui/issues/issue-6936.rs +++ b/tests/ui/issues/issue-6936.rs @@ -1,22 +1,22 @@ struct T; mod t1 { - type Foo = ::T; + type Foo = crate::T; mod Foo {} //~ ERROR the name `Foo` is defined multiple times } mod t2 { - type Foo = ::T; + type Foo = crate::T; struct Foo; //~ ERROR the name `Foo` is defined multiple times } mod t3 { - type Foo = ::T; + type Foo = crate::T; enum Foo {} //~ ERROR the name `Foo` is defined multiple times } mod t4 { - type Foo = ::T; + type Foo = crate::T; fn Foo() {} // ok } @@ -26,7 +26,7 @@ mod t5 { } mod t6 { - type Foo = ::T; + type Foo = crate::T; impl Foo {} // ok } diff --git a/tests/ui/issues/issue-6936.stderr b/tests/ui/issues/issue-6936.stderr index 9292d60ca68..03cc50636b4 100644 --- a/tests/ui/issues/issue-6936.stderr +++ b/tests/ui/issues/issue-6936.stderr @@ -1,8 +1,8 @@ error[E0428]: the name `Foo` is defined multiple times --> $DIR/issue-6936.rs:5:5 | -LL | type Foo = ::T; - | --------------- previous definition of the type `Foo` here +LL | type Foo = crate::T; + | -------------------- previous definition of the type `Foo` here LL | mod Foo {} | ^^^^^^^ `Foo` redefined here | @@ -11,8 +11,8 @@ LL | mod Foo {} error[E0428]: the name `Foo` is defined multiple times --> $DIR/issue-6936.rs:10:5 | -LL | type Foo = ::T; - | --------------- previous definition of the type `Foo` here +LL | type Foo = crate::T; + | -------------------- previous definition of the type `Foo` here LL | struct Foo; | ^^^^^^^^^^^ `Foo` redefined here | @@ -21,8 +21,8 @@ LL | struct Foo; error[E0428]: the name `Foo` is defined multiple times --> $DIR/issue-6936.rs:15:5 | -LL | type Foo = ::T; - | --------------- previous definition of the type `Foo` here +LL | type Foo = crate::T; + | -------------------- previous definition of the type `Foo` here LL | enum Foo {} | ^^^^^^^^ `Foo` redefined here | diff --git a/tests/ui/issues/issue-76191.rs b/tests/ui/issues/issue-76191.rs index 277624c005a..d2de44380c3 100644 --- a/tests/ui/issues/issue-76191.rs +++ b/tests/ui/issues/issue-76191.rs @@ -6,7 +6,7 @@ use std::ops::RangeInclusive; const RANGE: RangeInclusive<i32> = 0..=255; const RANGE2: RangeInclusive<i32> = panic!(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR evaluation panicked: explicit panic fn main() { let n: i32 = 1; diff --git a/tests/ui/issues/issue-76191.stderr b/tests/ui/issues/issue-76191.stderr index ac1bdfaa847..d8b54be88f4 100644 --- a/tests/ui/issues/issue-76191.stderr +++ b/tests/ui/issues/issue-76191.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: explicit panic --> $DIR/issue-76191.rs:8:37 | LL | const RANGE2: RangeInclusive<i32> = panic!(); - | ^^^^^^^^ evaluation panicked: explicit panic + | ^^^^^^^^ evaluation of `RANGE2` failed here error[E0308]: mismatched types --> $DIR/issue-76191.rs:14:9 diff --git a/tests/ui/issues/issue-7663.rs b/tests/ui/issues/issue-7663.rs index ad52ea21127..d2b2c727cab 100644 --- a/tests/ui/issues/issue-7663.rs +++ b/tests/ui/issues/issue-7663.rs @@ -8,7 +8,7 @@ mod test1 { mod bar { pub fn p() -> isize { 2 } } pub mod baz { - use test1::bar::p; + use crate::test1::bar::p; pub fn my_main() { assert_eq!(p(), 2); } } @@ -20,7 +20,7 @@ mod test2 { mod bar { pub fn p() -> isize { 2 } } pub mod baz { - use test2::bar::p; + use crate::test2::bar::p; pub fn my_main() { assert_eq!(p(), 2); } } diff --git a/tests/ui/issues/issue-86756.rs b/tests/ui/issues/issue-86756.rs index 7f864eb2850..55a6c144839 100644 --- a/tests/ui/issues/issue-86756.rs +++ b/tests/ui/issues/issue-86756.rs @@ -1,3 +1,4 @@ +//@ edition: 2015 trait Foo<T, T = T> {} //~^ ERROR the name `T` is already used for a generic parameter in this item's generic parameters diff --git a/tests/ui/issues/issue-86756.stderr b/tests/ui/issues/issue-86756.stderr index 728d7ea7095..0f68b764850 100644 --- a/tests/ui/issues/issue-86756.stderr +++ b/tests/ui/issues/issue-86756.stderr @@ -1,5 +1,5 @@ error[E0403]: the name `T` is already used for a generic parameter in this item's generic parameters - --> $DIR/issue-86756.rs:1:14 + --> $DIR/issue-86756.rs:2:14 | LL | trait Foo<T, T = T> {} | - ^ already used @@ -7,13 +7,13 @@ LL | trait Foo<T, T = T> {} | first use of `T` error[E0412]: cannot find type `dyn` in this scope - --> $DIR/issue-86756.rs:5:10 + --> $DIR/issue-86756.rs:6:10 | LL | eq::<dyn, Foo> | ^^^ not found in this scope warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/issue-86756.rs:5:15 + --> $DIR/issue-86756.rs:6:15 | LL | eq::<dyn, Foo> | ^^^ @@ -27,13 +27,13 @@ LL | eq::<dyn, dyn Foo> | +++ error[E0107]: missing generics for trait `Foo` - --> $DIR/issue-86756.rs:5:15 + --> $DIR/issue-86756.rs:6:15 | LL | eq::<dyn, Foo> | ^^^ expected at least 1 generic argument | note: trait defined here, with at least 1 generic parameter: `T` - --> $DIR/issue-86756.rs:1:7 + --> $DIR/issue-86756.rs:2:7 | LL | trait Foo<T, T = T> {} | ^^^ - diff --git a/tests/ui/iterators/generator.rs b/tests/ui/iterators/generator.rs new file mode 100644 index 00000000000..e633efb11c1 --- /dev/null +++ b/tests/ui/iterators/generator.rs @@ -0,0 +1,24 @@ +//@ run-pass + +#![feature(iter_macro, yield_expr)] + +use std::iter::iter; + +fn main() { + let i = iter! { || { + yield 0; + for x in 5..10 { + yield x * 2; + } + } }; + let mut i = i(); + assert_eq!(i.next(), Some(0)); + assert_eq!(i.next(), Some(10)); + assert_eq!(i.next(), Some(12)); + assert_eq!(i.next(), Some(14)); + assert_eq!(i.next(), Some(16)); + assert_eq!(i.next(), Some(18)); + assert_eq!(i.next(), None); + assert_eq!(i.next(), None); + assert_eq!(i.next(), None); +} diff --git a/tests/ui/iterators/generator_args.rs b/tests/ui/iterators/generator_args.rs new file mode 100644 index 00000000000..c9da9e5fba6 --- /dev/null +++ b/tests/ui/iterators/generator_args.rs @@ -0,0 +1,24 @@ +//@ run-pass + +#![feature(iter_macro, yield_expr)] + +use std::iter::iter; + +fn main() { + let i = iter! {|foo| { + yield foo; + for x in 5..10 { + yield x * 2; + } + }}; + let mut i = i(3); + assert_eq!(i.next(), Some(3)); + assert_eq!(i.next(), Some(10)); + assert_eq!(i.next(), Some(12)); + assert_eq!(i.next(), Some(14)); + assert_eq!(i.next(), Some(16)); + assert_eq!(i.next(), Some(18)); + assert_eq!(i.next(), None); + assert_eq!(i.next(), None); + assert_eq!(i.next(), None); +} diff --git a/tests/ui/iterators/generator_capture.rs b/tests/ui/iterators/generator_capture.rs new file mode 100644 index 00000000000..c790b7a4b96 --- /dev/null +++ b/tests/ui/iterators/generator_capture.rs @@ -0,0 +1,27 @@ +//@ run-pass + +#![feature(iter_macro, yield_expr)] + +use std::iter::iter; + +fn main() { + let i = { + let s = String::new(); + iter! { move || { + yield s.len(); + for x in 5..10 { + yield x * 2; + } + }} + }; + let mut i = i(); + assert_eq!(i.next(), Some(0)); + assert_eq!(i.next(), Some(10)); + assert_eq!(i.next(), Some(12)); + assert_eq!(i.next(), Some(14)); + assert_eq!(i.next(), Some(16)); + assert_eq!(i.next(), Some(18)); + assert_eq!(i.next(), None); + assert_eq!(i.next(), None); + assert_eq!(i.next(), None); +} diff --git a/tests/ui/iterators/generator_capture_.rs b/tests/ui/iterators/generator_capture_.rs new file mode 100644 index 00000000000..f630bc64b97 --- /dev/null +++ b/tests/ui/iterators/generator_capture_.rs @@ -0,0 +1,26 @@ +// This test exercises lending behavior for iterator closures which is not yet supported. + +#![feature(iter_macro, yield_expr)] + +use std::iter::iter; + +fn main() { + let f = { + let s = "foo".to_string(); + iter! { move || { + for c in s.chars() { + yield c; + } + }} + }; + let mut i = f(); + assert_eq!(i.next(), Some('f')); + assert_eq!(i.next(), Some('o')); + assert_eq!(i.next(), Some('o')); + assert_eq!(i.next(), None); + let mut i = f(); //~ ERROR use of moved value: `f` + assert_eq!(i.next(), Some('f')); + assert_eq!(i.next(), Some('o')); + assert_eq!(i.next(), Some('o')); + assert_eq!(i.next(), None); +} diff --git a/tests/ui/iterators/generator_capture_.stderr b/tests/ui/iterators/generator_capture_.stderr new file mode 100644 index 00000000000..3d9647ae16f --- /dev/null +++ b/tests/ui/iterators/generator_capture_.stderr @@ -0,0 +1,25 @@ +error[E0382]: use of moved value: `f` + --> $DIR/generator_capture_.rs:21:17 + | +LL | let f = { + | - move occurs because `f` has type `{gen closure@$DIR/generator_capture_.rs:10:17: 10:24}`, which does not implement the `Copy` trait +... +LL | let mut i = f(); + | --- `f` moved due to this call +... +LL | let mut i = f(); + | ^ value used here after move + | +note: this value implements `FnOnce`, which causes it to be moved when called + --> $DIR/generator_capture_.rs:16:17 + | +LL | let mut i = f(); + | ^ +help: consider cloning the value if the performance cost is acceptable + | +LL | let mut i = f.clone()(); + | ++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/tests/ui/iterators/generator_capture_fail.rs b/tests/ui/iterators/generator_capture_fail.rs new file mode 100644 index 00000000000..d987b2df011 --- /dev/null +++ b/tests/ui/iterators/generator_capture_fail.rs @@ -0,0 +1,25 @@ +#![feature(iter_macro, yield_expr)] + +use std::iter::iter; + +fn main() { + let i = { + let s = String::new(); + iter! { || { //~ ERROR `s` does not live long enough + yield s.len(); + for x in 5..10 { + yield x * 2; + } + } } + }; + let mut i = i(); + assert_eq!(i.next(), Some(0)); + assert_eq!(i.next(), Some(10)); + assert_eq!(i.next(), Some(12)); + assert_eq!(i.next(), Some(14)); + assert_eq!(i.next(), Some(16)); + assert_eq!(i.next(), Some(18)); + assert_eq!(i.next(), None); + assert_eq!(i.next(), None); + assert_eq!(i.next(), None); +} diff --git a/tests/ui/iterators/generator_capture_fail.stderr b/tests/ui/iterators/generator_capture_fail.stderr new file mode 100644 index 00000000000..225a385d6a0 --- /dev/null +++ b/tests/ui/iterators/generator_capture_fail.stderr @@ -0,0 +1,20 @@ +error[E0597]: `s` does not live long enough + --> $DIR/generator_capture_fail.rs:8:17 + | +LL | let i = { + | - borrow later stored here +LL | let s = String::new(); +LL | iter! { || { + | _________________^ +LL | | yield s.len(); +LL | | for x in 5..10 { +LL | | yield x * 2; +LL | | } +LL | | } } + | |_________^ borrowed value does not live long enough +LL | }; + | - `s` dropped here while still borrowed + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/tests/ui/iterators/generator_capture_fnonce.rs b/tests/ui/iterators/generator_capture_fnonce.rs new file mode 100644 index 00000000000..090727eb9b7 --- /dev/null +++ b/tests/ui/iterators/generator_capture_fnonce.rs @@ -0,0 +1,32 @@ +//@ run-pass + +#![feature(iter_macro, yield_expr)] + +use std::iter::iter; + +fn main() { + let i = { + let s = String::new(); + iter! { move || { + yield s.len(); + for x in 5..10 { + yield x * 2; + } + }} + }; + test_iterator(i); +} + +/// Exercise the iterator in a separate function to ensure it's not capturing anything it shoudln't. +fn test_iterator<I: Iterator<Item = usize>>(i: impl FnOnce() -> I) { + let mut i = i(); + assert_eq!(i.next(), Some(0)); + assert_eq!(i.next(), Some(10)); + assert_eq!(i.next(), Some(12)); + assert_eq!(i.next(), Some(14)); + assert_eq!(i.next(), Some(16)); + assert_eq!(i.next(), Some(18)); + assert_eq!(i.next(), None); + assert_eq!(i.next(), None); + assert_eq!(i.next(), None); +} diff --git a/tests/ui/iterators/generator_capture_no_lend.rs b/tests/ui/iterators/generator_capture_no_lend.rs new file mode 100644 index 00000000000..822db58d48d --- /dev/null +++ b/tests/ui/iterators/generator_capture_no_lend.rs @@ -0,0 +1,30 @@ +//@ run-pass + +#![feature(iter_macro, yield_expr)] + +// This test creates an iterator that captures a reference and ensure that doesn't force the +// iterator to become lending. + +use std::iter::iter; + +fn main() { + let s = "foo".to_string(); + let f = iter! { || { + for c in s.chars() { + yield c; + } + }}; + + let mut i = f(); + let mut j = f(); + + assert_eq!(i.next(), Some('f')); + assert_eq!(i.next(), Some('o')); + assert_eq!(i.next(), Some('o')); + assert_eq!(i.next(), None); + + assert_eq!(j.next(), Some('f')); + assert_eq!(j.next(), Some('o')); + assert_eq!(j.next(), Some('o')); + assert_eq!(j.next(), None); +} diff --git a/tests/ui/iterators/generator_returned_from_fn.rs b/tests/ui/iterators/generator_returned_from_fn.rs new file mode 100644 index 00000000000..bd0317b1ffb --- /dev/null +++ b/tests/ui/iterators/generator_returned_from_fn.rs @@ -0,0 +1,63 @@ +#![feature(iter_macro, impl_trait_in_fn_trait_return, yield_expr)] + +use std::iter::iter; + +fn plain() -> impl Fn() -> impl Iterator<Item = u32> { + iter! { || { + yield 0; + for x in 5..10 { + yield x * 2; + } + } } +} + +fn arg() -> impl Fn(u32) -> impl Iterator<Item = u32> { + iter! { |arg| { + yield arg; + for x in 5..10 { + yield x * 2; + } + } } +} + +fn capture<'a>(a: &'a u32) -> impl Fn() -> (impl Iterator<Item = u32> + 'a) { + iter! { || { //~ ERROR cannot return reference to function parameter `a` + yield *a; + for x in 5..10 { + yield x * 2; + } + } } +} + +fn capture_move(a: &u32) -> impl Fn() -> impl Iterator<Item = u32> { + iter! { move || { //~ ERROR does not implement `Fn` because it captures + yield *a; + for x in 5..10 { + yield x * 2; + } + } } +} + +fn capture_move_once(a: &u32) -> impl FnOnce() -> impl Iterator<Item = u32> { + iter! { move || { + //~^ ERROR captures lifetime + //~| ERROR: captures lifetime + yield *a; + for x in 5..10 { + yield x * 2; + } + } } +} + +fn capture_move_once_lifetimes<'a>( + a: &'a u32, +) -> impl FnOnce() -> (impl Iterator<Item = u32> + 'a) { + iter! { move || { + yield *a; + for x in 5..10 { + yield x * 2; + } + } } +} + +fn main() {} diff --git a/tests/ui/iterators/generator_returned_from_fn.stderr b/tests/ui/iterators/generator_returned_from_fn.stderr new file mode 100644 index 00000000000..b2324af6d5e --- /dev/null +++ b/tests/ui/iterators/generator_returned_from_fn.stderr @@ -0,0 +1,70 @@ +error[E0515]: cannot return reference to function parameter `a` + --> $DIR/generator_returned_from_fn.rs:24:13 + | +LL | iter! { || { + | _____________^ +LL | | yield *a; +LL | | for x in 5..10 { +LL | | yield x * 2; +LL | | } +LL | | } } + | |_____^ returns a reference to data owned by the current function + +error: gen closure does not implement `Fn` because it captures state from its environment + --> $DIR/generator_returned_from_fn.rs:33:13 + | +LL | iter! { move || { + | _____________-^^^^^^ +LL | | yield *a; +LL | | for x in 5..10 { +LL | | yield x * 2; +LL | | } +LL | | } } + | |_____- return type was inferred to be `{gen closure@$DIR/generator_returned_from_fn.rs:33:13: 33:20}` here + +error[E0700]: hidden type for `impl FnOnce() -> impl Iterator<Item = u32>` captures lifetime that does not appear in bounds + --> $DIR/generator_returned_from_fn.rs:42:13 + | +LL | fn capture_move_once(a: &u32) -> impl FnOnce() -> impl Iterator<Item = u32> { + | ---- ------------------------------------------ opaque type defined here + | | + | hidden type `{gen closure@$DIR/generator_returned_from_fn.rs:42:13: 42:20}` captures the anonymous lifetime defined here +LL | iter! { move || { + | _____________^ +LL | | +LL | | +LL | | yield *a; +... | +LL | | } } + | |_____^ + | +help: add a `use<...>` bound to explicitly capture `'_` + | +LL | fn capture_move_once(a: &u32) -> impl FnOnce() -> impl Iterator<Item = u32> + use<'_> { + | +++++++++ + +error[E0700]: hidden type for `impl Iterator<Item = u32>` captures lifetime that does not appear in bounds + --> $DIR/generator_returned_from_fn.rs:42:13 + | +LL | fn capture_move_once(a: &u32) -> impl FnOnce() -> impl Iterator<Item = u32> { + | ---- ------------------------- opaque type defined here + | | + | hidden type `{gen closure body@$DIR/generator_returned_from_fn.rs:42:21: 49:6}` captures the anonymous lifetime defined here +LL | iter! { move || { + | _____________^ +LL | | +LL | | +LL | | yield *a; +... | +LL | | } } + | |_____^ + | +help: add a `use<...>` bound to explicitly capture `'_` + | +LL | fn capture_move_once(a: &u32) -> impl FnOnce() -> impl Iterator<Item = u32> + use<'_> { + | +++++++++ + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0515, E0700. +For more information about an error, try `rustc --explain E0515`. diff --git a/tests/ui/iterators/iter-macro-not-async-closure-simplified.narrow.stderr b/tests/ui/iterators/iter-macro-not-async-closure-simplified.narrow.stderr new file mode 100644 index 00000000000..4e0dabade2d --- /dev/null +++ b/tests/ui/iterators/iter-macro-not-async-closure-simplified.narrow.stderr @@ -0,0 +1,18 @@ +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:21:21: 21:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure-simplified.rs:27:21 + | +LL | call_async_once(f); + | --------------- ^ unsatisfied trait bound + | | + | required by a bound introduced by this call + | + = help: the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:21:21: 21:28}` +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure-simplified.rs:18:28 + | +LL | ...pl AsyncFnOnce()) {} + | ^^^^^^^^^^^^^ required by this bound in `call_async_once` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/iterators/iter-macro-not-async-closure-simplified.rs b/tests/ui/iterators/iter-macro-not-async-closure-simplified.rs new file mode 100644 index 00000000000..4fa14fda661 --- /dev/null +++ b/tests/ui/iterators/iter-macro-not-async-closure-simplified.rs @@ -0,0 +1,29 @@ +// This test ensures iterators created with the `iter!` macro are not +// accidentally async closures. +// +// We test this both in a `narrow` and `wide` configuration because +// the way that the diagnostic is emitted varies depending on the +// diagnostic width. If it's too narrow to fit the explanation, that +// explanation is moved to the `help` instead of the span label. +// +//@ edition: 2024 +//@ revisions: narrow wide +//@[narrow] compile-flags: --diagnostic-width=20 +//@[wide] compile-flags: --diagnostic-width=300 + +#![feature(yield_expr, iter_macro)] + +use std::iter::iter; + +fn call_async_once(_: impl AsyncFnOnce()) {} + +fn main() { + let f = iter! { move || { + for i in 0..10 { + yield i; + } + }}; + + call_async_once(f); + //~^ ERROR AsyncFnOnce()` is not satisfied +} diff --git a/tests/ui/iterators/iter-macro-not-async-closure-simplified.wide.stderr b/tests/ui/iterators/iter-macro-not-async-closure-simplified.wide.stderr new file mode 100644 index 00000000000..a6c239c181b --- /dev/null +++ b/tests/ui/iterators/iter-macro-not-async-closure-simplified.wide.stderr @@ -0,0 +1,17 @@ +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:21:21: 21:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure-simplified.rs:27:21 + | +LL | call_async_once(f); + | --------------- ^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure-simplified.rs:21:21: 21:28}` + | | + | required by a bound introduced by this call + | +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure-simplified.rs:18:28 + | +LL | fn call_async_once(_: impl AsyncFnOnce()) {} + | ^^^^^^^^^^^^^ required by this bound in `call_async_once` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/iterators/iter-macro-not-async-closure.narrow.stderr b/tests/ui/iterators/iter-macro-not-async-closure.narrow.stderr new file mode 100644 index 00000000000..af3289c3d4e --- /dev/null +++ b/tests/ui/iterators/iter-macro-not-async-closure.narrow.stderr @@ -0,0 +1,72 @@ +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:32:34 + | +LL | ...n!(call_async_once(f)); + | --------------- ^ unsatisfied trait bound + | | + | required by a bound introduced by this call + | + = help: the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}` +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:21:34 + | +LL | ...pl AsyncFnOnce()) { + | ^^^^^^^^^^^^^ required by this bound in `call_async_once` + +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:32:18 + | +LL | ...n!(call_async_once(f)); + | ^^^^^^^^^^^^^^^^^^ unsatisfied trait bound + | + = help: the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}` +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:21:34 + | +LL | ...pl AsyncFnOnce()) { + | ^^^^^^^^^^^^^ required by this bound in `call_async_once` + +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:32:13 + | +LL | ... = pin!(call_async_once(f)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound + | + = help: the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}` +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:21:34 + | +LL | ...pl AsyncFnOnce()) { + | ^^^^^^^^^^^^^ required by this bound in `call_async_once` + = note: this error originates in the macro `pin` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:32:13 + | +LL | ... = pin!(call_async_once(f)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound + | + = help: the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}` +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:21:34 + | +LL | ...pl AsyncFnOnce()) { + | ^^^^^^^^^^^^^ required by this bound in `call_async_once` + = note: this error originates in the macro `pin` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:37:5 + | +LL | ...::noop())); + | ...^^^^^^^^^^ unsatisfied trait bound + | + = help: the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:26:21: 26:28}` +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:21:34 + | +LL | ...pl AsyncFnOnce()) { + | ^^^^^^^^^^^^^ required by this bound in `call_async_once` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/iterators/iter-macro-not-async-closure.rs b/tests/ui/iterators/iter-macro-not-async-closure.rs new file mode 100644 index 00000000000..634391883ea --- /dev/null +++ b/tests/ui/iterators/iter-macro-not-async-closure.rs @@ -0,0 +1,32 @@ +// This test ensures iterators created with the `iter!` macro are not +// accidentally async closures. +// +//@ edition: 2024 +//@ remap-src-base + +#![feature(yield_expr, iter_macro)] + +use std::task::{Waker, Context}; +use std::iter::iter; +use std::pin::pin; +use std::future::Future; + +async fn call_async_once(f: impl AsyncFnOnce()) { + f().await +} + +fn main() { + let f = iter! { move || { + for i in 0..10 { + yield i; + } + }}; + + let x = pin!(call_async_once(f)); + //~^ ERROR AsyncFnOnce()` is not satisfied + //~^^ ERROR AsyncFnOnce()` is not satisfied + //~^^^ ERROR AsyncFnOnce()` is not satisfied + //~^^^^ ERROR AsyncFnOnce()` is not satisfied + x.poll(&mut Context::from_waker(Waker::noop())); + //~^ ERROR AsyncFnOnce()` is not satisfied +} diff --git a/tests/ui/iterators/iter-macro-not-async-closure.stderr b/tests/ui/iterators/iter-macro-not-async-closure.stderr new file mode 100644 index 00000000000..2f0343a2d0d --- /dev/null +++ b/tests/ui/iterators/iter-macro-not-async-closure.stderr @@ -0,0 +1,67 @@ +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:19:21: 19:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:25:34 + | +LL | let x = pin!(call_async_once(f)); + | --------------- ^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:19:21: 19:28}` + | | + | required by a bound introduced by this call + | +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:14:34 + | +LL | async fn call_async_once(f: impl AsyncFnOnce()) { + | ^^^^^^^^^^^^^ required by this bound in `call_async_once` + +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:19:21: 19:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:25:18 + | +LL | let x = pin!(call_async_once(f)); + | ^^^^^^^^^^^^^^^^^^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:19:21: 19:28}` + | +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:14:34 + | +LL | async fn call_async_once(f: impl AsyncFnOnce()) { + | ^^^^^^^^^^^^^ required by this bound in `call_async_once` + +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:19:21: 19:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:25:13 + | +LL | let x = pin!(call_async_once(f)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:19:21: 19:28}` + | +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:14:34 + | +LL | async fn call_async_once(f: impl AsyncFnOnce()) { + | ^^^^^^^^^^^^^ required by this bound in `call_async_once` + = note: this error originates in the macro `pin` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:19:21: 19:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:25:13 + | +LL | let x = pin!(call_async_once(f)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:19:21: 19:28}` + | +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:14:34 + | +LL | async fn call_async_once(f: impl AsyncFnOnce()) { + | ^^^^^^^^^^^^^ required by this bound in `call_async_once` + = note: this error originates in the macro `pin` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:19:21: 19:28}: AsyncFnOnce()` is not satisfied + --> $DIR/iter-macro-not-async-closure.rs:30:5 + | +LL | x.poll(&mut Context::from_waker(Waker::noop())); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:19:21: 19:28}` + | +note: required by a bound in `call_async_once` + --> $DIR/iter-macro-not-async-closure.rs:14:34 + | +LL | async fn call_async_once(f: impl AsyncFnOnce()) { + | ^^^^^^^^^^^^^ required by this bound in `call_async_once` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/kindck/kindck-inherited-copy-bound.rs b/tests/ui/kindck/kindck-inherited-copy-bound.rs index 20d54a3fb10..92c2b273c2c 100644 --- a/tests/ui/kindck/kindck-inherited-copy-bound.rs +++ b/tests/ui/kindck/kindck-inherited-copy-bound.rs @@ -22,7 +22,6 @@ fn b() { let y = &x; let z = &x as &dyn Foo; //~^ ERROR E0038 - //~| ERROR E0038 } fn main() { } diff --git a/tests/ui/kindck/kindck-inherited-copy-bound.stderr b/tests/ui/kindck/kindck-inherited-copy-bound.stderr index edfa7ae7769..c15aabacddd 100644 --- a/tests/ui/kindck/kindck-inherited-copy-bound.stderr +++ b/tests/ui/kindck/kindck-inherited-copy-bound.stderr @@ -20,10 +20,10 @@ LL | fn take_param<T:Foo>(foo: &T) { } | ^^^ required by this bound in `take_param` error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/kindck-inherited-copy-bound.rs:23:19 + --> $DIR/kindck-inherited-copy-bound.rs:23:24 | LL | let z = &x as &dyn Foo; - | ^^^^^^^^ `Foo` is not dyn compatible + | ^^^ `Foo` 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> @@ -34,23 +34,7 @@ LL | trait Foo : Copy { | | | this trait is not dyn compatible... -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/kindck-inherited-copy-bound.rs:23:13 - | -LL | let z = &x as &dyn Foo; - | ^^ `Foo` 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/kindck-inherited-copy-bound.rs:6:13 - | -LL | trait Foo : Copy { - | --- ^^^^ ...because it requires `Self: Sized` - | | - | this trait is not dyn compatible... - = note: required for the cast from `&Box<{integer}>` to `&dyn Foo` - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0038, E0277. For more information about an error, try `rustc --explain E0038`. diff --git a/tests/ui/label/continue-pointing-to-block-ice-113379.rs b/tests/ui/label/continue-pointing-to-block-ice-113379.rs new file mode 100644 index 00000000000..8a6a9cc8409 --- /dev/null +++ b/tests/ui/label/continue-pointing-to-block-ice-113379.rs @@ -0,0 +1,12 @@ +//! Regression test for ICE #113379. Liveness linting assumes that `continue`s all point to loops. +//! This tests that if a `continue` points to a block, we don't run liveness lints. + +async fn f999() -> Vec<usize> { + //~^ ERROR `async fn` is not permitted in Rust 2015 + 'b: { + //~^ ERROR mismatched types + continue 'b; + //~^ ERROR `continue` pointing to a labeled block + } +} +//~^ ERROR `main` function not found diff --git a/tests/ui/label/continue-pointing-to-block-ice-113379.stderr b/tests/ui/label/continue-pointing-to-block-ice-113379.stderr new file mode 100644 index 00000000000..ada6305ec99 --- /dev/null +++ b/tests/ui/label/continue-pointing-to-block-ice-113379.stderr @@ -0,0 +1,43 @@ +error[E0670]: `async fn` is not permitted in Rust 2015 + --> $DIR/continue-pointing-to-block-ice-113379.rs:4:1 + | +LL | async fn f999() -> Vec<usize> { + | ^^^^^ to use `async fn`, switch to Rust 2018 or later + | + = help: pass `--edition 2024` to `rustc` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + +error[E0601]: `main` function not found in crate `continue_pointing_to_block_ice_113379` + --> $DIR/continue-pointing-to-block-ice-113379.rs:11:2 + | +LL | } + | ^ consider adding a `main` function to `$DIR/continue-pointing-to-block-ice-113379.rs` + +error[E0696]: `continue` pointing to a labeled block + --> $DIR/continue-pointing-to-block-ice-113379.rs:8:9 + | +LL | / 'b: { +LL | | +LL | | continue 'b; + | | ^^^^^^^^^^^ labeled blocks cannot be `continue`'d +LL | | +LL | | } + | |_____- labeled block the `continue` points to + +error[E0308]: mismatched types + --> $DIR/continue-pointing-to-block-ice-113379.rs:6:5 + | +LL | / 'b: { +LL | | +LL | | continue 'b; +LL | | +LL | | } + | |_____^ expected `Vec<usize>`, found `()` + | + = note: expected struct `Vec<usize>` + found unit type `()` + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0308, E0601, E0670, E0696. +For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/label/continue-pointing-to-block-ice-121623.rs b/tests/ui/label/continue-pointing-to-block-ice-121623.rs new file mode 100644 index 00000000000..7047f7a309a --- /dev/null +++ b/tests/ui/label/continue-pointing-to-block-ice-121623.rs @@ -0,0 +1,11 @@ +//! Regression test for ICE #121623. Liveness linting assumes that `continue`s all point to loops. +//! This tests that if a `continue` points to a block, we don't run liveness lints. + +fn main() { + match () { + _ => 'b: { + continue 'b; + //~^ ERROR `continue` pointing to a labeled block + } + } +} diff --git a/tests/ui/label/continue-pointing-to-block-ice-121623.stderr b/tests/ui/label/continue-pointing-to-block-ice-121623.stderr new file mode 100644 index 00000000000..a484fb629d1 --- /dev/null +++ b/tests/ui/label/continue-pointing-to-block-ice-121623.stderr @@ -0,0 +1,14 @@ +error[E0696]: `continue` pointing to a labeled block + --> $DIR/continue-pointing-to-block-ice-121623.rs:7:13 + | +LL | _ => 'b: { + | ______________- +LL | | continue 'b; + | | ^^^^^^^^^^^ labeled blocks cannot be `continue`'d +LL | | +LL | | } + | |_________- labeled block the `continue` points to + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0696`. diff --git a/tests/ui/lang-items/lang-item-generic-requirements.rs b/tests/ui/lang-items/lang-item-generic-requirements.rs index 90ed5f3f0ef..25a4ff283ba 100644 --- a/tests/ui/lang-items/lang-item-generic-requirements.rs +++ b/tests/ui/lang-items/lang-item-generic-requirements.rs @@ -48,16 +48,17 @@ fn ice() { // Use index let arr = [0; 5]; + //~^ ERROR requires `copy` lang_item let _ = arr[2]; + //~^ ERROR cannot index into a value of type `[{integer}; 5]` // Use phantomdata let _ = MyPhantomData::<(), i32>; // Use Foo let _: () = Foo; + //~^ ERROR mismatched types } // use `start` fn main() {} - -//~? ERROR requires `copy` lang_item diff --git a/tests/ui/lang-items/lang-item-generic-requirements.stderr b/tests/ui/lang-items/lang-item-generic-requirements.stderr index 3de67d65940..c82bdb00fd1 100644 --- a/tests/ui/lang-items/lang-item-generic-requirements.stderr +++ b/tests/ui/lang-items/lang-item-generic-requirements.stderr @@ -76,9 +76,27 @@ LL | r + a; | | | {integer} +error[E0608]: cannot index into a value of type `[{integer}; 5]` + --> $DIR/lang-item-generic-requirements.rs:52:16 + | +LL | let _ = arr[2]; + | ^^^ + +error[E0308]: mismatched types + --> $DIR/lang-item-generic-requirements.rs:59:17 + | +LL | let _: () = Foo; + | -- ^^^ expected `()`, found `Foo` + | | + | expected due to this + error: requires `copy` lang_item + --> $DIR/lang-item-generic-requirements.rs:50:16 + | +LL | let arr = [0; 5]; + | ^ -error: aborting due to 10 previous errors +error: aborting due to 12 previous errors -Some errors have detailed explanations: E0369, E0392, E0718. -For more information about an error, try `rustc --explain E0369`. +Some errors have detailed explanations: E0308, E0369, E0392, E0608, E0718. +For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/layout/debug.stderr b/tests/ui/layout/debug.stderr index abaa16cdefa..b2ce6385ab6 100644 --- a/tests/ui/layout/debug.stderr +++ b/tests/ui/layout/debug.stderr @@ -6,9 +6,8 @@ LL | union EmptyUnion {} error: layout_of(E) = Layout { size: Size(12 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -45,9 +44,8 @@ error: layout_of(E) = Layout { variants: [ Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -67,9 +65,8 @@ error: layout_of(E) = Layout { }, Layout { size: Size(12 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -108,9 +105,8 @@ LL | enum E { Foo, Bar(!, i32, i32) } error: layout_of(S) = Layout { size: Size(8 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -156,9 +152,8 @@ LL | struct S { f1: i32, f2: (), f3: i32 } error: layout_of(U) = Layout { size: Size(8 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -182,9 +177,8 @@ LL | union U { f1: (i32, i32), f3: i32 } error: layout_of(Result<i32, i32>) = Layout { size: Size(8 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -234,9 +228,8 @@ error: layout_of(Result<i32, i32>) = Layout { variants: [ Layout { size: Size(8 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -273,9 +266,8 @@ error: layout_of(Result<i32, i32>) = Layout { }, Layout { size: Size(8 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -323,9 +315,8 @@ LL | type Test = Result<i32, i32>; error: layout_of(i32) = Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -353,9 +344,8 @@ LL | type T = impl std::fmt::Debug; error: layout_of(V) = Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(2 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -379,9 +369,8 @@ LL | pub union V { error: layout_of(W) = Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(2 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -405,9 +394,8 @@ LL | pub union W { error: layout_of(Y) = Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(2 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -431,9 +419,8 @@ LL | pub union Y { error: layout_of(P1) = Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -457,9 +444,8 @@ LL | union P1 { x: u32 } error: layout_of(P2) = Layout { size: Size(8 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -483,9 +469,8 @@ LL | union P2 { x: (u32, u32) } error: layout_of(P3) = Layout { size: Size(16 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -509,9 +494,8 @@ LL | union P3 { x: F32x4 } error: layout_of(P4) = Layout { size: Size(12 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -535,9 +519,8 @@ LL | union P4 { x: E } error: layout_of(P5) = Layout { size: Size(1 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $SOME_ALIGN, }, backend_repr: Scalar( Union { @@ -566,9 +549,8 @@ LL | union P5 { zst: [u16; 0], byte: u8 } error: layout_of(MaybeUninit<u8>) = Layout { size: Size(1 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $SOME_ALIGN, }, backend_repr: Scalar( Union { diff --git a/tests/ui/layout/enum.stderr b/tests/ui/layout/enum.stderr index 7f0b38d0a07..f95b577bfc9 100644 --- a/tests/ui/layout/enum.stderr +++ b/tests/ui/layout/enum.stderr @@ -1,4 +1,4 @@ -error: align: AbiAndPrefAlign { abi: Align(2 bytes), pref: $PREF_ALIGN } +error: align: AbiAlign { abi: Align(2 bytes) } --> $DIR/enum.rs:9:1 | LL | enum UninhabitedVariantAlign { diff --git a/tests/ui/layout/hexagon-enum.stderr b/tests/ui/layout/hexagon-enum.stderr index 9c3a8662d4f..d910456c0e6 100644 --- a/tests/ui/layout/hexagon-enum.stderr +++ b/tests/ui/layout/hexagon-enum.stderr @@ -1,8 +1,7 @@ error: layout_of(A) = Layout { size: Size(1 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: Align(1 bytes), }, backend_repr: Scalar( Initialized { @@ -45,9 +44,8 @@ error: layout_of(A) = Layout { variants: [ Layout { size: Size(1 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: Align(1 bytes), }, backend_repr: Memory { sized: true, @@ -78,9 +76,8 @@ LL | enum A { Apple } error: layout_of(B) = Layout { size: Size(1 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: Align(1 bytes), }, backend_repr: Scalar( Initialized { @@ -123,9 +120,8 @@ error: layout_of(B) = Layout { variants: [ Layout { size: Size(1 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: Align(1 bytes), }, backend_repr: Memory { sized: true, @@ -156,9 +152,8 @@ LL | enum B { Banana = 255, } error: layout_of(C) = Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(2 bytes), - pref: Align(2 bytes), }, backend_repr: Scalar( Initialized { @@ -201,9 +196,8 @@ error: layout_of(C) = Layout { variants: [ Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(2 bytes), - pref: Align(2 bytes), }, backend_repr: Memory { sized: true, @@ -234,9 +228,8 @@ LL | enum C { Chaenomeles = 256, } error: layout_of(P) = Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: Align(4 bytes), }, backend_repr: Scalar( Initialized { @@ -279,9 +272,8 @@ error: layout_of(P) = Layout { variants: [ Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: Align(4 bytes), }, backend_repr: Memory { sized: true, @@ -312,9 +304,8 @@ LL | enum P { Peach = 0x1000_0000isize, } error: layout_of(T) = Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: Align(4 bytes), }, backend_repr: Scalar( Initialized { @@ -357,9 +348,8 @@ error: layout_of(T) = Layout { variants: [ Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: Align(4 bytes), }, backend_repr: Memory { sized: true, diff --git a/tests/ui/layout/invalid-unsized-const-eval.rs b/tests/ui/layout/invalid-unsized-const-eval.rs index 1f664d30055..94fa6449e67 100644 --- a/tests/ui/layout/invalid-unsized-const-eval.rs +++ b/tests/ui/layout/invalid-unsized-const-eval.rs @@ -10,6 +10,6 @@ struct LazyLock { } static EMPTY_SET: LazyLock = todo!(); -//~^ ERROR could not evaluate static initializer +//~^ ERROR the type `(dyn Sync, ())` has an unknown layout fn main() {} diff --git a/tests/ui/layout/invalid-unsized-const-eval.stderr b/tests/ui/layout/invalid-unsized-const-eval.stderr index a434ca9b2c7..d5a294d11f4 100644 --- a/tests/ui/layout/invalid-unsized-const-eval.stderr +++ b/tests/ui/layout/invalid-unsized-const-eval.stderr @@ -7,11 +7,11 @@ LL | data: (dyn Sync, ()), = help: the trait `Sized` is not implemented for `(dyn Sync + 'static)` = note: only the last element of a tuple may have a dynamically sized type -error[E0080]: could not evaluate static initializer +error[E0080]: the type `(dyn Sync, ())` has an unknown layout --> $DIR/invalid-unsized-const-eval.rs:12:1 | LL | static EMPTY_SET: LazyLock = todo!(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `(dyn Sync, ())` has an unknown layout + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `EMPTY_SET` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/layout/invalid-unsized-in-always-sized-tail.rs b/tests/ui/layout/invalid-unsized-in-always-sized-tail.rs index c6d5f2bfa0e..8da2bb385ef 100644 --- a/tests/ui/layout/invalid-unsized-in-always-sized-tail.rs +++ b/tests/ui/layout/invalid-unsized-in-always-sized-tail.rs @@ -12,6 +12,7 @@ struct P2 { //~^ ERROR: the size for values of type `[bool]` cannot be known at compilation time } -static CHECK: () = assert!(align_of::<P2>() == 1); //~ ERROR could not evaluate static initializer +static CHECK: () = assert!(align_of::<P2>() == 1); +//~^ ERROR the type `MySlice<[bool]>` has an unknown layout fn main() {} diff --git a/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr b/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr index 3a4735e4832..1a43fd4ad18 100644 --- a/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr +++ b/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr @@ -18,11 +18,11 @@ LL | struct MySlice<T>(T); | | | this could be changed to `T: ?Sized`... -error[E0080]: could not evaluate static initializer +error[E0080]: the type `MySlice<[bool]>` has an unknown layout --> $DIR/invalid-unsized-in-always-sized-tail.rs:15:28 | LL | static CHECK: () = assert!(align_of::<P2>() == 1); - | ^^^^^^^^^^^^^^^^ the type `MySlice<[bool]>` has an unknown layout + | ^^^^^^^^^^^^^^^^ evaluation of `CHECK` failed inside this call | note: inside `align_of::<P2>` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL diff --git a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr index ef7f0cd2d1c..2087fedeb19 100644 --- a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr +++ b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr @@ -1,8 +1,7 @@ error: layout_of(MissingPayloadField) = Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $PREF_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -51,9 +50,8 @@ error: layout_of(MissingPayloadField) = Layout { variants: [ Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $PREF_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -89,9 +87,8 @@ error: layout_of(MissingPayloadField) = Layout { }, Layout { size: Size(1 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $PREF_ALIGN, }, backend_repr: Memory { sized: true, @@ -122,9 +119,8 @@ LL | pub enum MissingPayloadField { error: layout_of(CommonPayloadField) = Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $PREF_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -174,9 +170,8 @@ error: layout_of(CommonPayloadField) = Layout { variants: [ Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $PREF_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -213,9 +208,8 @@ error: layout_of(CommonPayloadField) = Layout { }, Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $PREF_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -263,9 +257,8 @@ LL | pub enum CommonPayloadField { error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $PREF_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -314,9 +307,8 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { variants: [ Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $PREF_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -352,9 +344,8 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { }, Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $PREF_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -401,9 +392,8 @@ LL | pub enum CommonPayloadFieldIsMaybeUninit { error: layout_of(NicheFirst) = Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $PREF_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -456,9 +446,8 @@ error: layout_of(NicheFirst) = Layout { variants: [ Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $PREF_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -506,9 +495,8 @@ error: layout_of(NicheFirst) = Layout { }, Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $PREF_ALIGN, }, backend_repr: Memory { sized: true, @@ -528,9 +516,8 @@ error: layout_of(NicheFirst) = Layout { }, Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $PREF_ALIGN, }, backend_repr: Memory { sized: true, @@ -561,9 +548,8 @@ LL | pub enum NicheFirst { error: layout_of(NicheSecond) = Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $PREF_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -616,9 +602,8 @@ error: layout_of(NicheSecond) = Layout { variants: [ Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $PREF_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -666,9 +651,8 @@ error: layout_of(NicheSecond) = Layout { }, Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $PREF_ALIGN, }, backend_repr: Memory { sized: true, @@ -688,9 +672,8 @@ error: layout_of(NicheSecond) = Layout { }, Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $PREF_ALIGN, }, backend_repr: Memory { sized: true, diff --git a/tests/ui/layout/issue-96185-overaligned-enum.stderr b/tests/ui/layout/issue-96185-overaligned-enum.stderr index a9081afc509..6bcc5b4906b 100644 --- a/tests/ui/layout/issue-96185-overaligned-enum.stderr +++ b/tests/ui/layout/issue-96185-overaligned-enum.stderr @@ -1,8 +1,7 @@ error: layout_of(Aligned1) = Layout { size: Size(8 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(8 bytes), - pref: $PREF_ALIGN, }, backend_repr: Memory { sized: true, @@ -39,9 +38,8 @@ error: layout_of(Aligned1) = Layout { variants: [ Layout { size: Size(8 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(8 bytes), - pref: $PREF_ALIGN, }, backend_repr: Memory { sized: true, @@ -63,9 +61,8 @@ error: layout_of(Aligned1) = Layout { }, Layout { size: Size(8 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(8 bytes), - pref: $PREF_ALIGN, }, backend_repr: Memory { sized: true, @@ -100,9 +97,8 @@ LL | pub enum Aligned1 { error: layout_of(Aligned2) = Layout { size: Size(1 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $PREF_ALIGN, }, backend_repr: Scalar( Initialized { @@ -145,9 +141,8 @@ error: layout_of(Aligned2) = Layout { variants: [ Layout { size: Size(1 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $PREF_ALIGN, }, backend_repr: Memory { sized: true, @@ -169,9 +164,8 @@ error: layout_of(Aligned2) = Layout { }, Layout { size: Size(1 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $PREF_ALIGN, }, backend_repr: Memory { sized: true, diff --git a/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.rs b/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.rs index f84c10d8e5c..92295704615 100644 --- a/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.rs +++ b/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.rs @@ -6,6 +6,6 @@ struct ArenaSet<U: Deref, V: ?Sized = <U as Deref>::Target>(V, U); //~^ ERROR the size for values of type `V` cannot be known at compilation time const DATA: *const ArenaSet<Vec<u8>> = std::ptr::null_mut(); -//~^ ERROR evaluation of constant value failed +//~^ ERROR the type `ArenaSet<Vec<u8>, [u8]>` has an unknown layout pub fn main() {} diff --git a/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.stderr b/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.stderr index 220951fab86..ea29320002b 100644 --- a/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.stderr +++ b/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.stderr @@ -22,11 +22,11 @@ help: the `Box` type always has a statically known size and allocates its conten LL | struct ArenaSet<U: Deref, V: ?Sized = <U as Deref>::Target>(Box<V>, U); | ++++ + -error[E0080]: evaluation of constant value failed +error[E0080]: the type `ArenaSet<Vec<u8>, [u8]>` has an unknown layout --> $DIR/issue-unsized-tail-restatic-ice-122488.rs:8:1 | LL | const DATA: *const ArenaSet<Vec<u8>> = std::ptr::null_mut(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `ArenaSet<Vec<u8>, [u8]>` has an unknown layout + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `DATA` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/layout/thumb-enum.stderr b/tests/ui/layout/thumb-enum.stderr index b635d1a45bb..9bd8ced0c02 100644 --- a/tests/ui/layout/thumb-enum.stderr +++ b/tests/ui/layout/thumb-enum.stderr @@ -1,8 +1,7 @@ error: layout_of(A) = Layout { size: Size(1 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: Align(4 bytes), }, backend_repr: Scalar( Initialized { @@ -45,9 +44,8 @@ error: layout_of(A) = Layout { variants: [ Layout { size: Size(1 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: Align(4 bytes), }, backend_repr: Memory { sized: true, @@ -78,9 +76,8 @@ LL | enum A { Apple } error: layout_of(B) = Layout { size: Size(1 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: Align(4 bytes), }, backend_repr: Scalar( Initialized { @@ -123,9 +120,8 @@ error: layout_of(B) = Layout { variants: [ Layout { size: Size(1 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: Align(4 bytes), }, backend_repr: Memory { sized: true, @@ -156,9 +152,8 @@ LL | enum B { Banana = 255, } error: layout_of(C) = Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(2 bytes), - pref: Align(4 bytes), }, backend_repr: Scalar( Initialized { @@ -201,9 +196,8 @@ error: layout_of(C) = Layout { variants: [ Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(2 bytes), - pref: Align(4 bytes), }, backend_repr: Memory { sized: true, @@ -234,9 +228,8 @@ LL | enum C { Chaenomeles = 256, } error: layout_of(P) = Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: Align(4 bytes), }, backend_repr: Scalar( Initialized { @@ -279,9 +272,8 @@ error: layout_of(P) = Layout { variants: [ Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: Align(4 bytes), }, backend_repr: Memory { sized: true, @@ -312,9 +304,8 @@ LL | enum P { Peach = 0x1000_0000isize, } error: layout_of(T) = Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: Align(4 bytes), }, backend_repr: Scalar( Initialized { @@ -357,9 +348,8 @@ error: layout_of(T) = Layout { variants: [ Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: Align(4 bytes), }, backend_repr: Memory { sized: true, diff --git a/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.rs b/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.rs index 91280e49dcd..4423b83e24d 100644 --- a/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.rs +++ b/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.rs @@ -5,7 +5,7 @@ where str: Sized, { [(); { let _a: Option<str> = None; 0 }]; - //~^ ERROR evaluation of constant value failed + //~^ ERROR the type `Option<str>` has an unknown layout } fn main() {} diff --git a/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.stderr b/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.stderr index 6c7c51db8df..43fe9e3a7a7 100644 --- a/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.stderr +++ b/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: the type `Option<str>` has an unknown layout --> $DIR/uncomputable-due-to-trivial-bounds-ice-135138.rs:7:16 | LL | [(); { let _a: Option<str> = None; 0 }]; - | ^^ the type `Option<str>` has an unknown layout + | ^^ evaluation of `return_str::{constant#0}` failed here error: aborting due to 1 previous error diff --git a/tests/ui/layout/unknown-when-no-type-parameter.rs b/tests/ui/layout/unknown-when-no-type-parameter.rs index 87f90aa438a..f787998868d 100644 --- a/tests/ui/layout/unknown-when-no-type-parameter.rs +++ b/tests/ui/layout/unknown-when-no-type-parameter.rs @@ -4,10 +4,14 @@ trait Project { type Assoc; } -fn foo() where (): Project { - [(); size_of::<<() as Project>::Assoc>()]; //~ ERROR evaluation of constant value failed - //~| NOTE the type `<() as Project>::Assoc` has an unknown layout +fn foo() +where + (): Project, +{ + [(); size_of::<<() as Project>::Assoc>()]; + //~^ ERROR the type `<() as Project>::Assoc` has an unknown layout //~| NOTE inside `std::mem::size_of::<<() as Project>::Assoc>` + //~| NOTE failed inside this call } fn main() {} diff --git a/tests/ui/layout/unknown-when-no-type-parameter.stderr b/tests/ui/layout/unknown-when-no-type-parameter.stderr index 35fbb11f156..9bb42c46ec3 100644 --- a/tests/ui/layout/unknown-when-no-type-parameter.stderr +++ b/tests/ui/layout/unknown-when-no-type-parameter.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/unknown-when-no-type-parameter.rs:8:10 +error[E0080]: the type `<() as Project>::Assoc` has an unknown layout + --> $DIR/unknown-when-no-type-parameter.rs:11:10 | LL | [(); size_of::<<() as Project>::Assoc>()]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `<() as Project>::Assoc` has an unknown layout + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `foo::{constant#0}` failed inside this call | note: inside `std::mem::size_of::<<() as Project>::Assoc>` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL diff --git a/tests/ui/layout/unknown-when-ptr-metadata-is-DST.rs b/tests/ui/layout/unknown-when-ptr-metadata-is-DST.rs index 973235fe65a..54f339711d5 100644 --- a/tests/ui/layout/unknown-when-ptr-metadata-is-DST.rs +++ b/tests/ui/layout/unknown-when-ptr-metadata-is-DST.rs @@ -6,7 +6,7 @@ where str: std::ptr::Pointee<Metadata = str>, { [(); { let _a: Option<&str> = None; 0 }]; - //~^ ERROR evaluation of constant value failed + //~^ ERROR the type `str` has an unknown layout } fn main() {} diff --git a/tests/ui/layout/unknown-when-ptr-metadata-is-DST.stderr b/tests/ui/layout/unknown-when-ptr-metadata-is-DST.stderr index 68bba2e9678..fd9eedc9267 100644 --- a/tests/ui/layout/unknown-when-ptr-metadata-is-DST.stderr +++ b/tests/ui/layout/unknown-when-ptr-metadata-is-DST.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: the type `str` has an unknown layout --> $DIR/unknown-when-ptr-metadata-is-DST.rs:8:16 | LL | [(); { let _a: Option<&str> = None; 0 }]; - | ^^ the type `str` has an unknown layout + | ^^ evaluation of `return_str::{constant#0}` failed here error: aborting due to 1 previous error diff --git a/tests/ui/layout/zero-sized-array-enum-niche.stderr b/tests/ui/layout/zero-sized-array-enum-niche.stderr index 1ba184bdace..1707b8aff81 100644 --- a/tests/ui/layout/zero-sized-array-enum-niche.stderr +++ b/tests/ui/layout/zero-sized-array-enum-niche.stderr @@ -1,8 +1,7 @@ error: layout_of(Result<[u32; 0], bool>) = Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $PREF_ALIGN, }, backend_repr: Memory { sized: true, @@ -39,9 +38,8 @@ error: layout_of(Result<[u32; 0], bool>) = Layout { variants: [ Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $PREF_ALIGN, }, backend_repr: Memory { sized: true, @@ -65,9 +63,8 @@ error: layout_of(Result<[u32; 0], bool>) = Layout { }, Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $PREF_ALIGN, }, backend_repr: Memory { sized: true, @@ -111,9 +108,8 @@ LL | type AlignedResult = Result<[u32; 0], bool>; error: layout_of(MultipleAlignments) = Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $PREF_ALIGN, }, backend_repr: Memory { sized: true, @@ -150,9 +146,8 @@ error: layout_of(MultipleAlignments) = Layout { variants: [ Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(2 bytes), - pref: $PREF_ALIGN, }, backend_repr: Memory { sized: true, @@ -176,9 +171,8 @@ error: layout_of(MultipleAlignments) = Layout { }, Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $PREF_ALIGN, }, backend_repr: Memory { sized: true, @@ -202,9 +196,8 @@ error: layout_of(MultipleAlignments) = Layout { }, Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $PREF_ALIGN, }, backend_repr: Memory { sized: true, @@ -248,9 +241,8 @@ LL | enum MultipleAlignments { error: layout_of(Result<[u32; 0], Packed<NonZero<u16>>>) = Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $PREF_ALIGN, }, backend_repr: Memory { sized: true, @@ -287,9 +279,8 @@ error: layout_of(Result<[u32; 0], Packed<NonZero<u16>>>) = Layout { variants: [ Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $PREF_ALIGN, }, backend_repr: Memory { sized: true, @@ -313,9 +304,8 @@ error: layout_of(Result<[u32; 0], Packed<NonZero<u16>>>) = Layout { }, Layout { size: Size(3 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $PREF_ALIGN, }, backend_repr: Memory { sized: true, @@ -359,9 +349,8 @@ LL | type NicheLosesToTagged = Result<[u32; 0], Packed<std::num::NonZero<u16>>>; error: layout_of(Result<[u32; 0], Packed<U16IsZero>>) = Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $PREF_ALIGN, }, backend_repr: Memory { sized: true, @@ -402,9 +391,8 @@ error: layout_of(Result<[u32; 0], Packed<U16IsZero>>) = Layout { variants: [ Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $PREF_ALIGN, }, backend_repr: Memory { sized: true, @@ -428,9 +416,8 @@ error: layout_of(Result<[u32; 0], Packed<U16IsZero>>) = Layout { }, Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $PREF_ALIGN, }, backend_repr: Memory { sized: true, diff --git a/tests/ui/lazy-type-alias/def-site-param-defaults-wf.rs b/tests/ui/lazy-type-alias/def-site-param-defaults-wf.rs index 90bb0a294f8..7f417de5fd3 100644 --- a/tests/ui/lazy-type-alias/def-site-param-defaults-wf.rs +++ b/tests/ui/lazy-type-alias/def-site-param-defaults-wf.rs @@ -2,8 +2,8 @@ #![feature(lazy_type_alias)] #![allow(incomplete_features)] -type Alias<T = Vec<str>, const N: usize = {0 - 1}> = T; -//~^ ERROR evaluation of constant value failed +type Alias<T = Vec<str>, const N: usize = { 0 - 1 }> = T; +//~^ ERROR attempt to compute `0_usize - 1_usize`, which would overflow //~| ERROR the size for values of type `str` cannot be known at compilation time fn main() {} diff --git a/tests/ui/lazy-type-alias/def-site-param-defaults-wf.stderr b/tests/ui/lazy-type-alias/def-site-param-defaults-wf.stderr index da0021ccaf4..b97f770c97f 100644 --- a/tests/ui/lazy-type-alias/def-site-param-defaults-wf.stderr +++ b/tests/ui/lazy-type-alias/def-site-param-defaults-wf.stderr @@ -1,13 +1,13 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/def-site-param-defaults-wf.rs:5:44 +error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow + --> $DIR/def-site-param-defaults-wf.rs:5:45 | -LL | type Alias<T = Vec<str>, const N: usize = {0 - 1}> = T; - | ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow +LL | type Alias<T = Vec<str>, const N: usize = { 0 - 1 }> = T; + | ^^^^^ evaluation of `Alias::{constant#0}` failed here error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/def-site-param-defaults-wf.rs:5:16 | -LL | type Alias<T = Vec<str>, const N: usize = {0 - 1}> = T; +LL | type Alias<T = Vec<str>, const N: usize = { 0 - 1 }> = T; | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` diff --git a/tests/ui/lexer/lex-bad-str-literal-as-char-3.rs b/tests/ui/lexer/lex-bad-str-literal-as-char-3.rs index 52781d9c6d8..5b290899a70 100644 --- a/tests/ui/lexer/lex-bad-str-literal-as-char-3.rs +++ b/tests/ui/lexer/lex-bad-str-literal-as-char-3.rs @@ -1,4 +1,5 @@ //@ revisions: rust2015 rust2018 rust2021 +//@[rust2015] edition:2015 //@[rust2018] edition:2018 //@[rust2021] edition:2021 fn main() { diff --git a/tests/ui/lexer/lex-bad-str-literal-as-char-3.rust2015.stderr b/tests/ui/lexer/lex-bad-str-literal-as-char-3.rust2015.stderr index 2f92225de1f..be3b114baf9 100644 --- a/tests/ui/lexer/lex-bad-str-literal-as-char-3.rust2015.stderr +++ b/tests/ui/lexer/lex-bad-str-literal-as-char-3.rust2015.stderr @@ -1,5 +1,5 @@ error[E0762]: unterminated character literal - --> $DIR/lex-bad-str-literal-as-char-3.rs:5:26 + --> $DIR/lex-bad-str-literal-as-char-3.rs:6:26 | LL | println!('hello world'); | ^^^ diff --git a/tests/ui/lexer/lex-bad-str-literal-as-char-3.rust2018.stderr b/tests/ui/lexer/lex-bad-str-literal-as-char-3.rust2018.stderr index 2f92225de1f..be3b114baf9 100644 --- a/tests/ui/lexer/lex-bad-str-literal-as-char-3.rust2018.stderr +++ b/tests/ui/lexer/lex-bad-str-literal-as-char-3.rust2018.stderr @@ -1,5 +1,5 @@ error[E0762]: unterminated character literal - --> $DIR/lex-bad-str-literal-as-char-3.rs:5:26 + --> $DIR/lex-bad-str-literal-as-char-3.rs:6:26 | LL | println!('hello world'); | ^^^ diff --git a/tests/ui/lexer/lex-bad-str-literal-as-char-3.rust2021.stderr b/tests/ui/lexer/lex-bad-str-literal-as-char-3.rust2021.stderr index e10046e58e4..605cb66df1c 100644 --- a/tests/ui/lexer/lex-bad-str-literal-as-char-3.rust2021.stderr +++ b/tests/ui/lexer/lex-bad-str-literal-as-char-3.rust2021.stderr @@ -1,5 +1,5 @@ error: prefix `world` is unknown - --> $DIR/lex-bad-str-literal-as-char-3.rs:5:21 + --> $DIR/lex-bad-str-literal-as-char-3.rs:6:21 | LL | println!('hello world'); | ^^^^^ unknown prefix @@ -12,7 +12,7 @@ LL + println!("hello world"); | error[E0762]: unterminated character literal - --> $DIR/lex-bad-str-literal-as-char-3.rs:5:26 + --> $DIR/lex-bad-str-literal-as-char-3.rs:6:26 | LL | println!('hello world'); | ^^^ diff --git a/tests/ui/lifetimes/auxiliary/lifetime_bound_will_change_warning_lib.rs b/tests/ui/lifetimes/auxiliary/lifetime_bound_will_change_warning_lib.rs index 58f1b81cf4d..e351cc9e8fe 100644 --- a/tests/ui/lifetimes/auxiliary/lifetime_bound_will_change_warning_lib.rs +++ b/tests/ui/lifetimes/auxiliary/lifetime_bound_will_change_warning_lib.rs @@ -3,9 +3,8 @@ // Helper for testing that we get suitable warnings when lifetime // bound change will cause breakage. -pub fn just_ref(x: &Fn()) { -} +pub fn just_ref(x: &dyn Fn()) {} -pub fn ref_obj(x: &Box<Fn()>) { +pub fn ref_obj(x: &Box<dyn Fn()>) { // this will change to &Box<Fn()+'static>... } diff --git a/tests/ui/lifetimes/bare-trait-object-borrowck.rs b/tests/ui/lifetimes/bare-trait-object-borrowck.rs index c54d3effffe..4b81b66118a 100644 --- a/tests/ui/lifetimes/bare-trait-object-borrowck.rs +++ b/tests/ui/lifetimes/bare-trait-object-borrowck.rs @@ -1,5 +1,7 @@ -#![allow(bare_trait_objects)] +//@ edition: 2015 //@ check-pass +#![allow(bare_trait_objects)] + pub struct FormatWith<'a, I, F> { sep: &'a str, /// FormatWith uses interior mutability because Display::fmt takes &self. diff --git a/tests/ui/lifetimes/bare-trait-object.rs b/tests/ui/lifetimes/bare-trait-object.rs index 2feb8a880b1..e74f8ac03ea 100644 --- a/tests/ui/lifetimes/bare-trait-object.rs +++ b/tests/ui/lifetimes/bare-trait-object.rs @@ -1,4 +1,5 @@ // Verify that lifetime resolution correctly accounts for `Fn` bare trait objects. +//@ edition: 2015 //@ check-pass #![allow(bare_trait_objects)] diff --git a/tests/ui/lifetimes/constructor-lifetime-early-binding-error.rs b/tests/ui/lifetimes/constructor-lifetime-early-binding-error.rs new file mode 100644 index 00000000000..2d5a444a942 --- /dev/null +++ b/tests/ui/lifetimes/constructor-lifetime-early-binding-error.rs @@ -0,0 +1,22 @@ +//! Tests that all lifetime parameters in struct (`S`) and enum (`E`) constructors are +//! treated as early bound, similar to associated items, rather than late bound as in manual +//! constructors. + +struct S<'a, 'b>(&'a u8, &'b u8); +enum E<'a, 'b> { + V(&'a u8), + U(&'b u8), +} + +fn main() { + S(&0, &0); // OK + S::<'static>(&0, &0); + //~^ ERROR struct takes 2 lifetime arguments + S::<'static, 'static, 'static>(&0, &0); + //~^ ERROR struct takes 2 lifetime arguments + E::V(&0); // OK + E::V::<'static>(&0); + //~^ ERROR enum takes 2 lifetime arguments + E::V::<'static, 'static, 'static>(&0); + //~^ ERROR enum takes 2 lifetime arguments +} diff --git a/tests/ui/constructor-lifetime-args.stderr b/tests/ui/lifetimes/constructor-lifetime-early-binding-error.stderr index d3759f4b365..94699a3509b 100644 --- a/tests/ui/constructor-lifetime-args.stderr +++ b/tests/ui/lifetimes/constructor-lifetime-early-binding-error.stderr @@ -1,5 +1,5 @@ error[E0107]: struct takes 2 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/constructor-lifetime-args.rs:17:5 + --> $DIR/constructor-lifetime-early-binding-error.rs:13:5 | LL | S::<'static>(&0, &0); | ^ ------- supplied 1 lifetime argument @@ -7,7 +7,7 @@ LL | S::<'static>(&0, &0); | expected 2 lifetime arguments | note: struct defined here, with 2 lifetime parameters: `'a`, `'b` - --> $DIR/constructor-lifetime-args.rs:9:8 + --> $DIR/constructor-lifetime-early-binding-error.rs:5:8 | LL | struct S<'a, 'b>(&'a u8, &'b u8); | ^ -- -- @@ -17,7 +17,7 @@ LL | S::<'static, 'static>(&0, &0); | +++++++++ error[E0107]: struct takes 2 lifetime arguments but 3 lifetime arguments were supplied - --> $DIR/constructor-lifetime-args.rs:19:5 + --> $DIR/constructor-lifetime-early-binding-error.rs:15:5 | LL | S::<'static, 'static, 'static>(&0, &0); | ^ --------- help: remove the lifetime argument @@ -25,13 +25,13 @@ LL | S::<'static, 'static, 'static>(&0, &0); | expected 2 lifetime arguments | note: struct defined here, with 2 lifetime parameters: `'a`, `'b` - --> $DIR/constructor-lifetime-args.rs:9:8 + --> $DIR/constructor-lifetime-early-binding-error.rs:5:8 | LL | struct S<'a, 'b>(&'a u8, &'b u8); | ^ -- -- error[E0107]: enum takes 2 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/constructor-lifetime-args.rs:22:8 + --> $DIR/constructor-lifetime-early-binding-error.rs:18:8 | LL | E::V::<'static>(&0); | ^ ------- supplied 1 lifetime argument @@ -39,7 +39,7 @@ LL | E::V::<'static>(&0); | expected 2 lifetime arguments | note: enum defined here, with 2 lifetime parameters: `'a`, `'b` - --> $DIR/constructor-lifetime-args.rs:10:6 + --> $DIR/constructor-lifetime-early-binding-error.rs:6:6 | LL | enum E<'a, 'b> { | ^ -- -- @@ -49,7 +49,7 @@ LL | E::V::<'static, 'static>(&0); | +++++++++ error[E0107]: enum takes 2 lifetime arguments but 3 lifetime arguments were supplied - --> $DIR/constructor-lifetime-args.rs:24:8 + --> $DIR/constructor-lifetime-early-binding-error.rs:20:8 | LL | E::V::<'static, 'static, 'static>(&0); | ^ --------- help: remove the lifetime argument @@ -57,7 +57,7 @@ LL | E::V::<'static, 'static, 'static>(&0); | expected 2 lifetime arguments | note: enum defined here, with 2 lifetime parameters: `'a`, `'b` - --> $DIR/constructor-lifetime-args.rs:10:6 + --> $DIR/constructor-lifetime-early-binding-error.rs:6:6 | LL | enum E<'a, 'b> { | ^ -- -- diff --git a/tests/ui/lifetimes/issue-103582-hint-for-missing-lifetime-bound-on-trait-object-using-type-alias.fixed b/tests/ui/lifetimes/issue-103582-hint-for-missing-lifetime-bound-on-trait-object-using-type-alias.fixed index 2ceaaf0339d..bcc4abc47e1 100644 --- a/tests/ui/lifetimes/issue-103582-hint-for-missing-lifetime-bound-on-trait-object-using-type-alias.fixed +++ b/tests/ui/lifetimes/issue-103582-hint-for-missing-lifetime-bound-on-trait-object-using-type-alias.fixed @@ -28,6 +28,7 @@ impl Greeter1 for FixedGreeter<'_> { struct Greetings(pub Vec<String>); impl Greetings { + #[expect(mismatched_lifetime_syntaxes)] pub fn get(&self, i: usize) -> BoxedGreeter { (Box::new(FixedGreeter(&self.0[i])), Box::new(FixedGreeter(&self.0[i]))) //~^ ERROR lifetime may not live long enough diff --git a/tests/ui/lifetimes/issue-103582-hint-for-missing-lifetime-bound-on-trait-object-using-type-alias.rs b/tests/ui/lifetimes/issue-103582-hint-for-missing-lifetime-bound-on-trait-object-using-type-alias.rs index e7d427517b5..9ca6077f47f 100644 --- a/tests/ui/lifetimes/issue-103582-hint-for-missing-lifetime-bound-on-trait-object-using-type-alias.rs +++ b/tests/ui/lifetimes/issue-103582-hint-for-missing-lifetime-bound-on-trait-object-using-type-alias.rs @@ -28,6 +28,7 @@ impl Greeter1 for FixedGreeter<'_> { struct Greetings(pub Vec<String>); impl Greetings { + #[expect(mismatched_lifetime_syntaxes)] pub fn get(&self, i: usize) -> BoxedGreeter { (Box::new(FixedGreeter(&self.0[i])), Box::new(FixedGreeter(&self.0[i]))) //~^ ERROR lifetime may not live long enough diff --git a/tests/ui/lifetimes/issue-103582-hint-for-missing-lifetime-bound-on-trait-object-using-type-alias.stderr b/tests/ui/lifetimes/issue-103582-hint-for-missing-lifetime-bound-on-trait-object-using-type-alias.stderr index 24bb9e2ef7d..2eba3ff418b 100644 --- a/tests/ui/lifetimes/issue-103582-hint-for-missing-lifetime-bound-on-trait-object-using-type-alias.stderr +++ b/tests/ui/lifetimes/issue-103582-hint-for-missing-lifetime-bound-on-trait-object-using-type-alias.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-103582-hint-for-missing-lifetime-bound-on-trait-object-using-type-alias.rs:32:9 + --> $DIR/issue-103582-hint-for-missing-lifetime-bound-on-trait-object-using-type-alias.rs:33:9 | LL | pub fn get(&self, i: usize) -> BoxedGreeter { | - let's call the lifetime of this reference `'1` diff --git a/tests/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.rs b/tests/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.rs index 63a2c9be9eb..d0a8fe795ef 100644 --- a/tests/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.rs +++ b/tests/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.rs @@ -47,6 +47,5 @@ fn l<'a>(_: &'a str, _: &'a str) -> &str { "" } // This is ok because both `'a` are for the same parameter. fn m<'a>(_: &'a Foo<'a>) -> &str { "" } -//~^ WARNING elided lifetime has a name fn main() {} diff --git a/tests/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr b/tests/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr index f835d2655bb..23ef36888f0 100644 --- a/tests/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr +++ b/tests/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr @@ -105,16 +105,6 @@ help: consider using the `'a` lifetime LL | fn l<'a>(_: &'a str, _: &'a str) -> &'a str { "" } | ++ -warning: elided lifetime has a name - --> $DIR/lifetime-elision-return-type-requires-explicit-lifetime.rs:49:29 - | -LL | fn m<'a>(_: &'a Foo<'a>) -> &str { "" } - | -- ^ this elided lifetime gets resolved as `'a` - | | - | lifetime `'a` declared here - | - = note: `#[warn(elided_named_lifetimes)]` on by default - -error: aborting due to 7 previous errors; 1 warning emitted +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0106`. diff --git a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.rs b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.rs index 598633d7576..5dbc0c556fb 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.rs +++ b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.rs @@ -4,12 +4,8 @@ struct Foo { impl Foo { fn foo<'a>(&'a self, x: &i32) -> &i32 { - //~^ WARNING elided lifetime has a name - if true { &self.field } else { x } //~ ERROR explicit lifetime - } - } fn main() { } diff --git a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.stderr b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.stderr index 2d5d4fb0e72..071bda24ef8 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.stderr @@ -1,22 +1,11 @@ -warning: elided lifetime has a name - --> $DIR/ex1-return-one-existing-name-if-else-using-impl-3.rs:6:36 - | -LL | fn foo<'a>(&'a self, x: &i32) -> &i32 { - | -- ^ this elided lifetime gets resolved as `'a` - | | - | lifetime `'a` declared here - | - = note: `#[warn(elided_named_lifetimes)]` on by default - error[E0621]: explicit lifetime required in the type of `x` - --> $DIR/ex1-return-one-existing-name-if-else-using-impl-3.rs:9:36 + --> $DIR/ex1-return-one-existing-name-if-else-using-impl-3.rs:7:36 | LL | fn foo<'a>(&'a self, x: &i32) -> &i32 { | ---- help: add explicit lifetime `'a` to the type of `x`: `&'a i32` -... LL | if true { &self.field } else { x } | ^ lifetime `'a` required -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0621`. diff --git a/tests/ui/lint/elided-named-lifetimes/example-from-issue48686.rs b/tests/ui/lifetimes/mismatched-lifetime-syntaxes-details/example-from-issue48686.rs index eac7c32a9aa..1804003d367 100644 --- a/tests/ui/lint/elided-named-lifetimes/example-from-issue48686.rs +++ b/tests/ui/lifetimes/mismatched-lifetime-syntaxes-details/example-from-issue48686.rs @@ -1,10 +1,10 @@ -#![deny(elided_named_lifetimes)] +#![deny(mismatched_lifetime_syntaxes)] struct Foo; impl Foo { pub fn get_mut(&'static self, x: &mut u8) -> &mut u8 { - //~^ ERROR elided lifetime has a name + //~^ ERROR lifetime flowing from input to output with different syntax unsafe { &mut *(x as *mut _) } } } diff --git a/tests/ui/lifetimes/mismatched-lifetime-syntaxes-details/example-from-issue48686.stderr b/tests/ui/lifetimes/mismatched-lifetime-syntaxes-details/example-from-issue48686.stderr new file mode 100644 index 00000000000..7c7411651d0 --- /dev/null +++ b/tests/ui/lifetimes/mismatched-lifetime-syntaxes-details/example-from-issue48686.stderr @@ -0,0 +1,20 @@ +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/example-from-issue48686.rs:6:21 + | +LL | pub fn get_mut(&'static self, x: &mut u8) -> &mut u8 { + | ^^^^^^^ ------- the lifetime gets resolved as `'static` + | | + | this lifetime flows to the output + | +note: the lint level is defined here + --> $DIR/example-from-issue48686.rs:1:9 + | +LL | #![deny(mismatched_lifetime_syntaxes)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: one option is to consistently use `'static` + | +LL | pub fn get_mut(&'static self, x: &mut u8) -> &'static mut u8 { + | +++++++ + +error: aborting due to 1 previous error + diff --git a/tests/ui/lifetimes/mismatched-lifetime-syntaxes-details/missing-lifetime-kind.rs b/tests/ui/lifetimes/mismatched-lifetime-syntaxes-details/missing-lifetime-kind.rs new file mode 100644 index 00000000000..3d5aab5c829 --- /dev/null +++ b/tests/ui/lifetimes/mismatched-lifetime-syntaxes-details/missing-lifetime-kind.rs @@ -0,0 +1,27 @@ +#![deny(mismatched_lifetime_syntaxes)] + +fn ampersand<'a>(x: &'a u8) -> &u8 { + //~^ ERROR lifetime flowing from input to output with different syntax + x +} + +struct Brackets<'a>(&'a u8); + +fn brackets<'a>(x: &'a u8) -> Brackets { + //~^ ERROR lifetime flowing from input to output with different syntax + Brackets(x) +} + +struct Comma<'a, T>(&'a T); + +fn comma<'a>(x: &'a u8) -> Comma<u8> { + //~^ ERROR lifetime flowing from input to output with different syntax + Comma(x) +} + +fn underscore<'a>(x: &'a u8) -> &'_ u8 { + //~^ ERROR lifetime flowing from input to output with different syntax + x +} + +fn main() {} diff --git a/tests/ui/lifetimes/mismatched-lifetime-syntaxes-details/missing-lifetime-kind.stderr b/tests/ui/lifetimes/mismatched-lifetime-syntaxes-details/missing-lifetime-kind.stderr new file mode 100644 index 00000000000..681b3c97052 --- /dev/null +++ b/tests/ui/lifetimes/mismatched-lifetime-syntaxes-details/missing-lifetime-kind.stderr @@ -0,0 +1,60 @@ +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/missing-lifetime-kind.rs:3:22 + | +LL | fn ampersand<'a>(x: &'a u8) -> &u8 { + | ^^ --- the lifetime gets resolved as `'a` + | | + | this lifetime flows to the output + | +note: the lint level is defined here + --> $DIR/missing-lifetime-kind.rs:1:9 + | +LL | #![deny(mismatched_lifetime_syntaxes)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: one option is to consistently use `'a` + | +LL | fn ampersand<'a>(x: &'a u8) -> &'a u8 { + | ++ + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/missing-lifetime-kind.rs:10:21 + | +LL | fn brackets<'a>(x: &'a u8) -> Brackets { + | ^^ -------- the lifetime gets resolved as `'a` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'a` + | +LL | fn brackets<'a>(x: &'a u8) -> Brackets<'a> { + | ++++ + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/missing-lifetime-kind.rs:17:18 + | +LL | fn comma<'a>(x: &'a u8) -> Comma<u8> { + | ^^ --------- the lifetime gets resolved as `'a` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'a` + | +LL | fn comma<'a>(x: &'a u8) -> Comma<'a, u8> { + | +++ + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/missing-lifetime-kind.rs:22:23 + | +LL | fn underscore<'a>(x: &'a u8) -> &'_ u8 { + | ^^ -- the lifetime gets resolved as `'a` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'a` + | +LL - fn underscore<'a>(x: &'a u8) -> &'_ u8 { +LL + fn underscore<'a>(x: &'a u8) -> &'a u8 { + | + +error: aborting due to 4 previous errors + diff --git a/tests/ui/lifetimes/mismatched-lifetime-syntaxes-details/not-tied-to-crate.rs b/tests/ui/lifetimes/mismatched-lifetime-syntaxes-details/not-tied-to-crate.rs new file mode 100644 index 00000000000..cc398ab7888 --- /dev/null +++ b/tests/ui/lifetimes/mismatched-lifetime-syntaxes-details/not-tied-to-crate.rs @@ -0,0 +1,20 @@ +#![allow(mismatched_lifetime_syntaxes)] + +//! Ensure that the lint level of `mismatched_lifetime_syntaxes` can +//! be adjusted by attributes not applied at the crate-level. + +#[warn(mismatched_lifetime_syntaxes)] +mod foo { + fn bar(x: &'static u8) -> &u8 { + //~^ WARNING lifetime flowing from input to output with different syntax + x + } + + #[deny(mismatched_lifetime_syntaxes)] + fn baz(x: &'static u8) -> &u8 { + //~^ ERROR lifetime flowing from input to output with different syntax + x + } +} + +fn main() {} diff --git a/tests/ui/lifetimes/mismatched-lifetime-syntaxes-details/not-tied-to-crate.stderr b/tests/ui/lifetimes/mismatched-lifetime-syntaxes-details/not-tied-to-crate.stderr new file mode 100644 index 00000000000..da691225c17 --- /dev/null +++ b/tests/ui/lifetimes/mismatched-lifetime-syntaxes-details/not-tied-to-crate.stderr @@ -0,0 +1,38 @@ +warning: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/not-tied-to-crate.rs:8:16 + | +LL | fn bar(x: &'static u8) -> &u8 { + | ^^^^^^^ --- the lifetime gets resolved as `'static` + | | + | this lifetime flows to the output + | +note: the lint level is defined here + --> $DIR/not-tied-to-crate.rs:6:8 + | +LL | #[warn(mismatched_lifetime_syntaxes)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: one option is to consistently use `'static` + | +LL | fn bar(x: &'static u8) -> &'static u8 { + | +++++++ + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/not-tied-to-crate.rs:14:16 + | +LL | fn baz(x: &'static u8) -> &u8 { + | ^^^^^^^ --- the lifetime gets resolved as `'static` + | | + | this lifetime flows to the output + | +note: the lint level is defined here + --> $DIR/not-tied-to-crate.rs:13:12 + | +LL | #[deny(mismatched_lifetime_syntaxes)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: one option is to consistently use `'static` + | +LL | fn baz(x: &'static u8) -> &'static u8 { + | +++++++ + +error: aborting due to 1 previous error; 1 warning emitted + diff --git a/tests/ui/lint/elided-named-lifetimes/static.rs b/tests/ui/lifetimes/mismatched-lifetime-syntaxes-details/static.rs index dc8222c6e6e..47ae258f138 100644 --- a/tests/ui/lint/elided-named-lifetimes/static.rs +++ b/tests/ui/lifetimes/mismatched-lifetime-syntaxes-details/static.rs @@ -1,4 +1,4 @@ -#![deny(elided_named_lifetimes)] +#![deny(mismatched_lifetime_syntaxes)] use std::borrow::Cow; @@ -14,26 +14,26 @@ impl Trait for () { } fn ampersand(x: &'static u8) -> &u8 { - //~^ ERROR elided lifetime has a name + //~^ ERROR lifetime flowing from input to output with different syntax x } struct Brackets<'a>(&'a u8); fn brackets(x: &'static u8) -> Brackets { - //~^ ERROR elided lifetime has a name + //~^ ERROR lifetime flowing from input to output with different syntax Brackets(x) } struct Comma<'a, T>(&'a T); fn comma(x: &'static u8) -> Comma<u8> { - //~^ ERROR elided lifetime has a name + //~^ ERROR lifetime flowing from input to output with different syntax Comma(x) } fn underscore(x: &'static u8) -> &'_ u8 { - //~^ ERROR elided lifetime has a name + //~^ ERROR lifetime flowing from input to output with different syntax x } diff --git a/tests/ui/lifetimes/mismatched-lifetime-syntaxes-details/static.stderr b/tests/ui/lifetimes/mismatched-lifetime-syntaxes-details/static.stderr new file mode 100644 index 00000000000..5b9a986bcbe --- /dev/null +++ b/tests/ui/lifetimes/mismatched-lifetime-syntaxes-details/static.stderr @@ -0,0 +1,60 @@ +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/static.rs:16:18 + | +LL | fn ampersand(x: &'static u8) -> &u8 { + | ^^^^^^^ --- the lifetime gets resolved as `'static` + | | + | this lifetime flows to the output + | +note: the lint level is defined here + --> $DIR/static.rs:1:9 + | +LL | #![deny(mismatched_lifetime_syntaxes)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: one option is to consistently use `'static` + | +LL | fn ampersand(x: &'static u8) -> &'static u8 { + | +++++++ + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/static.rs:23:17 + | +LL | fn brackets(x: &'static u8) -> Brackets { + | ^^^^^^^ -------- the lifetime gets resolved as `'static` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'static` + | +LL | fn brackets(x: &'static u8) -> Brackets<'static> { + | +++++++++ + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/static.rs:30:14 + | +LL | fn comma(x: &'static u8) -> Comma<u8> { + | ^^^^^^^ --------- the lifetime gets resolved as `'static` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'static` + | +LL | fn comma(x: &'static u8) -> Comma<'static, u8> { + | ++++++++ + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/static.rs:35:19 + | +LL | fn underscore(x: &'static u8) -> &'_ u8 { + | ^^^^^^^ -- the lifetime gets resolved as `'static` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'static` + | +LL - fn underscore(x: &'static u8) -> &'_ u8 { +LL + fn underscore(x: &'static u8) -> &'static u8 { + | + +error: aborting due to 4 previous errors + diff --git a/tests/ui/lifetimes/mismatched-lifetime-syntaxes.rs b/tests/ui/lifetimes/mismatched-lifetime-syntaxes.rs new file mode 100644 index 00000000000..6d8487b99c6 --- /dev/null +++ b/tests/ui/lifetimes/mismatched-lifetime-syntaxes.rs @@ -0,0 +1,315 @@ +#![deny(mismatched_lifetime_syntaxes)] + +#[derive(Copy, Clone)] +struct ContainsLifetime<'a>(&'a u8); + +struct S(u8); + +fn explicit_bound_ref_to_implicit_ref<'a>(v: &'a u8) -> &u8 { + //~^ ERROR lifetime flowing from input to output with different syntax + v +} + +fn explicit_bound_ref_to_explicit_anonymous_ref<'a>(v: &'a u8) -> &'_ u8 { + //~^ ERROR lifetime flowing from input to output with different syntax + v +} + +// --- + +fn implicit_path_to_explicit_anonymous_path(v: ContainsLifetime) -> ContainsLifetime<'_> { + //~^ ERROR lifetime flowing from input to output with different syntax + v +} + +fn explicit_anonymous_path_to_implicit_path(v: ContainsLifetime<'_>) -> ContainsLifetime { + //~^ ERROR lifetime flowing from input to output with different syntax + v +} + +fn explicit_bound_path_to_implicit_path<'a>(v: ContainsLifetime<'a>) -> ContainsLifetime { + //~^ ERROR lifetime flowing from input to output with different syntax + v +} + +fn explicit_bound_path_to_explicit_anonymous_path<'a>( + v: ContainsLifetime<'a>, + //~^ ERROR lifetime flowing from input to output with different syntax +) -> ContainsLifetime<'_> { + v +} + +// --- + +fn implicit_ref_to_implicit_path(v: &u8) -> ContainsLifetime { + //~^ ERROR lifetime flowing from input to output with different syntax + ContainsLifetime(v) +} + +fn explicit_anonymous_ref_to_implicit_path(v: &'_ u8) -> ContainsLifetime { + //~^ ERROR lifetime flowing from input to output with different syntax + ContainsLifetime(v) +} + +fn explicit_bound_ref_to_implicit_path<'a>(v: &'a u8) -> ContainsLifetime { + //~^ ERROR lifetime flowing from input to output with different syntax + ContainsLifetime(v) +} + +fn explicit_bound_ref_to_explicit_anonymous_path<'a>(v: &'a u8) -> ContainsLifetime<'_> { + //~^ ERROR lifetime flowing from input to output with different syntax + ContainsLifetime(v) +} + +// --- + +fn implicit_path_to_implicit_ref(v: ContainsLifetime) -> &u8 { + //~^ ERROR lifetime flowing from input to output with different syntax + v.0 +} + +fn implicit_path_to_explicit_anonymous_ref(v: ContainsLifetime) -> &'_ u8 { + //~^ ERROR lifetime flowing from input to output with different syntax + v.0 +} + +fn explicit_bound_path_to_implicit_ref<'a>(v: ContainsLifetime<'a>) -> &u8 { + //~^ ERROR lifetime flowing from input to output with different syntax + v.0 +} + +fn explicit_bound_path_to_explicit_anonymous_ref<'a>(v: ContainsLifetime<'a>) -> &'_ u8 { + //~^ ERROR lifetime flowing from input to output with different syntax + v.0 +} + +impl S { + fn method_explicit_bound_ref_to_implicit_ref<'a>(&'a self) -> &u8 { + //~^ ERROR lifetime flowing from input to output with different syntax + &self.0 + } + + fn method_explicit_bound_ref_to_explicit_anonymous_ref<'a>(&'a self) -> &'_ u8 { + //~^ ERROR lifetime flowing from input to output with different syntax + &self.0 + } + + // --- + + fn method_explicit_anonymous_ref_to_implicit_path(&'_ self) -> ContainsLifetime { + //~^ ERROR lifetime flowing from input to output with different syntax + ContainsLifetime(&self.0) + } + + fn method_explicit_bound_ref_to_implicit_path<'a>(&'a self) -> ContainsLifetime { + //~^ ERROR lifetime flowing from input to output with different syntax + ContainsLifetime(&self.0) + } + + fn method_explicit_bound_ref_to_explicit_anonymous_path<'a>(&'a self) -> ContainsLifetime<'_> { + //~^ ERROR lifetime flowing from input to output with different syntax + ContainsLifetime(&self.0) + } +} + +// If a function uses the `'static` lifetime, we should not suggest +// replacing it with an explicitly anonymous or implicit +// lifetime. Only suggest using `'static` everywhere. +mod static_suggestions { + #[derive(Copy, Clone)] + struct ContainsLifetime<'a>(&'a u8); + + struct S(u8); + + fn static_ref_to_implicit_ref(v: &'static u8) -> &u8 { + //~^ ERROR lifetime flowing from input to output with different syntax + v + } + + fn static_ref_to_explicit_anonymous_ref(v: &'static u8) -> &'_ u8 { + //~^ ERROR lifetime flowing from input to output with different syntax + v + } + + fn static_ref_to_implicit_path(v: &'static u8) -> ContainsLifetime { + //~^ ERROR lifetime flowing from input to output with different syntax + ContainsLifetime(v) + } + + fn static_ref_to_explicit_anonymous_path(v: &'static u8) -> ContainsLifetime<'_> { + //~^ ERROR lifetime flowing from input to output with different syntax + ContainsLifetime(v) + } + + impl S { + fn static_ref_to_implicit_ref(&'static self) -> &u8 { + //~^ ERROR lifetime flowing from input to output with different syntax + &self.0 + } + + fn static_ref_to_explicit_anonymous_ref(&'static self) -> &'_ u8 { + //~^ ERROR lifetime flowing from input to output with different syntax + &self.0 + } + + fn static_ref_to_implicit_path(&'static self) -> ContainsLifetime { + //~^ ERROR lifetime flowing from input to output with different syntax + ContainsLifetime(&self.0) + } + + fn static_ref_to_explicit_anonymous_path(&'static self) -> ContainsLifetime<'_> { + //~^ ERROR lifetime flowing from input to output with different syntax + ContainsLifetime(&self.0) + } + } +} + +/// `impl Trait` uses lifetimes in some additional ways. +mod impl_trait { + #[derive(Copy, Clone)] + struct ContainsLifetime<'a>(&'a u8); + + fn explicit_bound_ref_to_impl_trait_bound<'a>(v: &'a u8) -> impl FnOnce() + '_ { + //~^ ERROR lifetime flowing from input to output with different syntax + move || _ = v + } + + fn explicit_bound_ref_to_impl_trait_precise_capture<'a>(v: &'a u8) -> impl FnOnce() + use<'_> { + //~^ ERROR lifetime flowing from input to output with different syntax + move || _ = v + } + + fn explicit_bound_path_to_impl_trait_bound<'a>(v: ContainsLifetime<'a>) -> impl FnOnce() + '_ { + //~^ ERROR lifetime flowing from input to output with different syntax + move || _ = v + } + + fn explicit_bound_path_to_impl_trait_precise_capture<'a>( + v: ContainsLifetime<'a>, + //~^ ERROR lifetime flowing from input to output with different syntax + ) -> impl FnOnce() + use<'_> { + move || _ = v + } +} + +/// `dyn Trait` uses lifetimes in some additional ways. +mod dyn_trait { + use std::iter; + + #[derive(Copy, Clone)] + struct ContainsLifetime<'a>(&'a u8); + + fn explicit_bound_ref_to_dyn_trait_bound<'a>(v: &'a u8) -> Box<dyn Iterator<Item = &u8> + '_> { + //~^ ERROR lifetime flowing from input to output with different syntax + Box::new(iter::once(v)) + } + + fn explicit_bound_path_to_dyn_trait_bound<'a>( + v: ContainsLifetime<'a>, + //~^ ERROR lifetime flowing from input to output with different syntax + ) -> Box<dyn Iterator<Item = ContainsLifetime> + '_> { + Box::new(iter::once(v)) + } +} + +/// These tests serve to exercise edge cases of the lint formatting +mod diagnostic_output { + fn multiple_outputs<'a>(v: &'a u8) -> (&u8, &u8) { + //~^ ERROR lifetime flowing from input to output with different syntax + (v, v) + } +} + +/// These usages are expected to **not** trigger the lint +mod acceptable_uses { + #[derive(Copy, Clone)] + struct ContainsLifetime<'a>(&'a u8); + + struct S(u8); + + fn implicit_ref_to_implicit_ref(v: &u8) -> &u8 { + v + } + + fn explicit_anonymous_ref_to_explicit_anonymous_ref(v: &'_ u8) -> &'_ u8 { + v + } + + fn explicit_bound_ref_to_explicit_bound_ref<'a>(v: &'a u8) -> &'a u8 { + v + } + + fn implicit_path_to_implicit_path(v: ContainsLifetime) -> ContainsLifetime { + v + } + + fn explicit_anonymous_path_to_explicit_anonymous_path( + v: ContainsLifetime<'_>, + ) -> ContainsLifetime<'_> { + v + } + + fn explicit_bound_path_to_explicit_bound_path<'a>( + v: ContainsLifetime<'a>, + ) -> ContainsLifetime<'a> { + v + } + + fn explicit_anonymous_ref_to_explicit_anonymous_path(v: &'_ u8) -> ContainsLifetime<'_> { + ContainsLifetime(v) + } + + fn explicit_bound_ref_to_explicit_bound_path<'a>(v: &'a u8) -> ContainsLifetime<'a> { + ContainsLifetime(v) + } + + fn explicit_anonymous_path_to_explicit_anonymous_ref(v: ContainsLifetime<'_>) -> &'_ u8 { + v.0 + } + + fn explicit_bound_path_to_explicit_bound_ref<'a>(v: ContainsLifetime<'a>) -> &'a u8 { + v.0 + } + + // These may be surprising, but ampersands count as enough of a + // visual indicator that a reference exists that we treat + // references with implicit lifetimes the same as if they were + // explicitly anonymous. + fn implicit_ref_to_explicit_anonymous_ref(v: &u8) -> &'_ u8 { + v + } + + fn explicit_anonymous_ref_to_implicit_ref(v: &'_ u8) -> &u8 { + v + } + + fn implicit_ref_to_explicit_anonymous_path(v: &u8) -> ContainsLifetime<'_> { + ContainsLifetime(v) + } + + fn explicit_anonymous_path_to_implicit_ref(v: ContainsLifetime<'_>) -> &u8 { + v.0 + } + + impl S { + fn method_implicit_ref_to_explicit_anonymous_ref(&self) -> &'_ u8 { + &self.0 + } + + fn method_explicit_anonymous_ref_to_implicit_ref(&'_ self) -> &u8 { + &self.0 + } + + fn method_implicit_ref_to_explicit_anonymous_path(&self) -> ContainsLifetime<'_> { + ContainsLifetime(&self.0) + } + } + + // `dyn Trait` has an "embedded" lifetime that we should **not** + // lint about. + fn dyn_trait_does_not_have_a_lifetime_generic(v: &u8) -> &dyn core::fmt::Debug { + v + } +} + +fn main() {} diff --git a/tests/ui/lifetimes/mismatched-lifetime-syntaxes.stderr b/tests/ui/lifetimes/mismatched-lifetime-syntaxes.stderr new file mode 100644 index 00000000000..0ec16a266b6 --- /dev/null +++ b/tests/ui/lifetimes/mismatched-lifetime-syntaxes.stderr @@ -0,0 +1,473 @@ +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:8:47 + | +LL | fn explicit_bound_ref_to_implicit_ref<'a>(v: &'a u8) -> &u8 { + | ^^ --- the lifetime gets resolved as `'a` + | | + | this lifetime flows to the output + | +note: the lint level is defined here + --> $DIR/mismatched-lifetime-syntaxes.rs:1:9 + | +LL | #![deny(mismatched_lifetime_syntaxes)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: one option is to consistently use `'a` + | +LL | fn explicit_bound_ref_to_implicit_ref<'a>(v: &'a u8) -> &'a u8 { + | ++ + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:13:57 + | +LL | fn explicit_bound_ref_to_explicit_anonymous_ref<'a>(v: &'a u8) -> &'_ u8 { + | ^^ -- the lifetime gets resolved as `'a` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'a` + | +LL - fn explicit_bound_ref_to_explicit_anonymous_ref<'a>(v: &'a u8) -> &'_ u8 { +LL + fn explicit_bound_ref_to_explicit_anonymous_ref<'a>(v: &'a u8) -> &'a u8 { + | + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:20:48 + | +LL | fn implicit_path_to_explicit_anonymous_path(v: ContainsLifetime) -> ContainsLifetime<'_> { + | ^^^^^^^^^^^^^^^^ -- the lifetime gets resolved as `'_` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'_` + | +LL | fn implicit_path_to_explicit_anonymous_path(v: ContainsLifetime<'_>) -> ContainsLifetime<'_> { + | ++++ + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:25:65 + | +LL | fn explicit_anonymous_path_to_implicit_path(v: ContainsLifetime<'_>) -> ContainsLifetime { + | ^^ ---------------- the lifetime gets resolved as `'_` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'_` + | +LL | fn explicit_anonymous_path_to_implicit_path(v: ContainsLifetime<'_>) -> ContainsLifetime<'_> { + | ++++ + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:30:65 + | +LL | fn explicit_bound_path_to_implicit_path<'a>(v: ContainsLifetime<'a>) -> ContainsLifetime { + | ^^ ---------------- the lifetime gets resolved as `'a` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'a` + | +LL | fn explicit_bound_path_to_implicit_path<'a>(v: ContainsLifetime<'a>) -> ContainsLifetime<'a> { + | ++++ + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:36:25 + | +LL | v: ContainsLifetime<'a>, + | ^^ this lifetime flows to the output +LL | +LL | ) -> ContainsLifetime<'_> { + | -- the lifetime gets resolved as `'a` + | +help: one option is to consistently use `'a` + | +LL - ) -> ContainsLifetime<'_> { +LL + ) -> ContainsLifetime<'a> { + | + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:44:37 + | +LL | fn implicit_ref_to_implicit_path(v: &u8) -> ContainsLifetime { + | ^^^ ---------------- the lifetime gets resolved as `'_` + | | + | this lifetime flows to the output + | +help: one option is to remove the lifetime for references and use the anonymous lifetime for paths + | +LL | fn implicit_ref_to_implicit_path(v: &u8) -> ContainsLifetime<'_> { + | ++++ + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:49:48 + | +LL | fn explicit_anonymous_ref_to_implicit_path(v: &'_ u8) -> ContainsLifetime { + | ^^ ---------------- the lifetime gets resolved as `'_` + | | + | this lifetime flows to the output + | +help: one option is to remove the lifetime for references and use the anonymous lifetime for paths + | +LL - fn explicit_anonymous_ref_to_implicit_path(v: &'_ u8) -> ContainsLifetime { +LL + fn explicit_anonymous_ref_to_implicit_path(v: &u8) -> ContainsLifetime<'_> { + | + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:54:48 + | +LL | fn explicit_bound_ref_to_implicit_path<'a>(v: &'a u8) -> ContainsLifetime { + | ^^ ---------------- the lifetime gets resolved as `'a` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'a` + | +LL | fn explicit_bound_ref_to_implicit_path<'a>(v: &'a u8) -> ContainsLifetime<'a> { + | ++++ + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:59:58 + | +LL | fn explicit_bound_ref_to_explicit_anonymous_path<'a>(v: &'a u8) -> ContainsLifetime<'_> { + | ^^ -- the lifetime gets resolved as `'a` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'a` + | +LL - fn explicit_bound_ref_to_explicit_anonymous_path<'a>(v: &'a u8) -> ContainsLifetime<'_> { +LL + fn explicit_bound_ref_to_explicit_anonymous_path<'a>(v: &'a u8) -> ContainsLifetime<'a> { + | + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:66:37 + | +LL | fn implicit_path_to_implicit_ref(v: ContainsLifetime) -> &u8 { + | ^^^^^^^^^^^^^^^^ --- the lifetime gets resolved as `'_` + | | + | this lifetime flows to the output + | +help: one option is to remove the lifetime for references and use the anonymous lifetime for paths + | +LL | fn implicit_path_to_implicit_ref(v: ContainsLifetime<'_>) -> &u8 { + | ++++ + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:71:47 + | +LL | fn implicit_path_to_explicit_anonymous_ref(v: ContainsLifetime) -> &'_ u8 { + | ^^^^^^^^^^^^^^^^ -- the lifetime gets resolved as `'_` + | | + | this lifetime flows to the output + | +help: one option is to remove the lifetime for references and use the anonymous lifetime for paths + | +LL - fn implicit_path_to_explicit_anonymous_ref(v: ContainsLifetime) -> &'_ u8 { +LL + fn implicit_path_to_explicit_anonymous_ref(v: ContainsLifetime<'_>) -> &u8 { + | + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:76:64 + | +LL | fn explicit_bound_path_to_implicit_ref<'a>(v: ContainsLifetime<'a>) -> &u8 { + | ^^ --- the lifetime gets resolved as `'a` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'a` + | +LL | fn explicit_bound_path_to_implicit_ref<'a>(v: ContainsLifetime<'a>) -> &'a u8 { + | ++ + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:81:74 + | +LL | fn explicit_bound_path_to_explicit_anonymous_ref<'a>(v: ContainsLifetime<'a>) -> &'_ u8 { + | ^^ -- the lifetime gets resolved as `'a` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'a` + | +LL - fn explicit_bound_path_to_explicit_anonymous_ref<'a>(v: ContainsLifetime<'a>) -> &'_ u8 { +LL + fn explicit_bound_path_to_explicit_anonymous_ref<'a>(v: ContainsLifetime<'a>) -> &'a u8 { + | + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:87:55 + | +LL | fn method_explicit_bound_ref_to_implicit_ref<'a>(&'a self) -> &u8 { + | ^^ --- the lifetime gets resolved as `'a` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'a` + | +LL | fn method_explicit_bound_ref_to_implicit_ref<'a>(&'a self) -> &'a u8 { + | ++ + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:92:65 + | +LL | fn method_explicit_bound_ref_to_explicit_anonymous_ref<'a>(&'a self) -> &'_ u8 { + | ^^ -- the lifetime gets resolved as `'a` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'a` + | +LL - fn method_explicit_bound_ref_to_explicit_anonymous_ref<'a>(&'a self) -> &'_ u8 { +LL + fn method_explicit_bound_ref_to_explicit_anonymous_ref<'a>(&'a self) -> &'a u8 { + | + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:99:56 + | +LL | fn method_explicit_anonymous_ref_to_implicit_path(&'_ self) -> ContainsLifetime { + | ^^ ---------------- the lifetime gets resolved as `'_` + | | + | this lifetime flows to the output + | +help: one option is to remove the lifetime for references and use the anonymous lifetime for paths + | +LL - fn method_explicit_anonymous_ref_to_implicit_path(&'_ self) -> ContainsLifetime { +LL + fn method_explicit_anonymous_ref_to_implicit_path(&self) -> ContainsLifetime<'_> { + | + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:104:56 + | +LL | fn method_explicit_bound_ref_to_implicit_path<'a>(&'a self) -> ContainsLifetime { + | ^^ ---------------- the lifetime gets resolved as `'a` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'a` + | +LL | fn method_explicit_bound_ref_to_implicit_path<'a>(&'a self) -> ContainsLifetime<'a> { + | ++++ + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:109:66 + | +LL | fn method_explicit_bound_ref_to_explicit_anonymous_path<'a>(&'a self) -> ContainsLifetime<'_> { + | ^^ -- the lifetime gets resolved as `'a` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'a` + | +LL - fn method_explicit_bound_ref_to_explicit_anonymous_path<'a>(&'a self) -> ContainsLifetime<'_> { +LL + fn method_explicit_bound_ref_to_explicit_anonymous_path<'a>(&'a self) -> ContainsLifetime<'a> { + | + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:124:39 + | +LL | fn static_ref_to_implicit_ref(v: &'static u8) -> &u8 { + | ^^^^^^^ --- the lifetime gets resolved as `'static` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'static` + | +LL | fn static_ref_to_implicit_ref(v: &'static u8) -> &'static u8 { + | +++++++ + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:129:49 + | +LL | fn static_ref_to_explicit_anonymous_ref(v: &'static u8) -> &'_ u8 { + | ^^^^^^^ -- the lifetime gets resolved as `'static` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'static` + | +LL - fn static_ref_to_explicit_anonymous_ref(v: &'static u8) -> &'_ u8 { +LL + fn static_ref_to_explicit_anonymous_ref(v: &'static u8) -> &'static u8 { + | + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:134:40 + | +LL | fn static_ref_to_implicit_path(v: &'static u8) -> ContainsLifetime { + | ^^^^^^^ ---------------- the lifetime gets resolved as `'static` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'static` + | +LL | fn static_ref_to_implicit_path(v: &'static u8) -> ContainsLifetime<'static> { + | +++++++++ + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:139:50 + | +LL | fn static_ref_to_explicit_anonymous_path(v: &'static u8) -> ContainsLifetime<'_> { + | ^^^^^^^ -- the lifetime gets resolved as `'static` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'static` + | +LL - fn static_ref_to_explicit_anonymous_path(v: &'static u8) -> ContainsLifetime<'_> { +LL + fn static_ref_to_explicit_anonymous_path(v: &'static u8) -> ContainsLifetime<'static> { + | + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:145:40 + | +LL | fn static_ref_to_implicit_ref(&'static self) -> &u8 { + | ^^^^^^^ --- the lifetime gets resolved as `'static` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'static` + | +LL | fn static_ref_to_implicit_ref(&'static self) -> &'static u8 { + | +++++++ + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:150:50 + | +LL | fn static_ref_to_explicit_anonymous_ref(&'static self) -> &'_ u8 { + | ^^^^^^^ -- the lifetime gets resolved as `'static` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'static` + | +LL - fn static_ref_to_explicit_anonymous_ref(&'static self) -> &'_ u8 { +LL + fn static_ref_to_explicit_anonymous_ref(&'static self) -> &'static u8 { + | + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:155:41 + | +LL | fn static_ref_to_implicit_path(&'static self) -> ContainsLifetime { + | ^^^^^^^ ---------------- the lifetime gets resolved as `'static` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'static` + | +LL | fn static_ref_to_implicit_path(&'static self) -> ContainsLifetime<'static> { + | +++++++++ + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:160:51 + | +LL | fn static_ref_to_explicit_anonymous_path(&'static self) -> ContainsLifetime<'_> { + | ^^^^^^^ -- the lifetime gets resolved as `'static` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'static` + | +LL - fn static_ref_to_explicit_anonymous_path(&'static self) -> ContainsLifetime<'_> { +LL + fn static_ref_to_explicit_anonymous_path(&'static self) -> ContainsLifetime<'static> { + | + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:172:55 + | +LL | fn explicit_bound_ref_to_impl_trait_bound<'a>(v: &'a u8) -> impl FnOnce() + '_ { + | ^^ -- the lifetime gets resolved as `'a` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'a` + | +LL - fn explicit_bound_ref_to_impl_trait_bound<'a>(v: &'a u8) -> impl FnOnce() + '_ { +LL + fn explicit_bound_ref_to_impl_trait_bound<'a>(v: &'a u8) -> impl FnOnce() + 'a { + | + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:177:65 + | +LL | fn explicit_bound_ref_to_impl_trait_precise_capture<'a>(v: &'a u8) -> impl FnOnce() + use<'_> { + | ^^ -- the lifetime gets resolved as `'a` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'a` + | +LL - fn explicit_bound_ref_to_impl_trait_precise_capture<'a>(v: &'a u8) -> impl FnOnce() + use<'_> { +LL + fn explicit_bound_ref_to_impl_trait_precise_capture<'a>(v: &'a u8) -> impl FnOnce() + use<'a> { + | + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:182:72 + | +LL | fn explicit_bound_path_to_impl_trait_bound<'a>(v: ContainsLifetime<'a>) -> impl FnOnce() + '_ { + | ^^ -- the lifetime gets resolved as `'a` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'a` + | +LL - fn explicit_bound_path_to_impl_trait_bound<'a>(v: ContainsLifetime<'a>) -> impl FnOnce() + '_ { +LL + fn explicit_bound_path_to_impl_trait_bound<'a>(v: ContainsLifetime<'a>) -> impl FnOnce() + 'a { + | + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:188:29 + | +LL | v: ContainsLifetime<'a>, + | ^^ this lifetime flows to the output +LL | +LL | ) -> impl FnOnce() + use<'_> { + | -- the lifetime gets resolved as `'a` + | +help: one option is to consistently use `'a` + | +LL - ) -> impl FnOnce() + use<'_> { +LL + ) -> impl FnOnce() + use<'a> { + | + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:202:54 + | +LL | fn explicit_bound_ref_to_dyn_trait_bound<'a>(v: &'a u8) -> Box<dyn Iterator<Item = &u8> + '_> { + | ^^ --- -- the lifetimes get resolved as `'a` + | | | + | | the lifetimes get resolved as `'a` + | this lifetime flows to the output + | +help: one option is to consistently use `'a` + | +LL | fn explicit_bound_ref_to_dyn_trait_bound<'a>(v: &'a u8) -> Box<dyn Iterator<Item = &'a u8> + '_> { + | ++ + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:208:29 + | +LL | v: ContainsLifetime<'a>, + | ^^ this lifetime flows to the output +LL | +LL | ) -> Box<dyn Iterator<Item = ContainsLifetime> + '_> { + | ---------------- -- the lifetimes get resolved as `'a` + | | + | the lifetimes get resolved as `'a` + | +help: one option is to consistently use `'a` + | +LL | ) -> Box<dyn Iterator<Item = ContainsLifetime<'a>> + '_> { + | ++++ + +error: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/mismatched-lifetime-syntaxes.rs:217:33 + | +LL | fn multiple_outputs<'a>(v: &'a u8) -> (&u8, &u8) { + | ^^ --- --- the lifetimes get resolved as `'a` + | | | + | | the lifetimes get resolved as `'a` + | this lifetime flows to the output + | +help: one option is to consistently use `'a` + | +LL | fn multiple_outputs<'a>(v: &'a u8) -> (&'a u8, &'a u8) { + | ++ ++ + +error: aborting due to 34 previous errors + diff --git a/tests/ui/cleanup-shortcircuit.rs b/tests/ui/lifetimes/rvalue-cleanup-shortcircuit.rs index 40a5dfa94e3..dba899585c4 100644 --- a/tests/ui/cleanup-shortcircuit.rs +++ b/tests/ui/lifetimes/rvalue-cleanup-shortcircuit.rs @@ -1,10 +1,9 @@ -//@ run-pass -// Test that cleanups for the RHS of shortcircuiting operators work. +//! Test that cleanups for the RHS of shortcircuiting operators work. +//@ run-pass #![allow(deref_nullptr)] - use std::env; pub fn main() { @@ -18,6 +17,8 @@ pub fn main() { if args.len() >= 2 && args[1] == "signal" { // Raise a segfault. - unsafe { *std::ptr::null_mut::<isize>() = 0; } + unsafe { + *std::ptr::null_mut::<isize>() = 0; + } } } diff --git a/tests/ui/lifetimes/rvalue-lifetime-drop-timing.rs b/tests/ui/lifetimes/rvalue-lifetime-drop-timing.rs new file mode 100644 index 00000000000..9e7b84bfccf --- /dev/null +++ b/tests/ui/lifetimes/rvalue-lifetime-drop-timing.rs @@ -0,0 +1,104 @@ +//! Test that destructors for temporaries run either at end of +//! statement or end of block as appropriate. + +//@ run-pass + +#![feature(box_patterns)] + +static mut FLAGS: u64 = 0; + +struct Box<T> { + f: T, +} + +struct AddFlags { + bits: u64, +} + +fn add_flags(bits: u64) -> AddFlags { + AddFlags { bits } +} + +fn arg(expected: u64, _x: &AddFlags) { + check_flags(expected); +} + +fn pass<T>(v: T) -> T { + v +} + +fn check_flags(expected: u64) { + unsafe { + let actual = FLAGS; + FLAGS = 0; + assert_eq!(actual, expected, "flags {}, expected {}", actual, expected); + } +} + +impl AddFlags { + fn check_flags(&self, expected: u64) -> &AddFlags { + check_flags(expected); + self + } + + fn bits(&self) -> u64 { + self.bits + } +} + +impl Drop for AddFlags { + fn drop(&mut self) { + unsafe { + FLAGS += self.bits; + } + } +} + +macro_rules! end_of_block { + ($pat:pat, $expr:expr) => {{ + { + let $pat = $expr; + check_flags(0); + } + check_flags(1); + }}; +} + +macro_rules! end_of_stmt { + ($pat:pat, $expr:expr) => {{ + { + let $pat = $expr; + check_flags(1); + } + check_flags(0); + }}; +} + +fn main() { + end_of_block!(_x, add_flags(1)); + end_of_block!(_x, &add_flags(1)); + end_of_block!(_x, &&add_flags(1)); + end_of_block!(_x, Box { f: add_flags(1) }); + end_of_block!(_x, Box { f: &add_flags(1) }); + end_of_block!(_x, pass(add_flags(1))); + end_of_block!(ref _x, add_flags(1)); + end_of_block!(AddFlags { bits: ref _x }, add_flags(1)); + end_of_block!(&AddFlags { bits: _ }, &add_flags(1)); + end_of_block!((_, ref _y), (add_flags(1), 22)); + end_of_block!(box ref _x, std::boxed::Box::new(add_flags(1))); + end_of_block!(box _x, std::boxed::Box::new(add_flags(1))); + end_of_block!(_, { + { + check_flags(0); + &add_flags(1) + } + }); + end_of_block!(_, &((Box { f: add_flags(1) }).f)); + end_of_block!(_, &(([add_flags(1)])[0])); + + end_of_stmt!(_, add_flags(1)); + end_of_stmt!((_, _), (add_flags(1), 22)); + end_of_stmt!(ref _x, arg(0, &add_flags(1))); + end_of_stmt!(ref _x, add_flags(1).check_flags(0).bits()); + end_of_stmt!(AddFlags { bits: _ }, add_flags(1)); +} diff --git a/tests/ui/limits/huge-static.rs b/tests/ui/limits/huge-static.rs index 4c3641ac7d4..1473fd6054e 100644 --- a/tests/ui/limits/huge-static.rs +++ b/tests/ui/limits/huge-static.rs @@ -5,22 +5,19 @@ const HUGE_SIZE: usize = 1 << 61; - pub struct TooBigArray { arr: [u8; HUGE_SIZE], } impl TooBigArray { pub const fn new() -> Self { - TooBigArray { arr: [0x00; HUGE_SIZE], } + TooBigArray { arr: [0x00; HUGE_SIZE] } } } static MY_TOO_BIG_ARRAY_1: TooBigArray = TooBigArray::new(); -//~^ ERROR could not evaluate static initializer -//~| NOTE too big +//~^ ERROR too big static MY_TOO_BIG_ARRAY_2: [u8; HUGE_SIZE] = [0x00; HUGE_SIZE]; -//~^ ERROR could not evaluate static initializer -//~| NOTE too big +//~^ ERROR too big -fn main() { } +fn main() {} diff --git a/tests/ui/limits/huge-static.stderr b/tests/ui/limits/huge-static.stderr index 684efeeb4a3..9073d7b03e9 100644 --- a/tests/ui/limits/huge-static.stderr +++ b/tests/ui/limits/huge-static.stderr @@ -1,14 +1,14 @@ -error[E0080]: could not evaluate static initializer - --> $DIR/huge-static.rs:19:1 +error[E0080]: values of the type `[u8; 2305843009213693952]` are too big for the target architecture + --> $DIR/huge-static.rs:18:1 | LL | static MY_TOO_BIG_ARRAY_1: TooBigArray = TooBigArray::new(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ values of the type `[u8; 2305843009213693952]` are too big for the target architecture + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `MY_TOO_BIG_ARRAY_1` failed here -error[E0080]: could not evaluate static initializer - --> $DIR/huge-static.rs:22:1 +error[E0080]: values of the type `[u8; 2305843009213693952]` are too big for the target architecture + --> $DIR/huge-static.rs:20:1 | LL | static MY_TOO_BIG_ARRAY_2: [u8; HUGE_SIZE] = [0x00; HUGE_SIZE]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ values of the type `[u8; 2305843009213693952]` are too big for the target architecture + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `MY_TOO_BIG_ARRAY_2` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/limits/issue-55878.rs b/tests/ui/limits/issue-55878.rs index 614ff328bf5..9e75f00a408 100644 --- a/tests/ui/limits/issue-55878.rs +++ b/tests/ui/limits/issue-55878.rs @@ -2,5 +2,5 @@ fn main() { println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); - //~^ ERROR evaluation of constant value failed + //~^ ERROR too big for the target architecture } diff --git a/tests/ui/limits/issue-55878.stderr b/tests/ui/limits/issue-55878.stderr index 9b3922d7933..a529efa2ad0 100644 --- a/tests/ui/limits/issue-55878.stderr +++ b/tests/ui/limits/issue-55878.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture --> $DIR/issue-55878.rs:4:26 | LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ values of the type `[u8; usize::MAX]` are too big for the target architecture + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main` failed inside this call | note: inside `std::mem::size_of::<[u8; usize::MAX]>` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL diff --git a/tests/ui/linkage-attr/raw-dylib/windows/unsupported-abi.rs b/tests/ui/linkage-attr/raw-dylib/windows/unsupported-abi.rs index 48af6b009d3..df69782e154 100644 --- a/tests/ui/linkage-attr/raw-dylib/windows/unsupported-abi.rs +++ b/tests/ui/linkage-attr/raw-dylib/windows/unsupported-abi.rs @@ -3,6 +3,8 @@ //@ compile-flags: --crate-type lib --emit link #[link(name = "foo", kind = "raw-dylib")] extern "stdcall" { +//~^ WARN: calling convention not supported on this target +//~| WARN: previously accepted fn f(x: i32); //~^ ERROR ABI not supported by `#[link(kind = "raw-dylib")]` on this architecture } diff --git a/tests/ui/linkage-attr/raw-dylib/windows/unsupported-abi.stderr b/tests/ui/linkage-attr/raw-dylib/windows/unsupported-abi.stderr index ef022404e7f..e7a32f4c84b 100644 --- a/tests/ui/linkage-attr/raw-dylib/windows/unsupported-abi.stderr +++ b/tests/ui/linkage-attr/raw-dylib/windows/unsupported-abi.stderr @@ -1,8 +1,41 @@ +warning: use of calling convention not supported on this target + --> $DIR/unsupported-abi.rs:5:1 + | +LL | / extern "stdcall" { +LL | | +LL | | +LL | | fn f(x: i32); +LL | | +LL | | } + | |_^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` + = note: `#[warn(unsupported_calling_conventions)]` on by default + error: ABI not supported by `#[link(kind = "raw-dylib")]` on this architecture - --> $DIR/unsupported-abi.rs:6:5 + --> $DIR/unsupported-abi.rs:8:5 | LL | fn f(x: i32); | ^^^^^^^^^^^^^ -error: aborting due to 1 previous error +error: aborting due to 1 previous error; 1 warning emitted + +Future incompatibility report: Future breakage diagnostic: +warning: use of calling convention not supported on this target + --> $DIR/unsupported-abi.rs:5:1 + | +LL | / extern "stdcall" { +LL | | +LL | | +LL | | fn f(x: i32); +LL | | +LL | | } + | |_^ + | + = 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 #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` + = note: `#[warn(unsupported_calling_conventions)]` on by default diff --git a/tests/ui/crate_type_flag.rs b/tests/ui/linking/crate-type-invalid-flag-error.rs index 03bea3638e1..3f84184c989 100644 --- a/tests/ui/crate_type_flag.rs +++ b/tests/ui/linking/crate-type-invalid-flag-error.rs @@ -1,3 +1,5 @@ +// Test for #70183 that --crate-type flag display valid value. + //@ compile-flags: --crate-type dynlib fn main() {} diff --git a/tests/ui/crate_type_flag.stderr b/tests/ui/linking/crate-type-invalid-flag-error.stderr index 26a3e1fbd68..26a3e1fbd68 100644 --- a/tests/ui/crate_type_flag.stderr +++ b/tests/ui/linking/crate-type-invalid-flag-error.stderr diff --git a/tests/ui/lint/bare-trait-objects-path.rs b/tests/ui/lint/bare-trait-objects-path.rs index 0e2294715cd..9643c48c9b8 100644 --- a/tests/ui/lint/bare-trait-objects-path.rs +++ b/tests/ui/lint/bare-trait-objects-path.rs @@ -1,3 +1,4 @@ +//@ edition: 2015 #![feature(associated_type_defaults)] trait Assoc { diff --git a/tests/ui/lint/bare-trait-objects-path.stderr b/tests/ui/lint/bare-trait-objects-path.stderr index fbb647c37c5..25f3e857806 100644 --- a/tests/ui/lint/bare-trait-objects-path.stderr +++ b/tests/ui/lint/bare-trait-objects-path.stderr @@ -1,5 +1,5 @@ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/bare-trait-objects-path.rs:14:5 + --> $DIR/bare-trait-objects-path.rs:15:5 | LL | Dyn::func(); | ^^^ @@ -13,7 +13,7 @@ LL | <dyn Dyn>::func(); | ++++ + warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/bare-trait-objects-path.rs:17:5 + --> $DIR/bare-trait-objects-path.rs:18:5 | LL | ::Dyn::func(); | ^^^^^ @@ -26,7 +26,7 @@ LL | <dyn (::Dyn)>::func(); | ++++++ ++ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/bare-trait-objects-path.rs:20:5 + --> $DIR/bare-trait-objects-path.rs:21:5 | LL | Dyn::CONST; | ^^^ @@ -39,7 +39,7 @@ LL | <dyn Dyn>::CONST; | ++++ + warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/bare-trait-objects-path.rs:23:12 + --> $DIR/bare-trait-objects-path.rs:24:12 | LL | let _: Dyn::Ty; | ^^^ @@ -52,10 +52,16 @@ LL | let _: <dyn Dyn>::Ty; | ++++ + error[E0223]: ambiguous associated type - --> $DIR/bare-trait-objects-path.rs:23:12 + --> $DIR/bare-trait-objects-path.rs:24:12 | LL | let _: Dyn::Ty; - | ^^^^^^^ help: use fully-qualified syntax: `<dyn Dyn as Assoc>::Ty` + | ^^^^^^^ + | +help: use fully-qualified syntax + | +LL - let _: Dyn::Ty; +LL + let _: <dyn Dyn as Assoc>::Ty; + | error: aborting due to 1 previous error; 4 warnings emitted diff --git a/tests/ui/lint/dead-code/alias-type-used-as-generic-arg-in-impl.rs b/tests/ui/lint/dead-code/alias-type-used-as-generic-arg-in-impl.rs new file mode 100644 index 00000000000..4857ef6a9b8 --- /dev/null +++ b/tests/ui/lint/dead-code/alias-type-used-as-generic-arg-in-impl.rs @@ -0,0 +1,19 @@ +//@ check-pass + +#![deny(dead_code)] + +struct T<X>(X); + +type A<X> = T<X>; + +trait Tr { + fn foo(); +} + +impl<X> Tr for T<A<X>> { + fn foo() {} +} + +fn main() { + T::<T<()>>::foo(); +} diff --git a/tests/ui/lint/dead-code/issue-41883.stderr b/tests/ui/lint/dead-code/issue-41883.stderr index 47ccef9a530..cf079e4dda3 100644 --- a/tests/ui/lint/dead-code/issue-41883.stderr +++ b/tests/ui/lint/dead-code/issue-41883.stderr @@ -29,6 +29,8 @@ error: struct `UnusedStruct` is never constructed | LL | struct UnusedStruct; | ^^^^^^^^^^^^ + | + = note: `UnusedStruct` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis error: aborting due to 4 previous errors diff --git a/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr b/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr index 25a7d96cb89..b992005318f 100644 --- a/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr +++ b/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr @@ -56,6 +56,8 @@ warning: struct `Foo` is never constructed | LL | struct Foo(usize, #[allow(unused)] usize); | ^^^ + | + = note: `Foo` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis error: aborting due to 2 previous errors; 2 warnings emitted diff --git a/tests/ui/lint/dead-code/trait-only-used-as-type-bound.rs b/tests/ui/lint/dead-code/trait-only-used-as-type-bound.rs new file mode 100644 index 00000000000..fb994653e1b --- /dev/null +++ b/tests/ui/lint/dead-code/trait-only-used-as-type-bound.rs @@ -0,0 +1,31 @@ +//@ check-pass + +#![deny(dead_code)] + +trait UInt: Copy + From<u8> {} + +impl UInt for u16 {} + +trait Int: Copy { + type Unsigned: UInt; + + fn as_unsigned(self) -> Self::Unsigned; +} + +impl Int for i16 { + type Unsigned = u16; + + fn as_unsigned(self) -> u16 { + self as _ + } +} + +fn priv_func<T: Int>(x: u8, y: T) -> (T::Unsigned, T::Unsigned) { + (T::Unsigned::from(x), y.as_unsigned()) +} + +pub fn pub_func(x: u8, y: i16) -> (u16, u16) { + priv_func(x, y) +} + +fn main() {} diff --git a/tests/ui/lint/elided-named-lifetimes/example-from-issue48686.stderr b/tests/ui/lint/elided-named-lifetimes/example-from-issue48686.stderr deleted file mode 100644 index 2d8c6e99643..00000000000 --- a/tests/ui/lint/elided-named-lifetimes/example-from-issue48686.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error: elided lifetime has a name - --> $DIR/example-from-issue48686.rs:6:50 - | -LL | pub fn get_mut(&'static self, x: &mut u8) -> &mut u8 { - | ^ this elided lifetime gets resolved as `'static` - | -note: the lint level is defined here - --> $DIR/example-from-issue48686.rs:1:9 - | -LL | #![deny(elided_named_lifetimes)] - | ^^^^^^^^^^^^^^^^^^^^^^ -help: consider specifying it explicitly - | -LL | pub fn get_mut(&'static self, x: &mut u8) -> &'static mut u8 { - | +++++++ - -error: aborting due to 1 previous error - diff --git a/tests/ui/lint/elided-named-lifetimes/missing-lifetime-kind.rs b/tests/ui/lint/elided-named-lifetimes/missing-lifetime-kind.rs deleted file mode 100644 index 2f9083ed65f..00000000000 --- a/tests/ui/lint/elided-named-lifetimes/missing-lifetime-kind.rs +++ /dev/null @@ -1,27 +0,0 @@ -#![deny(elided_named_lifetimes)] - -fn ampersand<'a>(x: &'a u8) -> &u8 { - //~^ ERROR elided lifetime has a name - x -} - -struct Brackets<'a>(&'a u8); - -fn brackets<'a>(x: &'a u8) -> Brackets { - //~^ ERROR elided lifetime has a name - Brackets(x) -} - -struct Comma<'a, T>(&'a T); - -fn comma<'a>(x: &'a u8) -> Comma<u8> { - //~^ ERROR elided lifetime has a name - Comma(x) -} - -fn underscore<'a>(x: &'a u8) -> &'_ u8 { - //~^ ERROR elided lifetime has a name - x -} - -fn main() {} diff --git a/tests/ui/lint/elided-named-lifetimes/missing-lifetime-kind.stderr b/tests/ui/lint/elided-named-lifetimes/missing-lifetime-kind.stderr deleted file mode 100644 index 249ae146b16..00000000000 --- a/tests/ui/lint/elided-named-lifetimes/missing-lifetime-kind.stderr +++ /dev/null @@ -1,40 +0,0 @@ -error: elided lifetime has a name - --> $DIR/missing-lifetime-kind.rs:3:32 - | -LL | fn ampersand<'a>(x: &'a u8) -> &u8 { - | -- ^ this elided lifetime gets resolved as `'a` - | | - | lifetime `'a` declared here - | -note: the lint level is defined here - --> $DIR/missing-lifetime-kind.rs:1:9 - | -LL | #![deny(elided_named_lifetimes)] - | ^^^^^^^^^^^^^^^^^^^^^^ - -error: elided lifetime has a name - --> $DIR/missing-lifetime-kind.rs:10:31 - | -LL | fn brackets<'a>(x: &'a u8) -> Brackets { - | -- ^^^^^^^^ this elided lifetime gets resolved as `'a` - | | - | lifetime `'a` declared here - -error: elided lifetime has a name - --> $DIR/missing-lifetime-kind.rs:17:33 - | -LL | fn comma<'a>(x: &'a u8) -> Comma<u8> { - | -- ^ this elided lifetime gets resolved as `'a` - | | - | lifetime `'a` declared here - -error: elided lifetime has a name - --> $DIR/missing-lifetime-kind.rs:22:34 - | -LL | fn underscore<'a>(x: &'a u8) -> &'_ u8 { - | -- ^^ this elided lifetime gets resolved as `'a` - | | - | lifetime `'a` declared here - -error: aborting due to 4 previous errors - diff --git a/tests/ui/lint/elided-named-lifetimes/not-tied-to-crate.rs b/tests/ui/lint/elided-named-lifetimes/not-tied-to-crate.rs deleted file mode 100644 index 4f9218130fb..00000000000 --- a/tests/ui/lint/elided-named-lifetimes/not-tied-to-crate.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![allow(elided_named_lifetimes)] - -#[warn(elided_named_lifetimes)] -mod foo { - fn bar(x: &'static u8) -> &u8 { - //~^ WARNING elided lifetime has a name - x - } - - #[deny(elided_named_lifetimes)] - fn baz(x: &'static u8) -> &u8 { - //~^ ERROR elided lifetime has a name - x - } -} - -fn main() {} diff --git a/tests/ui/lint/elided-named-lifetimes/not-tied-to-crate.stderr b/tests/ui/lint/elided-named-lifetimes/not-tied-to-crate.stderr deleted file mode 100644 index 3c01375d501..00000000000 --- a/tests/ui/lint/elided-named-lifetimes/not-tied-to-crate.stderr +++ /dev/null @@ -1,34 +0,0 @@ -warning: elided lifetime has a name - --> $DIR/not-tied-to-crate.rs:5:31 - | -LL | fn bar(x: &'static u8) -> &u8 { - | ^ this elided lifetime gets resolved as `'static` - | -note: the lint level is defined here - --> $DIR/not-tied-to-crate.rs:3:8 - | -LL | #[warn(elided_named_lifetimes)] - | ^^^^^^^^^^^^^^^^^^^^^^ -help: consider specifying it explicitly - | -LL | fn bar(x: &'static u8) -> &'static u8 { - | +++++++ - -error: elided lifetime has a name - --> $DIR/not-tied-to-crate.rs:11:31 - | -LL | fn baz(x: &'static u8) -> &u8 { - | ^ this elided lifetime gets resolved as `'static` - | -note: the lint level is defined here - --> $DIR/not-tied-to-crate.rs:10:12 - | -LL | #[deny(elided_named_lifetimes)] - | ^^^^^^^^^^^^^^^^^^^^^^ -help: consider specifying it explicitly - | -LL | fn baz(x: &'static u8) -> &'static u8 { - | +++++++ - -error: aborting due to 1 previous error; 1 warning emitted - diff --git a/tests/ui/lint/elided-named-lifetimes/static.stderr b/tests/ui/lint/elided-named-lifetimes/static.stderr deleted file mode 100644 index 7ad08dbf04b..00000000000 --- a/tests/ui/lint/elided-named-lifetimes/static.stderr +++ /dev/null @@ -1,52 +0,0 @@ -error: elided lifetime has a name - --> $DIR/static.rs:16:33 - | -LL | fn ampersand(x: &'static u8) -> &u8 { - | ^ this elided lifetime gets resolved as `'static` - | -note: the lint level is defined here - --> $DIR/static.rs:1:9 - | -LL | #![deny(elided_named_lifetimes)] - | ^^^^^^^^^^^^^^^^^^^^^^ -help: consider specifying it explicitly - | -LL | fn ampersand(x: &'static u8) -> &'static u8 { - | +++++++ - -error: elided lifetime has a name - --> $DIR/static.rs:23:32 - | -LL | fn brackets(x: &'static u8) -> Brackets { - | ^^^^^^^^ this elided lifetime gets resolved as `'static` - | -help: consider specifying it explicitly - | -LL | fn brackets(x: &'static u8) -> Brackets<'static> { - | +++++++++ - -error: elided lifetime has a name - --> $DIR/static.rs:30:34 - | -LL | fn comma(x: &'static u8) -> Comma<u8> { - | ^ this elided lifetime gets resolved as `'static` - | -help: consider specifying it explicitly - | -LL | fn comma(x: &'static u8) -> Comma<'static, u8> { - | ++++++++ - -error: elided lifetime has a name - --> $DIR/static.rs:35:35 - | -LL | fn underscore(x: &'static u8) -> &'_ u8 { - | ^^ this elided lifetime gets resolved as `'static` - | -help: consider specifying it explicitly - | -LL - fn underscore(x: &'static u8) -> &'_ u8 { -LL + fn underscore(x: &'static u8) -> &'static u8 { - | - -error: aborting due to 4 previous errors - diff --git a/tests/ui/lint/force-warn/ice-free.rs b/tests/ui/lint/force-warn/ice-free.rs new file mode 100644 index 00000000000..99b79f44648 --- /dev/null +++ b/tests/ui/lint/force-warn/ice-free.rs @@ -0,0 +1,9 @@ +//@ compile-flags: --force-warn pub_use_of_private_extern_crate +//@ check-pass + +extern crate core; +pub use core as reexported_core; +//~^ warning: extern crate `core` is private +//~| warning: this was previously accepted by the compiler + +fn main() {} diff --git a/tests/ui/lint/force-warn/ice-free.stderr b/tests/ui/lint/force-warn/ice-free.stderr new file mode 100644 index 00000000000..b64e3b138a2 --- /dev/null +++ b/tests/ui/lint/force-warn/ice-free.stderr @@ -0,0 +1,32 @@ +warning[E0365]: extern crate `core` is private and cannot be re-exported + --> $DIR/ice-free.rs:5:9 + | +LL | pub use core as reexported_core; + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #127909 <https://github.com/rust-lang/rust/issues/127909> + = note: requested on the command line with `--force-warn pub-use-of-private-extern-crate` +help: consider making the `extern crate` item publicly accessible + | +LL | pub extern crate core; + | +++ + +warning: 1 warning emitted + +For more information about this error, try `rustc --explain E0365`. +Future incompatibility report: Future breakage diagnostic: +warning[E0365]: extern crate `core` is private and cannot be re-exported + --> $DIR/ice-free.rs:5:9 + | +LL | pub use core as reexported_core; + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #127909 <https://github.com/rust-lang/rust/issues/127909> + = note: requested on the command line with `--force-warn pub-use-of-private-extern-crate` +help: consider making the `extern crate` item publicly accessible + | +LL | pub extern crate core; + | +++ + diff --git a/tests/ui/lint/implicit_autorefs.fixed b/tests/ui/lint/implicit_autorefs.fixed index 454dfe76372..7aa21e77458 100644 --- a/tests/ui/lint/implicit_autorefs.fixed +++ b/tests/ui/lint/implicit_autorefs.fixed @@ -1,4 +1,4 @@ -//@ check-pass +//@ check-fail //@ run-rustfix #![allow(dead_code)] // For the rustfix-ed code. @@ -8,7 +8,7 @@ use std::ops::Deref; unsafe fn test_const(ptr: *const [u8]) { let _ = (&(*ptr))[..16]; - //~^ WARN implicit autoref + //~^ ERROR implicit autoref } struct Test { @@ -17,36 +17,36 @@ struct Test { unsafe fn test_field(ptr: *const Test) -> *const [u8] { let l = (&(*ptr).field).len(); - //~^ WARN implicit autoref + //~^ ERROR implicit autoref &raw const (&(*ptr).field)[..l - 1] - //~^ WARN implicit autoref + //~^ ERROR implicit autoref } unsafe fn test_builtin_index(a: *mut [String]) { _ = (&(*a)[0]).len(); - //~^ WARN implicit autoref + //~^ ERROR implicit autoref _ = (&(&(*a))[..1][0]).len(); - //~^ WARN implicit autoref - //~^^ WARN implicit autoref + //~^ ERROR implicit autoref + //~^^ ERROR implicit autoref } unsafe fn test_overloaded_deref_const(ptr: *const ManuallyDrop<Test>) { let _ = (&(*ptr)).field; - //~^ WARN implicit autoref + //~^ ERROR implicit autoref let _ = &raw const (&(*ptr)).field; - //~^ WARN implicit autoref + //~^ ERROR implicit autoref } unsafe fn test_overloaded_deref_mut(ptr: *mut ManuallyDrop<Test>) { let _ = (&(*ptr)).field; - //~^ WARN implicit autoref + //~^ ERROR implicit autoref } unsafe fn test_double_overloaded_deref_const(ptr: *const ManuallyDrop<ManuallyDrop<Test>>) { let _ = (&(*ptr)).field; - //~^ WARN implicit autoref + //~^ ERROR implicit autoref } unsafe fn test_manually_overloaded_deref() { @@ -54,52 +54,55 @@ unsafe fn test_manually_overloaded_deref() { impl<T> Deref for W<T> { type Target = T; - fn deref(&self) -> &T { &self.0 } + 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 + //~^ ERROR implicit autoref } struct Test2 { // Derefs to `[u8]`. - field: &'static [u8] + field: &'static [u8], } fn test_more_manual_deref(ptr: *const Test2) -> usize { unsafe { (&(*ptr).field).len() } - //~^ WARN implicit autoref + //~^ ERROR 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]` + // Should not warn, as `ManuallyDrop::write` is not + // annotated with `#[rustc_no_implicit_auto_ref]` + ptr.write(ManuallyDrop::new(1)); } unsafe fn test_vec_get(ptr: *mut Vec<u8>) { let _ = (&(*ptr)).get(0); - //~^ WARN implicit autoref + //~^ ERROR implicit autoref let _ = (&(*ptr)).get_unchecked(0); - //~^ WARN implicit autoref + //~^ ERROR implicit autoref let _ = (&mut (*ptr)).get_mut(0); - //~^ WARN implicit autoref + //~^ ERROR implicit autoref let _ = (&mut (*ptr)).get_unchecked_mut(0); - //~^ WARN implicit autoref + //~^ ERROR implicit autoref } unsafe fn test_string(ptr: *mut String) { let _ = (&(*ptr)).len(); - //~^ WARN implicit autoref + //~^ ERROR implicit autoref let _ = (&(*ptr)).is_empty(); - //~^ WARN implicit autoref + //~^ ERROR implicit autoref } unsafe fn slice_ptr_len_because_of_msrv<T>(slice: *const [T]) { let _ = (&(&(*slice))[..]).len(); - //~^ WARN implicit autoref - //~^^ WARN implicit autoref + //~^ ERROR implicit autoref + //~^^ ERROR implicit autoref } fn main() {} diff --git a/tests/ui/lint/implicit_autorefs.rs b/tests/ui/lint/implicit_autorefs.rs index 507d6536828..f33cb08e985 100644 --- a/tests/ui/lint/implicit_autorefs.rs +++ b/tests/ui/lint/implicit_autorefs.rs @@ -1,4 +1,4 @@ -//@ check-pass +//@ check-fail //@ run-rustfix #![allow(dead_code)] // For the rustfix-ed code. @@ -8,7 +8,7 @@ use std::ops::Deref; unsafe fn test_const(ptr: *const [u8]) { let _ = (*ptr)[..16]; - //~^ WARN implicit autoref + //~^ ERROR implicit autoref } struct Test { @@ -17,36 +17,36 @@ struct Test { unsafe fn test_field(ptr: *const Test) -> *const [u8] { let l = (*ptr).field.len(); - //~^ WARN implicit autoref + //~^ ERROR implicit autoref &raw const (*ptr).field[..l - 1] - //~^ WARN implicit autoref + //~^ ERROR implicit autoref } unsafe fn test_builtin_index(a: *mut [String]) { _ = (*a)[0].len(); - //~^ WARN implicit autoref + //~^ ERROR implicit autoref _ = (*a)[..1][0].len(); - //~^ WARN implicit autoref - //~^^ WARN implicit autoref + //~^ ERROR implicit autoref + //~^^ ERROR implicit autoref } unsafe fn test_overloaded_deref_const(ptr: *const ManuallyDrop<Test>) { let _ = (*ptr).field; - //~^ WARN implicit autoref + //~^ ERROR implicit autoref let _ = &raw const (*ptr).field; - //~^ WARN implicit autoref + //~^ ERROR implicit autoref } unsafe fn test_overloaded_deref_mut(ptr: *mut ManuallyDrop<Test>) { let _ = (*ptr).field; - //~^ WARN implicit autoref + //~^ ERROR implicit autoref } unsafe fn test_double_overloaded_deref_const(ptr: *const ManuallyDrop<ManuallyDrop<Test>>) { let _ = (*ptr).field; - //~^ WARN implicit autoref + //~^ ERROR implicit autoref } unsafe fn test_manually_overloaded_deref() { @@ -54,52 +54,55 @@ unsafe fn test_manually_overloaded_deref() { impl<T> Deref for W<T> { type Target = T; - fn deref(&self) -> &T { &self.0 } + 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 + //~^ ERROR implicit autoref } struct Test2 { // Derefs to `[u8]`. - field: &'static [u8] + field: &'static [u8], } fn test_more_manual_deref(ptr: *const Test2) -> usize { unsafe { (*ptr).field.len() } - //~^ WARN implicit autoref + //~^ ERROR 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]` + // Should not warn, as `ManuallyDrop::write` is not + // annotated with `#[rustc_no_implicit_auto_ref]` + ptr.write(ManuallyDrop::new(1)); } unsafe fn test_vec_get(ptr: *mut Vec<u8>) { let _ = (*ptr).get(0); - //~^ WARN implicit autoref + //~^ ERROR implicit autoref let _ = (*ptr).get_unchecked(0); - //~^ WARN implicit autoref + //~^ ERROR implicit autoref let _ = (*ptr).get_mut(0); - //~^ WARN implicit autoref + //~^ ERROR implicit autoref let _ = (*ptr).get_unchecked_mut(0); - //~^ WARN implicit autoref + //~^ ERROR implicit autoref } unsafe fn test_string(ptr: *mut String) { let _ = (*ptr).len(); - //~^ WARN implicit autoref + //~^ ERROR implicit autoref let _ = (*ptr).is_empty(); - //~^ WARN implicit autoref + //~^ ERROR implicit autoref } unsafe fn slice_ptr_len_because_of_msrv<T>(slice: *const [T]) { let _ = (*slice)[..].len(); - //~^ WARN implicit autoref - //~^^ WARN implicit autoref + //~^ ERROR implicit autoref + //~^^ ERROR implicit autoref } fn main() {} diff --git a/tests/ui/lint/implicit_autorefs.stderr b/tests/ui/lint/implicit_autorefs.stderr index 80ba8ae2fd2..bd914e2998a 100644 --- a/tests/ui/lint/implicit_autorefs.stderr +++ b/tests/ui/lint/implicit_autorefs.stderr @@ -1,4 +1,4 @@ -warning: implicit autoref creates a reference to the dereference of a raw pointer +error: implicit autoref creates a reference to the dereference of a raw pointer --> $DIR/implicit_autorefs.rs:10:13 | LL | let _ = (*ptr)[..16]; @@ -12,13 +12,13 @@ note: autoref is being applied to this expression, resulting in: `&[u8]` | LL | let _ = (*ptr)[..16]; | ^^^^^^ - = note: `#[warn(dangerous_implicit_autorefs)]` on by default + = note: `#[deny(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 +error: implicit autoref creates a reference to the dereference of a raw pointer --> $DIR/implicit_autorefs.rs:19:13 | LL | let l = (*ptr).field.len(); @@ -39,7 +39,7 @@ help: try using a raw pointer method instead; or if this reference is intentiona LL | let l = (&(*ptr).field).len(); | ++ + -warning: implicit autoref creates a reference to the dereference of a raw pointer +error: 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] @@ -58,7 +58,7 @@ help: try using a raw pointer method instead; or if this reference is intentiona LL | &raw const (&(*ptr).field)[..l - 1] | ++ + -warning: implicit autoref creates a reference to the dereference of a raw pointer +error: implicit autoref creates a reference to the dereference of a raw pointer --> $DIR/implicit_autorefs.rs:27:9 | LL | _ = (*a)[0].len(); @@ -79,7 +79,7 @@ help: try using a raw pointer method instead; or if this reference is intentiona LL | _ = (&(*a)[0]).len(); | ++ + -warning: implicit autoref creates a reference to the dereference of a raw pointer +error: implicit autoref creates a reference to the dereference of a raw pointer --> $DIR/implicit_autorefs.rs:30:9 | LL | _ = (*a)[..1][0].len(); @@ -100,7 +100,7 @@ help: try using a raw pointer method instead; or if this reference is intentiona LL | _ = (&(*a)[..1][0]).len(); | ++ + -warning: implicit autoref creates a reference to the dereference of a raw pointer +error: implicit autoref creates a reference to the dereference of a raw pointer --> $DIR/implicit_autorefs.rs:30:9 | LL | _ = (*a)[..1][0].len(); @@ -119,7 +119,7 @@ help: try using a raw pointer method instead; or if this reference is intentiona LL | _ = (&(*a))[..1][0].len(); | ++ + -warning: implicit autoref creates a reference to the dereference of a raw pointer +error: implicit autoref creates a reference to the dereference of a raw pointer --> $DIR/implicit_autorefs.rs:36:13 | LL | let _ = (*ptr).field; @@ -134,7 +134,7 @@ help: try using a raw pointer method instead; or if this reference is intentiona LL | let _ = (&(*ptr)).field; | ++ + -warning: implicit autoref creates a reference to the dereference of a raw pointer +error: implicit autoref creates a reference to the dereference of a raw pointer --> $DIR/implicit_autorefs.rs:38:24 | LL | let _ = &raw const (*ptr).field; @@ -149,7 +149,7 @@ help: try using a raw pointer method instead; or if this reference is intentiona LL | let _ = &raw const (&(*ptr)).field; | ++ + -warning: implicit autoref creates a reference to the dereference of a raw pointer +error: implicit autoref creates a reference to the dereference of a raw pointer --> $DIR/implicit_autorefs.rs:43:13 | LL | let _ = (*ptr).field; @@ -164,7 +164,7 @@ help: try using a raw pointer method instead; or if this reference is intentiona LL | let _ = (&(*ptr)).field; | ++ + -warning: implicit autoref creates a reference to the dereference of a raw pointer +error: implicit autoref creates a reference to the dereference of a raw pointer --> $DIR/implicit_autorefs.rs:48:13 | LL | let _ = (*ptr).field; @@ -179,8 +179,8 @@ help: try using a raw pointer method instead; or if this reference is intentiona LL | let _ = (&(*ptr)).field; | ++ + -warning: implicit autoref creates a reference to the dereference of a raw pointer - --> $DIR/implicit_autorefs.rs:62:26 +error: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:64:26 | LL | let _p: *const i32 = &raw const **w; | ^^^^^^^^^^^^^- @@ -189,7 +189,7 @@ LL | let _p: *const i32 = &raw const **w; | = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements note: autoref is being applied to this expression, resulting in: `&W<i32>` - --> $DIR/implicit_autorefs.rs:62:38 + --> $DIR/implicit_autorefs.rs:64:38 | LL | let _p: *const i32 = &raw const **w; | ^^ @@ -198,8 +198,8 @@ help: try using a raw pointer method instead; or if this reference is intentiona 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 +error: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:74:14 | LL | unsafe { (*ptr).field.len() } | ^^---^^^^^^^^^^^^^ @@ -208,7 +208,7 @@ LL | unsafe { (*ptr).field.len() } | = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements note: autoref is being applied to this expression, resulting in: `&[u8]` - --> $DIR/implicit_autorefs.rs:72:14 + --> $DIR/implicit_autorefs.rs:74:14 | LL | unsafe { (*ptr).field.len() } | ^^^^^^^^^^^^ @@ -219,8 +219,8 @@ help: try using a raw pointer method instead; or if this reference is intentiona LL | unsafe { (&(*ptr).field).len() } | ++ + -warning: implicit autoref creates a reference to the dereference of a raw pointer - --> $DIR/implicit_autorefs.rs:82:13 +error: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:85:13 | LL | let _ = (*ptr).get(0); | ^^---^^^^^^^^ @@ -229,7 +229,7 @@ LL | let _ = (*ptr).get(0); | = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements note: autoref is being applied to this expression, resulting in: `&[u8]` - --> $DIR/implicit_autorefs.rs:82:13 + --> $DIR/implicit_autorefs.rs:85:13 | LL | let _ = (*ptr).get(0); | ^^^^^^ @@ -240,8 +240,8 @@ help: try using a raw pointer method instead; or if this reference is intentiona LL | let _ = (&(*ptr)).get(0); | ++ + -warning: implicit autoref creates a reference to the dereference of a raw pointer - --> $DIR/implicit_autorefs.rs:84:13 +error: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:87:13 | LL | let _ = (*ptr).get_unchecked(0); | ^^---^^^^^^^^^^^^^^^^^^ @@ -250,7 +250,7 @@ LL | let _ = (*ptr).get_unchecked(0); | = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements note: autoref is being applied to this expression, resulting in: `&[u8]` - --> $DIR/implicit_autorefs.rs:84:13 + --> $DIR/implicit_autorefs.rs:87:13 | LL | let _ = (*ptr).get_unchecked(0); | ^^^^^^ @@ -261,8 +261,8 @@ help: try using a raw pointer method instead; or if this reference is intentiona 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 +error: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:89:13 | LL | let _ = (*ptr).get_mut(0); | ^^---^^^^^^^^^^^^ @@ -271,7 +271,7 @@ LL | let _ = (*ptr).get_mut(0); | = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements note: autoref is being applied to this expression, resulting in: `&mut [u8]` - --> $DIR/implicit_autorefs.rs:86:13 + --> $DIR/implicit_autorefs.rs:89:13 | LL | let _ = (*ptr).get_mut(0); | ^^^^^^ @@ -282,8 +282,8 @@ help: try using a raw pointer method instead; or if this reference is intentiona 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 +error: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:91:13 | LL | let _ = (*ptr).get_unchecked_mut(0); | ^^---^^^^^^^^^^^^^^^^^^^^^^ @@ -292,7 +292,7 @@ LL | let _ = (*ptr).get_unchecked_mut(0); | = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements note: autoref is being applied to this expression, resulting in: `&mut [u8]` - --> $DIR/implicit_autorefs.rs:88:13 + --> $DIR/implicit_autorefs.rs:91:13 | LL | let _ = (*ptr).get_unchecked_mut(0); | ^^^^^^ @@ -303,8 +303,8 @@ help: try using a raw pointer method instead; or if this reference is intentiona 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 +error: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:96:13 | LL | let _ = (*ptr).len(); | ^^---^^^^^^^ @@ -313,7 +313,7 @@ LL | let _ = (*ptr).len(); | = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements note: autoref is being applied to this expression, resulting in: `&String` - --> $DIR/implicit_autorefs.rs:93:13 + --> $DIR/implicit_autorefs.rs:96:13 | LL | let _ = (*ptr).len(); | ^^^^^^ @@ -324,8 +324,8 @@ help: try using a raw pointer method instead; or if this reference is intentiona LL | let _ = (&(*ptr)).len(); | ++ + -warning: implicit autoref creates a reference to the dereference of a raw pointer - --> $DIR/implicit_autorefs.rs:95:13 +error: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:98:13 | LL | let _ = (*ptr).is_empty(); | ^^---^^^^^^^^^^^^ @@ -334,7 +334,7 @@ LL | let _ = (*ptr).is_empty(); | = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements note: autoref is being applied to this expression, resulting in: `&String` - --> $DIR/implicit_autorefs.rs:95:13 + --> $DIR/implicit_autorefs.rs:98:13 | LL | let _ = (*ptr).is_empty(); | ^^^^^^ @@ -345,8 +345,8 @@ help: try using a raw pointer method instead; or if this reference is intentiona LL | let _ = (&(*ptr)).is_empty(); | ++ + -warning: implicit autoref creates a reference to the dereference of a raw pointer - --> $DIR/implicit_autorefs.rs:100:13 +error: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:103:13 | LL | let _ = (*slice)[..].len(); | ^^-----^^^^^^^^^^^ @@ -355,7 +355,7 @@ LL | let _ = (*slice)[..].len(); | = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements note: autoref is being applied to this expression, resulting in: `&[T]` - --> $DIR/implicit_autorefs.rs:100:13 + --> $DIR/implicit_autorefs.rs:103:13 | LL | let _ = (*slice)[..].len(); | ^^^^^^^^^^^^ @@ -366,8 +366,8 @@ help: try using a raw pointer method instead; or if this reference is intentiona LL | let _ = (&(*slice)[..]).len(); | ++ + -warning: implicit autoref creates a reference to the dereference of a raw pointer - --> $DIR/implicit_autorefs.rs:100:13 +error: implicit autoref creates a reference to the dereference of a raw pointer + --> $DIR/implicit_autorefs.rs:103:13 | LL | let _ = (*slice)[..].len(); | ^^-----^^^^^ @@ -376,7 +376,7 @@ LL | let _ = (*slice)[..].len(); | = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements note: autoref is being applied to this expression, resulting in: `&[T]` - --> $DIR/implicit_autorefs.rs:100:13 + --> $DIR/implicit_autorefs.rs:103:13 | LL | let _ = (*slice)[..].len(); | ^^^^^^^^ @@ -385,5 +385,5 @@ help: try using a raw pointer method instead; or if this reference is intentiona LL | let _ = (&(*slice))[..].len(); | ++ + -warning: 20 warnings emitted +error: aborting due to 20 previous errors diff --git a/tests/ui/lint/lint-ctypes-enum.rs b/tests/ui/lint/lint-ctypes-enum.rs index b2ef27b833b..f900f998d06 100644 --- a/tests/ui/lint/lint-ctypes-enum.rs +++ b/tests/ui/lint/lint-ctypes-enum.rs @@ -2,8 +2,6 @@ #![deny(improper_ctypes)] #![feature(ptr_internals)] #![feature(transparent_unions)] -#![feature(repr128)] -#![allow(incomplete_features)] use std::num; @@ -87,8 +85,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 repr_u128(x: U128); + fn repr_i128(x: 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>>); @@ -98,14 +96,12 @@ extern "C" { fn option_nonzero_u32(x: Option<num::NonZero<u32>>); fn option_nonzero_u64(x: Option<num::NonZero<u64>>); fn option_nonzero_u128(x: Option<num::NonZero<u128>>); - //~^ ERROR `extern` block uses type `u128` fn option_nonzero_usize(x: Option<num::NonZero<usize>>); fn option_nonzero_i8(x: Option<num::NonZero<i8>>); fn option_nonzero_i16(x: Option<num::NonZero<i16>>); fn option_nonzero_i32(x: Option<num::NonZero<i32>>); fn option_nonzero_i64(x: Option<num::NonZero<i64>>); fn option_nonzero_i128(x: Option<num::NonZero<i128>>); - //~^ ERROR `extern` block uses type `i128` fn option_nonzero_isize(x: Option<num::NonZero<isize>>); fn option_transparent_struct(x: Option<TransparentStruct<num::NonZero<u8>>>); fn option_transparent_enum(x: Option<TransparentEnum<num::NonZero<u8>>>); @@ -123,14 +119,12 @@ extern "C" { fn result_nonzero_u32_t(x: Result<num::NonZero<u32>, ()>); fn result_nonzero_u64_t(x: Result<num::NonZero<u64>, ()>); fn result_nonzero_u128_t(x: Result<num::NonZero<u128>, ()>); - //~^ ERROR `extern` block uses type `u128` fn result_nonzero_usize_t(x: Result<num::NonZero<usize>, ()>); fn result_nonzero_i8_t(x: Result<num::NonZero<i8>, ()>); fn result_nonzero_i16_t(x: Result<num::NonZero<i16>, ()>); fn result_nonzero_i32_t(x: Result<num::NonZero<i32>, ()>); fn result_nonzero_i64_t(x: Result<num::NonZero<i64>, ()>); fn result_nonzero_i128_t(x: Result<num::NonZero<i128>, ()>); - //~^ ERROR `extern` block uses type `i128` fn result_nonzero_isize_t(x: Result<num::NonZero<isize>, ()>); fn result_transparent_struct_t(x: Result<TransparentStruct<num::NonZero<u8>>, ()>); fn result_transparent_enum_t(x: Result<TransparentEnum<num::NonZero<u8>>, ()>); @@ -161,14 +155,12 @@ extern "C" { fn result_nonzero_u32_e(x: Result<(), num::NonZero<u32>>); fn result_nonzero_u64_e(x: Result<(), num::NonZero<u64>>); fn result_nonzero_u128_e(x: Result<(), num::NonZero<u128>>); - //~^ ERROR `extern` block uses type `u128` fn result_nonzero_usize_e(x: Result<(), num::NonZero<usize>>); fn result_nonzero_i8_e(x: Result<(), num::NonZero<i8>>); fn result_nonzero_i16_e(x: Result<(), num::NonZero<i16>>); fn result_nonzero_i32_e(x: Result<(), num::NonZero<i32>>); fn result_nonzero_i64_e(x: Result<(), num::NonZero<i64>>); fn result_nonzero_i128_e(x: Result<(), num::NonZero<i128>>); - //~^ ERROR `extern` block uses type `i128` fn result_nonzero_isize_e(x: Result<(), num::NonZero<isize>>); fn result_transparent_struct_e(x: Result<(), TransparentStruct<num::NonZero<u8>>>); fn result_transparent_enum_e(x: Result<(), TransparentEnum<num::NonZero<u8>>>); diff --git a/tests/ui/lint/lint-ctypes-enum.stderr b/tests/ui/lint/lint-ctypes-enum.stderr index d5fc844f756..40d22723309 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:84:14 + --> $DIR/lint-ctypes-enum.rs:82: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:11:1 + --> $DIR/lint-ctypes-enum.rs:9: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:85:14 + --> $DIR/lint-ctypes-enum.rs:83: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:14:1 + --> $DIR/lint-ctypes-enum.rs:12:1 | LL | enum B { | ^^^^^^ error: `extern` block uses type `T`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:86:14 + --> $DIR/lint-ctypes-enum.rs:84:14 | LL | fn tf(x: T); | ^ not FFI-safe @@ -40,55 +40,13 @@ 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:18:1 + --> $DIR/lint-ctypes-enum.rs:16: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:100:31 - | -LL | fn option_nonzero_u128(x: Option<num::NonZero<u128>>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe - | - = 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:107:31 - | -LL | fn option_nonzero_i128(x: Option<num::NonZero<i128>>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe - | - = 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:112:36 + --> $DIR/lint-ctypes-enum.rs:108:36 | LL | fn option_transparent_union(x: Option<TransparentUnion<num::NonZero<u8>>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -97,7 +55,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:114:28 + --> $DIR/lint-ctypes-enum.rs:110:28 | LL | fn option_repr_rust(x: Option<Rust<num::NonZero<u8>>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -106,7 +64,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:115:21 + --> $DIR/lint-ctypes-enum.rs:111:21 | LL | fn option_u8(x: Option<u8>); | ^^^^^^^^^^ not FFI-safe @@ -114,24 +72,8 @@ LL | fn option_u8(x: Option<u8>); = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum = note: enum has no representation hint -error: `extern` block uses type `u128`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:125:33 - | -LL | fn result_nonzero_u128_t(x: Result<num::NonZero<u128>, ()>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe - | - = 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:132:33 - | -LL | fn result_nonzero_i128_t(x: Result<num::NonZero<i128>, ()>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe - | - = 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:137:38 + --> $DIR/lint-ctypes-enum.rs:131:38 | LL | fn result_transparent_union_t(x: Result<TransparentUnion<num::NonZero<u8>>, ()>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -140,7 +82,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:139:30 + --> $DIR/lint-ctypes-enum.rs:133:30 | LL | fn result_repr_rust_t(x: Result<Rust<num::NonZero<u8>>, ()>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -149,7 +91,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:143:51 + --> $DIR/lint-ctypes-enum.rs:137:51 | LL | fn result_1zst_exhaustive_single_variant_t(x: Result<num::NonZero<u8>, U>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -158,7 +100,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:145:53 + --> $DIR/lint-ctypes-enum.rs:139:53 | LL | fn result_1zst_exhaustive_multiple_variant_t(x: Result<num::NonZero<u8>, B>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -167,7 +109,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:147:51 + --> $DIR/lint-ctypes-enum.rs:141:51 | LL | fn result_1zst_non_exhaustive_no_variant_t(x: Result<num::NonZero<u8>, NonExhaustive>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -176,7 +118,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:150:49 + --> $DIR/lint-ctypes-enum.rs:144:49 | LL | fn result_1zst_exhaustive_single_field_t(x: Result<num::NonZero<u8>, Field>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -185,7 +127,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:152:30 + --> $DIR/lint-ctypes-enum.rs:146:30 | LL | fn result_cascading_t(x: Result<Result<(), num::NonZero<u8>>, ()>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -193,24 +135,8 @@ LL | fn result_cascading_t(x: Result<Result<(), num::NonZero<u8>>, ()>); = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum = note: enum has no representation hint -error: `extern` block uses type `u128`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:163:33 - | -LL | fn result_nonzero_u128_e(x: Result<(), num::NonZero<u128>>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe - | - = 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:170:33 - | -LL | fn result_nonzero_i128_e(x: Result<(), num::NonZero<i128>>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe - | - = 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:175:38 + --> $DIR/lint-ctypes-enum.rs:167:38 | LL | fn result_transparent_union_e(x: Result<(), TransparentUnion<num::NonZero<u8>>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -219,7 +145,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:177:30 + --> $DIR/lint-ctypes-enum.rs:169:30 | LL | fn result_repr_rust_e(x: Result<(), Rust<num::NonZero<u8>>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -228,7 +154,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:181:51 + --> $DIR/lint-ctypes-enum.rs:173:51 | LL | fn result_1zst_exhaustive_single_variant_e(x: Result<U, num::NonZero<u8>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -237,7 +163,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:183:53 + --> $DIR/lint-ctypes-enum.rs:175:53 | LL | fn result_1zst_exhaustive_multiple_variant_e(x: Result<B, num::NonZero<u8>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -246,7 +172,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:185:51 + --> $DIR/lint-ctypes-enum.rs:177:51 | LL | fn result_1zst_non_exhaustive_no_variant_e(x: Result<NonExhaustive, num::NonZero<u8>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -255,7 +181,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:188:49 + --> $DIR/lint-ctypes-enum.rs:180:49 | LL | fn result_1zst_exhaustive_single_field_e(x: Result<Field, num::NonZero<u8>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -264,7 +190,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:190:30 + --> $DIR/lint-ctypes-enum.rs:182:30 | LL | fn result_cascading_e(x: Result<(), Result<(), num::NonZero<u8>>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -273,7 +199,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:192:27 + --> $DIR/lint-ctypes-enum.rs:184:27 | LL | fn result_unit_t_e(x: Result<(), ()>); | ^^^^^^^^^^^^^^ not FFI-safe @@ -281,5 +207,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 29 previous errors +error: aborting due to 21 previous errors diff --git a/tests/ui/lint/lint-ctypes-fn.rs b/tests/ui/lint/lint-ctypes-fn.rs index 73820c86d1a..0b84098e390 100644 --- a/tests/ui/lint/lint-ctypes-fn.rs +++ b/tests/ui/lint/lint-ctypes-fn.rs @@ -89,12 +89,6 @@ pub extern "C" fn boxed_trait(p: Box<dyn Trait>) { } pub extern "C" fn char_type(p: char) { } //~^ ERROR uses type `char` -pub extern "C" fn i128_type(p: i128) { } -//~^ ERROR uses type `i128` - -pub extern "C" fn u128_type(p: u128) { } -//~^ ERROR uses type `u128` - pub extern "C" fn tuple_type(p: (i32, i32)) { } //~^ ERROR uses type `(i32, i32)` @@ -120,9 +114,6 @@ pub extern "C" fn fn_type2(p: fn()) { } pub extern "C" fn fn_contained(p: RustBadRet) { } -pub extern "C" fn transparent_i128(p: TransparentI128) { } -//~^ ERROR: uses type `i128` - pub extern "C" fn transparent_str(p: TransparentStr) { } //~^ ERROR: uses type `str` @@ -161,6 +152,12 @@ pub extern "C" fn good17(p: TransparentCustomZst) { } #[allow(improper_ctypes_definitions)] pub extern "C" fn good18(_: &String) { } +pub extern "C" fn good_i128_type(p: i128) { } + +pub extern "C" fn good_u128_type(p: u128) { } + +pub extern "C" fn good_transparent_i128(p: TransparentI128) { } + #[cfg(not(target_arch = "wasm32"))] pub extern "C" fn good1(size: *const c_int) { } diff --git a/tests/ui/lint/lint-ctypes-fn.stderr b/tests/ui/lint/lint-ctypes-fn.stderr index a62533a4be1..a19c04a63b5 100644 --- a/tests/ui/lint/lint-ctypes-fn.stderr +++ b/tests/ui/lint/lint-ctypes-fn.stderr @@ -54,24 +54,8 @@ LL | pub extern "C" fn char_type(p: char) { } = help: consider using `u32` or `libc::wchar_t` instead = note: the `char` type has no C equivalent -error: `extern` fn uses type `i128`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:92:32 - | -LL | pub extern "C" fn i128_type(p: i128) { } - | ^^^^ not FFI-safe - | - = note: 128-bit integers don't currently have a known stable ABI - -error: `extern` fn uses type `u128`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:95:32 - | -LL | pub extern "C" fn u128_type(p: u128) { } - | ^^^^ not FFI-safe - | - = note: 128-bit integers don't currently have a known stable ABI - error: `extern` fn uses type `(i32, i32)`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:98:33 + --> $DIR/lint-ctypes-fn.rs:92:33 | LL | pub extern "C" fn tuple_type(p: (i32, i32)) { } | ^^^^^^^^^^ not FFI-safe @@ -80,7 +64,7 @@ LL | pub extern "C" fn tuple_type(p: (i32, i32)) { } = note: tuples have unspecified layout error: `extern` fn uses type `(i32, i32)`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:101:34 + --> $DIR/lint-ctypes-fn.rs:95:34 | LL | pub extern "C" fn tuple_type2(p: I32Pair) { } | ^^^^^^^ not FFI-safe @@ -89,7 +73,7 @@ LL | pub extern "C" fn tuple_type2(p: I32Pair) { } = note: tuples have unspecified layout error: `extern` fn uses type `ZeroSize`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:104:32 + --> $DIR/lint-ctypes-fn.rs:98:32 | LL | pub extern "C" fn zero_size(p: ZeroSize) { } | ^^^^^^^^ not FFI-safe @@ -103,7 +87,7 @@ LL | pub struct ZeroSize; | ^^^^^^^^^^^^^^^^^^^ error: `extern` fn uses type `ZeroSizeWithPhantomData`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:107:40 + --> $DIR/lint-ctypes-fn.rs:101:40 | LL | pub extern "C" fn zero_size_phantom(p: ZeroSizeWithPhantomData) { } | ^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -116,7 +100,7 @@ LL | pub struct ZeroSizeWithPhantomData(PhantomData<i32>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `extern` fn uses type `PhantomData<bool>`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:110:51 + --> $DIR/lint-ctypes-fn.rs:104:51 | LL | pub extern "C" fn zero_size_phantom_toplevel() -> PhantomData<bool> { | ^^^^^^^^^^^^^^^^^ not FFI-safe @@ -124,7 +108,7 @@ LL | pub extern "C" fn zero_size_phantom_toplevel() -> PhantomData<bool> { = note: composed only of `PhantomData` error: `extern` fn uses type `fn()`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:115:30 + --> $DIR/lint-ctypes-fn.rs:109:30 | LL | pub extern "C" fn fn_type(p: RustFn) { } | ^^^^^^ not FFI-safe @@ -133,7 +117,7 @@ LL | pub extern "C" fn fn_type(p: RustFn) { } = note: this function pointer has Rust-specific calling convention error: `extern` fn uses type `fn()`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:118:31 + --> $DIR/lint-ctypes-fn.rs:112:31 | LL | pub extern "C" fn fn_type2(p: fn()) { } | ^^^^ not FFI-safe @@ -141,16 +125,8 @@ LL | pub extern "C" fn fn_type2(p: fn()) { } = help: consider using an `extern fn(...) -> ...` function pointer instead = note: this function pointer has Rust-specific calling convention -error: `extern` fn uses type `i128`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:123:39 - | -LL | pub extern "C" fn transparent_i128(p: TransparentI128) { } - | ^^^^^^^^^^^^^^^ not FFI-safe - | - = note: 128-bit integers don't currently have a known stable ABI - error: `extern` fn uses type `str`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:126:38 + --> $DIR/lint-ctypes-fn.rs:117:38 | LL | pub extern "C" fn transparent_str(p: TransparentStr) { } | ^^^^^^^^^^^^^^ not FFI-safe @@ -159,7 +135,7 @@ LL | pub extern "C" fn transparent_str(p: TransparentStr) { } = note: string slices have no C equivalent error: `extern` fn uses type `PhantomData<bool>`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:172:43 + --> $DIR/lint-ctypes-fn.rs:169:43 | LL | pub extern "C" fn unused_generic2<T>() -> PhantomData<bool> { | ^^^^^^^^^^^^^^^^^ not FFI-safe @@ -167,7 +143,7 @@ LL | pub extern "C" fn unused_generic2<T>() -> PhantomData<bool> { = note: composed only of `PhantomData` error: `extern` fn uses type `Vec<T>`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:185:39 + --> $DIR/lint-ctypes-fn.rs:182:39 | LL | pub extern "C" fn used_generic4<T>(x: Vec<T>) { } | ^^^^^^ not FFI-safe @@ -176,7 +152,7 @@ LL | pub extern "C" fn used_generic4<T>(x: Vec<T>) { } = note: this struct has unspecified layout error: `extern` fn uses type `Vec<T>`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:188:41 + --> $DIR/lint-ctypes-fn.rs:185:41 | LL | pub extern "C" fn used_generic5<T>() -> Vec<T> { | ^^^^^^ not FFI-safe @@ -184,5 +160,5 @@ LL | pub extern "C" fn used_generic5<T>() -> Vec<T> { = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct = note: this struct has unspecified layout -error: aborting due to 20 previous errors +error: aborting due to 17 previous errors diff --git a/tests/ui/lint/lint-ctypes.rs b/tests/ui/lint/lint-ctypes.rs index 6dd9be10a48..47586c826ab 100644 --- a/tests/ui/lint/lint-ctypes.rs +++ b/tests/ui/lint/lint-ctypes.rs @@ -54,8 +54,6 @@ extern "C" { pub fn opt_box_type(p: Option<Box<u32>>); //~^ ERROR uses type `Option<Box<u32>>` pub fn char_type(p: char); //~ ERROR uses type `char` - pub fn i128_type(p: i128); //~ ERROR uses type `i128` - pub fn u128_type(p: u128); //~ ERROR uses type `u128` pub fn trait_type(p: &dyn Bar); //~ ERROR uses type `dyn Bar` pub fn tuple_type(p: (i32, i32)); //~ ERROR uses type `(i32, i32)` pub fn tuple_type2(p: I32Pair); //~ ERROR uses type `(i32, i32)` @@ -67,7 +65,6 @@ extern "C" { pub fn fn_type(p: RustFn); //~ ERROR uses type `fn()` pub fn fn_type2(p: fn()); //~ ERROR uses type `fn()` pub fn fn_contained(p: RustBadRet); //~ ERROR: uses type `Box<u32>` - pub fn transparent_i128(p: TransparentI128); //~ ERROR: uses type `i128` pub fn transparent_str(p: TransparentStr); //~ ERROR: uses type `str` pub fn transparent_fn(p: TransparentBadFn); //~ ERROR: uses type `Box<u32>` pub fn raw_array(arr: [u8; 8]); //~ ERROR: uses type `[u8; 8]` @@ -77,9 +74,6 @@ extern "C" { pub fn no_niche_b(b: Option<UnsafeCell<&i32>>); //~^ ERROR: uses type `Option<UnsafeCell<&i32>>` - pub static static_u128_type: u128; //~ ERROR: uses type `u128` - pub static static_u128_array_type: [u128; 16]; //~ ERROR: uses type `u128` - pub fn good3(fptr: Option<extern "C" fn()>); pub fn good4(aptr: &[u8; 4 as usize]); pub fn good5(s: StructWithProjection); @@ -99,7 +93,11 @@ extern "C" { pub fn good18(_: &String); pub fn good20(arr: *const [u8; 8]); pub static good21: [u8; 8]; - + pub fn good_i128_type(p: i128); + pub fn good_u128_type(p: u128); + pub fn good_transparent_i128(p: TransparentI128); + pub static good_static_u128_type: u128; + pub static good_static_u128_array_type: [u128; 16]; } #[allow(improper_ctypes)] diff --git a/tests/ui/lint/lint-ctypes.stderr b/tests/ui/lint/lint-ctypes.stderr index 8137ae868d3..3fb36647d4f 100644 --- a/tests/ui/lint/lint-ctypes.stderr +++ b/tests/ui/lint/lint-ctypes.stderr @@ -85,24 +85,8 @@ LL | pub fn char_type(p: char); = help: consider using `u32` or `libc::wchar_t` instead = note: the `char` type has no C equivalent -error: `extern` block uses type `i128`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:57:25 - | -LL | pub fn i128_type(p: i128); - | ^^^^ not FFI-safe - | - = note: 128-bit integers don't currently have a known stable ABI - -error: `extern` block uses type `u128`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:58:25 - | -LL | pub fn u128_type(p: u128); - | ^^^^ not FFI-safe - | - = note: 128-bit integers don't currently have a known stable ABI - error: `extern` block uses type `dyn Bar`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:59:26 + --> $DIR/lint-ctypes.rs:57:26 | LL | pub fn trait_type(p: &dyn Bar); | ^^^^^^^^ not FFI-safe @@ -110,7 +94,7 @@ LL | pub fn trait_type(p: &dyn Bar); = note: trait objects have no C equivalent error: `extern` block uses type `(i32, i32)`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:60:26 + --> $DIR/lint-ctypes.rs:58:26 | LL | pub fn tuple_type(p: (i32, i32)); | ^^^^^^^^^^ not FFI-safe @@ -119,7 +103,7 @@ LL | pub fn tuple_type(p: (i32, i32)); = note: tuples have unspecified layout error: `extern` block uses type `(i32, i32)`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:61:27 + --> $DIR/lint-ctypes.rs:59:27 | LL | pub fn tuple_type2(p: I32Pair); | ^^^^^^^ not FFI-safe @@ -128,7 +112,7 @@ LL | pub fn tuple_type2(p: I32Pair); = note: tuples have unspecified layout error: `extern` block uses type `ZeroSize`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:62:25 + --> $DIR/lint-ctypes.rs:60:25 | LL | pub fn zero_size(p: ZeroSize); | ^^^^^^^^ not FFI-safe @@ -142,7 +126,7 @@ LL | pub struct ZeroSize; | ^^^^^^^^^^^^^^^^^^^ error: `extern` block uses type `ZeroSizeWithPhantomData`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:63:33 + --> $DIR/lint-ctypes.rs:61:33 | LL | pub fn zero_size_phantom(p: ZeroSizeWithPhantomData); | ^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -155,7 +139,7 @@ LL | pub struct ZeroSizeWithPhantomData(::std::marker::PhantomData<i32>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `extern` block uses type `PhantomData<bool>`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:66:12 + --> $DIR/lint-ctypes.rs:64:12 | LL | -> ::std::marker::PhantomData<bool>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -163,7 +147,7 @@ LL | -> ::std::marker::PhantomData<bool>; = note: composed only of `PhantomData` error: `extern` block uses type `fn()`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:67:23 + --> $DIR/lint-ctypes.rs:65:23 | LL | pub fn fn_type(p: RustFn); | ^^^^^^ not FFI-safe @@ -172,7 +156,7 @@ LL | pub fn fn_type(p: RustFn); = note: this function pointer has Rust-specific calling convention error: `extern` block uses type `fn()`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:68:24 + --> $DIR/lint-ctypes.rs:66:24 | LL | pub fn fn_type2(p: fn()); | ^^^^ not FFI-safe @@ -181,7 +165,7 @@ LL | pub fn fn_type2(p: fn()); = note: this function pointer has Rust-specific calling convention error: `extern` block uses type `Box<u32>`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:69:28 + --> $DIR/lint-ctypes.rs:67:28 | LL | pub fn fn_contained(p: RustBadRet); | ^^^^^^^^^^ not FFI-safe @@ -189,16 +173,8 @@ LL | pub fn fn_contained(p: RustBadRet); = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct = note: this struct has unspecified layout -error: `extern` block uses type `i128`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:70:32 - | -LL | pub fn transparent_i128(p: TransparentI128); - | ^^^^^^^^^^^^^^^ not FFI-safe - | - = note: 128-bit integers don't currently have a known stable ABI - error: `extern` block uses type `str`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:71:31 + --> $DIR/lint-ctypes.rs:68:31 | LL | pub fn transparent_str(p: TransparentStr); | ^^^^^^^^^^^^^^ not FFI-safe @@ -207,7 +183,7 @@ LL | pub fn transparent_str(p: TransparentStr); = note: string slices have no C equivalent error: `extern` block uses type `Box<u32>`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:72:30 + --> $DIR/lint-ctypes.rs:69:30 | LL | pub fn transparent_fn(p: TransparentBadFn); | ^^^^^^^^^^^^^^^^ not FFI-safe @@ -216,7 +192,7 @@ LL | pub fn transparent_fn(p: TransparentBadFn); = note: this struct has unspecified layout error: `extern` block uses type `[u8; 8]`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:73:27 + --> $DIR/lint-ctypes.rs:70:27 | LL | pub fn raw_array(arr: [u8; 8]); | ^^^^^^^ not FFI-safe @@ -225,7 +201,7 @@ LL | pub fn raw_array(arr: [u8; 8]); = note: passing raw arrays by value is not FFI-safe error: `extern` block uses type `Option<UnsafeCell<extern "C" fn()>>`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:75:26 + --> $DIR/lint-ctypes.rs:72:26 | LL | pub fn no_niche_a(a: Option<UnsafeCell<extern "C" fn()>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -234,7 +210,7 @@ LL | pub fn no_niche_a(a: Option<UnsafeCell<extern "C" fn()>>); = note: enum has no representation hint error: `extern` block uses type `Option<UnsafeCell<&i32>>`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:77:26 + --> $DIR/lint-ctypes.rs:74:26 | LL | pub fn no_niche_b(b: Option<UnsafeCell<&i32>>); | ^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -242,21 +218,5 @@ LL | pub fn no_niche_b(b: Option<UnsafeCell<&i32>>); = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum = note: enum has no representation hint -error: `extern` block uses type `u128`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:80:34 - | -LL | pub static static_u128_type: u128; - | ^^^^ not FFI-safe - | - = note: 128-bit integers don't currently have a known stable ABI - -error: `extern` block uses type `u128`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:81:40 - | -LL | pub static static_u128_array_type: [u128; 16]; - | ^^^^^^^^^^ not FFI-safe - | - = note: 128-bit integers don't currently have a known stable ABI - -error: aborting due to 27 previous errors +error: aborting due to 22 previous errors diff --git a/tests/ui/lint/lint-directives-on-use-items-issue-10534.rs b/tests/ui/lint/lint-directives-on-use-items-issue-10534.rs index e5cb0d3df0e..55ecb564beb 100644 --- a/tests/ui/lint/lint-directives-on-use-items-issue-10534.rs +++ b/tests/ui/lint/lint-directives-on-use-items-issue-10534.rs @@ -9,16 +9,16 @@ mod a { pub static x: isize = 3; pub static y: isize = 4; } mod b { - use a::x; //~ ERROR: unused import + use crate::a::x; //~ ERROR: unused import #[allow(unused_imports)] - use a::y; // no error here + use crate::a::y; // no error here } #[allow(unused_imports)] mod c { - use a::x; + use crate::a::x; #[deny(unused_imports)] - use a::y; //~ ERROR: unused import + use crate::a::y; //~ ERROR: unused import } fn main() {} diff --git a/tests/ui/lint/lint-directives-on-use-items-issue-10534.stderr b/tests/ui/lint/lint-directives-on-use-items-issue-10534.stderr index ccb139e0ed6..c394d1e7932 100644 --- a/tests/ui/lint/lint-directives-on-use-items-issue-10534.stderr +++ b/tests/ui/lint/lint-directives-on-use-items-issue-10534.stderr @@ -1,8 +1,8 @@ -error: unused import: `a::x` +error: unused import: `crate::a::x` --> $DIR/lint-directives-on-use-items-issue-10534.rs:12:9 | -LL | use a::x; - | ^^^^ +LL | use crate::a::x; + | ^^^^^^^^^^^ | note: the lint level is defined here --> $DIR/lint-directives-on-use-items-issue-10534.rs:1:9 @@ -10,11 +10,11 @@ note: the lint level is defined here LL | #![deny(unused_imports)] | ^^^^^^^^^^^^^^ -error: unused import: `a::y` +error: unused import: `crate::a::y` --> $DIR/lint-directives-on-use-items-issue-10534.rs:21:9 | -LL | use a::y; - | ^^^^ +LL | use crate::a::y; + | ^^^^^^^^^^^ | note: the lint level is defined here --> $DIR/lint-directives-on-use-items-issue-10534.rs:20:12 diff --git a/tests/ui/lint/lint-missing-doc.rs b/tests/ui/lint/lint-missing-doc.rs index 0b7c99e5012..b8655994fc2 100644 --- a/tests/ui/lint/lint-missing-doc.rs +++ b/tests/ui/lint/lint-missing-doc.rs @@ -184,10 +184,10 @@ mod internal_impl { } /// dox pub mod public_interface { - pub use internal_impl::documented as foo; - pub use internal_impl::undocumented1 as bar; - pub use internal_impl::{documented, undocumented2}; - pub use internal_impl::globbed::*; + pub use crate::internal_impl::documented as foo; + pub use crate::internal_impl::undocumented1 as bar; + pub use crate::internal_impl::{documented, undocumented2}; + pub use crate::internal_impl::globbed::*; } extern "C" { diff --git a/tests/ui/lint/lint-pre-expansion-extern-module.rs b/tests/ui/lint/lint-pre-expansion-extern-module.rs index f1ab0cf3b74..e85261befbc 100644 --- a/tests/ui/lint/lint-pre-expansion-extern-module.rs +++ b/tests/ui/lint/lint-pre-expansion-extern-module.rs @@ -1,5 +1,6 @@ //@ check-pass //@ compile-flags: -W rust-2018-compatibility +//@ edition: 2015 fn main() {} diff --git a/tests/ui/lint/lint-qualification.fixed b/tests/ui/lint/lint-qualification.fixed index 7c8fd5236e6..04067b6b6ff 100644 --- a/tests/ui/lint/lint-qualification.fixed +++ b/tests/ui/lint/lint-qualification.fixed @@ -1,3 +1,4 @@ +//@ edition: 2015 //@ run-rustfix #![deny(unused_qualifications)] #![deny(unused_imports)] diff --git a/tests/ui/lint/lint-qualification.rs b/tests/ui/lint/lint-qualification.rs index 009b3080d5c..20c261bf878 100644 --- a/tests/ui/lint/lint-qualification.rs +++ b/tests/ui/lint/lint-qualification.rs @@ -1,3 +1,4 @@ +//@ edition: 2015 //@ run-rustfix #![deny(unused_qualifications)] #![deny(unused_imports)] diff --git a/tests/ui/lint/lint-qualification.stderr b/tests/ui/lint/lint-qualification.stderr index cefa54a12ae..1e8b8da1e86 100644 --- a/tests/ui/lint/lint-qualification.stderr +++ b/tests/ui/lint/lint-qualification.stderr @@ -1,11 +1,11 @@ error: unnecessary qualification - --> $DIR/lint-qualification.rs:12:5 + --> $DIR/lint-qualification.rs:13:5 | LL | foo::bar(); | ^^^^^^^^ | note: the lint level is defined here - --> $DIR/lint-qualification.rs:2:9 + --> $DIR/lint-qualification.rs:3:9 | LL | #![deny(unused_qualifications)] | ^^^^^^^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL + bar(); | error: unnecessary qualification - --> $DIR/lint-qualification.rs:13:5 + --> $DIR/lint-qualification.rs:14:5 | LL | crate::foo::bar(); | ^^^^^^^^^^^^^^^ @@ -28,7 +28,7 @@ LL + bar(); | error: unnecessary qualification - --> $DIR/lint-qualification.rs:18:13 + --> $DIR/lint-qualification.rs:19:13 | LL | let _ = std::string::String::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -40,7 +40,7 @@ LL + let _ = String::new(); | error: unnecessary qualification - --> $DIR/lint-qualification.rs:20:12 + --> $DIR/lint-qualification.rs:21:12 | LL | let _: std::vec::Vec<String> = std::vec::Vec::<String>::new(); | ^^^^^^^^^^^^^^^^^^^^^ @@ -52,7 +52,7 @@ LL + let _: Vec<String> = std::vec::Vec::<String>::new(); | error: unnecessary qualification - --> $DIR/lint-qualification.rs:20:36 + --> $DIR/lint-qualification.rs:21:36 | LL | let _: std::vec::Vec<String> = std::vec::Vec::<String>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -64,19 +64,19 @@ LL + let _: std::vec::Vec<String> = Vec::<String>::new(); | error: unused import: `std::fmt` - --> $DIR/lint-qualification.rs:24:9 + --> $DIR/lint-qualification.rs:25:9 | LL | use std::fmt; | ^^^^^^^^ | note: the lint level is defined here - --> $DIR/lint-qualification.rs:3:9 + --> $DIR/lint-qualification.rs:4:9 | LL | #![deny(unused_imports)] | ^^^^^^^^^^^^^^ error: unnecessary qualification - --> $DIR/lint-qualification.rs:29:13 + --> $DIR/lint-qualification.rs:30:13 | LL | let _ = <bool as std::default::Default>::default(); // issue #121999 (modified) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/lint/lint-unnecessary-import-braces.rs b/tests/ui/lint/lint-unnecessary-import-braces.rs index 9a3398a8734..a9c8da85a22 100644 --- a/tests/ui/lint/lint-unnecessary-import-braces.rs +++ b/tests/ui/lint/lint-unnecessary-import-braces.rs @@ -1,10 +1,10 @@ #![deny(unused_import_braces)] -use test::{A}; //~ ERROR braces around A is unnecessary +use crate::test::{A}; //~ ERROR braces around A is unnecessary mod test { - use test::{self}; // OK - use test::{self as rename}; // OK + use crate::test::{self}; // OK + use crate::test::{self as rename}; // OK pub struct A; } diff --git a/tests/ui/lint/lint-unnecessary-import-braces.stderr b/tests/ui/lint/lint-unnecessary-import-braces.stderr index 5f441ef4a66..dc470551cd4 100644 --- a/tests/ui/lint/lint-unnecessary-import-braces.stderr +++ b/tests/ui/lint/lint-unnecessary-import-braces.stderr @@ -1,8 +1,8 @@ error: braces around A is unnecessary --> $DIR/lint-unnecessary-import-braces.rs:3:1 | -LL | use test::{A}; - | ^^^^^^^^^^^^^^ +LL | use crate::test::{A}; + | ^^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here --> $DIR/lint-unnecessary-import-braces.rs:1:9 diff --git a/tests/ui/big-literals.rs b/tests/ui/lint/overflowing-literals-valid.rs index d2f447a595c..08aa092ee71 100644 --- a/tests/ui/big-literals.rs +++ b/tests/ui/lint/overflowing-literals-valid.rs @@ -1,5 +1,7 @@ +//! Test that valid large numeric literals do not trigger the `overflowing_literals` lint. + //@ run-pass -// Catch mistakes in the overflowing literals lint. + #![deny(overflowing_literals)] pub fn main() { diff --git a/tests/ui/lint/unnecessary-extern-crate.stderr b/tests/ui/lint/unnecessary-extern-crate.stderr index 1fa4aa9c9a9..db5406bc567 100644 --- a/tests/ui/lint/unnecessary-extern-crate.stderr +++ b/tests/ui/lint/unnecessary-extern-crate.stderr @@ -2,43 +2,72 @@ error: unused extern crate --> $DIR/unnecessary-extern-crate.rs:6:1 | LL | extern crate core; - | ^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^ unused | note: the lint level is defined here --> $DIR/unnecessary-extern-crate.rs:3:9 | LL | #![deny(unused_extern_crates)] | ^^^^^^^^^^^^^^^^^^^^ +help: remove the unused `extern crate` + | +LL - extern crate core; + | error: unused extern crate --> $DIR/unnecessary-extern-crate.rs:9:1 | LL | extern crate core as x; - | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^^^^^^ unused + | +help: remove the unused `extern crate` + | +LL - extern crate core as x; + | error: unused extern crate --> $DIR/unnecessary-extern-crate.rs:31:5 | LL | extern crate core; - | ^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^ unused + | +help: remove the unused `extern crate` + | +LL - extern crate core; + | error: unused extern crate --> $DIR/unnecessary-extern-crate.rs:35:5 | LL | extern crate core as x; - | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^^^^^^ unused + | +help: remove the unused `extern crate` + | +LL - extern crate core as x; + | error: unused extern crate --> $DIR/unnecessary-extern-crate.rs:44:9 | LL | extern crate core; - | ^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^ unused + | +help: remove the unused `extern crate` + | +LL - extern crate core; + | error: unused extern crate --> $DIR/unnecessary-extern-crate.rs:48:9 | LL | extern crate core as x; - | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^^^^^^ unused + | +help: remove the unused `extern crate` + | +LL - extern crate core as x; + | error: aborting due to 6 previous errors diff --git a/tests/ui/lint/unused/lint-unused-extern-crate.stderr b/tests/ui/lint/unused/lint-unused-extern-crate.stderr index 46d8f3beeab..7fcbdd813ce 100644 --- a/tests/ui/lint/unused/lint-unused-extern-crate.stderr +++ b/tests/ui/lint/unused/lint-unused-extern-crate.stderr @@ -2,19 +2,30 @@ error: unused extern crate --> $DIR/lint-unused-extern-crate.rs:11:1 | LL | extern crate lint_unused_extern_crate5; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused | note: the lint level is defined here --> $DIR/lint-unused-extern-crate.rs:7:9 | LL | #![deny(unused_extern_crates)] | ^^^^^^^^^^^^^^^^^^^^ +help: remove the unused `extern crate` + | +LL - extern crate lint_unused_extern_crate5; +LL + + | error: unused extern crate --> $DIR/lint-unused-extern-crate.rs:29:5 | LL | extern crate lint_unused_extern_crate2; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused + | +help: remove the unused `extern crate` + | +LL - extern crate lint_unused_extern_crate2; +LL + + | error: aborting due to 2 previous errors diff --git a/tests/ui/lint/unused/lint-unused-imports.rs b/tests/ui/lint/unused/lint-unused-imports.rs index 710fb7a5ed1..d09a84b59a3 100644 --- a/tests/ui/lint/unused/lint-unused-imports.rs +++ b/tests/ui/lint/unused/lint-unused-imports.rs @@ -48,8 +48,8 @@ pub mod bar { pub struct Square; pub mod c { - use foo::Point; - use foo::Square; //~ ERROR unused import: `foo::Square` + use crate::foo::Point; + use crate::foo::Square; //~ ERROR unused import: `crate::foo::Square` pub fn cc(_p: Point) -> super::Square { fn f() -> super::Square { super::Square @@ -74,7 +74,7 @@ fn g() { // cf. issue #35135. #[allow(unused_variables)] fn h() { - use test2::foo; //~ ERROR unused import: `test2::foo` + use crate::test2::foo; //~ ERROR unused import: `crate::test2::foo` let foo = 0; } @@ -83,6 +83,6 @@ fn main() { let mut a = 3; let mut b = 4; swap(&mut a, &mut b); - test::C.b(); + crate::test::C.b(); foo(); } diff --git a/tests/ui/lint/unused/lint-unused-imports.stderr b/tests/ui/lint/unused/lint-unused-imports.stderr index a848fb31eba..750bc059de0 100644 --- a/tests/ui/lint/unused/lint-unused-imports.stderr +++ b/tests/ui/lint/unused/lint-unused-imports.stderr @@ -28,11 +28,11 @@ error: unused import: `bar` LL | use test2::{foo, bar}; | ^^^ -error: unused import: `foo::Square` +error: unused import: `crate::foo::Square` --> $DIR/lint-unused-imports.rs:52:13 | -LL | use foo::Square; - | ^^^^^^^^^^^ +LL | use crate::foo::Square; + | ^^^^^^^^^^^^^^^^^^ error: unused import: `self::g` --> $DIR/lint-unused-imports.rs:68:9 @@ -40,11 +40,11 @@ error: unused import: `self::g` LL | use self::g; | ^^^^^^^ -error: unused import: `test2::foo` +error: unused import: `crate::test2::foo` --> $DIR/lint-unused-imports.rs:77:9 | -LL | use test2::foo; - | ^^^^^^^^^^ +LL | use crate::test2::foo; + | ^^^^^^^^^^^^^^^^^ error: unused import: `test::B2` --> $DIR/lint-unused-imports.rs:20:5 diff --git a/tests/ui/lint/unused/unused-braces-attrs-issue-141549.fixed b/tests/ui/lint/unused/unused-braces-attrs-issue-141549.fixed new file mode 100644 index 00000000000..6129da30676 --- /dev/null +++ b/tests/ui/lint/unused/unused-braces-attrs-issue-141549.fixed @@ -0,0 +1,15 @@ +//@ check-pass +//@ run-rustfix + +#![allow(dead_code)] +#![warn(unused_braces)] + +use std::cmp::Ordering; + +#[rustfmt::skip] +fn ptr_cmp<T: ?Sized>(p1: *const T, p2: *const T) -> Ordering { + #[expect(ambiguous_wide_pointer_comparisons)] p1.cmp(&p2) + //~^ WARN unnecessary braces around block return value +} + +fn main() {} diff --git a/tests/ui/lint/unused/unused-braces-attrs-issue-141549.rs b/tests/ui/lint/unused/unused-braces-attrs-issue-141549.rs new file mode 100644 index 00000000000..a550ebc4973 --- /dev/null +++ b/tests/ui/lint/unused/unused-braces-attrs-issue-141549.rs @@ -0,0 +1,15 @@ +//@ check-pass +//@ run-rustfix + +#![allow(dead_code)] +#![warn(unused_braces)] + +use std::cmp::Ordering; + +#[rustfmt::skip] +fn ptr_cmp<T: ?Sized>(p1: *const T, p2: *const T) -> Ordering { + { #[expect(ambiguous_wide_pointer_comparisons)] p1.cmp(&p2) } + //~^ WARN unnecessary braces around block return value +} + +fn main() {} diff --git a/tests/ui/lint/unused/unused-braces-attrs-issue-141549.stderr b/tests/ui/lint/unused/unused-braces-attrs-issue-141549.stderr new file mode 100644 index 00000000000..0b2b6211ab9 --- /dev/null +++ b/tests/ui/lint/unused/unused-braces-attrs-issue-141549.stderr @@ -0,0 +1,19 @@ +warning: unnecessary braces around block return value + --> $DIR/unused-braces-attrs-issue-141549.rs:11:5 + | +LL | { #[expect(ambiguous_wide_pointer_comparisons)] p1.cmp(&p2) } + | ^^ ^^ + | +note: the lint level is defined here + --> $DIR/unused-braces-attrs-issue-141549.rs:5:9 + | +LL | #![warn(unused_braces)] + | ^^^^^^^^^^^^^ +help: remove these braces + | +LL - { #[expect(ambiguous_wide_pointer_comparisons)] p1.cmp(&p2) } +LL + #[expect(ambiguous_wide_pointer_comparisons)] p1.cmp(&p2) + | + +warning: 1 warning emitted + diff --git a/tests/ui/lint/unused/useless-comment.rs b/tests/ui/lint/unused/useless-comment.rs index 4ec52f20747..898665278e3 100644 --- a/tests/ui/lint/unused/useless-comment.rs +++ b/tests/ui/lint/unused/useless-comment.rs @@ -9,8 +9,13 @@ macro_rules! mac { /// foo //~ ERROR unused doc comment mac!(); +/// a //~ ERROR unused doc comment +#[doc(test(attr(allow(dead_code))))] //~ ERROR unused doc comment +unsafe extern "C" { } + fn foo() { /// a //~ ERROR unused doc comment + #[doc(test(attr(allow(dead_code))))] //~ ERROR unused doc comment let x = 12; /// multi-line //~ ERROR unused doc comment @@ -19,6 +24,7 @@ fn foo() { match x { /// c //~ ERROR unused doc comment 1 => {}, + #[doc(test(attr(allow(dead_code))))] //~ ERROR unused doc comment _ => {} } @@ -32,6 +38,7 @@ fn foo() { /// bar //~ ERROR unused doc comment mac!(); + #[doc(test(attr(allow(dead_code))))] //~ ERROR unused doc comment let x = /** comment */ 47; //~ ERROR unused doc comment /// dox //~ ERROR unused doc comment diff --git a/tests/ui/lint/unused/useless-comment.stderr b/tests/ui/lint/unused/useless-comment.stderr index 8bb5bdaeb25..39873b82b75 100644 --- a/tests/ui/lint/unused/useless-comment.stderr +++ b/tests/ui/lint/unused/useless-comment.stderr @@ -12,7 +12,28 @@ LL | #![deny(unused_doc_comments)] | ^^^^^^^^^^^^^^^^^^^ error: unused doc comment - --> $DIR/useless-comment.rs:32:5 + --> $DIR/useless-comment.rs:12:1 + | +LL | /// a + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[doc(test(attr(allow(dead_code))))] +LL | unsafe extern "C" { } + | --------------------- rustdoc does not generate documentation for extern blocks + | + = help: use `//` for a plain comment + +error: unused doc comment + --> $DIR/useless-comment.rs:13:1 + | +LL | #[doc(test(attr(allow(dead_code))))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | unsafe extern "C" { } + | --------------------- rustdoc does not generate documentation for extern blocks + | + = help: use `//` for a plain comment + +error: unused doc comment + --> $DIR/useless-comment.rs:38:5 | LL | /// bar | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ rustdoc does not generate documentation for macro invocations @@ -20,17 +41,28 @@ LL | /// bar = help: to document an item produced by a macro, the macro must produce the documentation as part of its expansion error: unused doc comment - --> $DIR/useless-comment.rs:13:5 + --> $DIR/useless-comment.rs:17:5 | LL | /// a | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[doc(test(attr(allow(dead_code))))] LL | let x = 12; | ----------- rustdoc does not generate documentation for statements | = help: use `//` for a plain comment error: unused doc comment - --> $DIR/useless-comment.rs:16:5 + --> $DIR/useless-comment.rs:18:5 + | +LL | #[doc(test(attr(allow(dead_code))))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let x = 12; + | ----------- rustdoc does not generate documentation for statements + | + = help: use `//` for a plain comment + +error: unused doc comment + --> $DIR/useless-comment.rs:21:5 | LL | / /// multi-line LL | | /// doc comment @@ -39,6 +71,7 @@ LL | | /// that is unused LL | / match x { LL | | /// c LL | | 1 => {}, +LL | | #[doc(test(attr(allow(dead_code))))] LL | | _ => {} LL | | } | |_____- rustdoc does not generate documentation for expressions @@ -46,7 +79,7 @@ LL | | } = help: use `//` for a plain comment error: unused doc comment - --> $DIR/useless-comment.rs:20:9 + --> $DIR/useless-comment.rs:25:9 | LL | /// c | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -56,7 +89,17 @@ LL | 1 => {}, = help: use `//` for a plain comment error: unused doc comment - --> $DIR/useless-comment.rs:25:5 + --> $DIR/useless-comment.rs:27:9 + | +LL | #[doc(test(attr(allow(dead_code))))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | _ => {} + | ------- rustdoc does not generate documentation for match arms + | + = help: use `//` for a plain comment + +error: unused doc comment + --> $DIR/useless-comment.rs:31:5 | LL | /// foo | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -66,7 +109,7 @@ LL | unsafe {} = help: use `//` for a plain comment error: unused doc comment - --> $DIR/useless-comment.rs:28:5 + --> $DIR/useless-comment.rs:34:5 | LL | #[doc = "foo"] | ^^^^^^^^^^^^^^ @@ -77,7 +120,7 @@ LL | 3; = help: use `//` for a plain comment error: unused doc comment - --> $DIR/useless-comment.rs:29:5 + --> $DIR/useless-comment.rs:35:5 | LL | #[doc = "bar"] | ^^^^^^^^^^^^^^ @@ -87,7 +130,17 @@ LL | 3; = help: use `//` for a plain comment error: unused doc comment - --> $DIR/useless-comment.rs:35:13 + --> $DIR/useless-comment.rs:41:5 + | +LL | #[doc(test(attr(allow(dead_code))))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let x = /** comment */ 47; + | -------------------------- rustdoc does not generate documentation for statements + | + = help: use `//` for a plain comment + +error: unused doc comment + --> $DIR/useless-comment.rs:42:13 | LL | let x = /** comment */ 47; | ^^^^^^^^^^^^^^ -- rustdoc does not generate documentation for expressions @@ -95,7 +148,7 @@ LL | let x = /** comment */ 47; = help: use `/* */` for a plain comment error: unused doc comment - --> $DIR/useless-comment.rs:37:5 + --> $DIR/useless-comment.rs:44:5 | LL | /// dox | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -106,5 +159,5 @@ LL | | } | = help: use `//` for a plain comment -error: aborting due to 10 previous errors +error: aborting due to 15 previous errors diff --git a/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.rs b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.rs index 6abe3602abe..7dc9ba0afea 100644 --- a/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.rs +++ b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.rs @@ -1,3 +1,4 @@ +//@ edition: 2015 //@ check-pass #![warn(redundant_imports)] diff --git a/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.stderr b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.stderr index 2b0e16a87dc..48d5c275055 100644 --- a/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.stderr +++ b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.stderr @@ -1,5 +1,5 @@ warning: the item `Some` is imported redundantly - --> $DIR/use-redundant-prelude-rust-2015.rs:5:5 + --> $DIR/use-redundant-prelude-rust-2015.rs:6:5 | LL | use std::option::Option::Some; | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,13 +8,13 @@ LL | use std::option::Option::Some; = note: the item `Some` is already defined here | note: the lint level is defined here - --> $DIR/use-redundant-prelude-rust-2015.rs:2:9 + --> $DIR/use-redundant-prelude-rust-2015.rs:3:9 | LL | #![warn(redundant_imports)] | ^^^^^^^^^^^^^^^^^ warning: the item `None` is imported redundantly - --> $DIR/use-redundant-prelude-rust-2015.rs:6:5 + --> $DIR/use-redundant-prelude-rust-2015.rs:7:5 | LL | use std::option::Option::None; | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | use std::option::Option::None; = note: the item `None` is already defined here warning: the item `Ok` is imported redundantly - --> $DIR/use-redundant-prelude-rust-2015.rs:8:5 + --> $DIR/use-redundant-prelude-rust-2015.rs:9:5 | LL | use std::result::Result::Ok; | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -32,7 +32,7 @@ LL | use std::result::Result::Ok; = note: the item `Ok` is already defined here warning: the item `Err` is imported redundantly - --> $DIR/use-redundant-prelude-rust-2015.rs:9:5 + --> $DIR/use-redundant-prelude-rust-2015.rs:10:5 | LL | use std::result::Result::Err; | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/lint/wide_pointer_comparisons.stderr b/tests/ui/lint/wide_pointer_comparisons.stderr index 5a0b914d832..4f5238e8252 100644 --- a/tests/ui/lint/wide_pointer_comparisons.stderr +++ b/tests/ui/lint/wide_pointer_comparisons.stderr @@ -29,10 +29,14 @@ warning: ambiguous wide pointer comparison, the comparison includes metadata whi LL | let _ = a < b; | ^^^^^ | -help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses +help: use untyped pointers to only compare their addresses | LL | let _ = a.cast::<()>() < b.cast::<()>(); | +++++++++++++ +++++++++++++ +help: or expect the lint to compare the pointers metadata and addresses + | +LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] (a < b) }; + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:26:13 @@ -40,10 +44,14 @@ warning: ambiguous wide pointer comparison, the comparison includes metadata whi LL | let _ = a <= b; | ^^^^^^ | -help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses +help: use untyped pointers to only compare their addresses | LL | let _ = a.cast::<()>() <= b.cast::<()>(); | +++++++++++++ +++++++++++++ +help: or expect the lint to compare the pointers metadata and addresses + | +LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] (a <= b) }; + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:28:13 @@ -51,10 +59,14 @@ warning: ambiguous wide pointer comparison, the comparison includes metadata whi LL | let _ = a > b; | ^^^^^ | -help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses +help: use untyped pointers to only compare their addresses | LL | let _ = a.cast::<()>() > b.cast::<()>(); | +++++++++++++ +++++++++++++ +help: or expect the lint to compare the pointers metadata and addresses + | +LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] (a > b) }; + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:30:13 @@ -62,10 +74,14 @@ warning: ambiguous wide pointer comparison, the comparison includes metadata whi LL | let _ = a >= b; | ^^^^^^ | -help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses +help: use untyped pointers to only compare their addresses | LL | let _ = a.cast::<()>() >= b.cast::<()>(); | +++++++++++++ +++++++++++++ +help: or expect the lint to compare the pointers metadata and addresses + | +LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] (a >= b) }; + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:33:13 @@ -121,10 +137,14 @@ warning: ambiguous wide pointer comparison, the comparison includes metadata whi LL | let _ = a.cmp(&b); | ^^^^^^^^^ | -help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses +help: use untyped pointers to only compare their addresses | LL | let _ = a.cast::<()>().cmp(&b.cast::<()>()); | +++++++++++++ +++++++++++++ +help: or expect the lint to compare the pointers metadata and addresses + | +LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] a.cmp(&b) }; + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:43:13 @@ -132,10 +152,14 @@ warning: ambiguous wide pointer comparison, the comparison includes metadata whi LL | let _ = a.partial_cmp(&b); | ^^^^^^^^^^^^^^^^^ | -help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses +help: use untyped pointers to only compare their addresses | LL | let _ = a.cast::<()>().partial_cmp(&b.cast::<()>()); | +++++++++++++ +++++++++++++ +help: or expect the lint to compare the pointers metadata and addresses + | +LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] a.partial_cmp(&b) }; + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:45:13 @@ -143,10 +167,14 @@ warning: ambiguous wide pointer comparison, the comparison includes metadata whi LL | let _ = a.le(&b); | ^^^^^^^^ | -help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses +help: use untyped pointers to only compare their addresses | LL | let _ = a.cast::<()>().le(&b.cast::<()>()); | +++++++++++++ +++++++++++++ +help: or expect the lint to compare the pointers metadata and addresses + | +LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] a.le(&b) }; + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:47:13 @@ -154,10 +182,14 @@ warning: ambiguous wide pointer comparison, the comparison includes metadata whi LL | let _ = a.lt(&b); | ^^^^^^^^ | -help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses +help: use untyped pointers to only compare their addresses | LL | let _ = a.cast::<()>().lt(&b.cast::<()>()); | +++++++++++++ +++++++++++++ +help: or expect the lint to compare the pointers metadata and addresses + | +LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] a.lt(&b) }; + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:49:13 @@ -165,10 +197,14 @@ warning: ambiguous wide pointer comparison, the comparison includes metadata whi LL | let _ = a.ge(&b); | ^^^^^^^^ | -help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses +help: use untyped pointers to only compare their addresses | LL | let _ = a.cast::<()>().ge(&b.cast::<()>()); | +++++++++++++ +++++++++++++ +help: or expect the lint to compare the pointers metadata and addresses + | +LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] a.ge(&b) }; + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:51:13 @@ -176,10 +212,14 @@ warning: ambiguous wide pointer comparison, the comparison includes metadata whi LL | let _ = a.gt(&b); | ^^^^^^^^ | -help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses +help: use untyped pointers to only compare their addresses | LL | let _ = a.cast::<()>().gt(&b.cast::<()>()); | +++++++++++++ +++++++++++++ +help: or expect the lint to compare the pointers metadata and addresses + | +LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] a.gt(&b) }; + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:57:17 @@ -199,10 +239,14 @@ warning: ambiguous wide pointer comparison, the comparison includes metadata whi LL | let _ = a >= b; | ^^^^^^ | -help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses +help: use untyped pointers to only compare their addresses | LL | let _ = a.as_ptr().cast::<()>() >= b.as_ptr().cast::<()>(); | ++++++++++++++++++++++ ++++++++++++++++++++++ +help: or expect the lint to compare the pointers metadata and addresses + | +LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] (a >= b) }; + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:61:17 @@ -246,10 +290,14 @@ warning: ambiguous wide pointer comparison, the comparison includes metadata whi LL | let _ = a < b; | ^^^^^ | -help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses +help: use untyped pointers to only compare their addresses | LL | let _ = (*a).cast::<()>() < (*b).cast::<()>(); | ++ ++++++++++++++ ++ ++++++++++++++ +help: or expect the lint to compare the pointers metadata and addresses + | +LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] (a < b) }; + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:76:17 @@ -257,10 +305,14 @@ warning: ambiguous wide pointer comparison, the comparison includes metadata whi LL | let _ = a <= b; | ^^^^^^ | -help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses +help: use untyped pointers to only compare their addresses | LL | let _ = (*a).cast::<()>() <= (*b).cast::<()>(); | ++ ++++++++++++++ ++ ++++++++++++++ +help: or expect the lint to compare the pointers metadata and addresses + | +LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] (a <= b) }; + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:78:17 @@ -268,10 +320,14 @@ warning: ambiguous wide pointer comparison, the comparison includes metadata whi LL | let _ = a > b; | ^^^^^ | -help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses +help: use untyped pointers to only compare their addresses | LL | let _ = (*a).cast::<()>() > (*b).cast::<()>(); | ++ ++++++++++++++ ++ ++++++++++++++ +help: or expect the lint to compare the pointers metadata and addresses + | +LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] (a > b) }; + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:80:17 @@ -279,10 +335,14 @@ warning: ambiguous wide pointer comparison, the comparison includes metadata whi LL | let _ = a >= b; | ^^^^^^ | -help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses +help: use untyped pointers to only compare their addresses | LL | let _ = (*a).cast::<()>() >= (*b).cast::<()>(); | ++ ++++++++++++++ ++ ++++++++++++++ +help: or expect the lint to compare the pointers metadata and addresses + | +LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] (a >= b) }; + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:83:17 @@ -362,10 +422,14 @@ warning: ambiguous wide pointer comparison, the comparison includes metadata whi LL | let _ = a.cmp(&b); | ^^^^^^^^^ | -help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses +help: use untyped pointers to only compare their addresses | LL | let _ = (*a).cast::<()>().cmp(&(*b).cast::<()>()); | ++ ++++++++++++++ ++ ++++++++++++++ +help: or expect the lint to compare the pointers metadata and addresses + | +LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] a.cmp(&b) }; + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:97:17 @@ -373,10 +437,14 @@ warning: ambiguous wide pointer comparison, the comparison includes metadata whi LL | let _ = a.partial_cmp(&b); | ^^^^^^^^^^^^^^^^^ | -help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses +help: use untyped pointers to only compare their addresses | LL | let _ = (*a).cast::<()>().partial_cmp(&(*b).cast::<()>()); | ++ ++++++++++++++ ++ ++++++++++++++ +help: or expect the lint to compare the pointers metadata and addresses + | +LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] a.partial_cmp(&b) }; + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:99:17 @@ -384,10 +452,14 @@ warning: ambiguous wide pointer comparison, the comparison includes metadata whi LL | let _ = a.le(&b); | ^^^^^^^^ | -help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses +help: use untyped pointers to only compare their addresses | LL | let _ = (*a).cast::<()>().le(&(*b).cast::<()>()); | ++ ++++++++++++++ ++ ++++++++++++++ +help: or expect the lint to compare the pointers metadata and addresses + | +LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] a.le(&b) }; + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:101:17 @@ -395,10 +467,14 @@ warning: ambiguous wide pointer comparison, the comparison includes metadata whi LL | let _ = a.lt(&b); | ^^^^^^^^ | -help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses +help: use untyped pointers to only compare their addresses | LL | let _ = (*a).cast::<()>().lt(&(*b).cast::<()>()); | ++ ++++++++++++++ ++ ++++++++++++++ +help: or expect the lint to compare the pointers metadata and addresses + | +LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] a.lt(&b) }; + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:103:17 @@ -406,10 +482,14 @@ warning: ambiguous wide pointer comparison, the comparison includes metadata whi LL | let _ = a.ge(&b); | ^^^^^^^^ | -help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses +help: use untyped pointers to only compare their addresses | LL | let _ = (*a).cast::<()>().ge(&(*b).cast::<()>()); | ++ ++++++++++++++ ++ ++++++++++++++ +help: or expect the lint to compare the pointers metadata and addresses + | +LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] a.ge(&b) }; + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:105:17 @@ -417,10 +497,14 @@ warning: ambiguous wide pointer comparison, the comparison includes metadata whi LL | let _ = a.gt(&b); | ^^^^^^^^ | -help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses +help: use untyped pointers to only compare their addresses | LL | let _ = (*a).cast::<()>().gt(&(*b).cast::<()>()); | ++ ++++++++++++++ ++ ++++++++++++++ +help: or expect the lint to compare the pointers metadata and addresses + | +LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] a.gt(&b) }; + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:110:13 @@ -496,10 +580,14 @@ warning: ambiguous wide pointer comparison, the comparison includes metadata whi LL | let _ = a < b; | ^^^^^ | -help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses +help: use untyped pointers to only compare their addresses | LL | let _ = a.cast::<()>() < b.cast::<()>(); | +++++++++++++ +++++++++++++ +help: or expect the lint to compare the pointers metadata and addresses + | +LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] (a < b) }; + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:124:17 @@ -507,10 +595,14 @@ warning: ambiguous wide pointer comparison, the comparison includes metadata whi LL | let _ = a <= b; | ^^^^^^ | -help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses +help: use untyped pointers to only compare their addresses | LL | let _ = a.cast::<()>() <= b.cast::<()>(); | +++++++++++++ +++++++++++++ +help: or expect the lint to compare the pointers metadata and addresses + | +LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] (a <= b) }; + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:126:17 @@ -518,10 +610,14 @@ warning: ambiguous wide pointer comparison, the comparison includes metadata whi LL | let _ = a > b; | ^^^^^ | -help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses +help: use untyped pointers to only compare their addresses | LL | let _ = a.cast::<()>() > b.cast::<()>(); | +++++++++++++ +++++++++++++ +help: or expect the lint to compare the pointers metadata and addresses + | +LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] (a > b) }; + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:128:17 @@ -529,10 +625,14 @@ warning: ambiguous wide pointer comparison, the comparison includes metadata whi LL | let _ = a >= b; | ^^^^^^ | -help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses +help: use untyped pointers to only compare their addresses | LL | let _ = a.cast::<()>() >= b.cast::<()>(); | +++++++++++++ +++++++++++++ +help: or expect the lint to compare the pointers metadata and addresses + | +LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] (a >= b) }; + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++ warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:131:17 diff --git a/tests/ui/loops/loop-break-never-type-mismatch.rs b/tests/ui/loops/loop-break-never-type-mismatch.rs new file mode 100644 index 00000000000..2be4e4f4ac5 --- /dev/null +++ b/tests/ui/loops/loop-break-never-type-mismatch.rs @@ -0,0 +1,56 @@ +//! Tests type mismatches with `break` and diverging types in loops + +#![feature(never_type)] + +fn loop_break_return() -> i32 { + let loop_value = loop { + break return 0; + }; // ok +} + +fn loop_break_loop() -> i32 { + let loop_value = loop { + break loop {}; + }; // ok +} + +fn loop_break_break() -> i32 { + //~^ ERROR mismatched types + let loop_value = loop { + break break; + }; +} + +fn loop_break_return_2() -> i32 { + let loop_value = loop { + break { + return 0; + () + }; + }; // ok +} + +enum Void {} + +fn get_void() -> Void { + panic!() +} + +fn loop_break_void() -> i32 { + //~^ ERROR mismatched types + let loop_value = loop { + break get_void(); + }; +} + +fn get_never() -> ! { + panic!() +} + +fn loop_break_never() -> i32 { + let loop_value = loop { + break get_never(); + }; // ok +} + +fn main() {} diff --git a/tests/ui/break-diverging-value.stderr b/tests/ui/loops/loop-break-never-type-mismatch.stderr index 69edcd24080..e6868f375e2 100644 --- a/tests/ui/break-diverging-value.stderr +++ b/tests/ui/loops/loop-break-never-type-mismatch.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/break-diverging-value.rs:11:26 + --> $DIR/loop-break-never-type-mismatch.rs:17:26 | LL | fn loop_break_break() -> i32 { | ---------------- ^^^ expected `i32`, found `()` @@ -7,7 +7,7 @@ LL | fn loop_break_break() -> i32 { | implicitly returns `()` as its body has no tail or `return` expression error[E0308]: mismatched types - --> $DIR/break-diverging-value.rs:25:25 + --> $DIR/loop-break-never-type-mismatch.rs:39:25 | LL | fn loop_break_void() -> i32 { | --------------- ^^^ expected `i32`, found `()` diff --git a/tests/ui/macros/auxiliary/borrowck-error-in-macro.rs b/tests/ui/macros/auxiliary/borrowck-error-in-macro.rs new file mode 100644 index 00000000000..2d5f2bda2ed --- /dev/null +++ b/tests/ui/macros/auxiliary/borrowck-error-in-macro.rs @@ -0,0 +1,10 @@ +#[macro_export] +macro_rules! ice { + () => { + fn main() { + let d = &mut 0; + let c = || *d += 1; + c(); + } + }; +} diff --git a/tests/ui/macros/borrowck-error-in-macro.rs b/tests/ui/macros/borrowck-error-in-macro.rs new file mode 100644 index 00000000000..fe75188efd2 --- /dev/null +++ b/tests/ui/macros/borrowck-error-in-macro.rs @@ -0,0 +1,8 @@ +//@ aux-build: borrowck-error-in-macro.rs +//@ error-pattern: a call in this macro requires a mutable binding due to mutable borrow of `d` +//FIXME: remove error-pattern (see #141896) + +extern crate borrowck_error_in_macro as a; + +a::ice! {} +//~^ ERROR cannot borrow value as mutable, as it is not declared as mutable diff --git a/tests/ui/macros/borrowck-error-in-macro.stderr b/tests/ui/macros/borrowck-error-in-macro.stderr new file mode 100644 index 00000000000..ec0302ee287 --- /dev/null +++ b/tests/ui/macros/borrowck-error-in-macro.stderr @@ -0,0 +1,19 @@ +error[E0596]: cannot borrow value as mutable, as it is not declared as mutable + --> $DIR/borrowck-error-in-macro.rs:7:1 + | +LL | a::ice! {} + | ^^^^^^^^^^ + | | + | cannot borrow as mutable + | a call in this macro requires a mutable binding due to mutable borrow of `d` + | + = note: this error originates in the macro `a::ice` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider changing this to be mutable + --> $DIR/auxiliary/borrowck-error-in-macro.rs:6:17 + | +LL | let mut c = || *d += 1; + | +++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/tests/ui/macros/format-args-temporaries.rs b/tests/ui/macros/format-args-temporaries.rs index ad9792bc796..74714be7653 100644 --- a/tests/ui/macros/format-args-temporaries.rs +++ b/tests/ui/macros/format-args-temporaries.rs @@ -5,7 +5,7 @@ use std::fmt::{self, Display}; struct Mutex; impl Mutex { - fn lock(&self) -> MutexGuard { + fn lock(&self) -> MutexGuard<'_> { MutexGuard(self) } } diff --git a/tests/ui/macros/ice-in-tokenstream-for-contracts-issue-140683.rs b/tests/ui/macros/ice-in-tokenstream-for-contracts-issue-140683.rs new file mode 100644 index 00000000000..68346a00ae1 --- /dev/null +++ b/tests/ui/macros/ice-in-tokenstream-for-contracts-issue-140683.rs @@ -0,0 +1,13 @@ +#![feature(contracts)] +#![allow(incomplete_features)] + +struct T; + +impl T { + #[core::contracts::ensures] //~ ERROR expected a `Fn(&_)` closure, found `()` + fn b() {(loop)} + //~^ ERROR expected `{`, found `)` + //~| ERROR expected `{`, found `)` +} + +fn main() {} diff --git a/tests/ui/macros/ice-in-tokenstream-for-contracts-issue-140683.stderr b/tests/ui/macros/ice-in-tokenstream-for-contracts-issue-140683.stderr new file mode 100644 index 00000000000..f1ffda2a9be --- /dev/null +++ b/tests/ui/macros/ice-in-tokenstream-for-contracts-issue-140683.stderr @@ -0,0 +1,34 @@ +error: expected `{`, found `)` + --> $DIR/ice-in-tokenstream-for-contracts-issue-140683.rs:8:18 + | +LL | fn b() {(loop)} + | ----^ expected `{` + | | + | while parsing this `loop` expression + +error: expected `{`, found `)` + --> $DIR/ice-in-tokenstream-for-contracts-issue-140683.rs:8:18 + | +LL | fn b() {(loop)} + | ----^ expected `{` + | | + | while parsing this `loop` expression + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0277]: expected a `Fn(&_)` closure, found `()` + --> $DIR/ice-in-tokenstream-for-contracts-issue-140683.rs:7:5 + | +LL | #[core::contracts::ensures] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected an `Fn(&_)` closure, found `()` + | required by a bound introduced by this call + | + = help: the trait `for<'a> Fn(&'a _)` is not implemented for `()` +note: required by a bound in `build_check_ensures` + --> $SRC_DIR/core/src/contracts.rs:LL:COL + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/macros/macro-pub-matcher.rs b/tests/ui/macros/macro-pub-matcher.rs index 538f55cc98d..e0b03dbbeb1 100644 --- a/tests/ui/macros/macro-pub-matcher.rs +++ b/tests/ui/macros/macro-pub-matcher.rs @@ -68,15 +68,15 @@ mod with_crate { mod garden { mod with_pub_restricted_path { - vis_passthru! { pub(in garden) const A: i32 = 0; } - vis_passthru! { pub(in garden) enum B {} } - vis_passthru! { pub(in garden) extern "C" fn c() {} } - vis_passthru! { pub(in garden) mod d {} } - vis_passthru! { pub(in garden) static E: i32 = 0; } - vis_passthru! { pub(in garden) struct F; } - vis_passthru! { pub(in garden) trait G {} } - vis_passthru! { pub(in garden) type H = i32; } - vis_passthru! { pub(in garden) use A as I; } + vis_passthru! { pub(in crate::garden) const A: i32 = 0; } + vis_passthru! { pub(in crate::garden) enum B {} } + vis_passthru! { pub(in crate::garden) extern "C" fn c() {} } + vis_passthru! { pub(in crate::garden) mod d {} } + vis_passthru! { pub(in crate::garden) static E: i32 = 0; } + vis_passthru! { pub(in crate::garden) struct F; } + vis_passthru! { pub(in crate::garden) trait G {} } + vis_passthru! { pub(in crate::garden) type H = i32; } + vis_passthru! { pub(in crate::garden) use A as I; } } } diff --git a/tests/ui/macros/missing-writer.stderr b/tests/ui/macros/missing-writer.stderr index 86dfe7d65ea..a3430cfc0ee 100644 --- a/tests/ui/macros/missing-writer.stderr +++ b/tests/ui/macros/missing-writer.stderr @@ -24,7 +24,7 @@ error[E0599]: cannot write into `&'static str` --> $DIR/missing-writer.rs:5:12 | LL | write!("{}_{}", x, y); - | -------^^^^^^^------- method not found in `&str` + | -------^^^^^^^------- method not found in `&'static str` | note: must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method --> $DIR/missing-writer.rs:5:12 @@ -41,7 +41,7 @@ error[E0599]: cannot write into `&'static str` --> $DIR/missing-writer.rs:11:14 | LL | writeln!("{}_{}", x, y); - | ---------^^^^^^^------- method not found in `&str` + | ---------^^^^^^^------- method not found in `&'static str` | note: must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method --> $DIR/missing-writer.rs:11:14 diff --git a/tests/ui/macros/no-close-delim-issue-139248.rs b/tests/ui/macros/no-close-delim-issue-139248.rs index 86583b2724e..f15234eaff1 100644 --- a/tests/ui/macros/no-close-delim-issue-139248.rs +++ b/tests/ui/macros/no-close-delim-issue-139248.rs @@ -2,9 +2,8 @@ macro_rules! m { (static a : () = $e:expr) => { - static a : () = $e; - //~^ ERROR macro expansion ends with an incomplete expression: expected expression - } + static a: () = $e; + }; } m! { static a : () = (if b) } diff --git a/tests/ui/macros/no-close-delim-issue-139248.stderr b/tests/ui/macros/no-close-delim-issue-139248.stderr index 6ed41ae9b46..8aa39851b4b 100644 --- a/tests/ui/macros/no-close-delim-issue-139248.stderr +++ b/tests/ui/macros/no-close-delim-issue-139248.stderr @@ -1,33 +1,27 @@ error: expected `{`, found `)` - --> $DIR/no-close-delim-issue-139248.rs:10:27 + --> $DIR/no-close-delim-issue-139248.rs:9:27 | LL | m! { static a : () = (if b) } | ^ expected `{` | note: the `if` expression is missing a block after this condition - --> $DIR/no-close-delim-issue-139248.rs:10:26 + --> $DIR/no-close-delim-issue-139248.rs:9:26 | LL | m! { static a : () = (if b) } | ^ error: expected `{`, found `)` - --> $DIR/no-close-delim-issue-139248.rs:10:27 + --> $DIR/no-close-delim-issue-139248.rs:9:27 | LL | m! { static a : () = (if b) } | ^ expected `{` | note: the `if` expression is missing a block after this condition - --> $DIR/no-close-delim-issue-139248.rs:10:26 + --> $DIR/no-close-delim-issue-139248.rs:9:26 | LL | m! { static a : () = (if b) } | ^ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: macro expansion ends with an incomplete expression: expected expression - --> $DIR/no-close-delim-issue-139248.rs:5:28 - | -LL | static a : () = $e; - | ^ expected expression - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/macros/paths-in-macro-invocations.rs b/tests/ui/macros/paths-in-macro-invocations.rs index c1b7789d6de..b8f4784298d 100644 --- a/tests/ui/macros/paths-in-macro-invocations.rs +++ b/tests/ui/macros/paths-in-macro-invocations.rs @@ -11,26 +11,26 @@ mod foo { pub use two_macros::macro_one as bar; } trait T { foo::bar!(); - ::foo::bar!(); + crate::foo::bar!(); } struct S { x: foo::bar!(i32), - y: ::foo::bar!(i32), + y: crate::foo::bar!(i32), } impl S { foo::bar!(); - ::foo::bar!(); + crate::foo::bar!(); } fn main() { foo::bar!(); - ::foo::bar!(); + crate::foo::bar!(); let _ = foo::bar!(0); - let _ = ::foo::bar!(0); + let _ = crate::foo::bar!(0); let foo::bar!(_) = 0; - let ::foo::bar!(_) = 0; + let crate::foo::bar!(_) = 0; } diff --git a/tests/ui/macros/return_from_external_macro.rs b/tests/ui/macros/return_from_external_macro.rs index 43fe99e63ad..91d0c4c64fd 100644 --- a/tests/ui/macros/return_from_external_macro.rs +++ b/tests/ui/macros/return_from_external_macro.rs @@ -5,7 +5,7 @@ extern crate ret_from_ext; fn foo() -> impl Sized { drop(|| ret_from_ext::foo!()); - //~^ ERROR cannot return reference to local binding + //~^ ERROR cannot return reference to temporary value ret_from_ext::foo!() //~^ ERROR temporary value dropped while borrowed diff --git a/tests/ui/macros/return_from_external_macro.stderr b/tests/ui/macros/return_from_external_macro.stderr index b6010b8ec79..6f707b9f52b 100644 --- a/tests/ui/macros/return_from_external_macro.stderr +++ b/tests/ui/macros/return_from_external_macro.stderr @@ -1,11 +1,11 @@ -error[E0515]: cannot return reference to local binding +error[E0515]: cannot return reference to temporary value --> $DIR/return_from_external_macro.rs:7:13 | LL | drop(|| ret_from_ext::foo!()); | ^^^^^^^^^^^^^^^^^^^^ | | | returns a reference to data owned by the current function - | local binding introduced here + | temporary value created here | = note: this error originates in the macro `ret_from_ext::foo` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/macros/try-macro.rs b/tests/ui/macros/try-macro.rs index b579143583e..f6268654cfc 100644 --- a/tests/ui/macros/try-macro.rs +++ b/tests/ui/macros/try-macro.rs @@ -1,4 +1,5 @@ //@ run-pass +//@ edition: 2015 #![allow(deprecated)] // for deprecated `try!()` macro use std::num::{ParseFloatError, ParseIntError}; diff --git a/tests/ui/methods/issue-19521.stderr b/tests/ui/methods/issue-19521.stderr index f451dc36d45..2ef83a4792a 100644 --- a/tests/ui/methods/issue-19521.stderr +++ b/tests/ui/methods/issue-19521.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `homura` found for reference `&'static str` in the --> $DIR/issue-19521.rs:2:8 | LL | "".homura()(); - | ^^^^^^ method not found in `&str` + | ^^^^^^ method not found in `&'static str` error: aborting due to 1 previous error diff --git a/tests/ui/methods/method-not-found-generic-arg-elision.stderr b/tests/ui/methods/method-not-found-generic-arg-elision.stderr index a665500fd9e..8429c3aebac 100644 --- a/tests/ui/methods/method-not-found-generic-arg-elision.stderr +++ b/tests/ui/methods/method-not-found-generic-arg-elision.stderr @@ -23,7 +23,7 @@ error[E0599]: no method named `extend` found for struct `Map` in the current sco --> $DIR/method-not-found-generic-arg-elision.rs:87:67 | LL | v.iter().map(Box::new(|x| x * x) as Box<dyn Fn(&i32) -> i32>).extend(std::iter::once(100)); - | ^^^^^^ method not found in `Map<Iter<'_, i32>, Box<dyn Fn(&i32) -> i32>>` + | ^^^^^^ method not found in `Map<std::slice::Iter<'_, i32>, Box<dyn for<'a> Fn(&'a i32) -> i32>>` error[E0599]: no method named `method` found for struct `Wrapper<bool>` in the current scope --> $DIR/method-not-found-generic-arg-elision.rs:90:13 diff --git a/tests/ui/methods/receiver-equality.stderr b/tests/ui/methods/receiver-equality.stderr index cea3340e386..bf149cc2eb4 100644 --- a/tests/ui/methods/receiver-equality.stderr +++ b/tests/ui/methods/receiver-equality.stderr @@ -5,7 +5,7 @@ LL | struct B<T>(T); | ----------- function or associated item `method` not found for this struct ... LL | B::<for<'a> fn(&'a ())>::method(y); - | ^^^^^^ function or associated item not found in `B<fn(&())>` + | ^^^^^^ function or associated item not found in `B<for<'a> fn(&'a ())>` error: aborting due to 1 previous error diff --git a/tests/ui/methods/untrimmed-path-type.rs b/tests/ui/methods/untrimmed-path-type.rs new file mode 100644 index 00000000000..e6e3ad79185 --- /dev/null +++ b/tests/ui/methods/untrimmed-path-type.rs @@ -0,0 +1,11 @@ +// Ensures that the path of the `Error` type is not trimmed +// to make it clear which Error type is meant. + +fn main() { + meow().unknown(); //~ ERROR no method named `unknown` found + //~^ NOTE method not found in `Result<(), std::io::Error>` +} + +fn meow() -> Result<(), std::io::Error> { + Ok(()) +} diff --git a/tests/ui/methods/untrimmed-path-type.stderr b/tests/ui/methods/untrimmed-path-type.stderr new file mode 100644 index 00000000000..1f3101ff4e7 --- /dev/null +++ b/tests/ui/methods/untrimmed-path-type.stderr @@ -0,0 +1,9 @@ +error[E0599]: no method named `unknown` found for enum `Result` in the current scope + --> $DIR/untrimmed-path-type.rs:5:11 + | +LL | meow().unknown(); + | ^^^^^^^ method not found in `Result<(), std::io::Error>` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/auto-ref-slice-plus-ref.rs b/tests/ui/methods/vec-autoderef-autoref.rs index 00b279d3226..38c0ba8574b 100644 --- a/tests/ui/auto-ref-slice-plus-ref.rs +++ b/tests/ui/methods/vec-autoderef-autoref.rs @@ -1,8 +1,7 @@ -fn main() { - - // Testing that method lookup does not automatically borrow - // vectors to slices then automatically create a self reference. +//! Test that method resolution does not autoderef `Vec` +//! into a slice or perform additional autorefs. +fn main() { let mut a = vec![0]; a.test_mut(); //~ ERROR no method named `test_mut` found a.test(); //~ ERROR no method named `test` found diff --git a/tests/ui/auto-ref-slice-plus-ref.stderr b/tests/ui/methods/vec-autoderef-autoref.stderr index 806c1ee064f..61c3bcc5b3b 100644 --- a/tests/ui/auto-ref-slice-plus-ref.stderr +++ b/tests/ui/methods/vec-autoderef-autoref.stderr @@ -1,12 +1,12 @@ error[E0599]: no method named `test_mut` found for struct `Vec<{integer}>` in the current scope - --> $DIR/auto-ref-slice-plus-ref.rs:7:7 + --> $DIR/vec-autoderef-autoref.rs:6:7 | LL | a.test_mut(); | ^^^^^^^^ | = help: items from traits can only be used if the trait is implemented and in scope note: `MyIter` defines an item `test_mut`, perhaps you need to implement it - --> $DIR/auto-ref-slice-plus-ref.rs:14:1 + --> $DIR/vec-autoderef-autoref.rs:13:1 | LL | trait MyIter { | ^^^^^^^^^^^^ @@ -14,40 +14,40 @@ help: there is a method `get_mut` with a similar name, but with different argume --> $SRC_DIR/core/src/slice/mod.rs:LL:COL error[E0599]: no method named `test` found for struct `Vec<{integer}>` in the current scope - --> $DIR/auto-ref-slice-plus-ref.rs:8:7 + --> $DIR/vec-autoderef-autoref.rs:7:7 | LL | a.test(); | ^^^^ method not found in `Vec<{integer}>` | = help: items from traits can only be used if the trait is implemented and in scope note: `MyIter` defines an item `test`, perhaps you need to implement it - --> $DIR/auto-ref-slice-plus-ref.rs:14:1 + --> $DIR/vec-autoderef-autoref.rs:13:1 | LL | trait MyIter { | ^^^^^^^^^^^^ error[E0599]: no method named `test` found for array `[{integer}; 1]` in the current scope - --> $DIR/auto-ref-slice-plus-ref.rs:10:11 + --> $DIR/vec-autoderef-autoref.rs:9:11 | LL | ([1]).test(); | ^^^^ method not found in `[{integer}; 1]` | = help: items from traits can only be used if the trait is implemented and in scope note: `MyIter` defines an item `test`, perhaps you need to implement it - --> $DIR/auto-ref-slice-plus-ref.rs:14:1 + --> $DIR/vec-autoderef-autoref.rs:13:1 | LL | trait MyIter { | ^^^^^^^^^^^^ error[E0599]: no method named `test` found for reference `&[{integer}; 1]` in the current scope - --> $DIR/auto-ref-slice-plus-ref.rs:11:12 + --> $DIR/vec-autoderef-autoref.rs:10:12 | LL | (&[1]).test(); | ^^^^ method not found in `&[{integer}; 1]` | = help: items from traits can only be used if the trait is implemented and in scope note: `MyIter` defines an item `test`, perhaps you need to implement it - --> $DIR/auto-ref-slice-plus-ref.rs:14:1 + --> $DIR/vec-autoderef-autoref.rs:13:1 | LL | trait MyIter { | ^^^^^^^^^^^^ diff --git a/tests/ui/mir/mir_fat_ptr.rs b/tests/ui/mir/mir_fat_ptr.rs index f2dd9e6fe40..af9831570d1 100644 --- a/tests/ui/mir/mir_fat_ptr.rs +++ b/tests/ui/mir/mir_fat_ptr.rs @@ -20,11 +20,11 @@ fn fat_ptr_via_local(a: &[u8]) -> &[u8] { x } -fn fat_ptr_from_struct(s: FatPtrContainer) -> &[u8] { +fn fat_ptr_from_struct(s: FatPtrContainer<'_>) -> &[u8] { s.ptr } -fn fat_ptr_to_struct(a: &[u8]) -> FatPtrContainer { +fn fat_ptr_to_struct(a: &[u8]) -> FatPtrContainer<'_> { FatPtrContainer { ptr: a } } diff --git a/tests/ui/mir/mir_match_guard_let_chains_drop_order.rs b/tests/ui/mir/mir_match_guard_let_chains_drop_order.rs new file mode 100644 index 00000000000..e98d57d1154 --- /dev/null +++ b/tests/ui/mir/mir_match_guard_let_chains_drop_order.rs @@ -0,0 +1,110 @@ +//@ run-pass +//@ needs-unwind +//@ revisions: edition2021 edition2024 +//@ [edition2021] edition: 2021 +//@ [edition2024] edition: 2024 + +// See `mir_drop_order.rs` for more information + +#![feature(if_let_guard)] +#![allow(irrefutable_let_patterns)] + +use std::cell::RefCell; +use std::panic; + +pub struct DropLogger<'a, T> { + extra: T, + id: usize, + log: &'a panic::AssertUnwindSafe<RefCell<Vec<usize>>>, +} + +impl<'a, T> Drop for DropLogger<'a, T> { + fn drop(&mut self) { + self.log.0.borrow_mut().push(self.id); + } +} + +struct InjectedFailure; + +#[allow(unreachable_code)] +fn main() { + let log = panic::AssertUnwindSafe(RefCell::new(vec![])); + let d = |id, extra| DropLogger { extra, id: id, log: &log }; + let get = || -> Vec<_> { + let mut m = log.0.borrow_mut(); + let n = m.drain(..); + n.collect() + }; + + { + let _x = ( + d( + 0, + d( + 1, + match () { () if let Some(_) = d(2, Some(true)).extra + && let DropLogger { .. } = d(3, None) => { + None + } + _ => { + Some(true) + } + } + ) + .extra, + ), + d(4, None), + &d(5, None), + d(6, None), + match () { + () if let DropLogger { .. } = d(7, None) + && let DropLogger { .. } = d(8, None) => { + d(9, None) + } + _ => { + // 10 is not constructed + d(10, None) + } + }, + ); + assert_eq!(get(), vec![3, 2, 8, 7, 1]); + } + assert_eq!(get(), vec![0, 4, 6, 9, 5]); + + let _ = std::panic::catch_unwind(|| { + ( + d( + 11, + d( + 12, + match () { + () if let Some(_) = d(13, Some(true)).extra + && let DropLogger { .. } = d(14, None) => { + None + } + _ => { + Some(true) + } + } + ) + .extra, + ), + d(15, None), + &d(16, None), + d(17, None), + match () { + () if let DropLogger { .. } = d(18, None) + && let DropLogger { .. } = d(19, None) + => { + d(20, None) + } + _ => { + // 10 is not constructed + d(21, None) + } + }, + panic::panic_any(InjectedFailure), + ); + }); + assert_eq!(get(), vec![14, 13, 19, 18, 20, 17, 15, 11, 16, 12]); +} diff --git a/tests/ui/mismatched_types/cast-rfc0401.stderr b/tests/ui/mismatched_types/cast-rfc0401.stderr index a4276395944..a188b7791fd 100644 --- a/tests/ui/mismatched_types/cast-rfc0401.stderr +++ b/tests/ui/mismatched_types/cast-rfc0401.stderr @@ -104,10 +104,13 @@ error[E0604]: only `u8` can be cast as `char`, not `u32` --> $DIR/cast-rfc0401.rs:41:13 | LL | let _ = 0x61u32 as char; - | ^^^^^^^^^^^^^^^ - | | - | invalid cast - | help: try `char::from_u32` instead: `char::from_u32(0x61u32)` + | ^^^^^^^^^^^^^^^ invalid cast + | +help: consider using `char::from_u32` instead + | +LL - let _ = 0x61u32 as char; +LL + let _ = char::from_u32(0x61u32); + | error[E0606]: casting `bool` as `f32` is invalid --> $DIR/cast-rfc0401.rs:43:13 diff --git a/tests/ui/mismatched_types/hr-projection-mismatch.current.stderr b/tests/ui/mismatched_types/hr-projection-mismatch.current.stderr new file mode 100644 index 00000000000..a2cec972e4a --- /dev/null +++ b/tests/ui/mismatched_types/hr-projection-mismatch.current.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/hr-projection-mismatch.rs:20:5 + | +LL | wrap::<_, Thing>(); + | ^^^^^^^^^^^^^^^^ one type is more general than the other + | + = note: expected reference `&'a _` + found reference `&_` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/mismatched_types/hr-projection-mismatch.next.stderr b/tests/ui/mismatched_types/hr-projection-mismatch.next.stderr new file mode 100644 index 00000000000..6ea0d43e153 --- /dev/null +++ b/tests/ui/mismatched_types/hr-projection-mismatch.next.stderr @@ -0,0 +1,20 @@ +error[E0271]: type mismatch resolving `<Thing as Trait<'a>>::Assoc == &i32` + --> $DIR/hr-projection-mismatch.rs:20:15 + | +LL | wrap::<_, Thing>(); + | ^^^^^ type mismatch resolving `<Thing as Trait<'a>>::Assoc == &i32` + | +note: types differ + --> $DIR/hr-projection-mismatch.rs:14:18 + | +LL | type Assoc = &'a i32; + | ^^^^^^^ +note: required by a bound in `wrap` + --> $DIR/hr-projection-mismatch.rs:17:33 + | +LL | fn wrap<T, U: for<'a> Trait<'a, Assoc = T>>() {} + | ^^^^^^^^^ required by this bound in `wrap` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/mismatched_types/hr-projection-mismatch.rs b/tests/ui/mismatched_types/hr-projection-mismatch.rs new file mode 100644 index 00000000000..f96314a3fca --- /dev/null +++ b/tests/ui/mismatched_types/hr-projection-mismatch.rs @@ -0,0 +1,25 @@ +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver + +// Regression test for <https://github.com/rust-lang/rust/issues/141322>. + +trait Trait<'a> { + type Assoc; +} + +struct Thing; + +impl<'a> Trait<'a> for Thing { + type Assoc = &'a i32; +} + +fn wrap<T, U: for<'a> Trait<'a, Assoc = T>>() {} + +fn foo() { + wrap::<_, Thing>(); + //[next]~^ ERROR type mismatch resolving `<Thing as Trait<'a>>::Assoc == &i32 + //[current]~^^ ERROR mismatched types +} + +fn main() {} diff --git a/tests/ui/mismatched_types/issue-36053-2.stderr b/tests/ui/mismatched_types/issue-36053-2.stderr index ffaa276b62e..8827be73a57 100644 --- a/tests/ui/mismatched_types/issue-36053-2.stderr +++ b/tests/ui/mismatched_types/issue-36053-2.stderr @@ -15,7 +15,7 @@ help: consider adjusting the signature so it borrows its argument LL | once::<&str>("str").fuse().filter(|a: &&str| true).count(); | + -error[E0599]: the method `count` exists for struct `Filter<Fuse<Once<&str>>, {closure@issue-36053-2.rs:7:39}>`, but its trait bounds were not satisfied +error[E0599]: the method `count` exists for struct `Filter<Fuse<std::iter::Once<&str>>, {closure@$DIR/issue-36053-2.rs:7:39: 7:48}>`, but its trait bounds were not satisfied --> $DIR/issue-36053-2.rs:7:55 | LL | once::<&str>("str").fuse().filter(|a: &str| true).count(); diff --git a/tests/ui/moves/issue-34721.fixed b/tests/ui/moves/issue-34721.fixed index 995fd920da7..4fdbee4d60b 100644 --- a/tests/ui/moves/issue-34721.fixed +++ b/tests/ui/moves/issue-34721.fixed @@ -9,15 +9,15 @@ impl Foo for u32 { } pub mod bar { - pub use Foo; + pub use crate::Foo; pub fn bar<T: Foo>(x: T) -> T { x.zero() } } mod baz { - use bar; - use Foo; + use crate::bar; + use crate::Foo; pub fn baz<T: Foo + Copy>(x: T) -> T { if 0 == 1 { bar::bar(x.zero()) diff --git a/tests/ui/moves/issue-34721.rs b/tests/ui/moves/issue-34721.rs index 747b15b4e02..4591b545b23 100644 --- a/tests/ui/moves/issue-34721.rs +++ b/tests/ui/moves/issue-34721.rs @@ -9,15 +9,15 @@ impl Foo for u32 { } pub mod bar { - pub use Foo; + pub use crate::Foo; pub fn bar<T: Foo>(x: T) -> T { x.zero() } } mod baz { - use bar; - use Foo; + use crate::bar; + use crate::Foo; pub fn baz<T: Foo>(x: T) -> T { if 0 == 1 { bar::bar(x.zero()) diff --git a/tests/ui/namespace/namespace-mix.stderr b/tests/ui/namespace/namespace-mix.stderr index 412ea4aba30..200d31cc710 100644 --- a/tests/ui/namespace/namespace-mix.stderr +++ b/tests/ui/namespace/namespace-mix.stderr @@ -7,7 +7,6 @@ LL | pub struct TS(); LL | check(m1::S); | ^^^^^ | - = note: can't use a type alias as a constructor help: a tuple struct with a similar name exists | LL | check(m1::TS); @@ -35,7 +34,6 @@ LL | check(xm1::S); LL | pub struct TS(); | ------------- similarly named tuple struct `TS` defined here | - = note: can't use a type alias as a constructor help: a tuple struct with a similar name exists | LL | check(xm1::TS); @@ -61,7 +59,6 @@ LL | TV(), LL | check(m7::V); | ^^^^^ | - = note: can't use a type alias as a constructor help: a tuple variant with a similar name exists | LL | check(m7::TV); @@ -89,7 +86,6 @@ LL | check(xm7::V); LL | TV(), | -- similarly named tuple variant `TV` defined here | - = note: can't use a type alias as a constructor help: a tuple variant with a similar name exists | LL | check(xm7::TV); diff --git a/tests/ui/namespace/namespaced-enum-glob-import-no-impls.rs b/tests/ui/namespace/namespaced-enum-glob-import-no-impls.rs index ab24f36f9a1..1586dd8bd59 100644 --- a/tests/ui/namespace/namespaced-enum-glob-import-no-impls.rs +++ b/tests/ui/namespace/namespaced-enum-glob-import-no-impls.rs @@ -12,11 +12,11 @@ mod m2 { } mod m { - pub use m2::Foo::*; + pub use crate::m2::Foo::*; } pub fn main() { - use m2::Foo::*; + use crate::m2::Foo::*; foo(); //~ ERROR cannot find function `foo` in this scope m::foo(); //~ ERROR cannot find function `foo` in module `m` diff --git a/tests/ui/never_type/feature-gate-never_type_fallback.stderr b/tests/ui/never_type/feature-gate-never_type_fallback.stderr index cbb670ea708..8dbd43e121b 100644 --- a/tests/ui/never_type/feature-gate-never_type_fallback.stderr +++ b/tests/ui/never_type/feature-gate-never_type_fallback.stderr @@ -2,10 +2,8 @@ error[E0277]: the trait bound `(): T` is not satisfied --> $DIR/feature-gate-never_type_fallback.rs:10:9 | LL | foo(panic!()) - | --- ^^^^^^^^ - | | | - | | the trait `T` is not implemented for `()` - | | this tail expression is of type `()` + | --- ^^^^^^^^ the trait `T` is not implemented for `()` + | | | required by a bound introduced by this call | help: this trait has no implementations, consider adding one diff --git a/tests/ui/nll/issue-53570.rs b/tests/ui/nll/issue-53570.rs index 882ce9e1c31..cfc1edd217d 100644 --- a/tests/ui/nll/issue-53570.rs +++ b/tests/ui/nll/issue-53570.rs @@ -22,7 +22,7 @@ struct Scratchpad<'a> { } impl<'a> Scratchpad<'a> { - fn get<T: GenericVec<T>>(&self) -> Ref<[T]> + fn get<T: GenericVec<T>>(&self) -> Ref<'_, [T]> where T: 'a { Ref::map(self.buffers.borrow(), |x| T::unwrap(x.as_ref())) diff --git a/tests/ui/nll/issue-54556-niconii.rs b/tests/ui/nll/issue-54556-niconii.rs index 9d37adede6a..dc641524b15 100644 --- a/tests/ui/nll/issue-54556-niconii.rs +++ b/tests/ui/nll/issue-54556-niconii.rs @@ -18,7 +18,7 @@ impl Drop for Mutex { fn drop(&mut self) { println!("Mutex::drop"); } } impl<'a> Drop for MutexGuard<'a> { fn drop(&mut self) { println!("MutexGuard::drop"); } } impl Mutex { - fn lock(&self) -> Result<MutexGuard, ()> { Ok(MutexGuard(self)) } + fn lock(&self) -> Result<MutexGuard<'_>, ()> { Ok(MutexGuard(self)) } } fn main() { diff --git a/tests/ui/nll/issue-57362-2.stderr b/tests/ui/nll/issue-57362-2.stderr index 24787b990e3..8a1a4d6b22c 100644 --- a/tests/ui/nll/issue-57362-2.stderr +++ b/tests/ui/nll/issue-57362-2.stderr @@ -2,7 +2,7 @@ error[E0599]: no function or associated item named `make_g` found for fn pointer --> $DIR/issue-57362-2.rs:23:25 | LL | let x = <fn (&())>::make_g(); - | ^^^^^^ function or associated item not found in `fn(&())` + | ^^^^^^ function or associated item not found in `for<'a> fn(&'a ())` | = help: items from traits can only be used if the trait is implemented and in scope note: `X` defines an item `make_g`, perhaps you need to implement it diff --git a/tests/ui/nll/issue-57642-higher-ranked-subtype.stderr b/tests/ui/nll/issue-57642-higher-ranked-subtype.stderr index 998d06b7706..27a887e8600 100644 --- a/tests/ui/nll/issue-57642-higher-ranked-subtype.stderr +++ b/tests/ui/nll/issue-57642-higher-ranked-subtype.stderr @@ -2,7 +2,7 @@ error[E0599]: no function or associated item named `make_g` found for fn pointer --> $DIR/issue-57642-higher-ranked-subtype.rs:31:25 | LL | let x = <fn (&())>::make_g(); - | ^^^^^^ function or associated item not found in `fn(&())` + | ^^^^^^ function or associated item not found in `for<'a> fn(&'a ())` | = help: items from traits can only be used if the trait is implemented and in scope note: `X` defines an item `make_g`, perhaps you need to implement it @@ -15,7 +15,7 @@ error[E0599]: no function or associated item named `make_f` found for fn pointer --> $DIR/issue-57642-higher-ranked-subtype.rs:36:25 | LL | let x = <fn (&())>::make_f(); - | ^^^^^^ function or associated item not found in `fn(&())` + | ^^^^^^ function or associated item not found in `for<'a> fn(&'a ())` | = help: items from traits can only be used if the trait is implemented and in scope note: `Y` defines an item `make_f`, perhaps you need to implement it diff --git a/tests/ui/nll/user-annotations/normalizing-user-annotation.rs b/tests/ui/nll/user-annotations/normalizing-user-annotation.rs new file mode 100644 index 00000000000..fa8b3bfd577 --- /dev/null +++ b/tests/ui/nll/user-annotations/normalizing-user-annotation.rs @@ -0,0 +1,31 @@ +//@ check-pass +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver + +// Regression test for <https://github.com/rust-lang/rust/issues/141708>. + +// See description in there; this has to do with fundamental limitations +// to the old trait solver surrounding higher-ranked aliases with infer +// vars. This always worked in the new trait solver, but I added a revision +// just for good measure. + +trait Foo<'a> { + type Assoc; +} + +impl Foo<'_> for i32 { + type Assoc = u32; +} + +impl Foo<'_> for u32 { + type Assoc = u32; +} + +fn foo<'b: 'b, T: for<'a> Foo<'a>, F: for<'a> Fn(<T as Foo<'a>>::Assoc)>(_: F) -> (T, F) { + todo!() +} + +fn main() { + let (x, c): (i32, _) = foo::<'static, _, _>(|_| {}); +} diff --git a/tests/ui/nonscalar-cast.stderr b/tests/ui/nonscalar-cast.stderr index 01b4a9a7ce0..834d4ea241c 100644 --- a/tests/ui/nonscalar-cast.stderr +++ b/tests/ui/nonscalar-cast.stderr @@ -2,9 +2,13 @@ error[E0605]: non-primitive cast: `Foo` as `isize` --> $DIR/nonscalar-cast.rs:15:20 | LL | println!("{}", Foo { x: 1 } as isize); - | ^^^^^^^^^^^^^^^^^^^^^ help: consider using the `From` trait instead: `isize::from(Foo { x: 1 })` + | ^^^^^^^^^^^^^^^^^^^^^ 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 - println!("{}", Foo { x: 1 } as isize); +LL + println!("{}", isize::from(Foo { x: 1 })); | - = note: an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object error: aborting due to 1 previous error diff --git a/tests/ui/not-enough-arguments.rs b/tests/ui/not-enough-arguments.rs index 4a2ea5e44c7..ec660a1de81 100644 --- a/tests/ui/not-enough-arguments.rs +++ b/tests/ui/not-enough-arguments.rs @@ -1,20 +1,16 @@ +//@ aux-build: delegate_macro.rs +extern crate delegate_macro; +use delegate_macro::delegate; + // Check that the only error msg we report is the // mismatch between the # of params, and not other // unrelated errors. - -fn foo(a: isize, b: isize, c: isize, d:isize) { - panic!(); +fn foo(a: isize, b: isize, c: isize, d: isize) { + panic!(); } // Check that all arguments are shown in the error message, even if they're across multiple lines. -fn bar( - a: i32, - b: i32, - c: i32, - d: i32, - e: i32, - f: i32, -) { +fn bar(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32) { println!("{}", a); println!("{}", b); println!("{}", c); @@ -23,9 +19,35 @@ fn bar( println!("{}", f); } +macro_rules! delegate_local { + ($method:ident) => { + <Self>::$method(8) + //~^ ERROR function takes 2 arguments but 1 + }; +} + +macro_rules! delegate_from { + ($from:ident, $method:ident) => { + <$from>::$method(8) + //~^ ERROR function takes 2 arguments but 1 + }; +} + +struct Bar; + +impl Bar { + fn foo(a: u8, b: u8) {} + fn bar() { + delegate_local!(foo); + delegate!(foo); + //~^ ERROR function takes 2 arguments but 1 + delegate_from!(Bar, foo); + } +} + fn main() { - foo(1, 2, 3); - //~^ ERROR function takes 4 arguments but 3 - bar(1, 2, 3); - //~^ ERROR function takes 6 arguments but 3 + foo(1, 2, 3); + //~^ ERROR function takes 4 arguments but 3 + bar(1, 2, 3); + //~^ ERROR function takes 6 arguments but 3 } diff --git a/tests/ui/not-enough-arguments.stderr b/tests/ui/not-enough-arguments.stderr index 099d82eb935..908d0273bbe 100644 --- a/tests/ui/not-enough-arguments.stderr +++ b/tests/ui/not-enough-arguments.stderr @@ -1,42 +1,88 @@ +error[E0061]: this function takes 2 arguments but 1 argument was supplied + --> $DIR/not-enough-arguments.rs:24:9 + | +LL | <Self>::$method(8) + | ^^^^^^^^^^^^^^^--- argument #2 of type `u8` is missing +... +LL | delegate_local!(foo); + | -------------------- in this macro invocation + | +note: associated function defined here + --> $DIR/not-enough-arguments.rs:39:8 + | +LL | fn foo(a: u8, b: u8) {} + | ^^^ ----- + = note: this error originates in the macro `delegate_local` (in Nightly builds, run with -Z macro-backtrace for more info) +help: provide the argument + | +LL | <Self>::$method(8, /* u8 */) + | ++++++++++ + +error[E0061]: this function takes 2 arguments but 1 argument was supplied + --> $DIR/not-enough-arguments.rs:42:9 + | +LL | delegate!(foo); + | ^^^^^^^^^^^^^^ argument #2 of type `u8` is missing + | +note: associated function defined here + --> $DIR/not-enough-arguments.rs:39:8 + | +LL | fn foo(a: u8, b: u8) {} + | ^^^ ----- + = note: this error originates in the macro `delegate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0061]: this function takes 2 arguments but 1 argument was supplied + --> $DIR/not-enough-arguments.rs:31:9 + | +LL | <$from>::$method(8) + | ^^^^^^^^^^^^^^^^--- argument #2 of type `u8` is missing +... +LL | delegate_from!(Bar, foo); + | ------------------------ in this macro invocation + | +note: associated function defined here + --> $DIR/not-enough-arguments.rs:39:8 + | +LL | fn foo(a: u8, b: u8) {} + | ^^^ ----- + = note: this error originates in the macro `delegate_from` (in Nightly builds, run with -Z macro-backtrace for more info) +help: provide the argument + | +LL | <$from>::$method(8, /* u8 */) + | ++++++++++ + error[E0061]: this function takes 4 arguments but 3 arguments were supplied - --> $DIR/not-enough-arguments.rs:27:3 + --> $DIR/not-enough-arguments.rs:49:5 | -LL | foo(1, 2, 3); - | ^^^--------- argument #4 of type `isize` is missing +LL | foo(1, 2, 3); + | ^^^--------- argument #4 of type `isize` is missing | note: function defined here - --> $DIR/not-enough-arguments.rs:5:4 + --> $DIR/not-enough-arguments.rs:8:4 | -LL | fn foo(a: isize, b: isize, c: isize, d:isize) { - | ^^^ ------- +LL | fn foo(a: isize, b: isize, c: isize, d: isize) { + | ^^^ -------- help: provide the argument | -LL | foo(1, 2, 3, /* isize */); - | +++++++++++++ +LL | foo(1, 2, 3, /* isize */); + | +++++++++++++ error[E0061]: this function takes 6 arguments but 3 arguments were supplied - --> $DIR/not-enough-arguments.rs:29:3 + --> $DIR/not-enough-arguments.rs:51:5 | -LL | bar(1, 2, 3); - | ^^^--------- three arguments of type `i32`, `i32`, and `i32` are missing +LL | bar(1, 2, 3); + | ^^^--------- three arguments of type `i32`, `i32`, and `i32` are missing | note: function defined here - --> $DIR/not-enough-arguments.rs:10:4 + --> $DIR/not-enough-arguments.rs:13:4 | -LL | fn bar( - | ^^^ -... -LL | d: i32, - | ------ -LL | e: i32, - | ------ -LL | f: i32, - | ------ +LL | fn bar(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32) { + | ^^^ ------ ------ ------ help: provide the arguments | -LL | bar(1, 2, 3, /* i32 */, /* i32 */, /* i32 */); - | +++++++++++++++++++++++++++++++++ +LL | bar(1, 2, 3, /* i32 */, /* i32 */, /* i32 */); + | +++++++++++++++++++++++++++++++++ -error: aborting due to 2 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0061`. diff --git a/tests/ui/bitwise.rs b/tests/ui/numbers-arithmetic/bitwise-ops-platform.rs index 0779e7f229c..60d552e904b 100644 --- a/tests/ui/bitwise.rs +++ b/tests/ui/numbers-arithmetic/bitwise-ops-platform.rs @@ -1,3 +1,5 @@ +//! Tests bitwise operations with platform-specific and negative number behavior. + //@ run-pass #[cfg(any(target_pointer_width = "32"))] diff --git a/tests/ui/object-lifetime/object-lifetime-default-elision.rs b/tests/ui/object-lifetime/object-lifetime-default-elision.rs index ede6af51174..f7c0261cfbb 100644 --- a/tests/ui/object-lifetime/object-lifetime-default-elision.rs +++ b/tests/ui/object-lifetime/object-lifetime-default-elision.rs @@ -46,8 +46,6 @@ fn load1(ss: &dyn SomeTrait) -> &dyn SomeTrait { } fn load2<'a>(ss: &'a dyn SomeTrait) -> &dyn SomeTrait { - //~^ WARNING elided lifetime has a name - // Same as `load1` but with an explicit name thrown in for fun. ss diff --git a/tests/ui/object-lifetime/object-lifetime-default-elision.stderr b/tests/ui/object-lifetime/object-lifetime-default-elision.stderr index b44a184c684..b5995687927 100644 --- a/tests/ui/object-lifetime/object-lifetime-default-elision.stderr +++ b/tests/ui/object-lifetime/object-lifetime-default-elision.stderr @@ -1,15 +1,5 @@ -warning: elided lifetime has a name - --> $DIR/object-lifetime-default-elision.rs:48:40 - | -LL | fn load2<'a>(ss: &'a dyn SomeTrait) -> &dyn SomeTrait { - | -- ^ this elided lifetime gets resolved as `'a` - | | - | lifetime `'a` declared here - | - = note: `#[warn(elided_named_lifetimes)]` on by default - error: lifetime may not live long enough - --> $DIR/object-lifetime-default-elision.rs:73:5 + --> $DIR/object-lifetime-default-elision.rs:71:5 | LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { | -- -- lifetime `'b` defined here @@ -21,5 +11,5 @@ LL | ss | = help: consider adding the following bound: `'a: 'b` -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 1 previous error diff --git a/tests/ui/object-pointer-types.stderr b/tests/ui/object-pointer-types.stderr index ac8e069cfd2..72b290f2ad9 100644 --- a/tests/ui/object-pointer-types.stderr +++ b/tests/ui/object-pointer-types.stderr @@ -25,7 +25,7 @@ error[E0599]: no method named `managed` found for struct `Box<(dyn Foo + 'static --> $DIR/object-pointer-types.rs:23:7 | LL | x.managed(); - | ^^^^^^^ method not found in `Box<dyn Foo>` + | ^^^^^^^ method not found in `Box<(dyn Foo + 'static)>` error: aborting due to 3 previous errors diff --git a/tests/ui/on-unimplemented/bad-annotation.rs b/tests/ui/on-unimplemented/bad-annotation.rs index 25de5978110..937e5b82da5 100644 --- a/tests/ui/on-unimplemented/bad-annotation.rs +++ b/tests/ui/on-unimplemented/bad-annotation.rs @@ -59,7 +59,7 @@ trait EmptyOn {} //~^^^ NOTE expected value here trait ExpectedPredicateInOn {} -#[rustc_on_unimplemented(on(x = "y"), message = "y")] +#[rustc_on_unimplemented(on(Self = "y"), message = "y")] trait OnWithoutDirectives {} #[rustc_on_unimplemented(on(from_desugaring, on(from_desugaring, message = "x")), message = "y")] @@ -107,3 +107,13 @@ trait InvalidPredicate {} //~^ ERROR invalid flag in `on`-clause //~^^ NOTE expected one of the `crate_local`, `direct` or `from_desugaring` flags, not `something` trait InvalidFlag {} + +#[rustc_on_unimplemented(on(_Self = "y", message = "y"))] +//~^ ERROR invalid name in `on`-clause +//~^^ NOTE expected one of `cause`, `from_desugaring`, `Self` or any generic parameter of the trait, not `_Self` +trait InvalidName {} + +#[rustc_on_unimplemented(on(abc = "y", message = "y"))] +//~^ ERROR invalid name in `on`-clause +//~^^ NOTE expected one of `cause`, `from_desugaring`, `Self` or any generic parameter of the trait, not `abc` +trait InvalidName2 {} diff --git a/tests/ui/on-unimplemented/bad-annotation.stderr b/tests/ui/on-unimplemented/bad-annotation.stderr index 35b919c7b78..3fc54532774 100644 --- a/tests/ui/on-unimplemented/bad-annotation.stderr +++ b/tests/ui/on-unimplemented/bad-annotation.stderr @@ -125,7 +125,19 @@ error[E0232]: invalid flag in `on`-clause LL | #[rustc_on_unimplemented(on(something, message = "y"))] | ^^^^^^^^^ expected one of the `crate_local`, `direct` or `from_desugaring` flags, not `something` -error: aborting due to 18 previous errors +error[E0232]: invalid name in `on`-clause + --> $DIR/bad-annotation.rs:111:29 + | +LL | #[rustc_on_unimplemented(on(_Self = "y", message = "y"))] + | ^^^^^ expected one of `cause`, `from_desugaring`, `Self` or any generic parameter of the trait, not `_Self` + +error[E0232]: invalid name in `on`-clause + --> $DIR/bad-annotation.rs:116:29 + | +LL | #[rustc_on_unimplemented(on(abc = "y", message = "y"))] + | ^^^ expected one of `cause`, `from_desugaring`, `Self` or any generic parameter of the trait, not `abc` + +error: aborting due to 20 previous errors Some errors have detailed explanations: E0230, E0231, E0232. For more information about an error, try `rustc --explain E0230`. diff --git a/tests/ui/on-unimplemented/on-trait.rs b/tests/ui/on-unimplemented/on-trait.rs index 556813cd479..91630af17e9 100644 --- a/tests/ui/on-unimplemented/on-trait.rs +++ b/tests/ui/on-unimplemented/on-trait.rs @@ -3,7 +3,7 @@ #![feature(rustc_attrs)] pub mod Bar { - #[rustc_on_unimplemented = "test error `{Self}` with `{Bar}` `{Baz}` `{Quux}` in `{Foo}`"] + #[rustc_on_unimplemented = "test error `{Self}` with `{Bar}` `{Baz}` `{Quux}` in `{This}`"] pub trait Foo<Bar, Baz, Quux> {} } diff --git a/tests/ui/panics/location-detail-unwrap-multiline.rs b/tests/ui/panics/location-detail-unwrap-multiline.rs new file mode 100644 index 00000000000..56e1760d851 --- /dev/null +++ b/tests/ui/panics/location-detail-unwrap-multiline.rs @@ -0,0 +1,12 @@ +//@ run-fail +//@ compile-flags: -Cstrip=none -Cdebuginfo=line-tables-only -Copt-level=0 +//@ exec-env:RUST_BACKTRACE=1 +//@ regex-error-pattern: location-detail-unwrap-multiline\.rs:11(:10)?\n +//@ needs-unwind +//@ ignore-android FIXME #17520 + +fn main() { + let opt: Option<u32> = None; + opt + .unwrap(); +} diff --git a/tests/ui/cleanup-rvalue-temp-during-incomplete-alloc.rs b/tests/ui/panics/rvalue-cleanup-during-box-panic.rs index 4c59df24e4b..84c5d85d7e0 100644 --- a/tests/ui/cleanup-rvalue-temp-during-incomplete-alloc.rs +++ b/tests/ui/panics/rvalue-cleanup-during-box-panic.rs @@ -25,16 +25,20 @@ use std::thread; enum Conzabble { - Bickwick(Foo) + Bickwick(Foo), } -struct Foo { field: Box<usize> } +struct Foo { + field: Box<usize>, +} fn do_it(x: &[usize]) -> Foo { panic!() } -fn get_bar(x: usize) -> Vec<usize> { vec![x * 2] } +fn get_bar(x: usize) -> Vec<usize> { + vec![x * 2] +} pub fn fails() { let x = 2; diff --git a/tests/ui/parser/bounds-obj-parens.rs b/tests/ui/parser/bounds-obj-parens.rs index eea4bccdc09..5ba90b50d2f 100644 --- a/tests/ui/parser/bounds-obj-parens.rs +++ b/tests/ui/parser/bounds-obj-parens.rs @@ -1,7 +1,5 @@ //@ check-pass -#![allow(bare_trait_objects)] - -type A = Box<(Fn(u8) -> u8) + 'static + Send + Sync>; // OK (but see #39318) +type A = Box<dyn (Fn(u8) -> u8) + 'static + Send + Sync>; // OK (but see #39318) fn main() {} diff --git a/tests/ui/parser/dyn-trait-compatibility.rs b/tests/ui/parser/dyn-trait-compatibility.rs index 717b14c5941..c6e84284fbe 100644 --- a/tests/ui/parser/dyn-trait-compatibility.rs +++ b/tests/ui/parser/dyn-trait-compatibility.rs @@ -1,3 +1,5 @@ +//@ edition: 2015 + type A0 = dyn; //~^ ERROR cannot find type `dyn` in this scope type A1 = dyn::dyn; diff --git a/tests/ui/parser/dyn-trait-compatibility.stderr b/tests/ui/parser/dyn-trait-compatibility.stderr index 08e0a50010a..a57c033c1e1 100644 --- a/tests/ui/parser/dyn-trait-compatibility.stderr +++ b/tests/ui/parser/dyn-trait-compatibility.stderr @@ -1,47 +1,47 @@ error[E0412]: cannot find type `dyn` in this scope - --> $DIR/dyn-trait-compatibility.rs:1:11 + --> $DIR/dyn-trait-compatibility.rs:3:11 | LL | type A0 = dyn; | ^^^ not found in this scope error[E0412]: cannot find type `dyn` in this scope - --> $DIR/dyn-trait-compatibility.rs:5:11 + --> $DIR/dyn-trait-compatibility.rs:7:11 | LL | type A2 = dyn<dyn, dyn>; | ^^^ not found in this scope error[E0412]: cannot find type `dyn` in this scope - --> $DIR/dyn-trait-compatibility.rs:5:15 + --> $DIR/dyn-trait-compatibility.rs:7:15 | LL | type A2 = dyn<dyn, dyn>; | ^^^ not found in this scope error[E0412]: cannot find type `dyn` in this scope - --> $DIR/dyn-trait-compatibility.rs:5:20 + --> $DIR/dyn-trait-compatibility.rs:7:20 | LL | type A2 = dyn<dyn, dyn>; | ^^^ not found in this scope error[E0412]: cannot find type `dyn` in this scope - --> $DIR/dyn-trait-compatibility.rs:9:11 + --> $DIR/dyn-trait-compatibility.rs:11:11 | LL | type A3 = dyn<<dyn as dyn>::dyn>; | ^^^ not found in this scope error[E0405]: cannot find trait `dyn` in this scope - --> $DIR/dyn-trait-compatibility.rs:9:23 + --> $DIR/dyn-trait-compatibility.rs:11:23 | LL | type A3 = dyn<<dyn as dyn>::dyn>; | ^^^ not found in this scope error[E0412]: cannot find type `dyn` in this scope - --> $DIR/dyn-trait-compatibility.rs:9:16 + --> $DIR/dyn-trait-compatibility.rs:11:16 | LL | type A3 = dyn<<dyn as dyn>::dyn>; | ^^^ not found in this scope error[E0433]: failed to resolve: use of unresolved module or unlinked crate `dyn` - --> $DIR/dyn-trait-compatibility.rs:3:11 + --> $DIR/dyn-trait-compatibility.rs:5:11 | LL | type A1 = dyn::dyn; | ^^^ use of unresolved module or unlinked crate `dyn` diff --git a/tests/ui/parser/extern-crate-async.rs b/tests/ui/parser/extern-crate-async.rs index 529e0f1ab5c..13bd786d092 100644 --- a/tests/ui/parser/extern-crate-async.rs +++ b/tests/ui/parser/extern-crate-async.rs @@ -1,6 +1,7 @@ -// Make sure that we don't parse `extern crate async` +// Make sure that we don't parse `extern crate async` as // the front matter of a function leading us astray. +//@ edition: 2015 //@ check-pass fn main() {} diff --git a/tests/ui/parser/fn-field-parse-error-ice.rs b/tests/ui/parser/fn-field-parse-error-ice.rs index 188257ea53a..f1bc561b89f 100644 --- a/tests/ui/parser/fn-field-parse-error-ice.rs +++ b/tests/ui/parser/fn-field-parse-error-ice.rs @@ -1,4 +1,5 @@ // Regression test for #85794 +//@ edition: 2015 struct Baz { inner : dyn fn () diff --git a/tests/ui/parser/fn-field-parse-error-ice.stderr b/tests/ui/parser/fn-field-parse-error-ice.stderr index 3bf68e8cc04..6f033e2b0c6 100644 --- a/tests/ui/parser/fn-field-parse-error-ice.stderr +++ b/tests/ui/parser/fn-field-parse-error-ice.stderr @@ -1,11 +1,11 @@ error: expected `,`, or `}`, found keyword `fn` - --> $DIR/fn-field-parse-error-ice.rs:4:16 + --> $DIR/fn-field-parse-error-ice.rs:5:16 | LL | inner : dyn fn () | ^ help: try adding a comma: `,` error: expected identifier, found keyword `fn` - --> $DIR/fn-field-parse-error-ice.rs:4:17 + --> $DIR/fn-field-parse-error-ice.rs:5:17 | LL | struct Baz { | --- while parsing this struct @@ -18,7 +18,7 @@ LL | inner : dyn r#fn () | ++ error[E0412]: cannot find type `dyn` in this scope - --> $DIR/fn-field-parse-error-ice.rs:4:13 + --> $DIR/fn-field-parse-error-ice.rs:5:13 | LL | inner : dyn fn () | ^^^ not found in this scope diff --git a/tests/ui/parser/issues/issue-114219.rs b/tests/ui/parser/issues/issue-114219.rs index 332258b628c..3f7e0f685ac 100644 --- a/tests/ui/parser/issues/issue-114219.rs +++ b/tests/ui/parser/issues/issue-114219.rs @@ -1,3 +1,5 @@ +//@ edition: 2015 + fn main() { async move {}; //~^ ERROR `async move` blocks are only allowed in Rust 2018 or later diff --git a/tests/ui/parser/issues/issue-114219.stderr b/tests/ui/parser/issues/issue-114219.stderr index 02323cb99cb..1243ef8b180 100644 --- a/tests/ui/parser/issues/issue-114219.stderr +++ b/tests/ui/parser/issues/issue-114219.stderr @@ -1,5 +1,5 @@ error: `async move` blocks are only allowed in Rust 2018 or later - --> $DIR/issue-114219.rs:2:5 + --> $DIR/issue-114219.rs:4:5 | LL | async move {}; | ^^^^^^^^^^ diff --git a/tests/ui/parser/macro/auxiliary/unicode-control.rs b/tests/ui/parser/macro/auxiliary/unicode-control.rs new file mode 100644 index 00000000000..8e73e3985ce --- /dev/null +++ b/tests/ui/parser/macro/auxiliary/unicode-control.rs @@ -0,0 +1,19 @@ +#![allow(text_direction_codepoint_in_literal)] + +extern crate proc_macro; +use proc_macro::*; + +#[proc_macro] +pub fn create_rtl_in_string(_: TokenStream) -> TokenStream { + r#""test RTL in string literal""#.parse().unwrap() +} + +#[proc_macro] +pub fn forward_stream(s: TokenStream) -> TokenStream { + s +} + +#[proc_macro] +pub fn recollect_stream(s: TokenStream) -> TokenStream { + s.into_iter().collect() +} diff --git a/tests/ui/parser/macro/unicode-control-codepoints-macros.rs b/tests/ui/parser/macro/unicode-control-codepoints-macros.rs new file mode 100644 index 00000000000..775c5077976 --- /dev/null +++ b/tests/ui/parser/macro/unicode-control-codepoints-macros.rs @@ -0,0 +1,49 @@ +// Regression test for #140281 +//@ edition: 2021 +//@ proc-macro: unicode-control.rs + +extern crate unicode_control; +use unicode_control::*; + +macro_rules! foo { + ($x:expr) => { + $x + }; +} + +macro_rules! empty { + ($x:expr) => {}; +} + +fn main() { + let t = vec![ + /// test RTL in doc in vec + //~^ ERROR unicode codepoint changing visible direction of text present in doc comment + 1 + ]; + foo!( + /** + * test RTL in doc in macro + */ + //~^^^ ERROR unicode codepoint changing visible direction of text present in doc comment + 1 + ); + empty!( + /** + * test RTL in doc in macro + */ + //~^^^ ERROR unicode codepoint changing visible direction of text present in doc comment + 1 + ); + let x = create_rtl_in_string!(); // OK + forward_stream!( + /// test RTL in doc in proc macro + //~^ ERROR unicode codepoint changing visible direction of text present in doc comment + mod a {} + ); + recollect_stream!( + /// test RTL in doc in proc macro + //~^ ERROR unicode codepoint changing visible direction of text present in doc comment + mod b {} + ); +} diff --git a/tests/ui/parser/macro/unicode-control-codepoints-macros.stderr b/tests/ui/parser/macro/unicode-control-codepoints-macros.stderr new file mode 100644 index 00000000000..ca813399eac --- /dev/null +++ b/tests/ui/parser/macro/unicode-control-codepoints-macros.stderr @@ -0,0 +1,57 @@ +error: unicode codepoint changing visible direction of text present in doc comment + --> $DIR/unicode-control-codepoints-macros.rs:20:9 + | +LL | /// �test� RTL in doc in vec + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this doc comment contains invisible unicode text flow control codepoints + | + = note: these kind of unicode codepoints change the way text flows on applications that support them, but can cause confusion because they change the order of characters on the screen + = note: if their presence wasn't intentional, you can remove them + = note: if you want to keep them but make them visible in your source code, you can escape them: '\u{202e}', '\u{2066}' + = note: `#[deny(text_direction_codepoint_in_literal)]` on by default + +error: unicode codepoint changing visible direction of text present in doc comment + --> $DIR/unicode-control-codepoints-macros.rs:25:9 + | +LL | / /** +LL | | * �test� RTL in doc in macro +LL | | */ + | |___________^ this doc comment contains invisible unicode text flow control codepoints + | + = note: these kind of unicode codepoints change the way text flows on applications that support them, but can cause confusion because they change the order of characters on the screen + = note: if their presence wasn't intentional, you can remove them + = note: if you want to keep them but make them visible in your source code, you can escape them: '\u{202e}', '\u{2066}' + +error: unicode codepoint changing visible direction of text present in doc comment + --> $DIR/unicode-control-codepoints-macros.rs:32:9 + | +LL | / /** +LL | | * �test� RTL in doc in macro +LL | | */ + | |___________^ this doc comment contains invisible unicode text flow control codepoints + | + = note: these kind of unicode codepoints change the way text flows on applications that support them, but can cause confusion because they change the order of characters on the screen + = note: if their presence wasn't intentional, you can remove them + = note: if you want to keep them but make them visible in your source code, you can escape them: '\u{202e}', '\u{2066}' + +error: unicode codepoint changing visible direction of text present in doc comment + --> $DIR/unicode-control-codepoints-macros.rs:40:9 + | +LL | /// �test� RTL in doc in proc macro + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this doc comment contains invisible unicode text flow control codepoints + | + = note: these kind of unicode codepoints change the way text flows on applications that support them, but can cause confusion because they change the order of characters on the screen + = note: if their presence wasn't intentional, you can remove them + = note: if you want to keep them but make them visible in your source code, you can escape them: '\u{202e}', '\u{2066}' + +error: unicode codepoint changing visible direction of text present in doc comment + --> $DIR/unicode-control-codepoints-macros.rs:45:9 + | +LL | /// �test� RTL in doc in proc macro + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this doc comment contains invisible unicode text flow control codepoints + | + = note: these kind of unicode codepoints change the way text flows on applications that support them, but can cause confusion because they change the order of characters on the screen + = note: if their presence wasn't intentional, you can remove them + = note: if you want to keep them but make them visible in your source code, you can escape them: '\u{202e}', '\u{2066}' + +error: aborting due to 5 previous errors + diff --git a/tests/ui/parser/match-arm-comma-typo-issue-140991.fixed b/tests/ui/parser/match-arm-comma-typo-issue-140991.fixed new file mode 100644 index 00000000000..4d99e4bdc1c --- /dev/null +++ b/tests/ui/parser/match-arm-comma-typo-issue-140991.fixed @@ -0,0 +1,24 @@ +//@ run-rustfix + +pub enum Foo { + X, Y +} + +pub fn typo1(foo: Foo) -> Foo { + use Foo::*; + match foo { + X => Y, + Y => X, //~ ERROR expected one of + } +} + +pub fn typo2(foo: Foo) -> Foo { + use Foo::*; + match foo { + X => Y, + Y => X, //~ ERROR expected one of + } +} + + +fn main() { } diff --git a/tests/ui/parser/match-arm-comma-typo-issue-140991.rs b/tests/ui/parser/match-arm-comma-typo-issue-140991.rs new file mode 100644 index 00000000000..3baf1ff3fa1 --- /dev/null +++ b/tests/ui/parser/match-arm-comma-typo-issue-140991.rs @@ -0,0 +1,24 @@ +//@ run-rustfix + +pub enum Foo { + X, Y +} + +pub fn typo1(foo: Foo) -> Foo { + use Foo::*; + match foo { + X => Y. + Y => X, //~ ERROR expected one of + } +} + +pub fn typo2(foo: Foo) -> Foo { + use Foo::*; + match foo { + X => Y/ + Y => X, //~ ERROR expected one of + } +} + + +fn main() { } diff --git a/tests/ui/parser/match-arm-comma-typo-issue-140991.stderr b/tests/ui/parser/match-arm-comma-typo-issue-140991.stderr new file mode 100644 index 00000000000..19532d14245 --- /dev/null +++ b/tests/ui/parser/match-arm-comma-typo-issue-140991.stderr @@ -0,0 +1,26 @@ +error: expected one of `(`, `,`, `.`, `::`, `?`, `}`, or an operator, found `=>` + --> $DIR/match-arm-comma-typo-issue-140991.rs:11:11 + | +LL | Y => X, + | ^^ expected one of 7 possible tokens + | +help: you might have meant to write a `,` to end this `match` arm + | +LL - X => Y. +LL + X => Y, + | + +error: expected one of `!`, `,`, `.`, `::`, `?`, `{`, `}`, or an operator, found `=>` + --> $DIR/match-arm-comma-typo-issue-140991.rs:19:11 + | +LL | Y => X, + | ^^ expected one of 8 possible tokens + | +help: you might have meant to write a `,` to end this `match` arm + | +LL - X => Y/ +LL + X => Y, + | + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/recover-hrtb-before-dyn-impl-kw.rs b/tests/ui/parser/recover-hrtb-before-dyn-impl-kw.rs index b9e3c5783eb..b78832bbe3d 100644 --- a/tests/ui/parser/recover-hrtb-before-dyn-impl-kw.rs +++ b/tests/ui/parser/recover-hrtb-before-dyn-impl-kw.rs @@ -1,3 +1,5 @@ +//@ edition: 2015 + trait Trait {} fn test(_: &for<'a> dyn Trait) {} diff --git a/tests/ui/parser/recover-hrtb-before-dyn-impl-kw.stderr b/tests/ui/parser/recover-hrtb-before-dyn-impl-kw.stderr index a012220e8c7..3745cf8b077 100644 --- a/tests/ui/parser/recover-hrtb-before-dyn-impl-kw.stderr +++ b/tests/ui/parser/recover-hrtb-before-dyn-impl-kw.stderr @@ -1,5 +1,5 @@ error: `for<...>` expected after `dyn`, not before - --> $DIR/recover-hrtb-before-dyn-impl-kw.rs:3:21 + --> $DIR/recover-hrtb-before-dyn-impl-kw.rs:5:21 | LL | fn test(_: &for<'a> dyn Trait) {} | ^^^ @@ -11,7 +11,7 @@ LL + fn test(_: &dyn for<'a> Trait) {} | error: `for<...>` expected after `impl`, not before - --> $DIR/recover-hrtb-before-dyn-impl-kw.rs:6:21 + --> $DIR/recover-hrtb-before-dyn-impl-kw.rs:8:21 | LL | fn test2(_: for<'a> impl Trait) {} | ^^^^ @@ -23,7 +23,7 @@ LL + fn test2(_: impl for<'a> Trait) {} | error: expected identifier, found `>` - --> $DIR/recover-hrtb-before-dyn-impl-kw.rs:10:24 + --> $DIR/recover-hrtb-before-dyn-impl-kw.rs:12:24 | LL | type A2 = dyn<for<> dyn>; | ^ expected identifier diff --git a/tests/ui/parser/trailing-plus-in-bounds.rs b/tests/ui/parser/trailing-plus-in-bounds.rs index ef9bdadb282..aa5bc3aca59 100644 --- a/tests/ui/parser/trailing-plus-in-bounds.rs +++ b/tests/ui/parser/trailing-plus-in-bounds.rs @@ -1,9 +1,7 @@ //@ check-pass -#![allow(bare_trait_objects)] - use std::fmt::Debug; fn main() { - let x: Box<Debug+> = Box::new(3) as Box<Debug+>; // Trailing `+` is OK + let x: Box<dyn Debug+> = Box::new(3) as Box<dyn Debug+>; // Trailing `+` is OK } diff --git a/tests/ui/parser/unicode-control-codepoints.rs b/tests/ui/parser/unicode-control-codepoints.rs index 14e1cfe59d3..e3c906063c4 100644 --- a/tests/ui/parser/unicode-control-codepoints.rs +++ b/tests/ui/parser/unicode-control-codepoints.rs @@ -34,7 +34,7 @@ fn main() { //~^ ERROR unicode codepoint changing visible direction of text present in literal println!("{{}}"); - //~^ ERROR unicode codepoint changing visible direction of text present in format string + //~^ ERROR unicode codepoint changing visible direction of text present in literal } //"/* } if isAdmin begin admins only */" diff --git a/tests/ui/parser/unicode-control-codepoints.stderr b/tests/ui/parser/unicode-control-codepoints.stderr index 27b95f9ac61..7978c1435f6 100644 --- a/tests/ui/parser/unicode-control-codepoints.stderr +++ b/tests/ui/parser/unicode-control-codepoints.stderr @@ -100,21 +100,6 @@ LL | // if access_level != "us�e�r" { // Check if admin = note: `#[deny(text_direction_codepoint_in_comment)]` on by default = help: if their presence wasn't intentional, you can remove them -error: unicode codepoint changing visible direction of text present in comment - --> $DIR/unicode-control-codepoints.rs:40:1 - | -LL | //"/*� } �if isAdmin� � begin admins only */" - | ^^^^^-^^^-^^^^^^^^^^-^-^^^^^^^^^^^^^^^^^^^^^^ - | | | | | | - | | | | | '\u{2066}' - | | | | '\u{2069}' - | | | '\u{2066}' - | | '\u{202e}' - | this comment contains invisible unicode text flow control codepoints - | - = note: these kind of unicode codepoints change the way text flows on applications that support them, but can cause confusion because they change the order of characters on the screen - = help: if their presence wasn't intentional, you can remove them - error: unicode codepoint changing visible direction of text present in literal --> $DIR/unicode-control-codepoints.rs:13:22 | @@ -207,14 +192,14 @@ LL - let _ = cr#"�"#; LL + let _ = cr#"\u{202e}"#; | -error: unicode codepoint changing visible direction of text present in format string +error: unicode codepoint changing visible direction of text present in literal --> $DIR/unicode-control-codepoints.rs:36:14 | LL | println!("{{�}}"); | ^^^-^^^ | | | | | '\u{202e}' - | this format string contains an invisible unicode text flow control codepoint + | this literal contains an invisible unicode text flow control codepoint | = note: these kind of unicode codepoints change the way text flows on applications that support them, but can cause confusion because they change the order of characters on the screen = help: if their presence wasn't intentional, you can remove them @@ -224,6 +209,21 @@ LL - println!("{{�}}"); LL + println!("{{\u{202e}}}"); | +error: unicode codepoint changing visible direction of text present in comment + --> $DIR/unicode-control-codepoints.rs:40:1 + | +LL | //"/*� } �if isAdmin� � begin admins only */" + | ^^^^^-^^^-^^^^^^^^^^-^-^^^^^^^^^^^^^^^^^^^^^^ + | | | | | | + | | | | | '\u{2066}' + | | | | '\u{2069}' + | | | '\u{2066}' + | | '\u{202e}' + | this comment contains invisible unicode text flow control codepoints + | + = note: these kind of unicode codepoints change the way text flows on applications that support them, but can cause confusion because they change the order of characters on the screen + = help: if their presence wasn't intentional, you can remove them + error: unicode codepoint changing visible direction of text present in doc comment --> $DIR/unicode-control-codepoints.rs:43:1 | diff --git a/tests/ui/pattern/issue-14221.rs b/tests/ui/pattern/issue-14221.rs index 13427d2c9b2..f5f419a6314 100644 --- a/tests/ui/pattern/issue-14221.rs +++ b/tests/ui/pattern/issue-14221.rs @@ -8,7 +8,7 @@ pub enum E { } pub mod b { - pub fn key(e: ::E) -> &'static str { + pub fn key(e: crate::E) -> &'static str { match e { A => "A", //~^ ERROR pattern binding `A` is named the same as one of the variants of the type `E` diff --git a/tests/ui/pattern/issue-22546.rs b/tests/ui/pattern/issue-22546.rs index fd1d5fb6c47..81908017b4e 100644 --- a/tests/ui/pattern/issue-22546.rs +++ b/tests/ui/pattern/issue-22546.rs @@ -7,7 +7,7 @@ use std::default::Default; #[derive(Default)] pub struct Foo<T>(T, T); -impl<T: ::std::fmt::Display> Foo<T> { +impl<T: std::fmt::Display> Foo<T> { fn foo(&self) { match *self { Foo::<T>(ref x, ref y) => println!("Goodbye, World! {} {}", x, y) @@ -36,7 +36,7 @@ fn main() { let w = Wrapper { value: Foo(10u8, 11u8) }; match w { Wrapper::<Foo<u8>> { value: Foo(10, 11) } => {}, - ::Wrapper::<<Foo<_> as Tr>::U> { value: Foo::<u8>(11, 16) } => { panic!() }, + crate::Wrapper::<<Foo<_> as Tr>::U> { value: Foo::<u8>(11, 16) } => { panic!() }, _ => { panic!() } } diff --git a/tests/ui/pattern/issue-6449.rs b/tests/ui/pattern/issue-6449.rs index 38399a18793..25152cf5d29 100644 --- a/tests/ui/pattern/issue-6449.rs +++ b/tests/ui/pattern/issue-6449.rs @@ -13,32 +13,32 @@ enum Other { fn main() { match Foo::Baz { - ::Foo::Bar(3) => panic!(), - ::Foo::Bar(_) if false => panic!(), - ::Foo::Bar(..) if false => panic!(), - ::Foo::Bar(_n) => panic!(), - ::Foo::Baz => {} + crate::Foo::Bar(3) => panic!(), + crate::Foo::Bar(_) if false => panic!(), + crate::Foo::Bar(..) if false => panic!(), + crate::Foo::Bar(_n) => panic!(), + crate::Foo::Baz => {} } match Foo::Bar(3) { - ::Foo::Bar(3) => {} - ::Foo::Bar(_) if false => panic!(), - ::Foo::Bar(..) if false => panic!(), - ::Foo::Bar(_n) => panic!(), - ::Foo::Baz => panic!(), + crate::Foo::Bar(3) => {} + crate::Foo::Bar(_) if false => panic!(), + crate::Foo::Bar(..) if false => panic!(), + crate::Foo::Bar(_n) => panic!(), + crate::Foo::Baz => panic!(), } match Foo::Bar(4) { - ::Foo::Bar(3) => panic!(), - ::Foo::Bar(_) if false => panic!(), - ::Foo::Bar(..) if false => panic!(), - ::Foo::Bar(n) => assert_eq!(n, 4), - ::Foo::Baz => panic!(), + crate::Foo::Bar(3) => panic!(), + crate::Foo::Bar(_) if false => panic!(), + crate::Foo::Bar(..) if false => panic!(), + crate::Foo::Bar(n) => assert_eq!(n, 4), + crate::Foo::Baz => panic!(), } match Other::Other1(Foo::Baz) { - ::Other::Other1(::Foo::Baz) => {} - ::Other::Other1(::Foo::Bar(_)) => {} - ::Other::Other2(::Foo::Baz, ::Foo::Bar(_)) => {} - ::Other::Other2(::Foo::Bar(..), ::Foo::Baz) => {} - ::Other::Other2(..) => {} + crate::Other::Other1(crate::Foo::Baz) => {} + crate::Other::Other1(crate::Foo::Bar(_)) => {} + crate::Other::Other2(crate::Foo::Baz, crate::Foo::Bar(_)) => {} + crate::Other::Other2(crate::Foo::Bar(..), crate::Foo::Baz) => {} + crate::Other::Other2(..) => {} } } diff --git a/tests/ui/pattern/missing_lifetime.rs b/tests/ui/pattern/missing_lifetime.rs index 081f667d8f6..53f8e155019 100644 --- a/tests/ui/pattern/missing_lifetime.rs +++ b/tests/ui/pattern/missing_lifetime.rs @@ -20,6 +20,6 @@ enum Other { fn main() { match Other::Other1(Foo::Baz) { - ::Other::Other2(::Foo::Bar(..)) => {} + crate::Other::Other2(crate::Foo::Bar(..)) => {} } } diff --git a/tests/ui/bind-by-move.rs b/tests/ui/pattern/pattern-match-arc-move.rs index 99f3536e533..bc79401e4e3 100644 --- a/tests/ui/bind-by-move.rs +++ b/tests/ui/pattern/pattern-match-arc-move.rs @@ -1,3 +1,5 @@ +//! Tests moving an `Arc` value out of an `Option` in a match expression. + //@ run-pass use std::sync::Arc; diff --git a/tests/ui/pattern/pattern-match-invalid-variant.rs b/tests/ui/pattern/pattern-match-invalid-variant.rs new file mode 100644 index 00000000000..183031553c0 --- /dev/null +++ b/tests/ui/pattern/pattern-match-invalid-variant.rs @@ -0,0 +1,19 @@ +//! Tests invalid enum variant in a match expression. + +enum Color { + Rgb(isize, isize, isize), + Rgba(isize, isize, isize, isize), +} + +fn main() { + let red: Color = Color::Rgb(255, 0, 0); + match red { + Color::Rgb(r, g, b) => { + println!("rgb"); + } + Color::Hsl(h, s, l) => { + //~^ ERROR no variant + println!("hsl"); + } + } +} diff --git a/tests/ui/bogus-tag.stderr b/tests/ui/pattern/pattern-match-invalid-variant.stderr index d94bd489ec6..08a99f696f6 100644 --- a/tests/ui/bogus-tag.stderr +++ b/tests/ui/pattern/pattern-match-invalid-variant.stderr @@ -1,10 +1,10 @@ error[E0599]: no variant or associated item named `Hsl` found for enum `Color` in the current scope - --> $DIR/bogus-tag.rs:7:16 + --> $DIR/pattern-match-invalid-variant.rs:14:16 | -LL | enum Color { Rgb(isize, isize, isize), Rgba(isize, isize, isize, isize), } +LL | enum Color { | ---------- variant or associated item `Hsl` not found for this enum ... -LL | Color::Hsl(h, s, l) => { println!("hsl"); } +LL | Color::Hsl(h, s, l) => { | ^^^ variant or associated item not found in `Color` error: aborting due to 1 previous error diff --git a/tests/ui/pattern/rfc-3637-guard-patterns/only-gather-locals-once.rs b/tests/ui/pattern/rfc-3637-guard-patterns/only-gather-locals-once.rs new file mode 100644 index 00000000000..7bb39ca7bb9 --- /dev/null +++ b/tests/ui/pattern/rfc-3637-guard-patterns/only-gather-locals-once.rs @@ -0,0 +1,15 @@ +//@ check-pass +//! Test that `GatherLocalsVisitor` only visits expressions in guard patterns when checking the +//! expressions, and not a second time when visiting the pattern. If locals are declared inside the +//! the guard expression, it would ICE if visited twice ("evaluated expression more than once"). + +#![feature(guard_patterns)] +#![expect(incomplete_features)] + +fn main() { + match (0,) { + // FIXME(guard_patterns): liveness lints don't work yet; this will ICE without the `_`. + (_ if { let _x = false; _x },) => {} + _ => {} + } +} diff --git a/tests/ui/pattern/rfc-3637-guard-patterns/only-resolve-top-level-guard-expr-once-ice-141265.rs b/tests/ui/pattern/rfc-3637-guard-patterns/only-resolve-top-level-guard-expr-once-ice-141265.rs new file mode 100644 index 00000000000..7dc9ef7161d --- /dev/null +++ b/tests/ui/pattern/rfc-3637-guard-patterns/only-resolve-top-level-guard-expr-once-ice-141265.rs @@ -0,0 +1,12 @@ +//! Regression test for <https://github.com/rust-lang/rust/issues/141265>. +//! Make sure expressions in top-level guard patterns are only resolved once. + +fn main() { + for + else if b 0 {} + //~^ ERROR expected identifier, found keyword `else` + //~| ERROR missing `in` in `for` loop + //~| ERROR cannot find value `b` in this scope + //~| ERROR guard patterns are experimental + //~| ERROR `{integer}` is not an iterator +} diff --git a/tests/ui/pattern/rfc-3637-guard-patterns/only-resolve-top-level-guard-expr-once-ice-141265.stderr b/tests/ui/pattern/rfc-3637-guard-patterns/only-resolve-top-level-guard-expr-once-ice-141265.stderr new file mode 100644 index 00000000000..dae384137f5 --- /dev/null +++ b/tests/ui/pattern/rfc-3637-guard-patterns/only-resolve-top-level-guard-expr-once-ice-141265.stderr @@ -0,0 +1,48 @@ +error: expected identifier, found keyword `else` + --> $DIR/only-resolve-top-level-guard-expr-once-ice-141265.rs:6:5 + | +LL | else if b 0 {} + | ^^^^ expected identifier, found keyword + +error: missing `in` in `for` loop + --> $DIR/only-resolve-top-level-guard-expr-once-ice-141265.rs:6:14 + | +LL | else if b 0 {} + | ^ + | +help: try adding `in` here + | +LL | else if b in 0 {} + | ++ + +error[E0425]: cannot find value `b` in this scope + --> $DIR/only-resolve-top-level-guard-expr-once-ice-141265.rs:6:13 + | +LL | else if b 0 {} + | ^ not found in this scope + +error[E0658]: guard patterns are experimental + --> $DIR/only-resolve-top-level-guard-expr-once-ice-141265.rs:6:13 + | +LL | else if b 0 {} + | ^ + | + = note: see issue #129967 <https://github.com/rust-lang/rust/issues/129967> for more information + = help: add `#![feature(guard_patterns)]` 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 using match arm guards + +error[E0277]: `{integer}` is not an iterator + --> $DIR/only-resolve-top-level-guard-expr-once-ice-141265.rs:6:15 + | +LL | else if b 0 {} + | ^ `{integer}` is not an iterator + | + = help: the trait `Iterator` is not implemented for `{integer}` + = note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end` + = note: required for `{integer}` to implement `IntoIterator` + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0277, E0425, E0658. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/pattern/unused-parameters-const-pattern.rs b/tests/ui/pattern/unused-parameters-const-pattern.rs new file mode 100644 index 00000000000..107c65ddfd3 --- /dev/null +++ b/tests/ui/pattern/unused-parameters-const-pattern.rs @@ -0,0 +1,19 @@ +//@ check-pass + +// Tests that const patterns that use generic parameters are +// allowed if we are still able to evaluate them. + +trait Trait { const ASSOC: usize; } + +impl<T> Trait for T { + const ASSOC: usize = 10; +} + +fn foo<T>(a: usize) { + match a { + <T as Trait>::ASSOC => (), + _ => (), + } +} + +fn main() {} diff --git a/tests/ui/pattern/usefulness/uninhabited.rs b/tests/ui/pattern/usefulness/uninhabited.rs index 5c774b7874a..0e2793fb448 100644 --- a/tests/ui/pattern/usefulness/uninhabited.rs +++ b/tests/ui/pattern/usefulness/uninhabited.rs @@ -120,7 +120,7 @@ mod visibility { mod c { use super::*; pub struct AlsoSecretlyUninhabited { - _priv: ::Struct1, + _priv: crate::Struct1, } assert_empty!(SometimesEmptyStruct); assert_non_empty!(SometimesEmptyEnum); diff --git a/tests/ui/print-request/emit-warning-print-link-info-without-staticlib.rs b/tests/ui/print-request/emit-warning-print-link-info-without-staticlib.rs new file mode 100644 index 00000000000..b100c062bba --- /dev/null +++ b/tests/ui/print-request/emit-warning-print-link-info-without-staticlib.rs @@ -0,0 +1,5 @@ +//@ compile-flags: --print native-static-libs +//@ check-pass +//~? WARN cannot output linkage information without staticlib crate-type + +fn main() {} diff --git a/tests/ui/print-request/emit-warning-print-link-info-without-staticlib.stderr b/tests/ui/print-request/emit-warning-print-link-info-without-staticlib.stderr new file mode 100644 index 00000000000..ceff08baa13 --- /dev/null +++ b/tests/ui/print-request/emit-warning-print-link-info-without-staticlib.stderr @@ -0,0 +1,6 @@ +warning: cannot output linkage information without staticlib crate-type + +note: consider `--crate-type staticlib` to print linkage information + +warning: 1 warning emitted + diff --git a/tests/ui/print-request/emit-warning-while-exe-and-print-link-info.rs b/tests/ui/print-request/emit-warning-while-exe-and-print-link-info.rs new file mode 100644 index 00000000000..3e9ca457a9c --- /dev/null +++ b/tests/ui/print-request/emit-warning-while-exe-and-print-link-info.rs @@ -0,0 +1,3 @@ +//@ compile-flags: --print native-static-libs --crate-type staticlib --emit metadata +//@ check-pass +//~? WARN cannot output linkage information when --emit link is not passed diff --git a/tests/ui/print-request/emit-warning-while-exe-and-print-link-info.stderr b/tests/ui/print-request/emit-warning-while-exe-and-print-link-info.stderr new file mode 100644 index 00000000000..b32e1437d6b --- /dev/null +++ b/tests/ui/print-request/emit-warning-while-exe-and-print-link-info.stderr @@ -0,0 +1,4 @@ +warning: cannot output linkage information when --emit link is not passed + +warning: 1 warning emitted + diff --git a/tests/ui/print-request/stability.rs b/tests/ui/print-request/stability.rs index 54142ce78ce..fbcdf916cc7 100644 --- a/tests/ui/print-request/stability.rs +++ b/tests/ui/print-request/stability.rs @@ -110,3 +110,4 @@ fn main() {} //[check_cfg]~? ERROR the `-Z unstable-options` flag must also be passed to enable the `check-cfg` print option //[supported_crate_types]~? ERROR the `-Z unstable-options` flag must also be passed to enable the `supported-crate-types` print option //[target_spec_json]~? ERROR the `-Z unstable-options` flag must also be passed to enable the `target-spec-json` print option +//[native_static_libs]~? WARNING cannot output linkage information without staticlib crate-type diff --git a/tests/ui/print_type_sizes/niche-filling.rs b/tests/ui/print_type_sizes/niche-filling.rs index 36739e3fc04..719bc2a07dc 100644 --- a/tests/ui/print_type_sizes/niche-filling.rs +++ b/tests/ui/print_type_sizes/niche-filling.rs @@ -55,7 +55,14 @@ pub struct NestedNonZero { impl Default for NestedNonZero { fn default() -> Self { - NestedNonZero { pre: 0, val: unsafe { NonZero::new_unchecked(1) }, post: 0 } + // Ideally we'd call NonZero::new_unchecked, but this test is supposed + // to be target-independent and NonZero::new_unchecked is #[track_caller] + // (see #129658) so mentioning that function pulls in std::panic::Location + // which contains a &str, whose layout is target-dependent. + const ONE: NonZero<u32> = const { + unsafe { std::mem::transmute(1u32) } + }; + NestedNonZero { pre: 0, val: ONE, post: 0 } } } diff --git a/tests/ui/print_type_sizes/niche-filling.stdout b/tests/ui/print_type_sizes/niche-filling.stdout index 70612490a47..3342f68dd70 100644 --- a/tests/ui/print_type_sizes/niche-filling.stdout +++ b/tests/ui/print_type_sizes/niche-filling.stdout @@ -72,10 +72,6 @@ print-type-size type: `core::num::niche_types::NonZeroU32Inner`: 4 bytes, alignm print-type-size field `.0`: 4 bytes print-type-size type: `std::num::NonZero<u32>`: 4 bytes, alignment: 4 bytes print-type-size field `.0`: 4 bytes -print-type-size type: `std::option::Option<std::num::NonZero<u32>>`: 4 bytes, alignment: 4 bytes -print-type-size variant `Some`: 4 bytes -print-type-size field `.0`: 4 bytes -print-type-size variant `None`: 0 bytes print-type-size type: `Enum4<(), (), (), MyOption<u8>>`: 2 bytes, alignment: 1 bytes print-type-size variant `Four`: 2 bytes print-type-size field `.0`: 2 bytes diff --git a/tests/ui/privacy/auxiliary/pub_use_mods_xcrate.rs b/tests/ui/privacy/auxiliary/pub_use_mods_xcrate.rs index 74d3504d5be..f754c01f3d5 100644 --- a/tests/ui/privacy/auxiliary/pub_use_mods_xcrate.rs +++ b/tests/ui/privacy/auxiliary/pub_use_mods_xcrate.rs @@ -1,5 +1,5 @@ pub mod a { - pub use a::b::c; + pub use crate::a::b::c; pub mod b { pub mod c { diff --git a/tests/ui/privacy/crate-private-reexport.rs b/tests/ui/privacy/crate-private-reexport.rs index fa4f88666d8..db0314683a0 100644 --- a/tests/ui/privacy/crate-private-reexport.rs +++ b/tests/ui/privacy/crate-private-reexport.rs @@ -5,10 +5,10 @@ struct S1 { bar: i32, } mod m1 { - pub use ::f1; //~ ERROR `f1` is only public within the crate, and cannot be re-exported outside - pub use ::S1; //~ ERROR `S1` is only public within the crate, and cannot be re-exported outside - pub use ::E1; //~ ERROR `E1` is only public within the crate, and cannot be re-exported outside - pub use ::E1::V; //~ ERROR `V` is only public within the crate, and cannot be re-exported outside + pub use crate::f1; //~ ERROR `f1` is only public within the crate, and cannot be re-exported outside + pub use crate::S1; //~ ERROR `S1` is only public within the crate, and cannot be re-exported outside + pub use crate::E1; //~ ERROR `E1` is only public within the crate, and cannot be re-exported outside + pub use crate::E1::V; //~ ERROR `V` is only public within the crate, and cannot be re-exported outside } pub(crate) fn f2() {} @@ -20,10 +20,10 @@ pub(crate) struct S2 { bar: i32, } mod m2 { - pub use ::f2; //~ ERROR `f2` is only public within the crate, and cannot be re-exported outside - pub use ::S2; //~ ERROR `S2` is only public within the crate, and cannot be re-exported outside - pub use ::E2; //~ ERROR `E2` is only public within the crate, and cannot be re-exported outside - pub use ::E2::V; //~ ERROR `V` is only public within the crate, and cannot be re-exported outside + pub use crate::f2; //~ ERROR `f2` is only public within the crate, and cannot be re-exported outside + pub use crate::S2; //~ ERROR `S2` is only public within the crate, and cannot be re-exported outside + pub use crate::E2; //~ ERROR `E2` is only public within the crate, and cannot be re-exported outside + pub use crate::E2::V; //~ ERROR `V` is only public within the crate, and cannot be re-exported outside } mod m3 { @@ -42,7 +42,7 @@ pub use m3::E3; //~ ERROR `E3` is only public within the crate, and cannot be re pub use m3::E3::V; //~ ERROR `V` is only public within the crate, and cannot be re-exported outside pub(self) fn f4() {} -pub use ::f4 as f5; //~ ERROR `f4` is only public within the crate, and cannot be re-exported outside +pub use crate::f4 as f5; //~ ERROR `f4` is only public within the crate, and cannot be re-exported outside pub mod m10 { pub mod m { diff --git a/tests/ui/privacy/crate-private-reexport.stderr b/tests/ui/privacy/crate-private-reexport.stderr index 66e11e82107..9b2626efacd 100644 --- a/tests/ui/privacy/crate-private-reexport.stderr +++ b/tests/ui/privacy/crate-private-reexport.stderr @@ -1,82 +1,82 @@ error[E0364]: `f1` is only public within the crate, and cannot be re-exported outside --> $DIR/crate-private-reexport.rs:8:13 | -LL | pub use ::f1; - | ^^^^ +LL | pub use crate::f1; + | ^^^^^^^^^ | note: consider marking `f1` as `pub` in the imported module --> $DIR/crate-private-reexport.rs:8:13 | -LL | pub use ::f1; - | ^^^^ +LL | pub use crate::f1; + | ^^^^^^^^^ error[E0365]: `S1` is only public within the crate, and cannot be re-exported outside --> $DIR/crate-private-reexport.rs:9:13 | -LL | pub use ::S1; - | ^^^^ re-export of crate public `S1` +LL | pub use crate::S1; + | ^^^^^^^^^ re-export of crate public `S1` | = note: consider declaring type or module `S1` with `pub` error[E0365]: `E1` is only public within the crate, and cannot be re-exported outside --> $DIR/crate-private-reexport.rs:10:13 | -LL | pub use ::E1; - | ^^^^ re-export of crate public `E1` +LL | pub use crate::E1; + | ^^^^^^^^^ re-export of crate public `E1` | = note: consider declaring type or module `E1` with `pub` error[E0364]: `V` is only public within the crate, and cannot be re-exported outside --> $DIR/crate-private-reexport.rs:11:13 | -LL | pub use ::E1::V; - | ^^^^^^^ +LL | pub use crate::E1::V; + | ^^^^^^^^^^^^ | note: consider marking `V` as `pub` in the imported module --> $DIR/crate-private-reexport.rs:11:13 | -LL | pub use ::E1::V; - | ^^^^^^^ +LL | pub use crate::E1::V; + | ^^^^^^^^^^^^ error[E0364]: `f2` is only public within the crate, and cannot be re-exported outside --> $DIR/crate-private-reexport.rs:23:13 | -LL | pub use ::f2; - | ^^^^ +LL | pub use crate::f2; + | ^^^^^^^^^ | note: consider marking `f2` as `pub` in the imported module --> $DIR/crate-private-reexport.rs:23:13 | -LL | pub use ::f2; - | ^^^^ +LL | pub use crate::f2; + | ^^^^^^^^^ error[E0365]: `S2` is only public within the crate, and cannot be re-exported outside --> $DIR/crate-private-reexport.rs:24:13 | -LL | pub use ::S2; - | ^^^^ re-export of crate public `S2` +LL | pub use crate::S2; + | ^^^^^^^^^ re-export of crate public `S2` | = note: consider declaring type or module `S2` with `pub` error[E0365]: `E2` is only public within the crate, and cannot be re-exported outside --> $DIR/crate-private-reexport.rs:25:13 | -LL | pub use ::E2; - | ^^^^ re-export of crate public `E2` +LL | pub use crate::E2; + | ^^^^^^^^^ re-export of crate public `E2` | = note: consider declaring type or module `E2` with `pub` error[E0364]: `V` is only public within the crate, and cannot be re-exported outside --> $DIR/crate-private-reexport.rs:26:13 | -LL | pub use ::E2::V; - | ^^^^^^^ +LL | pub use crate::E2::V; + | ^^^^^^^^^^^^ | note: consider marking `V` as `pub` in the imported module --> $DIR/crate-private-reexport.rs:26:13 | -LL | pub use ::E2::V; - | ^^^^^^^ +LL | pub use crate::E2::V; + | ^^^^^^^^^^^^ error[E0364]: `f3` is only public within the crate, and cannot be re-exported outside --> $DIR/crate-private-reexport.rs:39:9 @@ -121,14 +121,14 @@ LL | pub use m3::E3::V; error[E0364]: `f4` is only public within the crate, and cannot be re-exported outside --> $DIR/crate-private-reexport.rs:45:9 | -LL | pub use ::f4 as f5; - | ^^^^^^^^^^ +LL | pub use crate::f4 as f5; + | ^^^^^^^^^^^^^^^ | note: consider marking `f4` as `pub` in the imported module --> $DIR/crate-private-reexport.rs:45:9 | -LL | pub use ::f4 as f5; - | ^^^^^^^^^^ +LL | pub use crate::f4 as f5; + | ^^^^^^^^^^^^^^^ error[E0364]: `f6` is private, and cannot be re-exported --> $DIR/crate-private-reexport.rs:53:13 diff --git a/tests/ui/privacy/issue-30079.rs b/tests/ui/privacy/issue-30079.rs index ddba629f528..3725540c24b 100644 --- a/tests/ui/privacy/issue-30079.rs +++ b/tests/ui/privacy/issue-30079.rs @@ -2,7 +2,7 @@ struct SemiPriv; mod m1 { struct Priv; - impl ::SemiPriv { + impl crate::SemiPriv { pub fn f(_: Priv) {} //~ WARN type `m1::Priv` is more private than the item `m1::<impl SemiPriv>::f` } @@ -13,12 +13,12 @@ mod m1 { mod m2 { struct Priv; - impl ::std::ops::Deref for ::SemiPriv { + impl std::ops::Deref for crate::SemiPriv { type Target = Priv; //~ ERROR private type `m2::Priv` in public interface fn deref(&self) -> &Self::Target { unimplemented!() } } - impl ::std::ops::Deref for Priv { + impl std::ops::Deref for Priv { type Target = Priv; // ok fn deref(&self) -> &Self::Target { unimplemented!() } } @@ -30,7 +30,7 @@ trait SemiPrivTrait { mod m3 { struct Priv; - impl ::SemiPrivTrait for () { + impl crate::SemiPrivTrait for () { type Assoc = Priv; //~ ERROR private type `m3::Priv` in public interface } } diff --git a/tests/ui/privacy/issue-30079.stderr b/tests/ui/privacy/issue-30079.stderr index f1facba7cd2..fcee1b5a93c 100644 --- a/tests/ui/privacy/issue-30079.stderr +++ b/tests/ui/privacy/issue-30079.stderr @@ -16,7 +16,7 @@ error[E0446]: private type `m2::Priv` in public interface | LL | struct Priv; | ----------- `m2::Priv` declared as private -LL | impl ::std::ops::Deref for ::SemiPriv { +LL | impl std::ops::Deref for crate::SemiPriv { LL | type Target = Priv; | ^^^^^^^^^^^ can't leak private type @@ -25,7 +25,7 @@ error[E0446]: private type `m3::Priv` in public interface | LL | struct Priv; | ----------- `m3::Priv` declared as private -LL | impl ::SemiPrivTrait for () { +LL | impl crate::SemiPrivTrait for () { LL | type Assoc = Priv; | ^^^^^^^^^^ can't leak private type diff --git a/tests/ui/privacy/issue-46209-private-enum-variant-reexport.rs b/tests/ui/privacy/issue-46209-private-enum-variant-reexport.rs index 796ba4d2332..1800648b954 100644 --- a/tests/ui/privacy/issue-46209-private-enum-variant-reexport.rs +++ b/tests/ui/privacy/issue-46209-private-enum-variant-reexport.rs @@ -26,7 +26,7 @@ mod rank { Full, } - pub(in rank) enum PettyOfficer { + pub(in crate::rank) enum PettyOfficer { SecondClass, FirstClass, Chief, diff --git a/tests/ui/privacy/legacy-ctor-visibility.rs b/tests/ui/privacy/legacy-ctor-visibility.rs index 5732b6446fe..e698a481173 100644 --- a/tests/ui/privacy/legacy-ctor-visibility.rs +++ b/tests/ui/privacy/legacy-ctor-visibility.rs @@ -4,7 +4,7 @@ mod m { pub struct S(u8); mod n { - use S; + use crate::S; fn f() { S(10); //~^ ERROR expected function, tuple struct or tuple variant, found struct `S` diff --git a/tests/ui/privacy/privacy-in-paths.rs b/tests/ui/privacy/privacy-in-paths.rs index 9cee2b89dd5..4baa9758bbe 100644 --- a/tests/ui/privacy/privacy-in-paths.rs +++ b/tests/ui/privacy/privacy-in-paths.rs @@ -2,7 +2,7 @@ mod foo { pub use self::bar::S; mod bar { pub struct S; - pub use baz; + pub use crate::baz; } trait T { @@ -21,9 +21,9 @@ pub mod baz { fn f() {} fn g() { - ::foo::bar::baz::f(); //~ERROR module `bar` is private - ::foo::bar::S::f(); //~ERROR module `bar` is private - <() as ::foo::T>::Assoc::f(); //~ERROR trait `T` is private + crate::foo::bar::baz::f(); //~ERROR module `bar` is private + crate::foo::bar::S::f(); //~ERROR module `bar` is private + <() as crate::foo::T>::Assoc::f(); //~ERROR trait `T` is private } } diff --git a/tests/ui/privacy/privacy-in-paths.stderr b/tests/ui/privacy/privacy-in-paths.stderr index e6ece35865d..4acb9baa66c 100644 --- a/tests/ui/privacy/privacy-in-paths.stderr +++ b/tests/ui/privacy/privacy-in-paths.stderr @@ -1,10 +1,10 @@ error[E0603]: module `bar` is private - --> $DIR/privacy-in-paths.rs:24:16 + --> $DIR/privacy-in-paths.rs:24:21 | -LL | ::foo::bar::baz::f(); - | ^^^ - function `f` is not publicly re-exported - | | - | private module +LL | crate::foo::bar::baz::f(); + | ^^^ - function `f` is not publicly re-exported + | | + | private module | note: the module `bar` is defined here --> $DIR/privacy-in-paths.rs:3:5 @@ -13,10 +13,10 @@ LL | mod bar { | ^^^^^^^ error[E0603]: module `bar` is private - --> $DIR/privacy-in-paths.rs:25:16 + --> $DIR/privacy-in-paths.rs:25:21 | -LL | ::foo::bar::S::f(); - | ^^^ private module +LL | crate::foo::bar::S::f(); + | ^^^ private module | note: the module `bar` is defined here --> $DIR/privacy-in-paths.rs:3:5 @@ -25,17 +25,17 @@ LL | mod bar { | ^^^^^^^ help: consider importing this struct through its public re-export instead | -LL - ::foo::bar::S::f(); +LL - crate::foo::bar::S::f(); LL + foo::S::f(); | error[E0603]: trait `T` is private - --> $DIR/privacy-in-paths.rs:26:23 + --> $DIR/privacy-in-paths.rs:26:28 | -LL | <() as ::foo::T>::Assoc::f(); - | ^ ----- associated type `Assoc` is not publicly re-exported - | | - | private trait +LL | <() as crate::foo::T>::Assoc::f(); + | ^ ----- associated type `Assoc` is not publicly re-exported + | | + | private trait | note: the trait `T` is defined here --> $DIR/privacy-in-paths.rs:8:5 diff --git a/tests/ui/privacy/privacy-ufcs.rs b/tests/ui/privacy/privacy-ufcs.rs index fec7f41340a..0ba682dde15 100644 --- a/tests/ui/privacy/privacy-ufcs.rs +++ b/tests/ui/privacy/privacy-ufcs.rs @@ -9,5 +9,5 @@ mod foo { } fn main() { - <i32 as ::foo::Bar>::baz(); //~ERROR trait `Bar` is private + <i32 as crate::foo::Bar>::baz(); //~ERROR trait `Bar` is private } diff --git a/tests/ui/privacy/privacy-ufcs.stderr b/tests/ui/privacy/privacy-ufcs.stderr index 5c986895d64..0608c06e8a4 100644 --- a/tests/ui/privacy/privacy-ufcs.stderr +++ b/tests/ui/privacy/privacy-ufcs.stderr @@ -1,10 +1,10 @@ error[E0603]: trait `Bar` is private - --> $DIR/privacy-ufcs.rs:12:20 + --> $DIR/privacy-ufcs.rs:12:25 | -LL | <i32 as ::foo::Bar>::baz(); - | ^^^ --- associated function `baz` is not publicly re-exported - | | - | private trait +LL | <i32 as crate::foo::Bar>::baz(); + | ^^^ --- associated function `baz` is not publicly re-exported + | | + | private trait | note: the trait `Bar` is defined here --> $DIR/privacy-ufcs.rs:4:5 diff --git a/tests/ui/privacy/privacy1.rs b/tests/ui/privacy/privacy1.rs index 9436441ecc6..6cd12b80782 100644 --- a/tests/ui/privacy/privacy1.rs +++ b/tests/ui/privacy/privacy1.rs @@ -98,34 +98,34 @@ fn lol() { mod foo { fn test() { - ::bar::A::foo(); - ::bar::A::bar(); //~ ERROR: associated function `bar` is private - ::bar::A.foo2(); - ::bar::baz::A::foo(); //~ ERROR: module `baz` is private - ::bar::baz::A::bar(); //~ ERROR: module `baz` is private + crate::bar::A::foo(); + crate::bar::A::bar(); //~ ERROR: associated function `bar` is private + crate::bar::A.foo2(); + crate::bar::baz::A::foo(); //~ ERROR: module `baz` is private + crate::bar::baz::A::bar(); //~ ERROR: module `baz` is private //~^ ERROR: associated function `bar` is private - ::bar::baz::A.foo2(); //~ ERROR: module `baz` is private - ::bar::baz::A.bar2(); //~ ERROR: module `baz` is private + crate::bar::baz::A.foo2(); //~ ERROR: module `baz` is private + crate::bar::baz::A.bar2(); //~ ERROR: module `baz` is private //~^ ERROR: method `bar2` is private let _: isize = - ::bar::B::foo(); //~ ERROR: trait `B` is private - ::lol(); + crate::bar::B::foo(); //~ ERROR: trait `B` is private + crate::lol(); - ::bar::Enum::Pub; + crate::bar::Enum::Pub; unsafe { - ::bar::epriv(); //~ ERROR: function `epriv` is private - ::bar::epub(); + crate::bar::epriv(); //~ ERROR: function `epriv` is private + crate::bar::epub(); } - ::bar::foo(); - ::bar::bar(); + crate::bar::foo(); + crate::bar::bar(); - ::bar::gpub(); + crate::bar::gpub(); - ::bar::baz::foo(); //~ ERROR: module `baz` is private - ::bar::baz::bar(); //~ ERROR: module `baz` is private + crate::bar::baz::foo(); //~ ERROR: module `baz` is private + crate::bar::baz::bar(); //~ ERROR: module `baz` is private } fn test2() { @@ -154,7 +154,7 @@ mod foo { bar::bar(); } - impl ::bar::B for f32 { fn foo() -> f32 { 1.0 } } + impl crate::bar::B for f32 { fn foo() -> f32 { 1.0 } } //~^ ERROR: trait `B` is private } diff --git a/tests/ui/privacy/privacy1.stderr b/tests/ui/privacy/privacy1.stderr index cb7b858e54d..1f2f4a92c48 100644 --- a/tests/ui/privacy/privacy1.stderr +++ b/tests/ui/privacy/privacy1.stderr @@ -48,12 +48,12 @@ LL | mod i { | ^^^^^ error[E0603]: module `baz` is private - --> $DIR/privacy1.rs:104:16 + --> $DIR/privacy1.rs:104:21 | -LL | ::bar::baz::A::foo(); - | ^^^ - struct `A` is not publicly re-exported - | | - | private module +LL | crate::bar::baz::A::foo(); + | ^^^ - struct `A` is not publicly re-exported + | | + | private module | note: the module `baz` is defined here --> $DIR/privacy1.rs:50:5 @@ -62,12 +62,12 @@ LL | mod baz { | ^^^^^^^ error[E0603]: module `baz` is private - --> $DIR/privacy1.rs:105:16 + --> $DIR/privacy1.rs:105:21 | -LL | ::bar::baz::A::bar(); - | ^^^ - struct `A` is not publicly re-exported - | | - | private module +LL | crate::bar::baz::A::bar(); + | ^^^ - struct `A` is not publicly re-exported + | | + | private module | note: the module `baz` is defined here --> $DIR/privacy1.rs:50:5 @@ -76,12 +76,12 @@ LL | mod baz { | ^^^^^^^ error[E0603]: module `baz` is private - --> $DIR/privacy1.rs:107:16 + --> $DIR/privacy1.rs:107:21 | -LL | ::bar::baz::A.foo2(); - | ^^^ - unit struct `A` is not publicly re-exported - | | - | private module +LL | crate::bar::baz::A.foo2(); + | ^^^ - unit struct `A` is not publicly re-exported + | | + | private module | note: the module `baz` is defined here --> $DIR/privacy1.rs:50:5 @@ -90,12 +90,12 @@ LL | mod baz { | ^^^^^^^ error[E0603]: module `baz` is private - --> $DIR/privacy1.rs:108:16 + --> $DIR/privacy1.rs:108:21 | -LL | ::bar::baz::A.bar2(); - | ^^^ - unit struct `A` is not publicly re-exported - | | - | private module +LL | crate::bar::baz::A.bar2(); + | ^^^ - unit struct `A` is not publicly re-exported + | | + | private module | note: the module `baz` is defined here --> $DIR/privacy1.rs:50:5 @@ -104,12 +104,12 @@ LL | mod baz { | ^^^^^^^ error[E0603]: trait `B` is private - --> $DIR/privacy1.rs:112:16 + --> $DIR/privacy1.rs:112:21 | -LL | ::bar::B::foo(); - | ^ --- associated function `foo` is not publicly re-exported - | | - | private trait +LL | crate::bar::B::foo(); + | ^ --- associated function `foo` is not publicly re-exported + | | + | private trait | note: the trait `B` is defined here --> $DIR/privacy1.rs:40:5 @@ -118,10 +118,10 @@ LL | trait B { | ^^^^^^^ error[E0603]: function `epriv` is private - --> $DIR/privacy1.rs:118:20 + --> $DIR/privacy1.rs:118:25 | -LL | ::bar::epriv(); - | ^^^^^ private function +LL | crate::bar::epriv(); + | ^^^^^ private function | note: the function `epriv` is defined here --> $DIR/privacy1.rs:65:9 @@ -130,10 +130,10 @@ LL | fn epriv(); | ^^^^^^^^^^^ error[E0603]: module `baz` is private - --> $DIR/privacy1.rs:127:16 + --> $DIR/privacy1.rs:127:21 | -LL | ::bar::baz::foo(); - | ^^^ private module +LL | crate::bar::baz::foo(); + | ^^^ private module | note: the module `baz` is defined here --> $DIR/privacy1.rs:50:5 @@ -142,15 +142,15 @@ LL | mod baz { | ^^^^^^^ help: consider importing this function through its public re-export instead | -LL - ::bar::baz::foo(); +LL - crate::bar::baz::foo(); LL + bar::foo(); | error[E0603]: module `baz` is private - --> $DIR/privacy1.rs:128:16 + --> $DIR/privacy1.rs:128:21 | -LL | ::bar::baz::bar(); - | ^^^ private module +LL | crate::bar::baz::bar(); + | ^^^ private module | note: the module `baz` is defined here --> $DIR/privacy1.rs:50:5 @@ -159,15 +159,15 @@ LL | mod baz { | ^^^^^^^ help: consider importing this function through its public re-export instead | -LL - ::bar::baz::bar(); +LL - crate::bar::baz::bar(); LL + bar::bar(); | error[E0603]: trait `B` is private - --> $DIR/privacy1.rs:157:17 + --> $DIR/privacy1.rs:157:22 | -LL | impl ::bar::B for f32 { fn foo() -> f32 { 1.0 } } - | ^ private trait +LL | impl crate::bar::B for f32 { fn foo() -> f32 { 1.0 } } + | ^ private trait | note: the trait `B` is defined here --> $DIR/privacy1.rs:40:5 @@ -194,31 +194,31 @@ LL | bar::A::bar(); | ^^^ private associated function error[E0624]: associated function `bar` is private - --> $DIR/privacy1.rs:102:19 + --> $DIR/privacy1.rs:102:24 | LL | fn bar() {} | -------- private associated function defined here ... -LL | ::bar::A::bar(); - | ^^^ private associated function +LL | crate::bar::A::bar(); + | ^^^ private associated function error[E0624]: associated function `bar` is private - --> $DIR/privacy1.rs:105:24 + --> $DIR/privacy1.rs:105:29 | LL | fn bar() {} | -------- private associated function defined here ... -LL | ::bar::baz::A::bar(); - | ^^^ private associated function +LL | crate::bar::baz::A::bar(); + | ^^^ private associated function error[E0624]: method `bar2` is private - --> $DIR/privacy1.rs:108:23 + --> $DIR/privacy1.rs:108:28 | LL | fn bar2(&self) {} | -------------- private method defined here ... -LL | ::bar::baz::A.bar2(); - | ^^^^ private method +LL | crate::bar::baz::A.bar2(); + | ^^^^ private method error: aborting due to 18 previous errors diff --git a/tests/ui/privacy/privacy2.rs b/tests/ui/privacy/privacy2.rs index e44100a8059..d4c4faf8ac4 100644 --- a/tests/ui/privacy/privacy2.rs +++ b/tests/ui/privacy/privacy2.rs @@ -10,7 +10,7 @@ mod bar { pub use self::glob::*; pub mod glob { - use foo; + use crate::foo; } } diff --git a/tests/ui/privacy/privacy2.stderr b/tests/ui/privacy/privacy2.stderr index b70134965fa..3d36f26f784 100644 --- a/tests/ui/privacy/privacy2.stderr +++ b/tests/ui/privacy/privacy2.stderr @@ -13,8 +13,8 @@ LL | use bar::glob::foo; note: the function import `foo` is defined here... --> $DIR/privacy2.rs:13:13 | -LL | use foo; - | ^^^ +LL | use crate::foo; + | ^^^^^^^^^^ note: ...and refers to the function `foo` which is defined here --> $DIR/privacy2.rs:17:1 | diff --git a/tests/ui/privacy/privacy3.stderr b/tests/ui/privacy/privacy3.stderr index 06a287d35ea..4530dfe447b 100644 --- a/tests/ui/privacy/privacy3.stderr +++ b/tests/ui/privacy/privacy3.stderr @@ -5,6 +5,12 @@ LL | use bar::gpriv; | ^^^^^^^^^^ no `gpriv` in `bar` error: requires `sized` lang_item + --> $DIR/privacy3.rs:13:20 + | +LL | fn gpriv() {} + | ^^ + +error: requires `sized` lang_item --> $DIR/privacy3.rs:18:14 | LL | pub fn foo() {} @@ -28,12 +34,6 @@ error: requires `sized` lang_item LL | fn main() {} | ^^ -error: requires `sized` lang_item - --> $DIR/privacy3.rs:13:20 - | -LL | fn gpriv() {} - | ^^ - error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/privacy/private-inferred-type-1.rs b/tests/ui/privacy/private-inferred-type-1.rs index b3eba53dd13..c5d90d50df4 100644 --- a/tests/ui/privacy/private-inferred-type-1.rs +++ b/tests/ui/privacy/private-inferred-type-1.rs @@ -12,9 +12,9 @@ trait Ref { mod m { struct Priv; - impl ::Arr0 for [Priv; 0] { fn arr0_secret(&self) {} } - impl ::TyParam for Option<Priv> { fn ty_param_secret(&self) {} } - impl<'a> ::Ref for &'a Priv { fn ref_secret(self) {} } + impl crate::Arr0 for [Priv; 0] { fn arr0_secret(&self) {} } + impl crate::TyParam for Option<Priv> { fn ty_param_secret(&self) {} } + impl<'a> crate::Ref for &'a Priv { fn ref_secret(self) {} } } fn anyref<'a, T>() -> &'a T { panic!() } diff --git a/tests/ui/privacy/restricted/lookup-ignores-private.rs b/tests/ui/privacy/restricted/lookup-ignores-private.rs index 7060db0092f..40fd8ff45b5 100644 --- a/tests/ui/privacy/restricted/lookup-ignores-private.rs +++ b/tests/ui/privacy/restricted/lookup-ignores-private.rs @@ -2,14 +2,14 @@ #![allow(warnings)] mod foo { - pub use foo::bar::S; + pub use crate::foo::bar::S; mod bar { #[derive(Default)] pub struct S { - pub(in foo) x: i32, + pub(in crate::foo) x: i32, } impl S { - pub(in foo) fn f(&self) -> i32 { 0 } + pub(in crate::foo) fn f(&self) -> i32 { 0 } } pub struct S2 { @@ -19,7 +19,7 @@ mod foo { pub(crate) fn f(&self) -> bool { false } } - impl ::std::ops::Deref for S { + impl std::ops::Deref for S { type Target = S2; fn deref(&self) -> &S2 { unimplemented!() } } diff --git a/tests/ui/privacy/restricted/private-in-public.rs b/tests/ui/privacy/restricted/private-in-public.rs index fa8371436b5..f54ab1d5a4a 100644 --- a/tests/ui/privacy/restricted/private-in-public.rs +++ b/tests/ui/privacy/restricted/private-in-public.rs @@ -2,7 +2,7 @@ mod foo { struct Priv; mod bar { - use foo::Priv; + use crate::foo::Priv; pub(super) fn f(_: Priv) {} pub(crate) fn g(_: Priv) {} pub(crate) fn h(_: Priv) {} diff --git a/tests/ui/privacy/restricted/struct-literal-field.rs b/tests/ui/privacy/restricted/struct-literal-field.rs index 9c6104755a4..2bb2a7fe95f 100644 --- a/tests/ui/privacy/restricted/struct-literal-field.rs +++ b/tests/ui/privacy/restricted/struct-literal-field.rs @@ -3,7 +3,7 @@ mod foo { pub mod bar { pub struct S { - pub(in foo) x: i32, + pub(in crate::foo) x: i32, } } @@ -14,6 +14,6 @@ mod foo { } fn main() { - use foo::bar::S; + use crate::foo::bar::S; S { x: 0 }; //~ ERROR private } diff --git a/tests/ui/privacy/trait-object-method-error.rs b/tests/ui/privacy/trait-object-method-error.rs new file mode 100644 index 00000000000..f0214dc6361 --- /dev/null +++ b/tests/ui/privacy/trait-object-method-error.rs @@ -0,0 +1,20 @@ +//! Trait objects only allow access to methods defined in the trait. + +trait MyTrait { + fn trait_method(&mut self); +} + +struct ImplType; + +impl MyTrait for ImplType { + fn trait_method(&mut self) {} +} + +impl ImplType { + fn struct_impl_method(&mut self) {} +} + +fn main() { + let obj: Box<dyn MyTrait> = Box::new(ImplType); + obj.struct_impl_method(); //~ ERROR no method named `struct_impl_method` found +} diff --git a/tests/ui/privacy/trait-object-method-error.stderr b/tests/ui/privacy/trait-object-method-error.stderr new file mode 100644 index 00000000000..40dde8fc47e --- /dev/null +++ b/tests/ui/privacy/trait-object-method-error.stderr @@ -0,0 +1,15 @@ +error[E0599]: no method named `struct_impl_method` found for struct `Box<dyn MyTrait>` in the current scope + --> $DIR/trait-object-method-error.rs:19:9 + | +LL | obj.struct_impl_method(); + | ^^^^^^^^^^^^^^^^^^ + | +help: there is a method `trait_method` with a similar name + | +LL - obj.struct_impl_method(); +LL + obj.trait_method(); + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/proc-macro/crate-var.rs b/tests/ui/proc-macro/crate-var.rs index cea5d48e080..56e9affae8b 100644 --- a/tests/ui/proc-macro/crate-var.rs +++ b/tests/ui/proc-macro/crate-var.rs @@ -31,7 +31,7 @@ macro_rules! local { () => { mod qself { #[derive(Double)] - struct QSelf(<::Foo as $crate::Trait>::Assoc); + struct QSelf(<crate::Foo as $crate::Trait>::Assoc); } mod qself_recurse { @@ -43,7 +43,7 @@ macro_rules! local { () => { #[derive(Double)] #[repr(u32)] enum QSelfInConst { - Variant = <::Foo as $crate::Trait>::CONST, + Variant = <crate::Foo as $crate::Trait>::CONST, } } } } diff --git a/tests/ui/proc-macro/helper-attr-blocked-by-import.rs b/tests/ui/proc-macro/helper-attr-blocked-by-import.rs index 53c079fd19c..bb5006d1c11 100644 --- a/tests/ui/proc-macro/helper-attr-blocked-by-import.rs +++ b/tests/ui/proc-macro/helper-attr-blocked-by-import.rs @@ -10,7 +10,7 @@ use self::two::*; mod empty_helper {} mod one { - use empty_helper; + use crate::empty_helper; #[derive(Empty)] #[empty_helper] @@ -18,7 +18,7 @@ mod one { } mod two { - use empty_helper; + use crate::empty_helper; #[derive(Empty)] #[empty_helper] diff --git a/tests/ui/proc-macro/issue-50493.rs b/tests/ui/proc-macro/issue-50493.rs index 4a88eee2185..2621e595baa 100644 --- a/tests/ui/proc-macro/issue-50493.rs +++ b/tests/ui/proc-macro/issue-50493.rs @@ -5,7 +5,7 @@ extern crate issue_50493; #[derive(Derive)] struct Restricted { - pub(in restricted) field: usize, //~ ERROR visibilities can only be restricted to ancestor modules + pub(in crate::restricted) field: usize, //~ ERROR visibilities can only be restricted to ancestor modules } mod restricted {} diff --git a/tests/ui/proc-macro/issue-50493.stderr b/tests/ui/proc-macro/issue-50493.stderr index 1cd3583135b..fc76e207bc7 100644 --- a/tests/ui/proc-macro/issue-50493.stderr +++ b/tests/ui/proc-macro/issue-50493.stderr @@ -1,8 +1,8 @@ error[E0742]: visibilities can only be restricted to ancestor modules --> $DIR/issue-50493.rs:8:12 | -LL | pub(in restricted) field: usize, - | ^^^^^^^^^^ +LL | pub(in crate::restricted) field: usize, + | ^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/proc-macro/issue-53481.rs b/tests/ui/proc-macro/issue-53481.rs index 11e11e2e6b6..ab5f175faf4 100644 --- a/tests/ui/proc-macro/issue-53481.rs +++ b/tests/ui/proc-macro/issue-53481.rs @@ -5,7 +5,7 @@ extern crate test_macros; mod m1 { - use m2::Empty; + use crate::m2::Empty; #[derive(Empty)] struct A {} diff --git a/tests/ui/proc-macro/no-macro-use-attr.stderr b/tests/ui/proc-macro/no-macro-use-attr.stderr index 4913672450a..0bef563fbb9 100644 --- a/tests/ui/proc-macro/no-macro-use-attr.stderr +++ b/tests/ui/proc-macro/no-macro-use-attr.stderr @@ -2,13 +2,17 @@ warning: unused extern crate --> $DIR/no-macro-use-attr.rs:6:1 | LL | extern crate test_macros; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^^^^^^^^ unused | note: the lint level is defined here --> $DIR/no-macro-use-attr.rs:4:9 | LL | #![warn(unused_extern_crates)] | ^^^^^^^^^^^^^^^^^^^^ +help: remove the unused `extern crate` + | +LL - extern crate test_macros; + | warning: 1 warning emitted diff --git a/tests/ui/proc-macro/trait-fn-args-2015.rs b/tests/ui/proc-macro/trait-fn-args-2015.rs index c25bd768efe..010d986a86d 100644 --- a/tests/ui/proc-macro/trait-fn-args-2015.rs +++ b/tests/ui/proc-macro/trait-fn-args-2015.rs @@ -1,6 +1,7 @@ // Unnamed arguments in trait functions can be passed through proc macros on 2015 edition. //@ check-pass +//@ edition: 2015 //@ proc-macro: test-macros.rs #![allow(anonymous_parameters)] diff --git a/tests/ui/pub/pub-reexport-priv-extern-crate.rs b/tests/ui/pub/pub-reexport-priv-extern-crate.rs index fb495be4001..9d615be30f4 100644 --- a/tests/ui/pub/pub-reexport-priv-extern-crate.rs +++ b/tests/ui/pub/pub-reexport-priv-extern-crate.rs @@ -7,14 +7,14 @@ mod foo1 { } mod foo2 { - use foo1::core; //~ ERROR crate import `core` is private + use crate::foo1::core; //~ ERROR crate import `core` is private pub mod bar { extern crate core; } } mod baz { - pub use foo2::bar::core; //~ ERROR crate import `core` is private + pub use crate::foo2::bar::core; //~ ERROR crate import `core` is private } fn main() {} diff --git a/tests/ui/pub/pub-reexport-priv-extern-crate.stderr b/tests/ui/pub/pub-reexport-priv-extern-crate.stderr index 8ab6e83641d..9bb64a3325b 100644 --- a/tests/ui/pub/pub-reexport-priv-extern-crate.stderr +++ b/tests/ui/pub/pub-reexport-priv-extern-crate.stderr @@ -1,8 +1,8 @@ error[E0603]: crate import `core` is private - --> $DIR/pub-reexport-priv-extern-crate.rs:10:15 + --> $DIR/pub-reexport-priv-extern-crate.rs:10:22 | -LL | use foo1::core; - | ^^^^ private crate import +LL | use crate::foo1::core; + | ^^^^ private crate import | note: the crate import `core` is defined here --> $DIR/pub-reexport-priv-extern-crate.rs:6:5 @@ -11,10 +11,10 @@ LL | extern crate core; | ^^^^^^^^^^^^^^^^^^ error[E0603]: crate import `core` is private - --> $DIR/pub-reexport-priv-extern-crate.rs:17:24 + --> $DIR/pub-reexport-priv-extern-crate.rs:17:31 | -LL | pub use foo2::bar::core; - | ^^^^ private crate import +LL | pub use crate::foo2::bar::core; + | ^^^^ private crate import | note: the crate import `core` is defined here --> $DIR/pub-reexport-priv-extern-crate.rs:12:9 diff --git a/tests/ui/pub/pub-restricted.rs b/tests/ui/pub/pub-restricted.rs index 2aa24121335..4d5eda69de5 100644 --- a/tests/ui/pub/pub-restricted.rs +++ b/tests/ui/pub/pub-restricted.rs @@ -7,7 +7,7 @@ pub (crate::a) fn cfn() {} //~ ERROR incorrect visibility restriction pub fn privfn() {} mod x { mod y { - pub (in x) fn foo() {} + pub (in crate::x) fn foo() {} pub (super) fn bar() {} pub (crate) fn qux() {} } @@ -18,9 +18,9 @@ mod y { pub (crate) c: usize, pub (super) s: usize, valid_private: usize, - pub (in y) valid_in_x: usize, + pub (in crate::y) valid_in_x: usize, pub (a) invalid: usize, //~ ERROR incorrect visibility restriction - pub (in x) non_parent_invalid: usize, //~ ERROR visibilities can only be restricted + pub (in crate::x) non_parent_invalid: usize, //~ ERROR visibilities can only be restricted } } diff --git a/tests/ui/pub/pub-restricted.stderr b/tests/ui/pub/pub-restricted.stderr index 6c913938bb8..0548116362b 100644 --- a/tests/ui/pub/pub-restricted.stderr +++ b/tests/ui/pub/pub-restricted.stderr @@ -76,8 +76,8 @@ LL | pub (in xyz) fn xyz() {} error[E0742]: visibilities can only be restricted to ancestor modules --> $DIR/pub-restricted.rs:23:17 | -LL | pub (in x) non_parent_invalid: usize, - | ^ +LL | pub (in crate::x) non_parent_invalid: usize, + | ^^^^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/qualified/qualified-path-params-2.stderr b/tests/ui/qualified/qualified-path-params-2.stderr index 6641e81013f..e70cdbdc3f4 100644 --- a/tests/ui/qualified/qualified-path-params-2.stderr +++ b/tests/ui/qualified/qualified-path-params-2.stderr @@ -7,7 +7,7 @@ LL | type A = <S as Tr>::A::f<u8>; help: if there were a trait named `Example` with associated type `f` implemented for `<S as Tr>::A`, you could use the fully-qualified path | LL - type A = <S as Tr>::A::f<u8>; -LL + type A = <<S as Tr>::A as Example>::f; +LL + type A = <<S as Tr>::A as Example>::f<u8>; | error: aborting due to 1 previous error diff --git a/tests/ui/query-system/issue-83479.rs b/tests/ui/query-system/issue-83479.rs index 32676dfe9c8..94ceccf49f4 100644 --- a/tests/ui/query-system/issue-83479.rs +++ b/tests/ui/query-system/issue-83479.rs @@ -8,6 +8,7 @@ type PairCoupledTypes: Trait< }], > = impl Trait< //~^ ERROR: cannot find trait `Trait` in this scope + //~| ERROR: unconstrained opaque type [u32; { static FOO: usize; //~ ERROR: free static item without body }], diff --git a/tests/ui/query-system/issue-83479.stderr b/tests/ui/query-system/issue-83479.stderr index 7cb41f5cbe5..79764d01b3b 100644 --- a/tests/ui/query-system/issue-83479.stderr +++ b/tests/ui/query-system/issue-83479.stderr @@ -20,7 +20,7 @@ LL | static FOO: usize; | help: provide a definition for the static: `= <expr>;` error: free static item without body - --> $DIR/issue-83479.rs:12:9 + --> $DIR/issue-83479.rs:13:9 | LL | static FOO: usize; | ^^^^^^^^^^^^^^^^^- @@ -39,6 +39,21 @@ error[E0405]: cannot find trait `Trait` in this scope LL | > = impl Trait< | ^^^^^ not found in this scope -error: aborting due to 5 previous errors +error: unconstrained opaque type + --> $DIR/issue-83479.rs:9:5 + | +LL | > = impl Trait< + | _____^ +LL | | +LL | | +LL | | [u32; { +LL | | static FOO: usize; +LL | | }], +LL | | >; + | |_^ + | + = note: `PairCoupledTypes` must be used in combination with a concrete type within the same crate + +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0405`. diff --git a/tests/ui/recursion/auxiliary/recursive_reexports.rs b/tests/ui/recursion/auxiliary/recursive_reexports.rs index f98fa71009f..47a79090f4d 100644 --- a/tests/ui/recursion/auxiliary/recursive_reexports.rs +++ b/tests/ui/recursion/auxiliary/recursive_reexports.rs @@ -1,3 +1,3 @@ pub mod foo { - pub use foo; + pub use crate::foo; } diff --git a/tests/ui/recursion/recursive-static-definition.rs b/tests/ui/recursion/recursive-static-definition.rs index 5317c47076e..55db6a86bf1 100644 --- a/tests/ui/recursion/recursive-static-definition.rs +++ b/tests/ui/recursion/recursive-static-definition.rs @@ -1,5 +1,5 @@ pub static FOO: u32 = FOO; -//~^ ERROR could not evaluate static initializer +//~^ ERROR encountered static that tried to initialize itself with itself #[derive(Copy, Clone)] pub union Foo { @@ -7,6 +7,6 @@ pub union Foo { } pub static BAR: Foo = BAR; -//~^ ERROR could not evaluate static initializer +//~^ ERROR encountered static that tried to initialize itself with itself fn main() {} diff --git a/tests/ui/recursion/recursive-static-definition.stderr b/tests/ui/recursion/recursive-static-definition.stderr index 86a22c990e9..ce93c41bc67 100644 --- a/tests/ui/recursion/recursive-static-definition.stderr +++ b/tests/ui/recursion/recursive-static-definition.stderr @@ -1,14 +1,14 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: encountered static that tried to initialize itself with itself --> $DIR/recursive-static-definition.rs:1:23 | LL | pub static FOO: u32 = FOO; - | ^^^ encountered static that tried to initialize itself with itself + | ^^^ evaluation of `FOO` failed here -error[E0080]: could not evaluate static initializer +error[E0080]: encountered static that tried to initialize itself with itself --> $DIR/recursive-static-definition.rs:9:23 | LL | pub static BAR: Foo = BAR; - | ^^^ encountered static that tried to initialize itself with itself + | ^^^ evaluation of `BAR` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/recursion_limit/issue-40003.rs b/tests/ui/recursion_limit/issue-40003.rs index 5032d0c9db3..6bc40690dad 100644 --- a/tests/ui/recursion_limit/issue-40003.rs +++ b/tests/ui/recursion_limit/issue-40003.rs @@ -17,7 +17,7 @@ use future::{Future, IntoFuture}; mod future { use std::result; - use {stream, Stream}; + use crate::{stream, Stream}; pub trait Future { type Item; @@ -100,7 +100,7 @@ mod future { } mod stream { - use IntoFuture; + use crate::IntoFuture; pub trait Stream { type Item; diff --git a/tests/ui/regions/init-res-into-things.rs b/tests/ui/regions/init-res-into-things.rs index 64909b32919..7b100d32533 100644 --- a/tests/ui/regions/init-res-into-things.rs +++ b/tests/ui/regions/init-res-into-things.rs @@ -20,7 +20,7 @@ impl<'a> Drop for r<'a> { } } -fn r(i: &Cell<isize>) -> r { +fn r(i: &Cell<isize>) -> r<'_> { r { i: i } diff --git a/tests/ui/regions/region-object-lifetime-1.rs b/tests/ui/regions/region-object-lifetime-1.rs index 11e3c8a1a33..7ff37d7a525 100644 --- a/tests/ui/regions/region-object-lifetime-1.rs +++ b/tests/ui/regions/region-object-lifetime-1.rs @@ -10,7 +10,7 @@ trait Foo { // Here the receiver and return value all have the same lifetime, // so no error results. -fn borrowed_receiver_same_lifetime<'a>(x: &'a Foo) -> &'a () { +fn borrowed_receiver_same_lifetime<'a>(x: &'a dyn Foo) -> &'a () { x.borrowed() } diff --git a/tests/ui/regions/region-object-lifetime-3.rs b/tests/ui/regions/region-object-lifetime-3.rs index ddeeec902f1..fee32f92059 100644 --- a/tests/ui/regions/region-object-lifetime-3.rs +++ b/tests/ui/regions/region-object-lifetime-3.rs @@ -10,7 +10,7 @@ trait Foo { // Borrowed receiver with two distinct lifetimes, but we know that // 'b:'a, hence &'a () is permitted. -fn borrowed_receiver_related_lifetimes<'a,'b>(x: &'a (Foo+'b)) -> &'a () { +fn borrowed_receiver_related_lifetimes<'a,'b>(x: &'a (dyn Foo+'b)) -> &'a () { x.borrowed() } diff --git a/tests/ui/regions/regions-nullary-variant.rs b/tests/ui/regions/regions-nullary-variant.rs index 8624f9961f6..24c5c6765a8 100644 --- a/tests/ui/regions/regions-nullary-variant.rs +++ b/tests/ui/regions/regions-nullary-variant.rs @@ -7,7 +7,7 @@ enum roption<'a> { a, b(&'a usize) } -fn mk(cond: bool, ptr: &usize) -> roption { +fn mk(cond: bool, ptr: &usize) -> roption<'_> { if cond {roption::a} else {roption::b(ptr)} } diff --git a/tests/ui/repeat-expr/copy-check-const-element-uninferred-count.rs b/tests/ui/repeat-expr/copy-check-const-element-uninferred-count.rs new file mode 100644 index 00000000000..6115146539c --- /dev/null +++ b/tests/ui/repeat-expr/copy-check-const-element-uninferred-count.rs @@ -0,0 +1,72 @@ +#![feature(generic_arg_infer)] + +// Test when deferring repeat expr copy checks to end of typechecking whether elements +// that are const items allow for repeat counts to go uninferred without an error being +// emitted if they would later wind up inferred by integer fallback. +// +// This test should be updated if we wind up deferring repeat expr checks until *after* +// integer fallback as the point of the test is not *specifically* about integer fallback +// but rather about the behaviour of `const` element exprs. + +trait Trait<const N: usize> {} + +// We impl `Trait` for both `i32` and `u32` to avoid being able +// to prove `?int: Trait<?n>` from there only being one impl. +impl Trait<2> for i32 {} +impl Trait<2> for u32 {} + +fn tie_and_make_goal<const N: usize, T: Trait<N>>(_: &T, _: &[String; N]) {} + +fn const_block() { + // Deferred repeat expr `String; ?n` + let a = [const { String::new() }; _]; + + // `?int: Trait<?n>` goal + tie_and_make_goal(&1, &a); + + // If repeat expr checks structurally resolve the `?n`s before checking if the + // element is a `const` then we would error here. Otherwise we avoid doing so, + // integer fallback occurs, allowing `?int: Trait<?n>` goals to make progress, + // inferring the repeat counts (to `2` but that doesn't matter as the element is `const`). +} + +fn const_item() { + const MY_CONST: String = String::new(); + + // Deferred repeat expr `String; ?n` + let a = [MY_CONST; _]; + + // `?int: Trait<?n>` goal + tie_and_make_goal(&1, &a); + + // ... same as `const_block` +} + +fn assoc_const() { + trait Dummy { + const ASSOC: String; + } + impl Dummy for () { + const ASSOC: String = String::new(); + } + + // Deferred repeat expr `String; ?n` + let a = [<() as Dummy>::ASSOC; _]; + + // `?int: Trait<?n>` goal + tie_and_make_goal(&1, &a); + + // ... same as `const_block` +} + +fn const_block_but_uninferred() { + // Deferred repeat expr `String; ?n` + let a = [const { String::new() }; _]; + //~^ ERROR: type annotations needed for `[String; _]` + + // Even if we don't structurally resolve the repeat count as part of repeat expr + // checks, we still error on the repeat count being uninferred as we require all + // types/consts to be inferred by the end of type checking. +} + +fn main() {} diff --git a/tests/ui/repeat-expr/copy-check-const-element-uninferred-count.stderr b/tests/ui/repeat-expr/copy-check-const-element-uninferred-count.stderr new file mode 100644 index 00000000000..2f52537fa94 --- /dev/null +++ b/tests/ui/repeat-expr/copy-check-const-element-uninferred-count.stderr @@ -0,0 +1,15 @@ +error[E0284]: type annotations needed for `[String; _]` + --> $DIR/copy-check-const-element-uninferred-count.rs:64:9 + | +LL | let a = [const { String::new() }; _]; + | ^ ---------------------------- type must be known at this point + | + = note: the length of array `[String; _]` must be type `usize` +help: consider giving `a` an explicit type, where the placeholders `_` are specified + | +LL | let a: [_; _] = [const { String::new() }; _]; + | ++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/repeat-expr/copy-check-deferred-after-fallback.rs b/tests/ui/repeat-expr/copy-check-deferred-after-fallback.rs index d9ad93541ec..3f310f07de0 100644 --- a/tests/ui/repeat-expr/copy-check-deferred-after-fallback.rs +++ b/tests/ui/repeat-expr/copy-check-deferred-after-fallback.rs @@ -1,37 +1,53 @@ #![feature(generic_arg_infer)] -// Test that would start passing if we defer repeat expr copy checks to end of -// typechecking and they're checked after integer fallback occurs. We accomplish -// this by contriving a situation where integer fallback allows progress to be -// made on a trait goal that infers the length of a repeat expr. +// Test when deferring repeat expr copy checks to end of typechecking whether they're +// checked before integer fallback occurs or not. We accomplish this by having a repeat +// count that can only be inferred after integer fallback has occured. This test will +// pass if we were to check repeat exprs after integer fallback. use std::marker::PhantomData; - -struct NotCopy; +struct Foo<T>(PhantomData<T>); + +// We impl Copy/Clone for multiple (but not all) substitutions +// to ensure that `Foo<?int>: Copy` can't be proven on the basis +// of there only being one applying impl. +impl Clone for Foo<u32> { + fn clone(&self) -> Self { + Foo(PhantomData) + } +} +impl Clone for Foo<i32> { + fn clone(&self) -> Self { + Foo(PhantomData) + } +} +impl Copy for Foo<u32> {} +impl Copy for Foo<i32> {} trait Trait<const N: usize> {} -impl Trait<2> for u32 {} +// We impl `Trait` for both `i32` and `u32` to avoid being able +// to prove `?int: Trait<?n>` from there only being one impl. impl Trait<1> for i32 {} +impl Trait<2> for u32 {} -fn make_goal<T: Trait<N>, const N: usize>(_: &T, _: [NotCopy; N]) {} +fn tie_and_make_goal<const N: usize, T: Trait<N>>(_: &T, _: &[Foo<T>; N]) {} fn main() { let a = 1; - let b = [NotCopy; _]; - //~^ ERROR: type annotations needed - - // a is of type `?y` - // b is of type `[NotCopy; ?x]` - // there is a goal ?y: Trait<?x>` with two candidates: - // - `i32: Trait<1>`, ?y=i32 ?x=1 which doesnt require `NotCopy: Copy` - // - `u32: Trait<2>` ?y=u32 ?x=2 which requires `NotCopy: Copy` - make_goal(&a, b); - - // final repeat expr checks: - // - // `NotCopy; ?x` - // - succeeds if fallback happens before repeat exprs as `i32: Trait<?x>` infers `?x=1` - // - fails if repeat expr checks happen first as `?x` is unconstrained so cannot be - // structurally resolved + // Deferred repeat expr `Foo<?int>; ?n` + let b = [Foo(PhantomData); _]; + //~^ ERROR: type annotations needed for `[Foo<{integer}>; _]` + + // Introduces a `?int: Trait<?n>` goal + tie_and_make_goal(&a, &b); + + // If fallback doesn't occur: + // - `Foo<?int>; ?n`is ambig as repeat count is unknown -> error + + // If fallback occurs: + // - `?int` inferred to `i32` + // - `?int: Trait<?n>` becomes `i32: Trait<?n>` wihhc infers `?n=1` + // - Repeat expr check `Foo<?int>; ?n` is now `Foo<i32>; 1` + // - `Foo<i32>; 1` doesn't require `Foo<i32>: Copy` } diff --git a/tests/ui/repeat-expr/copy-check-deferred-after-fallback.stderr b/tests/ui/repeat-expr/copy-check-deferred-after-fallback.stderr index 2a0cb3fb7a3..103b074dda7 100644 --- a/tests/ui/repeat-expr/copy-check-deferred-after-fallback.stderr +++ b/tests/ui/repeat-expr/copy-check-deferred-after-fallback.stderr @@ -1,13 +1,13 @@ -error[E0282]: type annotations needed for `[NotCopy; _]` - --> $DIR/copy-check-deferred-after-fallback.rs:21:9 +error[E0282]: type annotations needed for `[Foo<{integer}>; _]` + --> $DIR/copy-check-deferred-after-fallback.rs:39:9 | -LL | let b = [NotCopy; _]; - | ^ ------- type must be known at this point +LL | let b = [Foo(PhantomData); _]; + | ^ ---------------- type must be known at this point | help: consider giving `b` an explicit type, where the value of const parameter `N` is specified | -LL | let b: [_; N] = [NotCopy; _]; - | ++++++++ +LL | let b: [Foo<{integer}>; N] = [Foo(PhantomData); _]; + | +++++++++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/repeat-expr/copy-check-deferred-before-fallback.rs b/tests/ui/repeat-expr/copy-check-deferred-before-fallback.rs index 4654d7483a6..4fbb8f0a00c 100644 --- a/tests/ui/repeat-expr/copy-check-deferred-before-fallback.rs +++ b/tests/ui/repeat-expr/copy-check-deferred-before-fallback.rs @@ -1,18 +1,13 @@ //@ check-pass - #![feature(generic_arg_infer)] -// Test that if we defer repeat expr copy checks to end of typechecking they're -// checked before integer fallback occurs. We accomplish this by contriving a -// situation where we have a goal that can be proven either via another repeat expr -// check or by integer fallback. In the integer fallback case an array length would -// be inferred to `2` requiring `NotCopy: Copy`, and in the repeat expr case it would -// be inferred to `1`. +// Test when deferring repeat expr checks to end of typechecking whether they're +// checked before integer fallback occurs. We accomplish this by having the repeat +// expr check allow inference progress on an ambiguous goal, where the ambiguous goal +// would fail if the inference variable was fallen back to `i32`. This test will +// pass if we check repeat exprs before integer fallback. use std::marker::PhantomData; - -struct NotCopy; - struct Foo<T>(PhantomData<T>); impl Clone for Foo<u32> { @@ -20,40 +15,34 @@ impl Clone for Foo<u32> { Foo(PhantomData) } } - impl Copy for Foo<u32> {} -fn tie<T>(_: &T, _: [Foo<T>; 2]) {} +trait Trait {} -trait Trait<const N: usize> {} +// Two impls just to ensure that `?int: Trait` wont itself succeed by unifying with +// a self type on an impl here. It also ensures that integer fallback would actually +// be valid for all of the stalled goals incase that's ever something we take into account. +impl Trait for i32 {} +impl Trait for u32 {} -impl Trait<2> for i32 {} -impl Trait<1> for u32 {} - -fn make_goal<T: Trait<N>, const N: usize>(_: &T, _: [NotCopy; N]) {} +fn make_goal<T: Trait>(_: &T) {} +fn tie<T>(_: &T, _: &[Foo<T>; 2]) {} fn main() { let a = 1; + // `?int: Trait` + make_goal(&a); + + // Deferred `Foo<?int>: Copy` requirement let b: [Foo<_>; 2] = [Foo(PhantomData); _]; - tie(&a, b); - let c = [NotCopy; _]; - - // a is of type `?y` - // b is of type `[Foo<?y>; 2]` - // c is of type `[NotCopy; ?x]` - // there is a goal ?y: Trait<?x>` with two candidates: - // - `i32: Trait<2>`, ?y=i32 ?x=2 which requires `NotCopy: Copy` when expr checks happen - // - `u32: Trait<1>` ?y=u32 ?x=1 which doesnt require `NotCopy: Copy` - make_goal(&a, c); - - // final repeat expr checks: - // - // `Foo<?y>; 2` - // - Foo<?y>: Copy - // - requires ?y=u32 - // - // `NotCopy; ?x` - // - fails if fallback happens before repeat exprs as `i32: Trait<?x>` infers `?x=2` - // - succeeds if repeat expr checks happen first as `?y=u32` means `u32: Trait<?x>` - // infers `?x=1` + tie(&a, &b); + + // If fallback doesn't occur: + // - `Foo<?int>; 2`is > 1, needs copy + // - `Foo<?int>: Copy` infers `?int=u32` + // - stalled goal `?int: Trait` can now make progress and succeed + + // If fallback occurs: + // - `Foo<i32>; 2` is > 1, needs copy + // - `Foo<i32>: Copy` doesn't hold -> error } diff --git a/tests/ui/repeat-expr/copy-check-inference-side-effects.rs b/tests/ui/repeat-expr/copy-check-inference-side-effects.rs new file mode 100644 index 00000000000..4e3bfdead26 --- /dev/null +++ b/tests/ui/repeat-expr/copy-check-inference-side-effects.rs @@ -0,0 +1,34 @@ +#![feature(generic_arg_infer)] + +struct Foo<const N: usize>; + +impl Clone for Foo<1> { + fn clone(&self) -> Self { + Self + } +} +impl Copy for Foo<1> {} + +fn unify<const N: usize>(_: &[Foo<N>; 2], _: &[String; N]) {} + +fn works_if_inference_side_effects() { + // This will only pass if inference side effects from proving `Foo<?x>: Copy` are + // able to be relied upon by other repeat expressions. + let a /* : [Foo<?x>; 2] */ = [Foo::<_>; 2]; + //~^ ERROR: type annotations needed for `[Foo<_>; 2]` + let b /* : [String; ?x] */ = ["string".to_string(); _]; + + unify(&a, &b); +} + +fn works_if_fixed_point() { + // This will only pass if the *second* array repeat expr is checked first + // allowing `Foo<?x>: Copy` to infer the array length of the first repeat expr. + let b /* : [String; ?x] */ = ["string".to_string(); _]; + //~^ ERROR: type annotations needed for `[String; _]` + let a /* : [Foo<?x>; 2] */ = [Foo::<_>; 2]; + + unify(&a, &b); +} + +fn main() {} diff --git a/tests/ui/repeat-expr/copy-check-inference-side-effects.stderr b/tests/ui/repeat-expr/copy-check-inference-side-effects.stderr new file mode 100644 index 00000000000..505beff0f6b --- /dev/null +++ b/tests/ui/repeat-expr/copy-check-inference-side-effects.stderr @@ -0,0 +1,28 @@ +error[E0282]: type annotations needed for `[Foo<_>; 2]` + --> $DIR/copy-check-inference-side-effects.rs:17:9 + | +LL | let a /* : [Foo<?x>; 2] */ = [Foo::<_>; 2]; + | ^ +LL | +LL | let b /* : [String; ?x] */ = ["string".to_string(); _]; + | -------------------- type must be known at this point + | +help: consider giving `a` an explicit type, where the value of const parameter `N` is specified + | +LL | let a: [Foo<N>; 2] /* : [Foo<?x>; 2] */ = [Foo::<_>; 2]; + | +++++++++++++ + +error[E0282]: type annotations needed for `[String; _]` + --> $DIR/copy-check-inference-side-effects.rs:27:9 + | +LL | let b /* : [String; ?x] */ = ["string".to_string(); _]; + | ^ -------------------- type must be known at this point + | +help: consider giving `b` an explicit type, where the value of const parameter `N` is specified + | +LL | let b: [_; N] /* : [String; ?x] */ = ["string".to_string(); _]; + | ++++++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/repeat-expr/copy-check-when-count-inferred-later.rs b/tests/ui/repeat-expr/copy-check-when-count-inferred-later.rs new file mode 100644 index 00000000000..b9d123cbefa --- /dev/null +++ b/tests/ui/repeat-expr/copy-check-when-count-inferred-later.rs @@ -0,0 +1,11 @@ +#![feature(generic_arg_infer)] + +// Test that we enforce repeat expr element types are `Copy` even +// when the repeat count is only inferred at a later point in type +// checking. + +fn main() { + let a = [String::new(); _]; + //~^ ERROR: the trait bound `String: Copy` is not satisfied + let b: [_; 2] = a; +} diff --git a/tests/ui/repeat-expr/copy-check-when-count-inferred-later.stderr b/tests/ui/repeat-expr/copy-check-when-count-inferred-later.stderr new file mode 100644 index 00000000000..1c862f2b606 --- /dev/null +++ b/tests/ui/repeat-expr/copy-check-when-count-inferred-later.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `String: Copy` is not satisfied + --> $DIR/copy-check-when-count-inferred-later.rs:8:14 + | +LL | let a = [String::new(); _]; + | ^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` + | + = note: the `Copy` trait is required because this value will be copied for each element of the array +help: create an inline `const` block + | +LL | let a = [const { String::new() }; _]; + | +++++++ + + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/repeat-expr/copy-inference-side-effects-are-lazy.rs b/tests/ui/repeat-expr/copy-inference-side-effects-are-lazy.rs index 0b0672d9c2b..d50466ac4bb 100644 --- a/tests/ui/repeat-expr/copy-inference-side-effects-are-lazy.rs +++ b/tests/ui/repeat-expr/copy-inference-side-effects-are-lazy.rs @@ -1,8 +1,3 @@ -//@revisions: current gai -//@[current] check-pass - -#![cfg_attr(gai, feature(generic_arg_infer))] - use std::marker::PhantomData; struct Foo<T>(PhantomData<T>); @@ -20,6 +15,6 @@ fn extract<T, const N: usize>(_: [Foo<T>; N]) -> T { fn main() { let x = [Foo(PhantomData); 2]; - //[gai]~^ ERROR: type annotations needed - _ = extract(x).max(2); + //~^ ERROR: type annotations needed + extract(x).max(2); } diff --git a/tests/ui/repeat-expr/copy-inference-side-effects-are-lazy.stderr b/tests/ui/repeat-expr/copy-inference-side-effects-are-lazy.stderr new file mode 100644 index 00000000000..ba44beb76db --- /dev/null +++ b/tests/ui/repeat-expr/copy-inference-side-effects-are-lazy.stderr @@ -0,0 +1,17 @@ +error[E0282]: type annotations needed for `[Foo<_>; 2]` + --> $DIR/copy-inference-side-effects-are-lazy.rs:17:9 + | +LL | let x = [Foo(PhantomData); 2]; + | ^ +LL | +LL | extract(x).max(2); + | ---------- type must be known at this point + | +help: consider giving `x` an explicit type, where the type for type parameter `T` is specified + | +LL | let x: [Foo<T>; 2] = [Foo(PhantomData); 2]; + | +++++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr b/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr index c11acc98637..63d685951d9 100644 --- a/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr +++ b/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr @@ -1,8 +1,7 @@ error: layout_of(Univariant) = Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -45,9 +44,8 @@ error: layout_of(Univariant) = Layout { variants: [ Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -88,9 +86,8 @@ LL | enum Univariant { error: layout_of(TwoVariants) = Layout { size: Size(8 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -139,9 +136,8 @@ error: layout_of(TwoVariants) = Layout { variants: [ Layout { size: Size(8 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -177,9 +173,8 @@ error: layout_of(TwoVariants) = Layout { }, Layout { size: Size(8 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -226,9 +221,8 @@ LL | enum TwoVariants { error: layout_of(DeadBranchHasOtherField) = Layout { size: Size(16 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(8 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -265,9 +259,8 @@ error: layout_of(DeadBranchHasOtherField) = Layout { variants: [ Layout { size: Size(16 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(8 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -295,9 +288,8 @@ error: layout_of(DeadBranchHasOtherField) = Layout { }, Layout { size: Size(16 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(8 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, diff --git a/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr b/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr index a7888155dea..555471be027 100644 --- a/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr +++ b/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr @@ -1,8 +1,7 @@ error: layout_of(Univariant) = Layout { size: Size(1 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -45,9 +44,8 @@ error: layout_of(Univariant) = Layout { variants: [ Layout { size: Size(1 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -88,9 +86,8 @@ LL | enum Univariant { error: layout_of(TwoVariants) = Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $SOME_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -139,9 +136,8 @@ error: layout_of(TwoVariants) = Layout { variants: [ Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $SOME_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -177,9 +173,8 @@ error: layout_of(TwoVariants) = Layout { }, Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $SOME_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -226,9 +221,8 @@ LL | enum TwoVariants { error: layout_of(DeadBranchHasOtherField) = Layout { size: Size(16 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(8 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -265,9 +259,8 @@ error: layout_of(DeadBranchHasOtherField) = Layout { variants: [ Layout { size: Size(16 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(8 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -295,9 +288,8 @@ error: layout_of(DeadBranchHasOtherField) = Layout { }, Layout { size: Size(16 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(8 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, diff --git a/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr b/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr index c11acc98637..63d685951d9 100644 --- a/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr +++ b/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr @@ -1,8 +1,7 @@ error: layout_of(Univariant) = Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -45,9 +44,8 @@ error: layout_of(Univariant) = Layout { variants: [ Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -88,9 +86,8 @@ LL | enum Univariant { error: layout_of(TwoVariants) = Layout { size: Size(8 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -139,9 +136,8 @@ error: layout_of(TwoVariants) = Layout { variants: [ Layout { size: Size(8 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -177,9 +173,8 @@ error: layout_of(TwoVariants) = Layout { }, Layout { size: Size(8 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -226,9 +221,8 @@ LL | enum TwoVariants { error: layout_of(DeadBranchHasOtherField) = Layout { size: Size(16 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(8 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -265,9 +259,8 @@ error: layout_of(DeadBranchHasOtherField) = Layout { variants: [ Layout { size: Size(16 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(8 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -295,9 +288,8 @@ error: layout_of(DeadBranchHasOtherField) = Layout { }, Layout { size: Size(16 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(8 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, diff --git a/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr b/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr index c11acc98637..63d685951d9 100644 --- a/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr +++ b/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr @@ -1,8 +1,7 @@ error: layout_of(Univariant) = Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -45,9 +44,8 @@ error: layout_of(Univariant) = Layout { variants: [ Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -88,9 +86,8 @@ LL | enum Univariant { error: layout_of(TwoVariants) = Layout { size: Size(8 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -139,9 +136,8 @@ error: layout_of(TwoVariants) = Layout { variants: [ Layout { size: Size(8 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -177,9 +173,8 @@ error: layout_of(TwoVariants) = Layout { }, Layout { size: Size(8 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -226,9 +221,8 @@ LL | enum TwoVariants { error: layout_of(DeadBranchHasOtherField) = Layout { size: Size(16 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(8 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -265,9 +259,8 @@ error: layout_of(DeadBranchHasOtherField) = Layout { variants: [ Layout { size: Size(16 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(8 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -295,9 +288,8 @@ error: layout_of(DeadBranchHasOtherField) = Layout { }, Layout { size: Size(16 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(8 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, diff --git a/tests/ui/repr/repr-c-int-dead-variants.stderr b/tests/ui/repr/repr-c-int-dead-variants.stderr index f63574182c2..d88a842f884 100644 --- a/tests/ui/repr/repr-c-int-dead-variants.stderr +++ b/tests/ui/repr/repr-c-int-dead-variants.stderr @@ -1,8 +1,7 @@ error: layout_of(UnivariantU8) = Layout { size: Size(1 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -45,9 +44,8 @@ error: layout_of(UnivariantU8) = Layout { variants: [ Layout { size: Size(1 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -88,9 +86,8 @@ LL | enum UnivariantU8 { error: layout_of(TwoVariantsU8) = Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $SOME_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -139,9 +136,8 @@ error: layout_of(TwoVariantsU8) = Layout { variants: [ Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $SOME_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -177,9 +173,8 @@ error: layout_of(TwoVariantsU8) = Layout { }, Layout { size: Size(2 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $SOME_ALIGN, }, backend_repr: ScalarPair( Initialized { @@ -226,9 +221,8 @@ LL | enum TwoVariantsU8 { error: layout_of(DeadBranchHasOtherFieldU8) = Layout { size: Size(16 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(8 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -265,9 +259,8 @@ error: layout_of(DeadBranchHasOtherFieldU8) = Layout { variants: [ Layout { size: Size(16 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(8 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -295,9 +288,8 @@ error: layout_of(DeadBranchHasOtherFieldU8) = Layout { }, Layout { size: Size(16 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(8 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, diff --git a/tests/ui/resolve/extern-crate-lint-issue-141785.rs b/tests/ui/resolve/extern-crate-lint-issue-141785.rs new file mode 100644 index 00000000000..8d044d666df --- /dev/null +++ b/tests/ui/resolve/extern-crate-lint-issue-141785.rs @@ -0,0 +1,11 @@ +//@ check-pass +//@ edition:2018 + +#![no_implicit_prelude] +#![warn(unused_extern_crates)] + +extern crate std; +fn main() { + let r = 1u16..10; + std::println!("{:?}", r.is_empty()); +} diff --git a/tests/ui/resolve/suggestions/sugg-field-in-format-string-issue-141136.rs b/tests/ui/resolve/suggestions/sugg-field-in-format-string-issue-141136.rs new file mode 100644 index 00000000000..d2aa61186bc --- /dev/null +++ b/tests/ui/resolve/suggestions/sugg-field-in-format-string-issue-141136.rs @@ -0,0 +1,15 @@ +struct Foo { + x: i32 +} + +impl Foo { + fn foo(&self) { + let _ = format!("{x}"); //~ ERROR cannot find value `x` in this scope [E0425] + let _ = format!("{x }"); //~ ERROR cannot find value `x` in this scope [E0425] + let _ = format!("{ x}"); //~ ERROR invalid format string: expected `}`, found `x` + let _ = format!("{}", x); //~ ERROR cannot find value `x` in this scope [E0425] + println!("{x}"); //~ ERROR cannot find value `x` in this scope [E0425] + } +} + +fn main(){} diff --git a/tests/ui/resolve/suggestions/sugg-field-in-format-string-issue-141136.stderr b/tests/ui/resolve/suggestions/sugg-field-in-format-string-issue-141136.stderr new file mode 100644 index 00000000000..0a84848081d --- /dev/null +++ b/tests/ui/resolve/suggestions/sugg-field-in-format-string-issue-141136.stderr @@ -0,0 +1,48 @@ +error: invalid format string: expected `}`, found `x` + --> $DIR/sugg-field-in-format-string-issue-141136.rs:9:28 + | +LL | let _ = format!("{ x}"); + | - ^ expected `}` in format string + | | + | because of this opening brace + | + = note: if you intended to print `{`, you can escape it using `{{` + +error[E0425]: cannot find value `x` in this scope + --> $DIR/sugg-field-in-format-string-issue-141136.rs:7:27 + | +LL | let _ = format!("{x}"); + | ^ + | + = help: you might have meant to use the available field in a format string: `"{}", self.x` + +error[E0425]: cannot find value `x` in this scope + --> $DIR/sugg-field-in-format-string-issue-141136.rs:8:27 + | +LL | let _ = format!("{x }"); + | ^^ + | + = help: you might have meant to use the available field in a format string: `"{}", self.x` + +error[E0425]: cannot find value `x` in this scope + --> $DIR/sugg-field-in-format-string-issue-141136.rs:10:31 + | +LL | let _ = format!("{}", x); + | ^ + | +help: you might have meant to use the available field + | +LL | let _ = format!("{}", self.x); + | +++++ + +error[E0425]: cannot find value `x` in this scope + --> $DIR/sugg-field-in-format-string-issue-141136.rs:11:20 + | +LL | println!("{x}"); + | ^ + | + = help: you might have meant to use the available field in a format string: `"{}", self.x` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/resolve/tuple-struct-alias.stderr b/tests/ui/resolve/tuple-struct-alias.stderr index a739ea43eed..bf026a499b8 100644 --- a/tests/ui/resolve/tuple-struct-alias.stderr +++ b/tests/ui/resolve/tuple-struct-alias.stderr @@ -6,8 +6,6 @@ LL | struct S(u8, u16); ... LL | A(..) => {} | ^ help: a tuple struct with a similar name exists: `S` - | - = note: can't use a type alias as a constructor error[E0423]: expected function, tuple struct or tuple variant, found type alias `A` --> $DIR/tuple-struct-alias.rs:5:13 @@ -16,9 +14,18 @@ LL | struct S(u8, u16); | ------------------ similarly named tuple struct `S` defined here ... LL | let s = A(0, 1); - | ^ help: a tuple struct with a similar name exists: `S` + | ^ + | +help: a tuple struct with a similar name exists + | +LL - let s = A(0, 1); +LL + let s = S(0, 1); + | +help: you might have meant to use `:` for type annotation + | +LL - let s = A(0, 1); +LL + let s: A(0, 1); | - = note: can't use a type alias as a constructor error: aborting due to 2 previous errors diff --git a/tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr b/tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr index 5832cb69a3d..1ecbfee17bc 100644 --- a/tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr +++ b/tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr @@ -20,17 +20,9 @@ error[E0425]: cannot find value `config` in this scope --> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:15:20 | LL | println!("{config}"); - | ^^^^^^ - | -help: you might have meant to use the available field - | -LL | println!("{self.config}"); - | +++++ -help: a local variable with a similar name exists - | -LL - println!("{config}"); -LL + println!("{cofig}"); + | ^^^^^^ help: a local variable with a similar name exists: `cofig` | + = help: you might have meant to use the available field in a format string: `"{}", self.config` error[E0425]: cannot find value `bah` in this scope --> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:33:9 diff --git a/tests/ui/resource-assign-is-not-copy.rs b/tests/ui/resource-assign-is-not-copy.rs index 078824cea1b..ab426016901 100644 --- a/tests/ui/resource-assign-is-not-copy.rs +++ b/tests/ui/resource-assign-is-not-copy.rs @@ -14,7 +14,7 @@ impl<'a> Drop for r<'a> { } } -fn r(i: &Cell<isize>) -> r { +fn r(i: &Cell<isize>) -> r<'_> { r { i: i } diff --git a/tests/ui/resource-destruct.rs b/tests/ui/resource-destruct.rs index cbb17bb6ba6..480cbe091a7 100644 --- a/tests/ui/resource-destruct.rs +++ b/tests/ui/resource-destruct.rs @@ -17,7 +17,7 @@ impl<'a> shrinky_pointer<'a> { pub fn look_at(&self) -> isize { return self.i.get(); } } -fn shrinky_pointer(i: &Cell<isize>) -> shrinky_pointer { +fn shrinky_pointer(i: &Cell<isize>) -> shrinky_pointer<'_> { shrinky_pointer { i: i } diff --git a/tests/ui/rfcs/rfc-2091-track-caller/file-is-nul-terminated.rs b/tests/ui/rfcs/rfc-2091-track-caller/file-is-nul-terminated.rs new file mode 100644 index 00000000000..65e61a21f1a --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/file-is-nul-terminated.rs @@ -0,0 +1,25 @@ +//@ run-pass +#![feature(file_with_nul)] + +#[track_caller] +const fn assert_file_has_trailing_zero() { + let caller = core::panic::Location::caller(); + let file_str = caller.file(); + let file_with_nul = caller.file_with_nul(); + if file_str.len() != file_with_nul.count_bytes() { + panic!("mismatched lengths"); + } + let trailing_byte: core::ffi::c_char = unsafe { + *file_with_nul.as_ptr().offset(file_with_nul.count_bytes() as _) + }; + if trailing_byte != 0 { + panic!("trailing byte was nonzero") + } +} + +#[allow(dead_code)] +const _: () = assert_file_has_trailing_zero(); + +fn main() { + assert_file_has_trailing_zero(); +} diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/temporary-early-drop.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/temporary-early-drop.rs new file mode 100644 index 00000000000..9bf6cfcccba --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/temporary-early-drop.rs @@ -0,0 +1,29 @@ +// issue-103476 +//@ revisions: edition2021 edition2024 +//@ [edition2021] edition: 2021 +//@ [edition2024] edition: 2024 +//@ check-pass + +#![feature(if_let_guard)] +#![allow(irrefutable_let_patterns)] + +struct Pd; + +impl Pd { + fn it(&self) -> It<'_> { + todo!() + } +} + +pub struct It<'a>(Box<dyn Tr<'a>>); + +trait Tr<'a> {} + +fn f(m: Option<Pd>) { + match () { + () if let Some(n) = m && let it = n.it() => {} + _ => {} + } +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/edition-gate-macro.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/edition-gate-macro.rs index 5dd928dbce5..a61be38a23a 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/edition-gate-macro.rs +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/edition-gate-macro.rs @@ -33,7 +33,7 @@ impl DropOrderCollector { println!("{n}"); self.0.borrow_mut().push(n) } - fn some_loud(&self, n: u32) -> Option<LoudDrop> { + fn some_loud(&self, n: u32) -> Option<LoudDrop<'_>> { Some(LoudDrop(self, n)) } diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/temporary-early-drop.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/temporary-early-drop.rs index 7d8dfe37135..3e4fae2e84e 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/temporary-early-drop.rs +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/temporary-early-drop.rs @@ -8,7 +8,7 @@ struct Pd; impl Pd { - fn it(&self) -> It { + fn it(&self) -> It<'_> { todo!() } } diff --git a/tests/ui/deep.rs b/tests/ui/runtime/deep_recursion.rs index 5a631d068b1..bf220f174a1 100644 --- a/tests/ui/deep.rs +++ b/tests/ui/runtime/deep_recursion.rs @@ -1,3 +1,5 @@ +//! Checks deep recursion behavior. + //@ run-pass //@ ignore-emscripten apparently blows the stack diff --git a/tests/ui/rust-2018/extern-crate-idiomatic-in-2018.stderr b/tests/ui/rust-2018/extern-crate-idiomatic-in-2018.stderr index a68d99c14ce..248d42ba3f4 100644 --- a/tests/ui/rust-2018/extern-crate-idiomatic-in-2018.stderr +++ b/tests/ui/rust-2018/extern-crate-idiomatic-in-2018.stderr @@ -2,7 +2,7 @@ error: unused extern crate --> $DIR/extern-crate-idiomatic-in-2018.rs:12:1 | LL | extern crate edition_lint_paths; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused | note: the lint level is defined here --> $DIR/extern-crate-idiomatic-in-2018.rs:9:9 @@ -10,6 +10,10 @@ note: the lint level is defined here LL | #![deny(rust_2018_idioms)] | ^^^^^^^^^^^^^^^^ = note: `#[deny(unused_extern_crates)]` implied by `#[deny(rust_2018_idioms)]` +help: remove the unused `extern crate` + | +LL - extern crate edition_lint_paths; + | error: aborting due to 1 previous error diff --git a/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.rs b/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.rs index 573942bd095..467914d6a5e 100644 --- a/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.rs +++ b/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.rs @@ -8,7 +8,7 @@ // The suggestion span should include the attribute. -#[cfg(not(FALSE))] //~ HELP remove it +#[cfg(not(FALSE))] //~ HELP remove extern crate edition_lint_paths; //~^ ERROR unused extern crate diff --git a/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.stderr b/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.stderr index 038a9dd967b..9efc3493d34 100644 --- a/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.stderr +++ b/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.stderr @@ -1,11 +1,8 @@ error: unused extern crate --> $DIR/issue-54400-unused-extern-crate-attr-span.rs:12:1 | -LL | / #[cfg(not(FALSE))] -LL | | extern crate edition_lint_paths; - | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | |________________________________| - | help: remove it +LL | extern crate edition_lint_paths; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused | note: the lint level is defined here --> $DIR/issue-54400-unused-extern-crate-attr-span.rs:6:9 @@ -13,6 +10,11 @@ note: the lint level is defined here LL | #![deny(rust_2018_idioms)] | ^^^^^^^^^^^^^^^^ = note: `#[deny(unused_extern_crates)]` implied by `#[deny(rust_2018_idioms)]` +help: remove the unused `extern crate` + | +LL - #[cfg(not(FALSE))] +LL - extern crate edition_lint_paths; + | error: aborting due to 1 previous error diff --git a/tests/ui/rust-2018/remove-extern-crate.stderr b/tests/ui/rust-2018/remove-extern-crate.stderr index cb090c621e9..a530d40188b 100644 --- a/tests/ui/rust-2018/remove-extern-crate.stderr +++ b/tests/ui/rust-2018/remove-extern-crate.stderr @@ -2,7 +2,7 @@ warning: unused extern crate --> $DIR/remove-extern-crate.rs:11:1 | LL | extern crate core; - | ^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^ unused | note: the lint level is defined here --> $DIR/remove-extern-crate.rs:7:9 @@ -10,6 +10,11 @@ note: the lint level is defined here LL | #![warn(rust_2018_idioms)] | ^^^^^^^^^^^^^^^^ = note: `#[warn(unused_extern_crates)]` implied by `#[warn(rust_2018_idioms)]` +help: remove the unused `extern crate` + | +LL - extern crate core; +LL + + | warning: `extern crate` is not idiomatic in the new edition --> $DIR/remove-extern-crate.rs:35:5 diff --git a/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.fixed b/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.fixed new file mode 100644 index 00000000000..26c1c9015da --- /dev/null +++ b/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.fixed @@ -0,0 +1,15 @@ +//@ edition:2018 +//@ aux-build:../removing-extern-crate.rs +//@ run-rustfix + +#![warn(rust_2018_idioms)] + + //~ WARNING unused extern crate + //~ WARNING unused extern crate + +mod another { + //~ WARNING unused extern crate + //~ WARNING unused extern crate +} + +fn main() {} diff --git a/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.rs b/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.rs new file mode 100644 index 00000000000..c5b629fa90b --- /dev/null +++ b/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.rs @@ -0,0 +1,17 @@ +//@ edition:2018 +//@ aux-build:../removing-extern-crate.rs +//@ run-rustfix + +#![warn(rust_2018_idioms)] + +#[cfg_attr(test, "macro_use")] //~ ERROR expected +extern crate removing_extern_crate as foo; //~ WARNING unused extern crate +extern crate core; //~ WARNING unused extern crate + +mod another { + #[cfg_attr(test)] //~ ERROR expected + extern crate removing_extern_crate as foo; //~ WARNING unused extern crate + extern crate core; //~ WARNING unused extern crate +} + +fn main() {} diff --git a/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.stderr b/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.stderr new file mode 100644 index 00000000000..0e834707bf9 --- /dev/null +++ b/tests/ui/rust-2018/removing-extern-crate-malformed-cfg.stderr @@ -0,0 +1,76 @@ +error: expected identifier, found `"macro_use"` + --> $DIR/removing-extern-crate-malformed-cfg.rs:7:18 + | +LL | #[cfg_attr(test, "macro_use")] + | ^^^^^^^^^^^ expected identifier + | + = help: the valid syntax is `#[cfg_attr(condition, attribute, other_attribute, ...)]` + = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute> + +error: expected one of `(`, `,`, `::`, or `=`, found `<eof>` + --> $DIR/removing-extern-crate-malformed-cfg.rs:12:16 + | +LL | #[cfg_attr(test)] + | ^^^^ expected one of `(`, `,`, `::`, or `=` + | + = help: the valid syntax is `#[cfg_attr(condition, attribute, other_attribute, ...)]` + = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute> + +warning: unused extern crate + --> $DIR/removing-extern-crate-malformed-cfg.rs:8:1 + | +LL | extern crate removing_extern_crate as foo; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused + | +note: the lint level is defined here + --> $DIR/removing-extern-crate-malformed-cfg.rs:5:9 + | +LL | #![warn(rust_2018_idioms)] + | ^^^^^^^^^^^^^^^^ + = note: `#[warn(unused_extern_crates)]` implied by `#[warn(rust_2018_idioms)]` +help: remove the unused `extern crate` + | +LL - #[cfg_attr(test, "macro_use")] +LL - extern crate removing_extern_crate as foo; +LL + + | + +warning: unused extern crate + --> $DIR/removing-extern-crate-malformed-cfg.rs:9:1 + | +LL | extern crate core; + | ^^^^^^^^^^^^^^^^^^ unused + | +help: remove the unused `extern crate` + | +LL - extern crate core; +LL + + | + +warning: unused extern crate + --> $DIR/removing-extern-crate-malformed-cfg.rs:13:5 + | +LL | extern crate removing_extern_crate as foo; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused + | +help: remove the unused `extern crate` + | +LL - #[cfg_attr(test)] +LL - extern crate removing_extern_crate as foo; +LL + + | + +warning: unused extern crate + --> $DIR/removing-extern-crate-malformed-cfg.rs:14:5 + | +LL | extern crate core; + | ^^^^^^^^^^^^^^^^^^ unused + | +help: remove the unused `extern crate` + | +LL - extern crate core; +LL + + | + +error: aborting due to 2 previous errors; 4 warnings emitted + diff --git a/tests/ui/rust-2018/removing-extern-crate.stderr b/tests/ui/rust-2018/removing-extern-crate.stderr index 57312542640..b6f8314ce4b 100644 --- a/tests/ui/rust-2018/removing-extern-crate.stderr +++ b/tests/ui/rust-2018/removing-extern-crate.stderr @@ -2,7 +2,7 @@ warning: unused extern crate --> $DIR/removing-extern-crate.rs:8:1 | LL | extern crate dummy_crate as foo; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused | note: the lint level is defined here --> $DIR/removing-extern-crate.rs:6:9 @@ -10,24 +10,47 @@ note: the lint level is defined here LL | #![warn(rust_2018_idioms)] | ^^^^^^^^^^^^^^^^ = note: `#[warn(unused_extern_crates)]` implied by `#[warn(rust_2018_idioms)]` +help: remove the unused `extern crate` + | +LL - extern crate dummy_crate as foo; +LL + + | warning: unused extern crate --> $DIR/removing-extern-crate.rs:9:1 | LL | extern crate core; - | ^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^ unused + | +help: remove the unused `extern crate` + | +LL - extern crate core; +LL + + | warning: unused extern crate --> $DIR/removing-extern-crate.rs:12:5 | LL | extern crate dummy_crate as foo; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unused + | +help: remove the unused `extern crate` + | +LL - extern crate dummy_crate as foo; +LL + + | warning: unused extern crate --> $DIR/removing-extern-crate.rs:13:5 | LL | extern crate core; - | ^^^^^^^^^^^^^^^^^^ help: remove it + | ^^^^^^^^^^^^^^^^^^ unused + | +help: remove the unused `extern crate` + | +LL - extern crate core; +LL + + | warning: 4 warnings emitted diff --git a/tests/ui/rustdoc/doc-test-attr-pass.rs b/tests/ui/rustdoc/doc-test-attr-pass.rs index f0120b7c2d0..60d1e3722bd 100644 --- a/tests/ui/rustdoc/doc-test-attr-pass.rs +++ b/tests/ui/rustdoc/doc-test-attr-pass.rs @@ -6,4 +6,46 @@ #![doc(test(attr(deny(warnings))))] #![doc(test())] +mod test { + #![doc(test(attr(allow(warnings))))] +} + +#[doc(test(attr(allow(dead_code))))] +static S: u32 = 5; + +#[doc(test(attr(allow(dead_code))))] +const C: u32 = 5; + +#[doc(test(attr(deny(dead_code))))] +struct A { + #[doc(test(attr(allow(dead_code))))] + field: u32 +} + +#[doc(test(attr(deny(dead_code))))] +union U { + #[doc(test(attr(allow(dead_code))))] + field: u32, + field2: u64, +} + +#[doc(test(attr(deny(dead_code))))] +enum Enum { + #[doc(test(attr(allow(dead_code))))] + Variant1, +} + +#[doc(test(attr(deny(dead_code))))] +impl A { + #[doc(test(attr(deny(dead_code))))] + fn method() {} +} + +#[doc(test(attr(deny(dead_code))))] +trait MyTrait { + #[doc(test(attr(deny(dead_code))))] + fn my_trait_fn(); +} + +#[doc(test(attr(deny(dead_code))))] pub fn foo() {} diff --git a/tests/ui/self/arbitrary-self-types-dyn-incompatible.rs b/tests/ui/self/arbitrary-self-types-dyn-incompatible.rs index 0477d9d79c7..b223f18327b 100644 --- a/tests/ui/self/arbitrary-self-types-dyn-incompatible.rs +++ b/tests/ui/self/arbitrary-self-types-dyn-incompatible.rs @@ -28,7 +28,6 @@ impl Bar for usize { fn make_foo() { let x = Rc::new(5usize) as Rc<dyn Foo>; //~^ ERROR E0038 - //~| ERROR E0038 } fn make_bar() { diff --git a/tests/ui/self/arbitrary-self-types-dyn-incompatible.stderr b/tests/ui/self/arbitrary-self-types-dyn-incompatible.stderr index 9fb4c80329d..fe4802c9b3a 100644 --- a/tests/ui/self/arbitrary-self-types-dyn-incompatible.stderr +++ b/tests/ui/self/arbitrary-self-types-dyn-incompatible.stderr @@ -1,11 +1,11 @@ error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/arbitrary-self-types-dyn-incompatible.rs:29:32 + --> $DIR/arbitrary-self-types-dyn-incompatible.rs:29:39 | LL | fn foo(self: &Rc<Self>) -> usize; | --------- help: consider changing method `foo`'s `self` parameter to be `&self`: `&Self` ... LL | let x = Rc::new(5usize) as Rc<dyn Foo>; - | ^^^^^^^^^^^ `Foo` is not dyn compatible + | ^^^ `Foo` 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> @@ -17,26 +17,6 @@ LL | fn foo(self: &Rc<Self>) -> usize; | ^^^^^^^^^ ...because method `foo`'s `self` parameter cannot be dispatched on = help: only type `usize` implements `Foo`; consider using it directly instead. -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/arbitrary-self-types-dyn-incompatible.rs:29:13 - | -LL | fn foo(self: &Rc<Self>) -> usize; - | --------- help: consider changing method `foo`'s `self` parameter to be `&self`: `&Self` -... -LL | let x = Rc::new(5usize) as Rc<dyn Foo>; - | ^^^^^^^^^^^^^^^ `Foo` 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/arbitrary-self-types-dyn-incompatible.rs:4:18 - | -LL | trait Foo { - | --- this trait is not dyn compatible... -LL | fn foo(self: &Rc<Self>) -> usize; - | ^^^^^^^^^ ...because method `foo`'s `self` parameter cannot be dispatched on - = help: only type `usize` implements `Foo`; consider using it directly instead. - = note: required for the cast from `Rc<usize>` to `Rc<dyn Foo>` - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/self/dispatch-dyn-incompatible-that-does-not-deref.rs b/tests/ui/self/dispatch-dyn-incompatible-that-does-not-deref.rs new file mode 100644 index 00000000000..af35d1e0359 --- /dev/null +++ b/tests/ui/self/dispatch-dyn-incompatible-that-does-not-deref.rs @@ -0,0 +1,18 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/141419>. + +use std::ops::Deref; + +struct W; + +trait Foo: Deref<Target = W> { + fn method(self: &W) {} + //~^ ERROR invalid `self` parameter type: `&W` +} + +fn test(x: &dyn Foo) { + //~^ ERROR the trait `Foo` is not dyn compatible + x.method(); + //~^ ERROR the trait `Foo` is not dyn compatible +} + +fn main() {} diff --git a/tests/ui/self/dispatch-dyn-incompatible-that-does-not-deref.stderr b/tests/ui/self/dispatch-dyn-incompatible-that-does-not-deref.stderr new file mode 100644 index 00000000000..237bbc56715 --- /dev/null +++ b/tests/ui/self/dispatch-dyn-incompatible-that-does-not-deref.stderr @@ -0,0 +1,49 @@ +error[E0038]: the trait `Foo` is not dyn compatible + --> $DIR/dispatch-dyn-incompatible-that-does-not-deref.rs:12:13 + | +LL | fn method(self: &W) {} + | -- help: consider changing method `method`'s `self` parameter to be `&self`: `&Self` +... +LL | fn test(x: &dyn Foo) { + | ^^^^^^^ `Foo` 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/dispatch-dyn-incompatible-that-does-not-deref.rs:8:21 + | +LL | trait Foo: Deref<Target = W> { + | --- this trait is not dyn compatible... +LL | fn method(self: &W) {} + | ^^ ...because method `method`'s `self` parameter cannot be dispatched on + +error[E0307]: invalid `self` parameter type: `&W` + --> $DIR/dispatch-dyn-incompatible-that-does-not-deref.rs:8:21 + | +LL | fn method(self: &W) {} + | ^^ + | + = note: type of `self` must be `Self` or a type that dereferences to it + = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`) + +error[E0038]: the trait `Foo` is not dyn compatible + --> $DIR/dispatch-dyn-incompatible-that-does-not-deref.rs:14:5 + | +LL | fn method(self: &W) {} + | -- help: consider changing method `method`'s `self` parameter to be `&self`: `&Self` +... +LL | x.method(); + | ^^^^^^^^^^ `Foo` 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/dispatch-dyn-incompatible-that-does-not-deref.rs:8:21 + | +LL | trait Foo: Deref<Target = W> { + | --- this trait is not dyn compatible... +LL | fn method(self: &W) {} + | ^^ ...because method `method`'s `self` parameter cannot be dispatched on + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0038, E0307. +For more information about an error, try `rustc --explain E0038`. diff --git a/tests/ui/self/elision/ignore-non-reference-lifetimes.rs b/tests/ui/self/elision/ignore-non-reference-lifetimes.rs index cedc6f0f9bc..ecd669059ed 100644 --- a/tests/ui/self/elision/ignore-non-reference-lifetimes.rs +++ b/tests/ui/self/elision/ignore-non-reference-lifetimes.rs @@ -4,11 +4,11 @@ struct Foo<'a>(&'a str); impl<'b> Foo<'b> { fn a<'a>(self: Self, a: &'a str) -> &str { - //~^ WARNING elided lifetime has a name + //~^ WARNING lifetime flowing from input to output with different syntax a } fn b<'a>(self: Foo<'b>, a: &'a str) -> &str { - //~^ WARNING elided lifetime has a name + //~^ WARNING lifetime flowing from input to output with different syntax a } } diff --git a/tests/ui/self/elision/ignore-non-reference-lifetimes.stderr b/tests/ui/self/elision/ignore-non-reference-lifetimes.stderr index 4465dbae529..5351bf3c94c 100644 --- a/tests/ui/self/elision/ignore-non-reference-lifetimes.stderr +++ b/tests/ui/self/elision/ignore-non-reference-lifetimes.stderr @@ -1,16 +1,29 @@ -warning: elided lifetime has a name - --> $DIR/ignore-non-reference-lifetimes.rs:6:41 +warning: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/ignore-non-reference-lifetimes.rs:6:30 | LL | fn a<'a>(self: Self, a: &'a str) -> &str { - | -- lifetime `'a` declared here ^ this elided lifetime gets resolved as `'a` + | ^^ ---- the lifetime gets resolved as `'a` + | | + | this lifetime flows to the output | - = note: `#[warn(elided_named_lifetimes)]` on by default + = note: `#[warn(mismatched_lifetime_syntaxes)]` on by default +help: one option is to consistently use `'a` + | +LL | fn a<'a>(self: Self, a: &'a str) -> &'a str { + | ++ -warning: elided lifetime has a name - --> $DIR/ignore-non-reference-lifetimes.rs:10:44 +warning: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/ignore-non-reference-lifetimes.rs:10:33 | LL | fn b<'a>(self: Foo<'b>, a: &'a str) -> &str { - | -- lifetime `'a` declared here ^ this elided lifetime gets resolved as `'a` + | ^^ ---- the lifetime gets resolved as `'a` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'a` + | +LL | fn b<'a>(self: Foo<'b>, a: &'a str) -> &'a str { + | ++ warning: 2 warnings emitted diff --git a/tests/ui/self/elision/lt-ref-self-async.fixed b/tests/ui/self/elision/lt-ref-self-async.fixed index aae94f7a6cc..191610336de 100644 --- a/tests/ui/self/elision/lt-ref-self-async.fixed +++ b/tests/ui/self/elision/lt-ref-self-async.fixed @@ -1,6 +1,6 @@ //@ edition:2018 //@ run-rustfix -#![allow(non_snake_case, dead_code, elided_named_lifetimes)] +#![allow(non_snake_case, dead_code, mismatched_lifetime_syntaxes)] use std::pin::Pin; diff --git a/tests/ui/self/elision/lt-ref-self-async.rs b/tests/ui/self/elision/lt-ref-self-async.rs index 0c11b271c35..c910a5d6d7e 100644 --- a/tests/ui/self/elision/lt-ref-self-async.rs +++ b/tests/ui/self/elision/lt-ref-self-async.rs @@ -1,6 +1,6 @@ //@ edition:2018 //@ run-rustfix -#![allow(non_snake_case, dead_code, elided_named_lifetimes)] +#![allow(non_snake_case, dead_code, mismatched_lifetime_syntaxes)] use std::pin::Pin; diff --git a/tests/ui/self/self-impl.stderr b/tests/ui/self/self-impl.stderr index 18ffd15427f..1bda307d0eb 100644 --- a/tests/ui/self/self-impl.stderr +++ b/tests/ui/self/self-impl.stderr @@ -2,13 +2,25 @@ error[E0223]: ambiguous associated type --> $DIR/self-impl.rs:23:16 | LL | let _: <Self>::Baz = true; - | ^^^^^^^^^^^ help: use fully-qualified syntax: `<Bar as Foo>::Baz` + | ^^^^^^^^^^^ + | +help: use fully-qualified syntax + | +LL - let _: <Self>::Baz = true; +LL + let _: <Bar as Foo>::Baz = true; + | error[E0223]: ambiguous associated type --> $DIR/self-impl.rs:25:16 | LL | let _: Self::Baz = true; - | ^^^^^^^^^ help: use fully-qualified syntax: `<Bar as Foo>::Baz` + | ^^^^^^^^^ + | +help: use fully-qualified syntax + | +LL - let _: Self::Baz = true; +LL + let _: <Bar as Foo>::Baz = true; + | error: aborting due to 2 previous errors diff --git a/tests/ui/self/self_lifetime-async.rs b/tests/ui/self/self_lifetime-async.rs index fd690207118..f839ab03a60 100644 --- a/tests/ui/self/self_lifetime-async.rs +++ b/tests/ui/self/self_lifetime-async.rs @@ -4,13 +4,13 @@ struct Foo<'a>(&'a ()); impl<'a> Foo<'a> { async fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 } - //~^ WARNING elided lifetime has a name + //~^ WARNING lifetime flowing from input to output with different syntax } type Alias = Foo<'static>; impl Alias { async fn bar<'a>(self: &Alias, arg: &'a ()) -> &() { arg } - //~^ WARNING elided lifetime has a name + //~^ WARNING lifetime flowing from input to output with different syntax } fn main() {} diff --git a/tests/ui/self/self_lifetime-async.stderr b/tests/ui/self/self_lifetime-async.stderr index 32de3fd18c9..a9c1be2e808 100644 --- a/tests/ui/self/self_lifetime-async.stderr +++ b/tests/ui/self/self_lifetime-async.stderr @@ -1,18 +1,29 @@ -warning: elided lifetime has a name - --> $DIR/self_lifetime-async.rs:6:44 +warning: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/self_lifetime-async.rs:6:29 | LL | async fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 } - | -- ^ this elided lifetime gets resolved as `'b` - | | - | lifetime `'b` declared here + | ^^ --- the lifetime gets resolved as `'b` + | | + | this lifetime flows to the output | - = note: `#[warn(elided_named_lifetimes)]` on by default + = note: `#[warn(mismatched_lifetime_syntaxes)]` on by default +help: one option is to consistently use `'b` + | +LL | async fn foo<'b>(self: &'b Foo<'a>) -> &'b () { self.0 } + | ++ -warning: elided lifetime has a name - --> $DIR/self_lifetime-async.rs:12:52 +warning: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/self_lifetime-async.rs:12:42 | LL | async fn bar<'a>(self: &Alias, arg: &'a ()) -> &() { arg } - | -- lifetime `'a` declared here ^ this elided lifetime gets resolved as `'a` + | ^^ --- the lifetime gets resolved as `'a` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'a` + | +LL | async fn bar<'a>(self: &Alias, arg: &'a ()) -> &'a () { arg } + | ++ warning: 2 warnings emitted diff --git a/tests/ui/self/self_lifetime.rs b/tests/ui/self/self_lifetime.rs index 0607c3b9317..aaa31f85ad5 100644 --- a/tests/ui/self/self_lifetime.rs +++ b/tests/ui/self/self_lifetime.rs @@ -5,13 +5,13 @@ struct Foo<'a>(&'a ()); impl<'a> Foo<'a> { fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 } - //~^ WARNING elided lifetime has a name + //~^ WARNING lifetime flowing from input to output with different syntax } type Alias = Foo<'static>; impl Alias { fn bar<'a>(self: &Alias, arg: &'a ()) -> &() { arg } - //~^ WARNING elided lifetime has a name + //~^ WARNING lifetime flowing from input to output with different syntax } fn main() {} diff --git a/tests/ui/self/self_lifetime.stderr b/tests/ui/self/self_lifetime.stderr index cd8f4d8adf8..ec676e69cf6 100644 --- a/tests/ui/self/self_lifetime.stderr +++ b/tests/ui/self/self_lifetime.stderr @@ -1,18 +1,29 @@ -warning: elided lifetime has a name - --> $DIR/self_lifetime.rs:7:38 +warning: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/self_lifetime.rs:7:23 | LL | fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 } - | -- ^ this elided lifetime gets resolved as `'b` - | | - | lifetime `'b` declared here + | ^^ --- the lifetime gets resolved as `'b` + | | + | this lifetime flows to the output | - = note: `#[warn(elided_named_lifetimes)]` on by default + = note: `#[warn(mismatched_lifetime_syntaxes)]` on by default +help: one option is to consistently use `'b` + | +LL | fn foo<'b>(self: &'b Foo<'a>) -> &'b () { self.0 } + | ++ -warning: elided lifetime has a name - --> $DIR/self_lifetime.rs:13:46 +warning: lifetime flowing from input to output with different syntax can be confusing + --> $DIR/self_lifetime.rs:13:36 | LL | fn bar<'a>(self: &Alias, arg: &'a ()) -> &() { arg } - | -- lifetime `'a` declared here ^ this elided lifetime gets resolved as `'a` + | ^^ --- the lifetime gets resolved as `'a` + | | + | this lifetime flows to the output + | +help: one option is to consistently use `'a` + | +LL | fn bar<'a>(self: &Alias, arg: &'a ()) -> &'a () { arg } + | ++ warning: 2 warnings emitted diff --git a/tests/ui/simd/const-err-trumps-simd-err.rs b/tests/ui/simd/const-err-trumps-simd-err.rs index 05a224d037a..8d9870855f8 100644 --- a/tests/ui/simd/const-err-trumps-simd-err.rs +++ b/tests/ui/simd/const-err-trumps-simd-err.rs @@ -16,8 +16,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 - //~| NOTE assertion failed + //~^ ERROR 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 389f75492c6..d4ba54a28da 100644 --- a/tests/ui/simd/const-err-trumps-simd-err.stderr +++ b/tests/ui/simd/const-err-trumps-simd-err.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `get_elem::<4>::{constant#0}` failed +error[E0080]: evaluation panicked: assertion failed: LANE < 4 --> $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 + | ^^^^^^^^^^^^^^^^^ evaluation of `get_elem::<4>::{constant#0}` failed here note: erroneous constant encountered --> $DIR/const-err-trumps-simd-err.rs:18:5 @@ -11,7 +11,7 @@ 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:25:5 + --> $DIR/const-err-trumps-simd-err.rs:24:5 | LL | get_elem::<4>(int8x4_t([0, 0, 0, 0])); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/sized/stack-overflow-trait-infer-98842.32bit.stderr b/tests/ui/sized/stack-overflow-trait-infer-98842.32bit.stderr index c01b2ccd163..d097b809b56 100644 --- a/tests/ui/sized/stack-overflow-trait-infer-98842.32bit.stderr +++ b/tests/ui/sized/stack-overflow-trait-infer-98842.32bit.stderr @@ -9,11 +9,11 @@ LL | const _: *const Foo = 0 as _; | ^^^^^^^^^^^^^^^^^^^ = 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[E0080]: evaluation of constant value failed +error[E0080]: a cycle occurred during layout computation --> $DIR/stack-overflow-trait-infer-98842.rs:14:1 | LL | const _: *const Foo = 0 as _; - | ^^^^^^^^^^^^^^^^^^^ a cycle occurred during layout computation + | ^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/sized/stack-overflow-trait-infer-98842.64bit.stderr b/tests/ui/sized/stack-overflow-trait-infer-98842.64bit.stderr index c01b2ccd163..d097b809b56 100644 --- a/tests/ui/sized/stack-overflow-trait-infer-98842.64bit.stderr +++ b/tests/ui/sized/stack-overflow-trait-infer-98842.64bit.stderr @@ -9,11 +9,11 @@ LL | const _: *const Foo = 0 as _; | ^^^^^^^^^^^^^^^^^^^ = 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[E0080]: evaluation of constant value failed +error[E0080]: a cycle occurred during layout computation --> $DIR/stack-overflow-trait-infer-98842.rs:14:1 | LL | const _: *const Foo = 0 as _; - | ^^^^^^^^^^^^^^^^^^^ a cycle occurred during layout computation + | ^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/sized/stack-overflow-trait-infer-98842.rs b/tests/ui/sized/stack-overflow-trait-infer-98842.rs index 8a958870b0e..1c9f6c593f4 100644 --- a/tests/ui/sized/stack-overflow-trait-infer-98842.rs +++ b/tests/ui/sized/stack-overflow-trait-infer-98842.rs @@ -12,6 +12,6 @@ struct Foo(<&'static Foo as ::core::ops::Deref>::Target); // and it will infinitely recurse somewhere trying to figure out the // size of this pointer (is my guess): const _: *const Foo = 0 as _; -//~^ ERROR evaluation of constant value failed +//~^ ERROR a cycle occurred during layout computation pub fn main() {} diff --git a/tests/crashes/140571.rs b/tests/ui/specialization/overlap-due-to-unsatisfied-const-bound.rs index 97fa1d8432d..f4cde1d62b2 100644 --- a/tests/crashes/140571.rs +++ b/tests/ui/specialization/overlap-due-to-unsatisfied-const-bound.rs @@ -1,14 +1,21 @@ -//@ known-bug: #140571 +// Regression test for #140571. The compiler used to ICE + +#![feature(associated_const_equality, specialization)] +//~^ WARN the feature `specialization` is incomplete + pub trait IsVoid { const IS_VOID: bool; } impl<T> IsVoid for T { default const IS_VOID: bool = false; } -impl<T> Maybe<T> for () where T: NotVoid + ?Sized {} pub trait NotVoid {} impl<T> NotVoid for T where T: IsVoid<IS_VOID = false> + ?Sized {} pub trait Maybe<T> {} impl<T> Maybe<T> for T {} +impl<T> Maybe<T> for () where T: NotVoid + ?Sized {} +//~^ ERROR conflicting implementations of trait `Maybe<()>` for type `()` + +fn main() {} diff --git a/tests/ui/specialization/overlap-due-to-unsatisfied-const-bound.stderr b/tests/ui/specialization/overlap-due-to-unsatisfied-const-bound.stderr new file mode 100644 index 00000000000..a26b30fbb63 --- /dev/null +++ b/tests/ui/specialization/overlap-due-to-unsatisfied-const-bound.stderr @@ -0,0 +1,21 @@ +warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/overlap-due-to-unsatisfied-const-bound.rs:3:39 + | +LL | #![feature(associated_const_equality, 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[E0119]: conflicting implementations of trait `Maybe<()>` for type `()` + --> $DIR/overlap-due-to-unsatisfied-const-bound.rs:18:1 + | +LL | impl<T> Maybe<T> for T {} + | ---------------------- first implementation here +LL | impl<T> Maybe<T> for () where T: NotVoid + ?Sized {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `()` + +error: aborting due to 1 previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/statics/issue-14227.rs b/tests/ui/statics/issue-14227.rs index 8a70f51d3b4..84994f033d1 100644 --- a/tests/ui/statics/issue-14227.rs +++ b/tests/ui/statics/issue-14227.rs @@ -3,6 +3,6 @@ extern "C" { } static CRASH: u32 = symbol; //~^ ERROR use of extern static is unsafe and requires -//~| ERROR could not evaluate static initializer +//~| ERROR cannot access extern static `symbol` fn main() {} diff --git a/tests/ui/statics/issue-14227.stderr b/tests/ui/statics/issue-14227.stderr index 3551821a3da..f5ab2314494 100644 --- a/tests/ui/statics/issue-14227.stderr +++ b/tests/ui/statics/issue-14227.stderr @@ -1,8 +1,8 @@ -error[E0080]: could not evaluate static initializer +error[E0080]: cannot access extern static `symbol` --> $DIR/issue-14227.rs:4:21 | LL | static CRASH: u32 = symbol; - | ^^^^^^ cannot access extern static `symbol` + | ^^^^^^ evaluation of `CRASH` failed here error[E0133]: use of extern static is unsafe and requires unsafe function or block --> $DIR/issue-14227.rs:4:21 diff --git a/tests/ui/statics/mutable_memory_validation.rs b/tests/ui/statics/mutable_memory_validation.rs index 3bb572d38bc..033c2bc2839 100644 --- a/tests/ui/statics/mutable_memory_validation.rs +++ b/tests/ui/statics/mutable_memory_validation.rs @@ -11,7 +11,7 @@ struct Meh { } const MUH: Meh = Meh { x: unsafe { &mut *(&READONLY as *const _ as *mut _) } }; -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: invalid value at .x.<deref>: encountered `UnsafeCell` in read-only memory static READONLY: i32 = 0; diff --git a/tests/ui/statics/mutable_memory_validation.stderr b/tests/ui/statics/mutable_memory_validation.stderr index 76e1827ea12..df36287cc69 100644 --- a/tests/ui/statics/mutable_memory_validation.stderr +++ b/tests/ui/statics/mutable_memory_validation.stderr @@ -1,8 +1,8 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .x.<deref>: encountered `UnsafeCell` in read-only memory --> $DIR/mutable_memory_validation.rs:13:1 | LL | const MUH: Meh = Meh { x: unsafe { &mut *(&READONLY as *const _ as *mut _) } }; - | ^^^^^^^^^^^^^^ constructing invalid value at .x.<deref>: encountered `UnsafeCell` in read-only memory + | ^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { diff --git a/tests/ui/statics/uninhabited-static.rs b/tests/ui/statics/uninhabited-static.rs index 0f7c5ae6ef4..955d489d313 100644 --- a/tests/ui/statics/uninhabited-static.rs +++ b/tests/ui/statics/uninhabited-static.rs @@ -11,9 +11,9 @@ extern "C" { static VOID2: Void = unsafe { std::mem::transmute(()) }; //~ ERROR static of uninhabited type //~| WARN: previously accepted -//~| ERROR could not evaluate static initializer +//~| ERROR value of uninhabited type `Void` static NEVER2: Void = unsafe { std::mem::transmute(()) }; //~ ERROR static of uninhabited type //~| WARN: previously accepted -//~| ERROR could not evaluate static initializer +//~| ERROR value of uninhabited type `Void` fn main() {} diff --git a/tests/ui/statics/uninhabited-static.stderr b/tests/ui/statics/uninhabited-static.stderr index f891c0ce25b..f799a82f139 100644 --- a/tests/ui/statics/uninhabited-static.stderr +++ b/tests/ui/statics/uninhabited-static.stderr @@ -43,17 +43,17 @@ LL | static NEVER2: Void = unsafe { std::mem::transmute(()) }; = note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840> = note: uninhabited statics cannot be initialized, and any access would be an immediate error -error[E0080]: could not evaluate static initializer +error[E0080]: constructing invalid value: encountered a value of uninhabited type `Void` --> $DIR/uninhabited-static.rs:12:31 | LL | static VOID2: Void = unsafe { std::mem::transmute(()) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type `Void` + | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `VOID2` failed here -error[E0080]: could not evaluate static initializer +error[E0080]: constructing invalid value: encountered a value of uninhabited type `Void` --> $DIR/uninhabited-static.rs:15:32 | LL | static NEVER2: Void = unsafe { std::mem::transmute(()) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type `Void` + | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `NEVER2` failed here error: aborting due to 6 previous errors diff --git a/tests/ui/statics/unsizing-wfcheck-issue-127299.rs b/tests/ui/statics/unsizing-wfcheck-issue-127299.rs index fd07937d90f..14ba38d7535 100644 --- a/tests/ui/statics/unsizing-wfcheck-issue-127299.rs +++ b/tests/ui/statics/unsizing-wfcheck-issue-127299.rs @@ -12,6 +12,5 @@ pub struct Lint { static FOO: &Lint = &Lint { desc: "desc" }; //~^ ERROR cannot be shared between threads safely //~| ERROR is not dyn compatible -//~| ERROR is not dyn compatible fn main() {} diff --git a/tests/ui/statics/unsizing-wfcheck-issue-127299.stderr b/tests/ui/statics/unsizing-wfcheck-issue-127299.stderr index 28427161e87..e401277a020 100644 --- a/tests/ui/statics/unsizing-wfcheck-issue-127299.stderr +++ b/tests/ui/statics/unsizing-wfcheck-issue-127299.stderr @@ -51,7 +51,6 @@ LL | trait Qux { | --- this trait is not dyn compatible... LL | fn bar() -> i32; | ^^^ ...because associated function `bar` has no `self` parameter - = note: required for the cast from `&'static str` to `&'static (dyn Qux + 'static)` help: consider turning `bar` into a method by giving it a `&self` argument | LL | fn bar(&self) -> i32; @@ -61,30 +60,7 @@ help: alternatively, consider constraining `bar` so it does not apply to trait o LL | fn bar() -> i32 where Self: Sized; | +++++++++++++++++ -error[E0038]: the trait `Qux` is not dyn compatible - --> $DIR/unsizing-wfcheck-issue-127299.rs:12:35 - | -LL | static FOO: &Lint = &Lint { desc: "desc" }; - | ^^^^^^ `Qux` 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/unsizing-wfcheck-issue-127299.rs:4:8 - | -LL | trait Qux { - | --- this trait is not dyn compatible... -LL | fn bar() -> i32; - | ^^^ ...because associated function `bar` has no `self` parameter -help: consider turning `bar` into a method by giving it a `&self` argument - | -LL | fn bar(&self) -> i32; - | +++++ -help: alternatively, consider constraining `bar` so it does not apply to trait objects - | -LL | fn bar() -> i32 where Self: Sized; - | +++++++++++++++++ - -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors Some errors have detailed explanations: E0038, E0277. For more information about an error, try `rustc --explain E0038`. diff --git a/tests/ui/stats/input-stats.rs b/tests/ui/stats/input-stats.rs index f19a53cc610..e760e2894e3 100644 --- a/tests/ui/stats/input-stats.rs +++ b/tests/ui/stats/input-stats.rs @@ -3,6 +3,10 @@ //@ only-64bit // layout randomization affects the hir stat output //@ needs-deterministic-layouts +// +// Filter out the percentages because a change to a single count can affect +// many or all percentages, which makes the diffs hard to read. +//@ normalize-stderr: "\([0-9 ][0-9]\.[0-9]%\)" -> "(NN.N%)" // Type layouts sometimes change. When that happens, until the next bootstrap // bump occurs, stage1 and stage2 will give different outputs for this test. diff --git a/tests/ui/stats/input-stats.stderr b/tests/ui/stats/input-stats.stderr index b369af62f87..f2598bd7eaf 100644 --- a/tests/ui/stats/input-stats.stderr +++ b/tests/ui/stats/input-stats.stderr @@ -1,178 +1,121 @@ -ast-stats-1 PRE EXPANSION AST STATS -ast-stats-1 Name Accumulated Size Count Item Size -ast-stats-1 ---------------------------------------------------------------- -ast-stats-1 Crate 40 ( 0.6%) 1 40 -ast-stats-1 GenericArgs 40 ( 0.6%) 1 40 -ast-stats-1 - AngleBracketed 40 ( 0.6%) 1 -ast-stats-1 ExprField 48 ( 0.7%) 1 48 -ast-stats-1 Attribute 64 ( 0.9%) 2 32 -ast-stats-1 - DocComment 32 ( 0.5%) 1 -ast-stats-1 - Normal 32 ( 0.5%) 1 -ast-stats-1 WherePredicate 72 ( 1.1%) 1 72 -ast-stats-1 - BoundPredicate 72 ( 1.1%) 1 -ast-stats-1 ForeignItem 80 ( 1.2%) 1 80 -ast-stats-1 - Fn 80 ( 1.2%) 1 -ast-stats-1 Arm 96 ( 1.4%) 2 48 -ast-stats-1 Local 96 ( 1.4%) 1 96 -ast-stats-1 FnDecl 120 ( 1.8%) 5 24 -ast-stats-1 Param 160 ( 2.4%) 4 40 -ast-stats-1 Stmt 160 ( 2.4%) 5 32 -ast-stats-1 - Let 32 ( 0.5%) 1 -ast-stats-1 - MacCall 32 ( 0.5%) 1 -ast-stats-1 - Expr 96 ( 1.4%) 3 -ast-stats-1 Block 192 ( 2.8%) 6 32 -ast-stats-1 FieldDef 208 ( 3.1%) 2 104 -ast-stats-1 Variant 208 ( 3.1%) 2 104 -ast-stats-1 AssocItem 320 ( 4.7%) 4 80 -ast-stats-1 - Fn 160 ( 2.4%) 2 -ast-stats-1 - Type 160 ( 2.4%) 2 -ast-stats-1 GenericBound 352 ( 5.2%) 4 88 -ast-stats-1 - Trait 352 ( 5.2%) 4 -ast-stats-1 GenericParam 480 ( 7.1%) 5 96 -ast-stats-1 Pat 504 ( 7.5%) 7 72 -ast-stats-1 - Struct 72 ( 1.1%) 1 -ast-stats-1 - Wild 72 ( 1.1%) 1 -ast-stats-1 - Ident 360 ( 5.3%) 5 -ast-stats-1 Expr 576 ( 8.5%) 8 72 -ast-stats-1 - Match 72 ( 1.1%) 1 -ast-stats-1 - Path 72 ( 1.1%) 1 -ast-stats-1 - Struct 72 ( 1.1%) 1 -ast-stats-1 - Lit 144 ( 2.1%) 2 -ast-stats-1 - Block 216 ( 3.2%) 3 -ast-stats-1 PathSegment 744 (11.0%) 31 24 -ast-stats-1 Ty 896 (13.3%) 14 64 -ast-stats-1 - Ptr 64 ( 0.9%) 1 -ast-stats-1 - Ref 64 ( 0.9%) 1 -ast-stats-1 - ImplicitSelf 128 ( 1.9%) 2 -ast-stats-1 - Path 640 ( 9.5%) 10 -ast-stats-1 Item 1_296 (19.2%) 9 144 -ast-stats-1 - Enum 144 ( 2.1%) 1 -ast-stats-1 - ForeignMod 144 ( 2.1%) 1 -ast-stats-1 - Impl 144 ( 2.1%) 1 -ast-stats-1 - Trait 144 ( 2.1%) 1 -ast-stats-1 - Fn 288 ( 4.3%) 2 -ast-stats-1 - Use 432 ( 6.4%) 3 -ast-stats-1 ---------------------------------------------------------------- -ast-stats-1 Total 6_752 116 -ast-stats-1 -ast-stats-2 POST EXPANSION AST STATS -ast-stats-2 Name Accumulated Size Count Item Size -ast-stats-2 ---------------------------------------------------------------- -ast-stats-2 Crate 40 ( 0.5%) 1 40 -ast-stats-2 GenericArgs 40 ( 0.5%) 1 40 -ast-stats-2 - AngleBracketed 40 ( 0.5%) 1 -ast-stats-2 ExprField 48 ( 0.6%) 1 48 -ast-stats-2 WherePredicate 72 ( 1.0%) 1 72 -ast-stats-2 - BoundPredicate 72 ( 1.0%) 1 -ast-stats-2 ForeignItem 80 ( 1.1%) 1 80 -ast-stats-2 - Fn 80 ( 1.1%) 1 -ast-stats-2 Arm 96 ( 1.3%) 2 48 -ast-stats-2 Local 96 ( 1.3%) 1 96 -ast-stats-2 FnDecl 120 ( 1.6%) 5 24 -ast-stats-2 InlineAsm 120 ( 1.6%) 1 120 -ast-stats-2 Attribute 128 ( 1.7%) 4 32 -ast-stats-2 - DocComment 32 ( 0.4%) 1 -ast-stats-2 - Normal 96 ( 1.3%) 3 -ast-stats-2 Param 160 ( 2.2%) 4 40 -ast-stats-2 Stmt 160 ( 2.2%) 5 32 -ast-stats-2 - Let 32 ( 0.4%) 1 -ast-stats-2 - Semi 32 ( 0.4%) 1 -ast-stats-2 - Expr 96 ( 1.3%) 3 -ast-stats-2 Block 192 ( 2.6%) 6 32 -ast-stats-2 FieldDef 208 ( 2.8%) 2 104 -ast-stats-2 Variant 208 ( 2.8%) 2 104 -ast-stats-2 AssocItem 320 ( 4.3%) 4 80 -ast-stats-2 - Fn 160 ( 2.2%) 2 -ast-stats-2 - Type 160 ( 2.2%) 2 -ast-stats-2 GenericBound 352 ( 4.7%) 4 88 -ast-stats-2 - Trait 352 ( 4.7%) 4 -ast-stats-2 GenericParam 480 ( 6.5%) 5 96 -ast-stats-2 Pat 504 ( 6.8%) 7 72 -ast-stats-2 - Struct 72 ( 1.0%) 1 -ast-stats-2 - Wild 72 ( 1.0%) 1 -ast-stats-2 - Ident 360 ( 4.9%) 5 -ast-stats-2 Expr 648 ( 8.7%) 9 72 -ast-stats-2 - InlineAsm 72 ( 1.0%) 1 -ast-stats-2 - Match 72 ( 1.0%) 1 -ast-stats-2 - Path 72 ( 1.0%) 1 -ast-stats-2 - Struct 72 ( 1.0%) 1 -ast-stats-2 - Lit 144 ( 1.9%) 2 -ast-stats-2 - Block 216 ( 2.9%) 3 -ast-stats-2 PathSegment 864 (11.7%) 36 24 -ast-stats-2 Ty 896 (12.1%) 14 64 -ast-stats-2 - Ptr 64 ( 0.9%) 1 -ast-stats-2 - Ref 64 ( 0.9%) 1 -ast-stats-2 - ImplicitSelf 128 ( 1.7%) 2 -ast-stats-2 - Path 640 ( 8.6%) 10 -ast-stats-2 Item 1_584 (21.4%) 11 144 -ast-stats-2 - Enum 144 ( 1.9%) 1 -ast-stats-2 - ExternCrate 144 ( 1.9%) 1 -ast-stats-2 - ForeignMod 144 ( 1.9%) 1 -ast-stats-2 - Impl 144 ( 1.9%) 1 -ast-stats-2 - Trait 144 ( 1.9%) 1 -ast-stats-2 - Fn 288 ( 3.9%) 2 -ast-stats-2 - Use 576 ( 7.8%) 4 -ast-stats-2 ---------------------------------------------------------------- -ast-stats-2 Total 7_416 127 -ast-stats-2 +ast-stats POST EXPANSION AST STATS +ast-stats Name Accumulated Size Count Item Size +ast-stats ---------------------------------------------------------------- +ast-stats Crate 40 (NN.N%) 1 40 +ast-stats GenericArgs 40 (NN.N%) 1 40 +ast-stats - AngleBracketed 40 (NN.N%) 1 +ast-stats ExprField 48 (NN.N%) 1 48 +ast-stats WherePredicate 72 (NN.N%) 1 72 +ast-stats - BoundPredicate 72 (NN.N%) 1 +ast-stats ForeignItem 80 (NN.N%) 1 80 +ast-stats - Fn 80 (NN.N%) 1 +ast-stats Arm 96 (NN.N%) 2 48 +ast-stats Local 96 (NN.N%) 1 96 +ast-stats FnDecl 120 (NN.N%) 5 24 +ast-stats InlineAsm 120 (NN.N%) 1 120 +ast-stats Attribute 128 (NN.N%) 4 32 +ast-stats - DocComment 32 (NN.N%) 1 +ast-stats - Normal 96 (NN.N%) 3 +ast-stats Param 160 (NN.N%) 4 40 +ast-stats Stmt 160 (NN.N%) 5 32 +ast-stats - Let 32 (NN.N%) 1 +ast-stats - Semi 32 (NN.N%) 1 +ast-stats - Expr 96 (NN.N%) 3 +ast-stats Block 192 (NN.N%) 6 32 +ast-stats FieldDef 208 (NN.N%) 2 104 +ast-stats Variant 208 (NN.N%) 2 104 +ast-stats AssocItem 320 (NN.N%) 4 80 +ast-stats - Fn 160 (NN.N%) 2 +ast-stats - Type 160 (NN.N%) 2 +ast-stats GenericBound 352 (NN.N%) 4 88 +ast-stats - Trait 352 (NN.N%) 4 +ast-stats GenericParam 480 (NN.N%) 5 96 +ast-stats Pat 504 (NN.N%) 7 72 +ast-stats - Struct 72 (NN.N%) 1 +ast-stats - Wild 72 (NN.N%) 1 +ast-stats - Ident 360 (NN.N%) 5 +ast-stats Expr 648 (NN.N%) 9 72 +ast-stats - InlineAsm 72 (NN.N%) 1 +ast-stats - Match 72 (NN.N%) 1 +ast-stats - Path 72 (NN.N%) 1 +ast-stats - Struct 72 (NN.N%) 1 +ast-stats - Lit 144 (NN.N%) 2 +ast-stats - Block 216 (NN.N%) 3 +ast-stats PathSegment 864 (NN.N%) 36 24 +ast-stats Ty 896 (NN.N%) 14 64 +ast-stats - Ptr 64 (NN.N%) 1 +ast-stats - Ref 64 (NN.N%) 1 +ast-stats - ImplicitSelf 128 (NN.N%) 2 +ast-stats - Path 640 (NN.N%) 10 +ast-stats Item 1_584 (NN.N%) 11 144 +ast-stats - Enum 144 (NN.N%) 1 +ast-stats - ExternCrate 144 (NN.N%) 1 +ast-stats - ForeignMod 144 (NN.N%) 1 +ast-stats - Impl 144 (NN.N%) 1 +ast-stats - Trait 144 (NN.N%) 1 +ast-stats - Fn 288 (NN.N%) 2 +ast-stats - Use 576 (NN.N%) 4 +ast-stats ---------------------------------------------------------------- +ast-stats Total 7_416 127 +ast-stats hir-stats HIR STATS hir-stats Name Accumulated Size Count Item Size hir-stats ---------------------------------------------------------------- -hir-stats ForeignItemRef 24 ( 0.3%) 1 24 -hir-stats Lifetime 28 ( 0.3%) 1 28 -hir-stats Mod 32 ( 0.4%) 1 32 -hir-stats ExprField 40 ( 0.4%) 1 40 -hir-stats TraitItemRef 56 ( 0.6%) 2 28 -hir-stats GenericArg 64 ( 0.7%) 4 16 -hir-stats - Type 16 ( 0.2%) 1 -hir-stats - Lifetime 48 ( 0.5%) 3 -hir-stats Param 64 ( 0.7%) 2 32 -hir-stats Body 72 ( 0.8%) 3 24 -hir-stats ImplItemRef 72 ( 0.8%) 2 36 -hir-stats InlineAsm 72 ( 0.8%) 1 72 -hir-stats Local 72 ( 0.8%) 1 72 -hir-stats WherePredicate 72 ( 0.8%) 3 24 -hir-stats - BoundPredicate 72 ( 0.8%) 3 -hir-stats Arm 80 ( 0.9%) 2 40 -hir-stats Stmt 96 ( 1.1%) 3 32 -hir-stats - Expr 32 ( 0.4%) 1 -hir-stats - Let 32 ( 0.4%) 1 -hir-stats - Semi 32 ( 0.4%) 1 -hir-stats FnDecl 120 ( 1.3%) 3 40 -hir-stats Attribute 128 ( 1.4%) 4 32 -hir-stats FieldDef 128 ( 1.4%) 2 64 -hir-stats GenericArgs 144 ( 1.6%) 3 48 -hir-stats Variant 144 ( 1.6%) 2 72 -hir-stats GenericBound 256 ( 2.8%) 4 64 -hir-stats - Trait 256 ( 2.8%) 4 -hir-stats Block 288 ( 3.2%) 6 48 -hir-stats Pat 360 ( 4.0%) 5 72 -hir-stats - Struct 72 ( 0.8%) 1 -hir-stats - Wild 72 ( 0.8%) 1 -hir-stats - Binding 216 ( 2.4%) 3 -hir-stats GenericParam 400 ( 4.5%) 5 80 -hir-stats Generics 560 ( 6.2%) 10 56 -hir-stats Ty 720 ( 8.0%) 15 48 -hir-stats - Ptr 48 ( 0.5%) 1 -hir-stats - Ref 48 ( 0.5%) 1 -hir-stats - Path 624 ( 6.9%) 13 -hir-stats Expr 768 ( 8.5%) 12 64 -hir-stats - InlineAsm 64 ( 0.7%) 1 -hir-stats - Match 64 ( 0.7%) 1 -hir-stats - Path 64 ( 0.7%) 1 -hir-stats - Struct 64 ( 0.7%) 1 -hir-stats - Lit 128 ( 1.4%) 2 -hir-stats - Block 384 ( 4.3%) 6 -hir-stats Item 968 (10.8%) 11 88 -hir-stats - Enum 88 ( 1.0%) 1 -hir-stats - ExternCrate 88 ( 1.0%) 1 -hir-stats - ForeignMod 88 ( 1.0%) 1 -hir-stats - Impl 88 ( 1.0%) 1 -hir-stats - Trait 88 ( 1.0%) 1 -hir-stats - Fn 176 ( 2.0%) 2 -hir-stats - Use 352 ( 3.9%) 4 -hir-stats Path 1_240 (13.8%) 31 40 -hir-stats PathSegment 1_920 (21.4%) 40 48 +hir-stats ForeignItemRef 24 (NN.N%) 1 24 +hir-stats Lifetime 28 (NN.N%) 1 28 +hir-stats Mod 32 (NN.N%) 1 32 +hir-stats ExprField 40 (NN.N%) 1 40 +hir-stats TraitItemRef 56 (NN.N%) 2 28 +hir-stats GenericArg 64 (NN.N%) 4 16 +hir-stats - Type 16 (NN.N%) 1 +hir-stats - Lifetime 48 (NN.N%) 3 +hir-stats Param 64 (NN.N%) 2 32 +hir-stats Body 72 (NN.N%) 3 24 +hir-stats ImplItemRef 72 (NN.N%) 2 36 +hir-stats InlineAsm 72 (NN.N%) 1 72 +hir-stats Local 72 (NN.N%) 1 72 +hir-stats WherePredicate 72 (NN.N%) 3 24 +hir-stats - BoundPredicate 72 (NN.N%) 3 +hir-stats Arm 80 (NN.N%) 2 40 +hir-stats Stmt 96 (NN.N%) 3 32 +hir-stats - Expr 32 (NN.N%) 1 +hir-stats - Let 32 (NN.N%) 1 +hir-stats - Semi 32 (NN.N%) 1 +hir-stats FnDecl 120 (NN.N%) 3 40 +hir-stats Attribute 128 (NN.N%) 4 32 +hir-stats FieldDef 128 (NN.N%) 2 64 +hir-stats GenericArgs 144 (NN.N%) 3 48 +hir-stats Variant 144 (NN.N%) 2 72 +hir-stats GenericBound 256 (NN.N%) 4 64 +hir-stats - Trait 256 (NN.N%) 4 +hir-stats Block 288 (NN.N%) 6 48 +hir-stats Pat 360 (NN.N%) 5 72 +hir-stats - Struct 72 (NN.N%) 1 +hir-stats - Wild 72 (NN.N%) 1 +hir-stats - Binding 216 (NN.N%) 3 +hir-stats GenericParam 400 (NN.N%) 5 80 +hir-stats Generics 560 (NN.N%) 10 56 +hir-stats Ty 720 (NN.N%) 15 48 +hir-stats - Ptr 48 (NN.N%) 1 +hir-stats - Ref 48 (NN.N%) 1 +hir-stats - Path 624 (NN.N%) 13 +hir-stats Expr 768 (NN.N%) 12 64 +hir-stats - InlineAsm 64 (NN.N%) 1 +hir-stats - Match 64 (NN.N%) 1 +hir-stats - Path 64 (NN.N%) 1 +hir-stats - Struct 64 (NN.N%) 1 +hir-stats - Lit 128 (NN.N%) 2 +hir-stats - Block 384 (NN.N%) 6 +hir-stats Item 968 (NN.N%) 11 88 +hir-stats - Enum 88 (NN.N%) 1 +hir-stats - ExternCrate 88 (NN.N%) 1 +hir-stats - ForeignMod 88 (NN.N%) 1 +hir-stats - Impl 88 (NN.N%) 1 +hir-stats - Trait 88 (NN.N%) 1 +hir-stats - Fn 176 (NN.N%) 2 +hir-stats - Use 352 (NN.N%) 4 +hir-stats Path 1_040 (NN.N%) 26 40 +hir-stats PathSegment 1_776 (NN.N%) 37 48 hir-stats ---------------------------------------------------------------- -hir-stats Total 8_988 180 +hir-stats Total 8_644 172 hir-stats diff --git a/tests/ui/bare-static-string.rs b/tests/ui/str/str-static-literal.rs index b71cf38cfe8..61630f0f22b 100644 --- a/tests/ui/bare-static-string.rs +++ b/tests/ui/str/str-static-literal.rs @@ -1,3 +1,5 @@ +//! Check that a bare string literal is typed as a `&'static str` and is usable. + //@ run-pass pub fn main() { diff --git a/tests/ui/structs/default-field-values/invalid-const.rs b/tests/ui/structs/default-field-values/invalid-const.rs index 203a712868b..ddb73f68865 100644 --- a/tests/ui/structs/default-field-values/invalid-const.rs +++ b/tests/ui/structs/default-field-values/invalid-const.rs @@ -3,13 +3,13 @@ pub struct Bat { pub bax: u8 = panic!("asdf"), - //~^ ERROR evaluation of constant value failed + //~^ ERROR evaluation panicked: asdf } pub struct Baz<const C: u8> { pub bax: u8 = 130 + C, // ok pub bat: u8 = 130 + 130, - //~^ ERROR evaluation of `Baz::<C>::bat::{constant#0}` failed + //~^ ERROR attempt to compute `130_u8 + 130_u8`, which would overflow pub bay: u8 = 1, // ok } diff --git a/tests/ui/structs/default-field-values/invalid-const.stderr b/tests/ui/structs/default-field-values/invalid-const.stderr index 030bdbfcc3e..545783e6c74 100644 --- a/tests/ui/structs/default-field-values/invalid-const.stderr +++ b/tests/ui/structs/default-field-values/invalid-const.stderr @@ -1,14 +1,14 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: asdf --> $DIR/invalid-const.rs:5:19 | LL | pub bax: u8 = panic!("asdf"), - | ^^^^^^^^^^^^^^ evaluation panicked: asdf + | ^^^^^^^^^^^^^^ evaluation of `Bat::bax::{constant#0}` failed here -error[E0080]: evaluation of `Baz::<C>::bat::{constant#0}` failed +error[E0080]: attempt to compute `130_u8 + 130_u8`, which would overflow --> $DIR/invalid-const.rs:11:19 | LL | pub bat: u8 = 130 + 130, - | ^^^^^^^^^ attempt to compute `130_u8 + 130_u8`, which would overflow + | ^^^^^^^^^ evaluation of `Baz::<C>::bat::{constant#0}` failed here error: aborting due to 2 previous errors diff --git a/tests/ui/structs/default-field-values/post-mono.direct.stderr b/tests/ui/structs/default-field-values/post-mono.direct.stderr index cdd80620c48..74e37795f06 100644 --- a/tests/ui/structs/default-field-values/post-mono.direct.stderr +++ b/tests/ui/structs/default-field-values/post-mono.direct.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Z::<1>::post_mono::{constant#0}` failed +error[E0080]: attempt to divide `1_usize` by zero --> $DIR/post-mono.rs:7:24 | LL | post_mono: usize = X / 0, - | ^^^^^ attempt to divide `1_usize` by zero + | ^^^^^ evaluation of `Z::<1>::post_mono::{constant#0}` failed here note: erroneous constant encountered --> $DIR/post-mono.rs:17:19 diff --git a/tests/ui/structs/default-field-values/post-mono.indirect.stderr b/tests/ui/structs/default-field-values/post-mono.indirect.stderr index 56c27a6e5dc..c8af9c959c1 100644 --- a/tests/ui/structs/default-field-values/post-mono.indirect.stderr +++ b/tests/ui/structs/default-field-values/post-mono.indirect.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of `Z::<1>::post_mono::{constant#0}` failed +error[E0080]: attempt to divide `1_usize` by zero --> $DIR/post-mono.rs:7:24 | LL | post_mono: usize = X / 0, - | ^^^^^ attempt to divide `1_usize` by zero + | ^^^^^ evaluation of `Z::<1>::post_mono::{constant#0}` failed here note: erroneous constant encountered --> $DIR/post-mono.rs:12:19 diff --git a/tests/ui/structs/default-field-values/post-mono.rs b/tests/ui/structs/default-field-values/post-mono.rs index 4de31f6e2fb..68dfa391bb4 100644 --- a/tests/ui/structs/default-field-values/post-mono.rs +++ b/tests/ui/structs/default-field-values/post-mono.rs @@ -5,7 +5,7 @@ struct Z<const X: usize> { post_mono: usize = X / 0, - //~^ ERROR evaluation of `Z::<1>::post_mono::{constant#0}` failed + //~^ ERROR attempt to divide `1_usize` by zero } fn indirect<const X: usize>() { diff --git a/tests/ui/structs/struct-path-associated-type.stderr b/tests/ui/structs/struct-path-associated-type.stderr index de396e875b0..110362293ac 100644 --- a/tests/ui/structs/struct-path-associated-type.stderr +++ b/tests/ui/structs/struct-path-associated-type.stderr @@ -48,19 +48,37 @@ error[E0223]: ambiguous associated type --> $DIR/struct-path-associated-type.rs:32:13 | LL | let s = S::A {}; - | ^^^^ help: use fully-qualified syntax: `<S as Tr>::A` + | ^^^^ + | +help: use fully-qualified syntax + | +LL - let s = S::A {}; +LL + let s = <S as Tr>::A {}; + | error[E0223]: ambiguous associated type --> $DIR/struct-path-associated-type.rs:33:13 | LL | let z = S::A::<u8> {}; - | ^^^^ help: use fully-qualified syntax: `<S as Tr>::A` + | ^^^^ + | +help: use fully-qualified syntax + | +LL - let z = S::A::<u8> {}; +LL + let z = <S as Tr>::A::<u8> {}; + | error[E0223]: ambiguous associated type --> $DIR/struct-path-associated-type.rs:35:9 | LL | S::A {} => {} - | ^^^^ help: use fully-qualified syntax: `<S as Tr>::A` + | ^^^^ + | +help: use fully-qualified syntax + | +LL - S::A {} => {} +LL + <S as Tr>::A {} => {} + | error: aborting due to 8 previous errors diff --git a/tests/ui/suggestions/abi-typo.fixed b/tests/ui/suggestions/abi-typo.fixed index 44fa80f6338..ae507c3e48f 100644 --- a/tests/ui/suggestions/abi-typo.fixed +++ b/tests/ui/suggestions/abi-typo.fixed @@ -1,6 +1,6 @@ //@ run-rustfix -extern "cdecl" fn cdedl() {} //~ ERROR invalid ABI +extern "system" fn systen() {} //~ ERROR invalid ABI fn main() { - cdedl(); + systen(); } diff --git a/tests/ui/suggestions/abi-typo.rs b/tests/ui/suggestions/abi-typo.rs index 3d5c23e0f23..c40bd803e53 100644 --- a/tests/ui/suggestions/abi-typo.rs +++ b/tests/ui/suggestions/abi-typo.rs @@ -1,6 +1,6 @@ //@ run-rustfix -extern "cdedl" fn cdedl() {} //~ ERROR invalid ABI +extern "systen" fn systen() {} //~ ERROR invalid ABI fn main() { - cdedl(); + systen(); } diff --git a/tests/ui/suggestions/abi-typo.stderr b/tests/ui/suggestions/abi-typo.stderr index 4d89ac16570..a8b4d366705 100644 --- a/tests/ui/suggestions/abi-typo.stderr +++ b/tests/ui/suggestions/abi-typo.stderr @@ -1,14 +1,14 @@ -error[E0703]: invalid ABI: found `cdedl` +error[E0703]: invalid ABI: found `systen` --> $DIR/abi-typo.rs:2:8 | -LL | extern "cdedl" fn cdedl() {} - | ^^^^^^^ invalid ABI +LL | extern "systen" fn systen() {} + | ^^^^^^^^ invalid ABI | = note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions -help: there's a similarly named valid ABI `cdecl` +help: there's a similarly named valid ABI `system` | -LL - extern "cdedl" fn cdedl() {} -LL + extern "cdecl" fn cdedl() {} +LL - extern "systen" fn systen() {} +LL + extern "system" fn systen() {} | error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/double-reference-ty-in-self-ty.rs b/tests/ui/suggestions/double-reference-ty-in-self-ty.rs new file mode 100644 index 00000000000..4ac13f0f635 --- /dev/null +++ b/tests/ui/suggestions/double-reference-ty-in-self-ty.rs @@ -0,0 +1,12 @@ +// issue#135863 + +struct A; + +impl A { + fn len(self: &&A) {} +} + +fn main() { + A.len(); + //~^ ERROR: no method named `len` found for struct `A` in the current scope +} diff --git a/tests/ui/suggestions/double-reference-ty-in-self-ty.stderr b/tests/ui/suggestions/double-reference-ty-in-self-ty.stderr new file mode 100644 index 00000000000..a7182342410 --- /dev/null +++ b/tests/ui/suggestions/double-reference-ty-in-self-ty.stderr @@ -0,0 +1,19 @@ +error[E0599]: no method named `len` found for struct `A` in the current scope + --> $DIR/double-reference-ty-in-self-ty.rs:10:7 + | +LL | struct A; + | -------- method `len` not found for this struct +... +LL | fn len(self: &&A) {} + | --- the method is available for `&A` here +... +LL | A.len(); + | ^^^ method not found in `A` + | + = help: items from traits can only be used if the trait is implemented and in scope + = note: the following trait defines an item `len`, perhaps you need to implement it: + candidate #1: `ExactSizeIterator` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/suggestions/impl-trait-missing-lifetime-gated.rs b/tests/ui/suggestions/impl-trait-missing-lifetime-gated.rs index f5c3da847c7..f176d52c087 100644 --- a/tests/ui/suggestions/impl-trait-missing-lifetime-gated.rs +++ b/tests/ui/suggestions/impl-trait-missing-lifetime-gated.rs @@ -73,7 +73,6 @@ mod in_path { // This must not err, as the `&` actually resolves to `'a`. fn resolved_anonymous<'a, T: 'a>(f: impl Fn(&'a str) -> &T) { - //~^ WARNING elided lifetime has a name f("f"); } diff --git a/tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr b/tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr index 92996ca8467..f29107b297a 100644 --- a/tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr +++ b/tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr @@ -149,14 +149,6 @@ LL - fn g(mut x: impl Foo<()>) -> Option<&()> { x.next() } LL + fn g(mut x: impl Foo<()>) -> Option<()> { x.next() } | -warning: elided lifetime has a name - --> $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` - | - = note: `#[warn(elided_named_lifetimes)]` on by default - error[E0658]: anonymous lifetimes in `impl Trait` are unstable --> $DIR/impl-trait-missing-lifetime-gated.rs:6:35 | @@ -289,7 +281,7 @@ help: consider introducing a named lifetime parameter LL | fn g<'a>(mut x: impl Foo<'a, ()>) -> Option<&()> { x.next() } | ++++ +++ -error: aborting due to 17 previous errors; 1 warning emitted +error: aborting due to 17 previous errors Some errors have detailed explanations: E0106, E0658. For more information about an error, try `rustc --explain E0106`. diff --git a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs index b61bea16e3b..b641f5941dc 100644 --- a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs +++ b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs @@ -100,7 +100,6 @@ where // This also works. The `'_` isn't necessary but it's where we arrive to following the suggestions: fn ok2<'a, G: 'a, T>(g: G, dest: &'a mut T) -> impl FnOnce() + '_ + 'a -//~^ WARNING elided lifetime has a name where G: Get<T>, { diff --git a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr index b92719e8033..41cb2ee46bb 100644 --- a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr +++ b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr @@ -6,14 +6,6 @@ LL | fn baz<G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | | | help: consider introducing lifetime `'a` here: `'a,` -warning: elided lifetime has a name - --> $DIR/missing-lifetimes-in-signature.rs:102:64 - | -LL | fn ok2<'a, G: 'a, T>(g: G, dest: &'a mut T) -> impl FnOnce() + '_ + 'a - | -- lifetime `'a` declared here ^^ this elided lifetime gets resolved as `'a` - | - = note: `#[warn(elided_named_lifetimes)]` on by default - error[E0700]: hidden type for `impl FnOnce()` captures lifetime that does not appear in bounds --> $DIR/missing-lifetimes-in-signature.rs:19:5 | @@ -136,7 +128,7 @@ help: consider adding an explicit lifetime bound LL | G: Get<T> + 'a, | ++++ -error: aborting due to 8 previous errors; 1 warning emitted +error: aborting due to 8 previous errors Some errors have detailed explanations: E0261, E0309, E0311, E0621, E0700. For more information about an error, try `rustc --explain E0261`. diff --git a/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr b/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr index 09a9b1d3b34..eadf512a63b 100644 --- a/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr +++ b/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr @@ -20,11 +20,11 @@ LL | let fp = BufWriter::new(fp); note: required by a bound in `BufWriter` --> $SRC_DIR/std/src/io/buffered/bufwriter.rs:LL:COL -error[E0599]: the method `write_fmt` exists for struct `BufWriter<&dyn Write>`, but its trait bounds were not satisfied +error[E0599]: the method `write_fmt` exists for struct `BufWriter<&dyn std::io::Write>`, but its trait bounds were not satisfied --> $DIR/mut-borrow-needed-by-trait.rs:21:14 | LL | writeln!(fp, "hello world").unwrap(); - | ---------^^---------------- method cannot be called on `BufWriter<&dyn Write>` due to unsatisfied trait bounds + | ---------^^---------------- method cannot be called on `BufWriter<&dyn std::io::Write>` due to unsatisfied trait bounds | note: must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method --> $DIR/mut-borrow-needed-by-trait.rs:21:14 diff --git a/tests/ui/suggestions/suggest-using-chars.stderr b/tests/ui/suggestions/suggest-using-chars.stderr index a197223beb0..20a162f8bfe 100644 --- a/tests/ui/suggestions/suggest-using-chars.stderr +++ b/tests/ui/suggestions/suggest-using-chars.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `iter` found for reference `&'static str` in the c --> $DIR/suggest-using-chars.rs:2:19 | LL | let _ = "foo".iter(); - | ^^^^ method not found in `&str` + | ^^^^ method not found in `&'static str` | help: because of the in-memory representation of `&str`, to obtain an `Iterator` over each of its codepoint use method `chars` | @@ -14,7 +14,7 @@ error[E0599]: no method named `foo` found for reference `&'static str` in the cu --> $DIR/suggest-using-chars.rs:3:19 | LL | let _ = "foo".foo(); - | ^^^ method not found in `&str` + | ^^^ method not found in `&'static str` error[E0599]: no method named `iter` found for struct `String` in the current scope --> $DIR/suggest-using-chars.rs:4:33 diff --git a/tests/ui/suggestions/unnamable-types.rs b/tests/ui/suggestions/unnamable-types.rs index 094584ff850..6772217a2f6 100644 --- a/tests/ui/suggestions/unnamable-types.rs +++ b/tests/ui/suggestions/unnamable-types.rs @@ -1,7 +1,7 @@ // Test that we do not suggest to add type annotations for unnamable types. #![crate_type="lib"] -#![feature(coroutines, stmt_expr_attributes)] +#![feature(coroutines, stmt_expr_attributes, const_async_blocks)] const A = 5; //~^ ERROR: missing type for `const` item diff --git a/tests/ui/tag-variant-cast-non-nullary.stderr b/tests/ui/tag-variant-cast-non-nullary.stderr index 2e1dde27d0f..8ec1c5f11ec 100644 --- a/tests/ui/tag-variant-cast-non-nullary.stderr +++ b/tests/ui/tag-variant-cast-non-nullary.stderr @@ -2,10 +2,14 @@ error[E0605]: non-primitive cast: `NonNullary` as `isize` --> $DIR/tag-variant-cast-non-nullary.rs:19:15 | LL | let val = v as isize; - | ^^^^^^^^^^ help: consider using the `From` trait instead: `isize::from(v)` + | ^^^^^^^^^^ an `as` expression can be used to convert enum types to numeric types only if the enum type is unit-only or field-less | - = note: an `as` expression can be used to convert enum types to numeric types only if the enum type is unit-only or field-less = note: see https://doc.rust-lang.org/reference/items/enumerations.html#casting for more information +help: consider using the `From` trait instead + | +LL - let val = v as isize; +LL + let val = isize::from(v); + | error: aborting due to 1 previous error diff --git a/tests/ui/target-feature/abi-incompatible-target-feature-attribute-fcw.rs b/tests/ui/target-feature/abi-incompatible-target-feature-attribute-fcw.rs new file mode 100644 index 00000000000..270874a9f58 --- /dev/null +++ b/tests/ui/target-feature/abi-incompatible-target-feature-attribute-fcw.rs @@ -0,0 +1,14 @@ +//@ compile-flags: --crate-type=lib +//@ compile-flags: --target=aarch64-unknown-none-softfloat +//@ needs-llvm-components: aarch64 +#![feature(no_core, lang_items)] +#![no_core] +#![deny(aarch64_softfloat_neon)] + +#[lang = "sized"] +pub trait Sized {} + +#[target_feature(enable = "neon")] +//~^ERROR: enabling the `neon` target feature on the current target is unsound +//~|WARN: previously accepted +pub unsafe fn my_fun() {} diff --git a/tests/ui/target-feature/abi-incompatible-target-feature-attribute-fcw.stderr b/tests/ui/target-feature/abi-incompatible-target-feature-attribute-fcw.stderr new file mode 100644 index 00000000000..bf745291a5a --- /dev/null +++ b/tests/ui/target-feature/abi-incompatible-target-feature-attribute-fcw.stderr @@ -0,0 +1,31 @@ +error: enabling the `neon` target feature on the current target is unsound due to ABI issues + --> $DIR/abi-incompatible-target-feature-attribute-fcw.rs:11:18 + | +LL | #[target_feature(enable = "neon")] + | ^^^^^^^^^^^^^^^ + | + = 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 #134375 <https://github.com/rust-lang/rust/issues/134375> +note: the lint level is defined here + --> $DIR/abi-incompatible-target-feature-attribute-fcw.rs:6:9 + | +LL | #![deny(aarch64_softfloat_neon)] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + +Future incompatibility report: Future breakage diagnostic: +error: enabling the `neon` target feature on the current target is unsound due to ABI issues + --> $DIR/abi-incompatible-target-feature-attribute-fcw.rs:11:18 + | +LL | #[target_feature(enable = "neon")] + | ^^^^^^^^^^^^^^^ + | + = 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 #134375 <https://github.com/rust-lang/rust/issues/134375> +note: the lint level is defined here + --> $DIR/abi-incompatible-target-feature-attribute-fcw.rs:6:9 + | +LL | #![deny(aarch64_softfloat_neon)] + | ^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/tests/ui/custom-test-frameworks-simple.rs b/tests/ui/test-attrs/custom_test_frameworks_simple.rs index 3fb7de6b26b..54a4e4095a7 100644 --- a/tests/ui/custom-test-frameworks-simple.rs +++ b/tests/ui/test-attrs/custom_test_frameworks_simple.rs @@ -1,3 +1,5 @@ +//! Checks run with a custom test framework and indexed test functions. + //@ compile-flags: --test //@ run-pass diff --git a/tests/ui/threads-sendsync/tls-dont-move-after-init.rs b/tests/ui/threads-sendsync/tls-dont-move-after-init.rs new file mode 100644 index 00000000000..54fcc32e9bd --- /dev/null +++ b/tests/ui/threads-sendsync/tls-dont-move-after-init.rs @@ -0,0 +1,37 @@ +//@ run-pass +//@ needs-threads + +use std::cell::Cell; +use std::thread; + +#[derive(Default)] +struct Foo { + ptr: Cell<*const Foo>, +} + +impl Foo { + fn touch(&self) { + if self.ptr.get().is_null() { + self.ptr.set(self); + } else { + assert!(self.ptr.get() == self); + } + } +} + +impl Drop for Foo { + fn drop(&mut self) { + self.touch(); + } +} + +thread_local!(static FOO: Foo = Foo::default()); + +fn main() { + thread::spawn(|| { + FOO.with(|foo| foo.touch()); + FOO.with(|foo| foo.touch()); + }) + .join() + .unwrap(); +} diff --git a/tests/ui/traits/associated_type_bound/116464-invalid-assoc-type-suggestion-in-trait-impl.stderr b/tests/ui/traits/associated_type_bound/116464-invalid-assoc-type-suggestion-in-trait-impl.stderr index a22d88b7c59..eedaae43f9a 100644 --- a/tests/ui/traits/associated_type_bound/116464-invalid-assoc-type-suggestion-in-trait-impl.stderr +++ b/tests/ui/traits/associated_type_bound/116464-invalid-assoc-type-suggestion-in-trait-impl.stderr @@ -49,23 +49,6 @@ LL | fn func<T: Trait<u32, String>>(t: T) -> impl Trait<(), Assoc = i32> { | +++++++ error[E0107]: trait takes 1 generic argument but 2 generic arguments were supplied - --> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:19:46 - | -LL | fn func<T: Trait<u32, String>>(t: T) -> impl Trait<(), i32> { - | ^^^^^ expected 1 generic argument - | -note: trait defined here, with 1 generic parameter: `T` - --> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:5:11 - | -LL | pub trait Trait<T> { - | ^^^^^ - - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: replace the generic bound with the associated type - | -LL | fn func<T: Trait<u32, String>>(t: T) -> impl Trait<(), Assoc = i32> { - | +++++++ - -error[E0107]: trait takes 1 generic argument but 2 generic arguments were supplied --> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:26:18 | LL | struct Struct<T: Trait<u32, String>> { @@ -127,6 +110,23 @@ note: struct defined here, with 1 generic parameter: `T` LL | struct Struct<T: Trait<u32, String>> { | ^^^^^^ - +error[E0107]: trait takes 1 generic argument but 2 generic arguments were supplied + --> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:19:46 + | +LL | fn func<T: Trait<u32, String>>(t: T) -> impl Trait<(), i32> { + | ^^^^^ expected 1 generic argument + | +note: trait defined here, with 1 generic parameter: `T` + --> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:5:11 + | +LL | pub trait Trait<T> { + | ^^^^^ - + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: replace the generic bound with the associated type + | +LL | fn func<T: Trait<u32, String>>(t: T) -> impl Trait<(), Assoc = i32> { + | +++++++ + error: aborting due to 9 previous errors Some errors have detailed explanations: E0107, E0207. diff --git a/tests/ui/builtin-clone-unwind.rs b/tests/ui/traits/clone-unwind-rc-cleanup.rs index 507ea045b4f..cd02050ea27 100644 --- a/tests/ui/builtin-clone-unwind.rs +++ b/tests/ui/traits/clone-unwind-rc-cleanup.rs @@ -1,14 +1,13 @@ +//! Tests cleanup behavior of the built-in `Clone` impl for tuples during unwinding. + //@ run-pass //@ needs-unwind #![allow(unused_variables)] #![allow(unused_imports)] -// Test that builtin implementations of `Clone` cleanup everything -// in case of unwinding. - -use std::thread; use std::rc::Rc; +use std::thread; struct S(Rc<()>); @@ -28,34 +27,20 @@ fn main() { // Unwinding with tuples... let ccounter = counter.clone(); let result = std::panic::catch_unwind(move || { - let _ = ( - S(ccounter.clone()), - S(ccounter.clone()), - S(ccounter.clone()), - S(ccounter) - ).clone(); + let _ = + (S(ccounter.clone()), S(ccounter.clone()), S(ccounter.clone()), S(ccounter)).clone(); }); assert!(result.is_err()); - assert_eq!( - 1, - Rc::strong_count(&counter) - ); + assert_eq!(1, Rc::strong_count(&counter)); // ... and with arrays. let ccounter = counter.clone(); let child = std::panic::catch_unwind(move || { - let _ = [ - S(ccounter.clone()), - S(ccounter.clone()), - S(ccounter.clone()), - S(ccounter) - ].clone(); + let _ = + [S(ccounter.clone()), S(ccounter.clone()), S(ccounter.clone()), S(ccounter)].clone(); }); assert!(child.is_err()); - assert_eq!( - 1, - Rc::strong_count(&counter) - ); + assert_eq!(1, Rc::strong_count(&counter)); } diff --git a/tests/ui/traits/const-traits/const-impl-trait.stderr b/tests/ui/traits/const-traits/const-impl-trait.stderr index 27d7957c001..6783cec3960 100644 --- a/tests/ui/traits/const-traits/const-impl-trait.stderr +++ b/tests/ui/traits/const-traits/const-impl-trait.stderr @@ -33,13 +33,14 @@ note: `PartialEq` can't be used with `~const` because it isn't annotated with `# --> $SRC_DIR/core/src/cmp.rs:LL:COL error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:17:11 + --> $DIR/const-impl-trait.rs:16:13 | -LL | ) -> impl ~const PartialEq + ~const Destruct { - | ^^^^^^ can't be applied to `PartialEq` +LL | x: impl ~const PartialEq + ~const Destruct, + | ^^^^^^ can't be applied to `PartialEq` | note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/cmp.rs:LL:COL + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/const-impl-trait.rs:17:11 @@ -49,7 +50,6 @@ LL | ) -> impl ~const PartialEq + ~const Destruct { | note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/cmp.rs:LL:COL - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/const-impl-trait.rs:17:11 @@ -62,32 +62,32 @@ note: `PartialEq` can't be used with `~const` because it isn't annotated with `# = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:16:13 + --> $DIR/const-impl-trait.rs:23:22 | -LL | x: impl ~const PartialEq + ~const Destruct, - | ^^^^^^ can't be applied to `PartialEq` +LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; + | ^^^^^^ can't be applied to `PartialEq` | note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/cmp.rs:LL:COL - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:23:22 + --> $DIR/const-impl-trait.rs:27:22 | -LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; +LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { | ^^^^^^ can't be applied to `PartialEq` | note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/cmp.rs:LL:COL error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:27:22 + --> $DIR/const-impl-trait.rs:17:11 | -LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { - | ^^^^^^ can't be applied to `PartialEq` +LL | ) -> impl ~const PartialEq + ~const Destruct { + | ^^^^^^ can't be applied to `PartialEq` | note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/cmp.rs:LL:COL + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/const-impl-trait.rs:27:22 diff --git a/tests/ui/traits/const-traits/staged-api.stderr b/tests/ui/traits/const-traits/staged-api.stderr index cdf577287ee..4756c490cb1 100644 --- a/tests/ui/traits/const-traits/staged-api.stderr +++ b/tests/ui/traits/const-traits/staged-api.stderr @@ -71,16 +71,11 @@ error: const function that might be (indirectly) exposed to stable cannot use `# LL | Unstable::func(); | ^^^^^^^^^^^^^^^^ | -help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the function is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn const_context() { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(const_trait_impl)] -LL | const fn const_context() { - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(unstable)]` --> $DIR/staged-api.rs:38:5 @@ -88,16 +83,11 @@ error: const function that might be (indirectly) exposed to stable cannot use `# LL | Unstable::func(); | ^^^^^^^^^^^^^^^^ | -help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the function is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn const_context() { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(unstable)] -LL | const fn const_context() { - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(const_trait_impl)]` --> $DIR/staged-api.rs:41:5 @@ -105,16 +95,11 @@ error: const function that might be (indirectly) exposed to stable cannot use `# LL | Foo::func(); | ^^^^^^^^^^^ | -help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the function is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn const_context() { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(const_trait_impl)] -LL | const fn const_context() { - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(unstable)]` --> $DIR/staged-api.rs:41:5 @@ -122,16 +107,11 @@ error: const function that might be (indirectly) exposed to stable cannot use `# LL | Foo::func(); | ^^^^^^^^^^^ | -help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the function is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn const_context() { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(unstable)] -LL | const fn const_context() { - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(const_trait_impl)]` --> $DIR/staged-api.rs:44:5 @@ -139,16 +119,11 @@ error: const function that might be (indirectly) exposed to stable cannot use `# LL | Unstable2::func(); | ^^^^^^^^^^^^^^^^^ | -help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the function is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn const_context() { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(const_trait_impl)] -LL | const fn const_context() { - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(unstable)]` --> $DIR/staged-api.rs:44:5 @@ -156,16 +131,11 @@ error: const function that might be (indirectly) exposed to stable cannot use `# LL | Unstable2::func(); | ^^^^^^^^^^^^^^^^^ | -help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the function is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn const_context() { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(unstable)] -LL | const fn const_context() { - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(const_trait_impl)]` --> $DIR/staged-api.rs:47:5 @@ -173,16 +143,11 @@ error: const function that might be (indirectly) exposed to stable cannot use `# LL | conditionally_const::<Foo>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the function is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn const_context() { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(const_trait_impl)] -LL | const fn const_context() { - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(const_trait_impl)]` --> $DIR/staged-api.rs:63:5 @@ -190,16 +155,11 @@ error: const function that might be (indirectly) exposed to stable cannot use `# LL | Unstable::func(); | ^^^^^^^^^^^^^^^^ | -help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the function is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn stable_const_context() { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(const_trait_impl)] -LL | const fn stable_const_context() { - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(unstable)]` --> $DIR/staged-api.rs:63:5 @@ -207,16 +167,11 @@ error: const function that might be (indirectly) exposed to stable cannot use `# LL | Unstable::func(); | ^^^^^^^^^^^^^^^^ | -help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the function is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn stable_const_context() { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(unstable)] -LL | const fn stable_const_context() { - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(const_trait_impl)]` --> $DIR/staged-api.rs:66:5 @@ -224,16 +179,11 @@ error: const function that might be (indirectly) exposed to stable cannot use `# LL | Foo::func(); | ^^^^^^^^^^^ | -help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the function is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn stable_const_context() { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(const_trait_impl)] -LL | const fn stable_const_context() { - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(unstable)]` --> $DIR/staged-api.rs:66:5 @@ -241,16 +191,11 @@ error: const function that might be (indirectly) exposed to stable cannot use `# LL | Foo::func(); | ^^^^^^^^^^^ | -help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the function is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn stable_const_context() { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(unstable)] -LL | const fn stable_const_context() { - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(local_feature)]` --> $DIR/staged-api.rs:69:5 @@ -259,16 +204,11 @@ LL | const_context_not_const_stable(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: mark the callee as `#[rustc_const_stable_indirect]` if it does not itself require any unstable features -help: if the caller is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the caller is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn stable_const_context() { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(local_feature)] -LL | const fn stable_const_context() { - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(const_trait_impl)]` --> $DIR/staged-api.rs:71:5 @@ -276,16 +216,11 @@ error: const function that might be (indirectly) exposed to stable cannot use `# LL | conditionally_const::<Foo>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the function is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn stable_const_context() { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(const_trait_impl)] -LL | const fn stable_const_context() { - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(const_trait_impl)]` --> $DIR/staged-api.rs:76:5 @@ -293,16 +228,11 @@ error: const function that might be (indirectly) exposed to stable cannot use `# LL | Unstable::func(); | ^^^^^^^^^^^^^^^^ | -help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the function is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn implicitly_stable_const_context() { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(const_trait_impl)] -LL | const fn implicitly_stable_const_context() { - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(unstable)]` --> $DIR/staged-api.rs:76:5 @@ -310,16 +240,11 @@ error: const function that might be (indirectly) exposed to stable cannot use `# LL | Unstable::func(); | ^^^^^^^^^^^^^^^^ | -help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the function is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn implicitly_stable_const_context() { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(unstable)] -LL | const fn implicitly_stable_const_context() { - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(const_trait_impl)]` --> $DIR/staged-api.rs:79:5 @@ -327,16 +252,11 @@ error: const function that might be (indirectly) exposed to stable cannot use `# LL | Foo::func(); | ^^^^^^^^^^^ | -help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the function is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn implicitly_stable_const_context() { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(const_trait_impl)] -LL | const fn implicitly_stable_const_context() { - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(unstable)]` --> $DIR/staged-api.rs:79:5 @@ -344,16 +264,11 @@ error: const function that might be (indirectly) exposed to stable cannot use `# LL | Foo::func(); | ^^^^^^^^^^^ | -help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the function is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn implicitly_stable_const_context() { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(unstable)] -LL | const fn implicitly_stable_const_context() { - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(local_feature)]` --> $DIR/staged-api.rs:82:5 @@ -362,16 +277,11 @@ LL | const_context_not_const_stable(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: mark the callee as `#[rustc_const_stable_indirect]` if it does not itself require any unstable features -help: if the caller is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the caller is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn implicitly_stable_const_context() { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(local_feature)] -LL | const fn implicitly_stable_const_context() { - | error: const function that might be (indirectly) exposed to stable cannot use `#[feature(const_trait_impl)]` --> $DIR/staged-api.rs:84:5 @@ -379,16 +289,11 @@ error: const function that might be (indirectly) exposed to stable cannot use `# LL | conditionally_const::<Foo>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do) +help: if the function is not (yet) meant to be exposed to stable const contexts, add `#[rustc_const_unstable]` | LL + #[rustc_const_unstable(feature = "...", issue = "...")] LL | const fn implicitly_stable_const_context() { | -help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval) - | -LL + #[rustc_allow_const_fn_unstable(const_trait_impl)] -LL | const fn implicitly_stable_const_context() { - | error: aborting due to 24 previous errors diff --git a/tests/ui/can-copy-pod.rs b/tests/ui/traits/copy-trait-implicit-copy.rs index ffb8a08fa98..e06385587b4 100644 --- a/tests/ui/can-copy-pod.rs +++ b/tests/ui/traits/copy-trait-implicit-copy.rs @@ -1,13 +1,13 @@ +//! Tests that type parameters with the `Copy` are implicitly copyable. + //@ run-pass /* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ -// Tests that type parameters with the `Copy` are implicitly copyable. - #![allow(dead_code)] -fn can_copy_copy<T:Copy>(v: T) { +fn can_copy_copy<T: Copy>(v: T) { let _a = v; let _b = v; } diff --git a/tests/ui/default-method-simple.rs b/tests/ui/traits/default_method_simple.rs index e5fbedfaece..96fad94f57a 100644 --- a/tests/ui/default-method-simple.rs +++ b/tests/ui/traits/default_method_simple.rs @@ -1,6 +1,6 @@ -//@ run-pass +//! Checks basic default method functionality. -#![allow(dead_code)] +//@ run-pass trait Foo { fn f(&self) { @@ -10,9 +10,7 @@ trait Foo { fn g(&self); } -struct A { - x: isize -} +struct A; impl Foo for A { fn g(&self) { @@ -21,6 +19,6 @@ impl Foo for A { } pub fn main() { - let a = A { x: 1 }; + let a = A; a.f(); } diff --git a/tests/ui/traits/issue-20692.rs b/tests/ui/traits/issue-20692.rs index 10611a232f7..79edc389ec4 100644 --- a/tests/ui/traits/issue-20692.rs +++ b/tests/ui/traits/issue-20692.rs @@ -2,7 +2,6 @@ trait Array: Sized + Copy {} fn f<T: Array>(x: &T) { let _ = x - //~^ ERROR `Array` is not dyn compatible as &dyn Array; //~^ ERROR `Array` is not dyn compatible diff --git a/tests/ui/traits/issue-20692.stderr b/tests/ui/traits/issue-20692.stderr index 32e29de49a1..d4a18899dcb 100644 --- a/tests/ui/traits/issue-20692.stderr +++ b/tests/ui/traits/issue-20692.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Array` is not dyn compatible - --> $DIR/issue-20692.rs:7:5 + --> $DIR/issue-20692.rs:6:10 | LL | &dyn Array; - | ^^^^^^^^^^ `Array` is not dyn compatible + | ^^^^^ `Array` 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> @@ -14,23 +14,6 @@ LL | trait Array: Sized + Copy {} | | ...because it requires `Self: Sized` | this trait is not dyn compatible... -error[E0038]: the trait `Array` is not dyn compatible - --> $DIR/issue-20692.rs:4:13 - | -LL | let _ = x - | ^ `Array` 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/issue-20692.rs:1:14 - | -LL | trait Array: Sized + Copy {} - | ----- ^^^^^ ^^^^ ...because it requires `Self: Sized` - | | | - | | ...because it requires `Self: Sized` - | this trait is not dyn compatible... - = note: required for the cast from `&T` to `&dyn Array` - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/traits/issue-38604.rs b/tests/ui/traits/issue-38604.rs index d90aa61ef9f..70f0ef0cb9c 100644 --- a/tests/ui/traits/issue-38604.rs +++ b/tests/ui/traits/issue-38604.rs @@ -12,5 +12,5 @@ impl Foo for () { fn main() { let _f: Box<dyn Foo> = //~ ERROR `Foo` is not dyn compatible - Box::new(()); //~ ERROR `Foo` is not dyn compatible + Box::new(()); } diff --git a/tests/ui/traits/issue-38604.stderr b/tests/ui/traits/issue-38604.stderr index e6a6b44e730..0f39dc536eb 100644 --- a/tests/ui/traits/issue-38604.stderr +++ b/tests/ui/traits/issue-38604.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/issue-38604.rs:14:13 + --> $DIR/issue-38604.rs:14:21 | LL | let _f: Box<dyn Foo> = - | ^^^^^^^^^^^^ `Foo` is not dyn compatible + | ^^^ `Foo` 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> @@ -14,23 +14,6 @@ LL | trait Foo where u32: Q<Self> { | this trait is not dyn compatible... = help: only type `()` implements `Foo`; consider using it directly instead. -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/issue-38604.rs:15:9 - | -LL | Box::new(()); - | ^^^^^^^^^^^^ `Foo` 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/issue-38604.rs:2:22 - | -LL | trait Foo where u32: Q<Self> { - | --- ^^^^^^^ ...because it uses `Self` as a type parameter - | | - | this trait is not dyn compatible... - = help: only type `()` implements `Foo`; consider using it directly instead. - = note: required for the cast from `Box<()>` to `Box<dyn Foo>` - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/traits/item-privacy.rs b/tests/ui/traits/item-privacy.rs index cdfd667a6f1..9f75e6e4c12 100644 --- a/tests/ui/traits/item-privacy.rs +++ b/tests/ui/traits/item-privacy.rs @@ -99,9 +99,7 @@ fn check_assoc_const() { S::C; // OK // A, B, C are resolved as inherent items, their traits don't need to be in scope <dyn C>::A; - //~^ ERROR associated constant `A` is private - //~| ERROR the trait `assoc_const::C` is not dyn compatible - //~| ERROR the trait `assoc_const::C` is not dyn compatible + //~^ ERROR the trait `assoc_const::C` is not dyn compatible <dyn C>::B; //~^ ERROR the trait `assoc_const::C` is not dyn compatible C::C; // OK diff --git a/tests/ui/traits/item-privacy.stderr b/tests/ui/traits/item-privacy.stderr index 4fd9ef91192..bf59cd079a5 100644 --- a/tests/ui/traits/item-privacy.stderr +++ b/tests/ui/traits/item-privacy.stderr @@ -131,44 +131,10 @@ LL + use assoc_const::B; | error[E0038]: the trait `assoc_const::C` is not dyn compatible - --> $DIR/item-privacy.rs:101:6 + --> $DIR/item-privacy.rs:101:10 | LL | <dyn C>::A; - | ^^^^^ `assoc_const::C` 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/item-privacy.rs:25:15 - | -LL | const A: u8 = 0; - | ^ ...because it contains this associated `const` -... -LL | const B: u8 = 0; - | ^ ...because it contains this associated `const` -... -LL | pub trait C: A + B { - | - this trait is not dyn compatible... -LL | const C: u8 = 0; - | ^ ...because it contains this associated `const` - = help: consider moving `C` to another trait - = help: consider moving `A` to another trait - = help: consider moving `B` to another trait - = help: only type `S` implements `assoc_const::C`; consider using it directly instead. - -error[E0624]: associated constant `A` is private - --> $DIR/item-privacy.rs:101:14 - | -LL | const A: u8 = 0; - | ----------- private associated constant defined here -... -LL | <dyn C>::A; - | ^ private associated constant - -error[E0038]: the trait `assoc_const::C` is not dyn compatible - --> $DIR/item-privacy.rs:101:5 - | -LL | <dyn C>::A; - | ^^^^^^^^^^ `assoc_const::C` is not dyn compatible + | ^ `assoc_const::C` 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> @@ -190,10 +156,10 @@ LL | const C: u8 = 0; = help: only type `S` implements `assoc_const::C`; consider using it directly instead. error[E0038]: the trait `assoc_const::C` is not dyn compatible - --> $DIR/item-privacy.rs:105:5 + --> $DIR/item-privacy.rs:103:10 | LL | <dyn C>::B; - | ^^^^^^^^^^ `assoc_const::C` is not dyn compatible + | ^ `assoc_const::C` 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> @@ -215,7 +181,7 @@ LL | const C: u8 = 0; = help: only type `S` implements `assoc_const::C`; consider using it directly instead. error[E0223]: ambiguous associated type - --> $DIR/item-privacy.rs:118:12 + --> $DIR/item-privacy.rs:116:12 | LL | let _: S::A; | ^^^^ @@ -227,19 +193,31 @@ LL + let _: <S as Example>::A; | error[E0223]: ambiguous associated type - --> $DIR/item-privacy.rs:119:12 + --> $DIR/item-privacy.rs:117:12 | LL | let _: S::B; - | ^^^^ help: use fully-qualified syntax: `<S as assoc_ty::B>::B` + | ^^^^ + | +help: use fully-qualified syntax + | +LL - let _: S::B; +LL + let _: <S as assoc_ty::B>::B; + | error[E0223]: ambiguous associated type - --> $DIR/item-privacy.rs:120:12 + --> $DIR/item-privacy.rs:118:12 | LL | let _: S::C; - | ^^^^ help: use fully-qualified syntax: `<S as assoc_ty::C>::C` + | ^^^^ + | +help: use fully-qualified syntax + | +LL - let _: S::C; +LL + let _: <S as assoc_ty::C>::C; + | error[E0624]: associated type `A` is private - --> $DIR/item-privacy.rs:122:12 + --> $DIR/item-privacy.rs:120:12 | LL | type A = u8; | ------ the associated type is defined here @@ -248,7 +226,7 @@ LL | let _: T::A; | ^^^^ private associated type error[E0624]: associated type `A` is private - --> $DIR/item-privacy.rs:131:9 + --> $DIR/item-privacy.rs:129:9 | LL | type A = u8; | ------ the associated type is defined here @@ -256,7 +234,7 @@ LL | type A = u8; LL | A = u8, | ^^^^^^ private associated type -error: aborting due to 17 previous errors +error: aborting due to 15 previous errors Some errors have detailed explanations: E0038, E0223, E0599, E0624. For more information about an error, try `rustc --explain E0038`. diff --git a/tests/ui/traits/next-solver/assembly/better_any-backcompat.rs b/tests/ui/traits/next-solver/assembly/better_any-backcompat.rs new file mode 100644 index 00000000000..8b153833e3a --- /dev/null +++ b/tests/ui/traits/next-solver/assembly/better_any-backcompat.rs @@ -0,0 +1,33 @@ +//@ check-pass +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) + +// A regression test for trait-system-refactor-initiative#183. While +// this concrete instance is likely not practically unsound, the general +// pattern is, see #57893. + +use std::any::TypeId; + +unsafe trait TidAble<'a>: Tid<'a> {} +trait TidExt<'a>: Tid<'a> { + fn downcast_box(self: Box<Self>) { + loop {} + } +} + +impl<'a, X: ?Sized + Tid<'a>> TidExt<'a> for X {} + +unsafe trait Tid<'a>: 'a {} + +unsafe impl<'a, T: ?Sized + TidAble<'a>> Tid<'a> for T {} + +impl<'a> dyn Tid<'a> + 'a { + fn downcast_any_box(self: Box<Self>) { + self.downcast_box(); + } +} + +unsafe impl<'a> TidAble<'a> for dyn Tid<'a> + 'a {} + +fn main() {} diff --git a/tests/ui/traits/next-solver/coerce-ambig-alias-to-rigid-alias.rs b/tests/ui/traits/next-solver/coercion/coerce-ambig-alias-to-rigid-alias.rs index cc78dc20eaf..cc78dc20eaf 100644 --- a/tests/ui/traits/next-solver/coerce-ambig-alias-to-rigid-alias.rs +++ b/tests/ui/traits/next-solver/coercion/coerce-ambig-alias-to-rigid-alias.rs diff --git a/tests/ui/traits/next-solver/coerce-depth.rs b/tests/ui/traits/next-solver/coercion/coerce-depth.rs index c8fc3fcab59..c8fc3fcab59 100644 --- a/tests/ui/traits/next-solver/coerce-depth.rs +++ b/tests/ui/traits/next-solver/coercion/coerce-depth.rs diff --git a/tests/ui/traits/next-solver/coercion/fn-def-coerce-nested-obligations.rs b/tests/ui/traits/next-solver/coercion/fn-def-coerce-nested-obligations.rs new file mode 100644 index 00000000000..1b5abcb02f2 --- /dev/null +++ b/tests/ui/traits/next-solver/coercion/fn-def-coerce-nested-obligations.rs @@ -0,0 +1,16 @@ +//@ compile-flags: -Znext-solver +//@ check-pass + +// Make sure that we consider nested obligations when checking whether +// we should coerce fn definitions to function pointers. + +fn foo<const N: usize>() {} +fn bar<T>() {} +fn main() { + let _ = if true { foo::<{ 0 + 0 }> } else { foo::<1> }; + let _ = if true { + bar::<for<'a> fn(<Vec<&'a ()> as IntoIterator>::Item)> + } else { + bar::<fn(i32)> + }; +} diff --git a/tests/ui/traits/next-solver/non-wf-in-coerce-pointers.rs b/tests/ui/traits/next-solver/coercion/non-wf-in-coerce-pointers.rs index d05def2cb75..d05def2cb75 100644 --- a/tests/ui/traits/next-solver/non-wf-in-coerce-pointers.rs +++ b/tests/ui/traits/next-solver/coercion/non-wf-in-coerce-pointers.rs diff --git a/tests/ui/traits/next-solver/non-wf-in-coerce-pointers.stderr b/tests/ui/traits/next-solver/coercion/non-wf-in-coerce-pointers.stderr index 72be10367da..72be10367da 100644 --- a/tests/ui/traits/next-solver/non-wf-in-coerce-pointers.stderr +++ b/tests/ui/traits/next-solver/coercion/non-wf-in-coerce-pointers.stderr diff --git a/tests/ui/traits/next-solver/trait-upcast-lhs-needs-normalization.rs b/tests/ui/traits/next-solver/coercion/trait-upcast-lhs-needs-normalization.rs index c6094b45775..c6094b45775 100644 --- a/tests/ui/traits/next-solver/trait-upcast-lhs-needs-normalization.rs +++ b/tests/ui/traits/next-solver/coercion/trait-upcast-lhs-needs-normalization.rs diff --git a/tests/ui/traits/next-solver/upcast-right-substs.rs b/tests/ui/traits/next-solver/coercion/upcast-right-substs.rs index 7a566b59b83..7a566b59b83 100644 --- a/tests/ui/traits/next-solver/upcast-right-substs.rs +++ b/tests/ui/traits/next-solver/coercion/upcast-right-substs.rs diff --git a/tests/ui/traits/next-solver/upcast-wrong-substs.rs b/tests/ui/traits/next-solver/coercion/upcast-wrong-substs.rs index 473977c527c..473977c527c 100644 --- a/tests/ui/traits/next-solver/upcast-wrong-substs.rs +++ b/tests/ui/traits/next-solver/coercion/upcast-wrong-substs.rs diff --git a/tests/ui/traits/next-solver/upcast-wrong-substs.stderr b/tests/ui/traits/next-solver/coercion/upcast-wrong-substs.stderr index 00ba1ef678f..00ba1ef678f 100644 --- a/tests/ui/traits/next-solver/upcast-wrong-substs.stderr +++ b/tests/ui/traits/next-solver/coercion/upcast-wrong-substs.stderr diff --git a/tests/ui/traits/next-solver/coherence/coherence-fulfill-overflow.stderr b/tests/ui/traits/next-solver/coherence/coherence-fulfill-overflow.stderr index 57cba790b55..7d39c82d22f 100644 --- a/tests/ui/traits/next-solver/coherence/coherence-fulfill-overflow.stderr +++ b/tests/ui/traits/next-solver/coherence/coherence-fulfill-overflow.stderr @@ -1,13 +1,10 @@ -error[E0119]: conflicting implementations of trait `Trait` for type `W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<_>>>>>>>>>>>>>>>>>>>>>` +error[E0119]: conflicting implementations of trait `Trait` for type `W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<_>>>>>>>>>>>>>>>>>>>>>>>` --> $DIR/coherence-fulfill-overflow.rs:12:1 | LL | impl<T: ?Sized + TwoW> Trait for W<T> {} | ------------------------------------- first implementation here LL | impl<T: ?Sized + TwoW> Trait for T {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<_>>>>>>>>>>>>>>>>>>>>>` - | - = note: overflow evaluating the requirement `W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<_>>>>>>>>>>>>>>>>>>>>>: TwoW` - = help: consider increasing the recursion limit by adding a `#![recursion_limit = "20"]` attribute to your crate (`coherence_fulfill_overflow`) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<_>>>>>>>>>>>>>>>>>>>>>>>` error: aborting due to 1 previous error diff --git a/tests/ui/traits/next-solver/method/param-method-from-unnormalized-param-env-2.rs b/tests/ui/traits/next-solver/method/param-method-from-unnormalized-param-env-2.rs new file mode 100644 index 00000000000..ffb99d6d638 --- /dev/null +++ b/tests/ui/traits/next-solver/method/param-method-from-unnormalized-param-env-2.rs @@ -0,0 +1,29 @@ +//@ check-pass +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver + +// Regression test for <https://github.com/rust-lang/trait-system-refactor-initiative/issues/214>. +// See comment below. + +trait A { + fn hello(&self) {} +} + +trait B { + fn hello(&self) {} +} + +impl<T> A for T {} +impl<T> B for T {} + +fn test<F, R>(q: F::Item) +where + F: Iterator<Item = R>, + // We want to prefer `A` for `R.hello()` + F::Item: A, +{ + q.hello(); +} + +fn main() {} diff --git a/tests/ui/traits/next-solver/method/param-method-from-unnormalized-param-env.rs b/tests/ui/traits/next-solver/method/param-method-from-unnormalized-param-env.rs new file mode 100644 index 00000000000..dde4f745879 --- /dev/null +++ b/tests/ui/traits/next-solver/method/param-method-from-unnormalized-param-env.rs @@ -0,0 +1,17 @@ +//@ check-pass +//@ compile-flags: -Znext-solver + +// Regression test for <https://github.com/rust-lang/trait-system-refactor-initiative/issues/214>. + +fn execute<K, F, R>(q: F::Item) -> R +where + F: Iterator<Item = R>, + // Both of the below bounds should be considered for `.into()`, and then be combined + // into a single `R: Into<?0>` bound which can be inferred to `?0 = R`. + F::Item: Into<K>, + R: Into<String>, +{ + q.into() +} + +fn main() {} diff --git a/tests/ui/traits/next-solver/no-param-env-const-fold.rs b/tests/ui/traits/next-solver/no-param-env-const-fold.rs new file mode 100644 index 00000000000..4f47332dd23 --- /dev/null +++ b/tests/ui/traits/next-solver/no-param-env-const-fold.rs @@ -0,0 +1,10 @@ +//@ check-pass +//@ compile-flags: -Znext-solver + +// Regression test for <https://github.com/rust-lang/trait-system-refactor-initiative/issues/213>. + +use std::ops::Deref; + +trait Trait: Deref<Target = [u8; { 1 + 1 }]> {} + +fn main() {} diff --git a/tests/ui/traits/next-solver/normalize/normalize-place-elem.rs b/tests/ui/traits/next-solver/normalize/normalize-place-elem.rs new file mode 100644 index 00000000000..9a600875bb9 --- /dev/null +++ b/tests/ui/traits/next-solver/normalize/normalize-place-elem.rs @@ -0,0 +1,32 @@ +//@ check-pass +//@ compile-flags: -Znext-solver + +// Regression test for <https://github.com/rust-lang/trait-system-refactor-initiative/issues/221>. +// Ensure that we normalize after applying projection elems in MIR typeck. + +use std::marker::PhantomData; + +#[derive(Copy, Clone)] +struct Span; + +trait AstKind { + type Inner; +} + +struct WithSpan; +impl AstKind for WithSpan { + type Inner + = (i32,); +} + +struct Expr<'a> { f: &'a <WithSpan as AstKind>::Inner } + +impl Expr<'_> { + fn span(self) { + match self { + Self { f: (n,) } => {}, + } + } +} + +fn main() {} diff --git a/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.rs b/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.rs index 28785ae3dea..96345732f0f 100644 --- a/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.rs +++ b/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.rs @@ -18,7 +18,5 @@ impl<T: ?Sized> Bar<T> for () {} fn main() { let x: &dyn Foo = &(); //~^ ERROR the trait `Foo` is not dyn compatible - //~| ERROR the trait `Foo` is not dyn compatible needs_bar(x); - //~^ ERROR the trait `Foo` is not dyn compatible } diff --git a/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.stderr b/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.stderr index 43b69d0b50e..aead19c4527 100644 --- a/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.stderr +++ b/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.stderr @@ -8,10 +8,10 @@ LL | #![feature(non_lifetime_binders)] = note: `#[warn(incomplete_features)]` on by default error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/supertrait-dyn-compatibility.rs:19:23 + --> $DIR/supertrait-dyn-compatibility.rs:19:17 | LL | let x: &dyn Foo = &(); - | ^^^ `Foo` is not dyn compatible + | ^^^ `Foo` 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> @@ -22,40 +22,7 @@ LL | trait Foo: for<T> Bar<T> {} | | | this trait is not dyn compatible... = help: only type `()` implements `Foo`; consider using it directly instead. - = note: required for the cast from `&()` to `&dyn Foo` -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/supertrait-dyn-compatibility.rs:19:12 - | -LL | let x: &dyn Foo = &(); - | ^^^^^^^^ `Foo` 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/supertrait-dyn-compatibility.rs:4:12 - | -LL | trait Foo: for<T> Bar<T> {} - | --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables - | | - | this trait is not dyn compatible... - = help: only type `()` implements `Foo`; consider using it directly instead. - -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/supertrait-dyn-compatibility.rs:22:5 - | -LL | needs_bar(x); - | ^^^^^^^^^ `Foo` 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/supertrait-dyn-compatibility.rs:4:12 - | -LL | trait Foo: for<T> Bar<T> {} - | --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables - | | - | this trait is not dyn compatible... - = help: only type `()` implements `Foo`; consider using it directly instead. - -error: aborting due to 3 previous errors; 1 warning emitted +error: aborting due to 1 previous error; 1 warning emitted For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.rs b/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.rs index 6fcd67b4950..9ac3b84dc12 100644 --- a/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.rs +++ b/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.rs @@ -9,8 +9,6 @@ trait Try { fn w<'a, T: 'a, F: Fn(&'a T)>() { let b: &dyn FromResidual = &(); //~^ ERROR: the trait `FromResidual` is not dyn compatible - //~| ERROR: the trait `FromResidual` is not dyn compatible - //~| ERROR the type parameter `R` must be explicitly specified } fn main() {} diff --git a/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.stderr b/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.stderr index b4bbd65b2f4..707aa9e9713 100644 --- a/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.stderr +++ b/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.stderr @@ -1,47 +1,8 @@ -error[E0393]: the type parameter `R` must be explicitly specified - --> $DIR/canonicalize-fresh-infer-vars-issue-103626.rs:10:17 - | -LL | trait FromResidual<R = <Self as Try>::Residual> { - | ----------------------------------------------- type parameter `R` must be specified for this -... -LL | let b: &dyn FromResidual = &(); - | ^^^^^^^^^^^^ - | - = note: because the parameter default references `Self`, the parameter must be specified on the object type -help: set the type parameter to the desired type - | -LL | let b: &dyn FromResidual<R> = &(); - | +++ - error[E0038]: the trait `FromResidual` is not dyn compatible - --> $DIR/canonicalize-fresh-infer-vars-issue-103626.rs:10:32 - | -LL | let b: &dyn FromResidual = &(); - | ^^^ `FromResidual` 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/canonicalize-fresh-infer-vars-issue-103626.rs:2:8 - | -LL | trait FromResidual<R = <Self as Try>::Residual> { - | ------------ this trait is not dyn compatible... -LL | fn from_residual(residual: R) -> Self; - | ^^^^^^^^^^^^^ ...because associated function `from_residual` has no `self` parameter - = note: required for the cast from `&()` to `&dyn FromResidual<{type error}>` -help: consider turning `from_residual` into a method by giving it a `&self` argument - | -LL | fn from_residual(&self, residual: R) -> Self; - | ++++++ -help: alternatively, consider constraining `from_residual` so it does not apply to trait objects - | -LL | fn from_residual(residual: R) -> Self where Self: Sized; - | +++++++++++++++++ - -error[E0038]: the trait `FromResidual` is not dyn compatible - --> $DIR/canonicalize-fresh-infer-vars-issue-103626.rs:10:12 + --> $DIR/canonicalize-fresh-infer-vars-issue-103626.rs:10:17 | LL | let b: &dyn FromResidual = &(); - | ^^^^^^^^^^^^^^^^^ `FromResidual` is not dyn compatible + | ^^^^^^^^^^^^ `FromResidual` 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> @@ -60,7 +21,6 @@ help: alternatively, consider constraining `from_residual` so it does not apply LL | fn from_residual(residual: R) -> Self where Self: Sized; | +++++++++++++++++ -error: aborting due to 3 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0038, E0393. -For more information about an error, try `rustc --explain E0038`. +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/traits/object/macro-matcher.stderr b/tests/ui/traits/object/macro-matcher.stderr index 3c668ce99c7..94d5c189a43 100644 --- a/tests/ui/traits/object/macro-matcher.stderr +++ b/tests/ui/traits/object/macro-matcher.stderr @@ -1,19 +1,19 @@ -error[E0224]: at least one trait is required for an object type - --> $DIR/macro-matcher.rs:11:8 - | -LL | m!(dyn 'static +); - | ^^^^^^^^^^^^^ - error[E0038]: the trait `Copy` is not dyn compatible - --> $DIR/macro-matcher.rs:8:8 + --> $DIR/macro-matcher.rs:8:12 | LL | m!(dyn Copy + Send + 'static); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ `Copy` is not dyn compatible + | ^^^^ `Copy` is not dyn compatible | = note: the trait is not dyn compatible because it requires `Self: Sized` = 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> +error[E0224]: at least one trait is required for an object type + --> $DIR/macro-matcher.rs:11:8 + | +LL | m!(dyn 'static +); + | ^^^^^^^^^^^^^ + error: aborting due to 2 previous errors Some errors have detailed explanations: E0038, E0224. diff --git a/tests/ui/traits/object/safety.rs b/tests/ui/traits/object/safety.rs index f4abcf8542e..ec039557b63 100644 --- a/tests/ui/traits/object/safety.rs +++ b/tests/ui/traits/object/safety.rs @@ -13,5 +13,4 @@ impl Tr for St { fn main() { let _: &dyn Tr = &St; //~ ERROR E0038 - //~^ ERROR E0038 } diff --git a/tests/ui/traits/object/safety.stderr b/tests/ui/traits/object/safety.stderr index 593e42619f4..c5637b43526 100644 --- a/tests/ui/traits/object/safety.stderr +++ b/tests/ui/traits/object/safety.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Tr` is not dyn compatible - --> $DIR/safety.rs:15:22 + --> $DIR/safety.rs:15:17 | LL | let _: &dyn Tr = &St; - | ^^^ `Tr` is not dyn compatible + | ^^ `Tr` 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> @@ -13,7 +13,6 @@ LL | trait Tr { LL | fn foo(); | ^^^ ...because associated function `foo` has no `self` parameter = help: only type `St` implements `Tr`; consider using it directly instead. - = note: required for the cast from `&St` to `&dyn Tr` help: consider turning `foo` into a method by giving it a `&self` argument | LL | fn foo(&self); @@ -23,30 +22,6 @@ help: alternatively, consider constraining `foo` so it does not apply to trait o LL | fn foo() where Self: Sized; | +++++++++++++++++ -error[E0038]: the trait `Tr` is not dyn compatible - --> $DIR/safety.rs:15:12 - | -LL | let _: &dyn Tr = &St; - | ^^^^^^^ `Tr` 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/safety.rs:4:8 - | -LL | trait Tr { - | -- this trait is not dyn compatible... -LL | fn foo(); - | ^^^ ...because associated function `foo` has no `self` parameter - = help: only type `St` implements `Tr`; consider using it directly instead. -help: consider turning `foo` into a method by giving it a `&self` argument - | -LL | fn foo(&self); - | +++++ -help: alternatively, consider constraining `foo` so it does not apply to trait objects - | -LL | fn foo() where Self: Sized; - | +++++++++++++++++ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/traits/test-2.rs b/tests/ui/traits/test-2.rs index ffb778a0141..1b7fc55b99a 100644 --- a/tests/ui/traits/test-2.rs +++ b/tests/ui/traits/test-2.rs @@ -12,6 +12,4 @@ fn main() { //~^ ERROR method takes 1 generic argument but 2 (Box::new(10) as Box<dyn bar>).dup(); //~^ ERROR E0038 - //~| ERROR E0038 - //~| ERROR E0038 } diff --git a/tests/ui/traits/test-2.stderr b/tests/ui/traits/test-2.stderr index 6a6cb503aa4..6a8109281a8 100644 --- a/tests/ui/traits/test-2.stderr +++ b/tests/ui/traits/test-2.stderr @@ -27,10 +27,10 @@ LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); } | ^^^^ - error[E0038]: the trait `bar` is not dyn compatible - --> $DIR/test-2.rs:13:22 + --> $DIR/test-2.rs:13:30 | LL | (Box::new(10) as Box<dyn bar>).dup(); - | ^^^^^^^^^^^^ `bar` is not dyn compatible + | ^^^ `bar` 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> @@ -49,54 +49,7 @@ LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); } consider defining an enum where each variant holds one of these types, implementing `bar` for this new enum and using it instead -error[E0038]: the trait `bar` is not dyn compatible - --> $DIR/test-2.rs:13:5 - | -LL | (Box::new(10) as Box<dyn bar>).dup(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `bar` 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/test-2.rs:4:30 - | -LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); } - | --- ^^^^ ^^^^ ...because method `blah` has generic type parameters - | | | - | | ...because method `dup` references the `Self` type in its return type - | this trait is not dyn compatible... - = help: consider moving `dup` to another trait - = help: consider moving `blah` to another trait - = help: the following types implement `bar`: - i32 - u32 - consider defining an enum where each variant holds one of these types, - implementing `bar` for this new enum and using it instead - -error[E0038]: the trait `bar` is not dyn compatible - --> $DIR/test-2.rs:13:6 - | -LL | (Box::new(10) as Box<dyn bar>).dup(); - | ^^^^^^^^^^^^ `bar` 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/test-2.rs:4:30 - | -LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); } - | --- ^^^^ ^^^^ ...because method `blah` has generic type parameters - | | | - | | ...because method `dup` references the `Self` type in its return type - | this trait is not dyn compatible... - = help: consider moving `dup` to another trait - = help: consider moving `blah` to another trait - = help: the following types implement `bar`: - i32 - u32 - consider defining an enum where each variant holds one of these types, - implementing `bar` for this new enum and using it instead - = note: required for the cast from `Box<{integer}>` to `Box<dyn bar>` - -error: aborting due to 5 previous errors +error: aborting due to 3 previous errors Some errors have detailed explanations: E0038, E0107. For more information about an error, try `rustc --explain E0038`. diff --git a/tests/ui/traits/trait-impl-missing-method.rs b/tests/ui/traits/trait-impl-missing-method.rs new file mode 100644 index 00000000000..1f03a332c4a --- /dev/null +++ b/tests/ui/traits/trait-impl-missing-method.rs @@ -0,0 +1,13 @@ +//! Trait impls must define all required methods. + +trait MyTrait { + fn trait_method(&self); +} + +struct ImplType; + +impl MyTrait for ImplType {} //~ ERROR not all trait items implemented, missing: `trait_method` + +fn main() { + let _ = ImplType; +} diff --git a/tests/ui/traits/trait-impl-missing-method.stderr b/tests/ui/traits/trait-impl-missing-method.stderr new file mode 100644 index 00000000000..ae11c3665ee --- /dev/null +++ b/tests/ui/traits/trait-impl-missing-method.stderr @@ -0,0 +1,12 @@ +error[E0046]: not all trait items implemented, missing: `trait_method` + --> $DIR/trait-impl-missing-method.rs:9:1 + | +LL | fn trait_method(&self); + | ----------------------- `trait_method` from trait +... +LL | impl MyTrait for ImplType {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ missing `trait_method` in implementation + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/transmutability/enums/repr/should_handle_all.rs b/tests/ui/transmutability/enums/repr/should_handle_all.rs index dec0126f22d..192b7cdcf72 100644 --- a/tests/ui/transmutability/enums/repr/should_handle_all.rs +++ b/tests/ui/transmutability/enums/repr/should_handle_all.rs @@ -1,8 +1,7 @@ //@ check-pass #![crate_type = "lib"] -#![feature(repr128)] #![feature(transmutability)] -#![allow(dead_code, incomplete_features, non_camel_case_types)] +#![allow(dead_code, non_camel_case_types)] mod assert { use std::mem::{Assume, TransmuteFrom}; diff --git a/tests/ui/transmutability/structs/repr/transmute_infinitely_recursive_type.stderr b/tests/ui/transmutability/structs/repr/transmute_infinitely_recursive_type.stderr index bdf2d3b6a58..1a0563b469c 100644 --- a/tests/ui/transmutability/structs/repr/transmute_infinitely_recursive_type.stderr +++ b/tests/ui/transmutability/structs/repr/transmute_infinitely_recursive_type.stderr @@ -12,7 +12,7 @@ LL | struct ExplicitlyPadded(Box<ExplicitlyPadded>); error[E0391]: cycle detected when computing layout of `should_pad_explicitly_packed_field::ExplicitlyPadded` | = note: ...which immediately requires computing layout of `should_pad_explicitly_packed_field::ExplicitlyPadded` again - = note: cycle used when evaluating trait selection obligation `(): core::mem::transmutability::TransmuteFrom<should_pad_explicitly_packed_field::ExplicitlyPadded, core::mem::transmutability::Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` + = note: cycle used when evaluating trait selection obligation `(): core::mem::transmutability::TransmuteFrom<should_pad_explicitly_packed_field::ExplicitlyPadded, ValTree(Branch([Leaf(0x00), Leaf(0x00), Leaf(0x00), Leaf(0x00)]): core::mem::transmutability::Assume)>` = 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 2 previous errors diff --git a/tests/ui/transmutability/uninhabited.rs b/tests/ui/transmutability/uninhabited.rs index 274104ffb39..4e48b590c42 100644 --- a/tests/ui/transmutability/uninhabited.rs +++ b/tests/ui/transmutability/uninhabited.rs @@ -38,7 +38,7 @@ fn yawning_void_struct() { const _: () = { assert!(std::mem::size_of::<YawningVoid>() == std::mem::size_of::<u128>()); // Just to be sure the above constant actually evaluated: - assert!(false); //~ ERROR: evaluation of constant value failed + assert!(false); //~ ERROR: evaluation panicked: assertion failed: false }; // This transmutation is vacuously acceptable; since one cannot construct a @@ -60,7 +60,7 @@ fn yawning_void_enum() { const _: () = { assert!(std::mem::size_of::<YawningVoid>() == std::mem::size_of::<u128>()); // Just to be sure the above constant actually evaluated: - assert!(false); //~ ERROR: evaluation of constant value failed + assert!(false); //~ ERROR: evaluation panicked: assertion failed: false }; // This transmutation is vacuously acceptable; since one cannot construct a @@ -84,7 +84,7 @@ fn distant_void() { const _: () = { assert!(std::mem::size_of::<DistantVoid>() == std::mem::size_of::<usize>()); // Just to be sure the above constant actually evaluated: - assert!(false); //~ ERROR: evaluation of constant value failed + assert!(false); //~ ERROR: evaluation panicked: assertion failed: false }; assert::is_maybe_transmutable::<DistantVoid, ()>(); diff --git a/tests/ui/transmutability/uninhabited.stderr b/tests/ui/transmutability/uninhabited.stderr index 3044b502d31..4757daec997 100644 --- a/tests/ui/transmutability/uninhabited.stderr +++ b/tests/ui/transmutability/uninhabited.stderr @@ -40,11 +40,11 @@ LL | | lifetimes: true, LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: assertion failed: false --> $DIR/uninhabited.rs:41:9 | LL | assert!(false); - | ^^^^^^^^^^^^^^ evaluation panicked: assertion failed: false + | ^^^^^^^^^^^^^^ evaluation of `yawning_void_struct::_` failed here error[E0277]: `()` cannot be safely transmuted into `yawning_void_enum::Void` --> $DIR/uninhabited.rs:71:41 @@ -67,11 +67,11 @@ LL | | lifetimes: true, LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: assertion failed: false --> $DIR/uninhabited.rs:63:9 | LL | assert!(false); - | ^^^^^^^^^^^^^^ evaluation panicked: assertion failed: false + | ^^^^^^^^^^^^^^ evaluation of `yawning_void_enum::_` failed here error[E0277]: `u128` cannot be safely transmuted into `DistantVoid` --> $DIR/uninhabited.rs:92:43 @@ -94,11 +94,11 @@ LL | | lifetimes: true, LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: assertion failed: false --> $DIR/uninhabited.rs:87:9 | LL | assert!(false); - | ^^^^^^^^^^^^^^ evaluation panicked: assertion failed: false + | ^^^^^^^^^^^^^^ evaluation of `distant_void::_` failed here error[E0277]: `Src` cannot be safely transmuted into `issue_126267::Error` --> $DIR/uninhabited.rs:108:42 diff --git a/tests/ui/transmute/unnecessary-transmutation.fixed b/tests/ui/transmute/unnecessary-transmutation.fixed index bf7d769348a..08010ec8b84 100644 --- a/tests/ui/transmute/unnecessary-transmutation.fixed +++ b/tests/ui/transmute/unnecessary-transmutation.fixed @@ -8,7 +8,27 @@ pub fn bytes_at_home(x: u32) -> [u8; 4] { //~^ ERROR } +pub const fn intinator_const(from: bool) -> u8 { + unsafe { (from) as u8 } + //~^ ERROR +} + +pub static X: u8 = unsafe { (true) as u8 }; +//~^ ERROR +pub const Y: u8 = unsafe { (true) as u8 }; +//~^ ERROR + +pub struct Z {} +impl Z { + pub const fn intinator_assoc(x: bool) -> u8 { + unsafe { (x) as u8 } + //~^ ERROR + } +} + fn main() { + const { unsafe { (true) as u8 } }; + //~^ ERROR unsafe { let x: u16 = u16::from_ne_bytes(*b"01"); //~^ ERROR @@ -81,14 +101,14 @@ fn main() { let y: i64 = f64::to_bits(1f64).cast_signed(); //~^ ERROR - let z: bool = (1u8 == 1); - //~^ ERROR - let z: u8 = (z) as u8; + let z: bool = transmute(1u8); + // clippy + let z: u8 = u8::from(z); //~^ ERROR let z: bool = transmute(1i8); - // no error! - let z: i8 = (z) as i8; + // clippy + let z: i8 = i8::from(z); //~^ ERROR } } diff --git a/tests/ui/transmute/unnecessary-transmutation.rs b/tests/ui/transmute/unnecessary-transmutation.rs index b9de529f1cc..43eefb97dc2 100644 --- a/tests/ui/transmute/unnecessary-transmutation.rs +++ b/tests/ui/transmute/unnecessary-transmutation.rs @@ -8,7 +8,27 @@ pub fn bytes_at_home(x: u32) -> [u8; 4] { //~^ ERROR } +pub const fn intinator_const(from: bool) -> u8 { + unsafe { transmute(from) } + //~^ ERROR +} + +pub static X: u8 = unsafe { transmute(true) }; +//~^ ERROR +pub const Y: u8 = unsafe { transmute(true) }; +//~^ ERROR + +pub struct Z {} +impl Z { + pub const fn intinator_assoc(x: bool) -> u8 { + unsafe { transmute(x) } + //~^ ERROR + } +} + fn main() { + const { unsafe { transmute::<_, u8>(true) } }; + //~^ ERROR unsafe { let x: u16 = transmute(*b"01"); //~^ ERROR @@ -82,12 +102,12 @@ fn main() { //~^ ERROR let z: bool = transmute(1u8); - //~^ ERROR + // clippy let z: u8 = transmute(z); //~^ ERROR let z: bool = transmute(1i8); - // no error! + // clippy let z: i8 = transmute(z); //~^ ERROR } diff --git a/tests/ui/transmute/unnecessary-transmutation.stderr b/tests/ui/transmute/unnecessary-transmutation.stderr index a19f1bebf16..0132ac4776b 100644 --- a/tests/ui/transmute/unnecessary-transmutation.stderr +++ b/tests/ui/transmute/unnecessary-transmutation.stderr @@ -2,7 +2,9 @@ error: unnecessary transmute --> $DIR/unnecessary-transmutation.rs:7:14 | LL | unsafe { transmute(x) } - | ^^^^^^^^^^^^ help: replace this with: `u32::to_ne_bytes(x)` + | ---------^^^ + | | + | help: replace this with: `u32::to_ne_bytes` | = 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 @@ -12,250 +14,387 @@ LL | #![deny(unnecessary_transmutes)] | ^^^^^^^^^^^^^^^^^^^^^^ error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:13:22 + --> $DIR/unnecessary-transmutation.rs:12:14 + | +LL | unsafe { transmute(from) } + | ^^^^^^^^^^^^^^^ + | +help: replace this with + | +LL - unsafe { transmute(from) } +LL + unsafe { (from) as u8 } + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:16:29 + | +LL | pub static X: u8 = unsafe { transmute(true) }; + | ^^^^^^^^^^^^^^^ + | +help: replace this with + | +LL - pub static X: u8 = unsafe { transmute(true) }; +LL + pub static X: u8 = unsafe { (true) as u8 }; + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:18:28 + | +LL | pub const Y: u8 = unsafe { transmute(true) }; + | ^^^^^^^^^^^^^^^ + | +help: replace this with + | +LL - pub const Y: u8 = unsafe { transmute(true) }; +LL + pub const Y: u8 = unsafe { (true) as u8 }; + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:24:18 + | +LL | unsafe { transmute(x) } + | ^^^^^^^^^^^^ + | +help: replace this with + | +LL - unsafe { transmute(x) } +LL + unsafe { (x) as u8 } + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:30:22 + | +LL | const { unsafe { transmute::<_, u8>(true) } }; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: replace this with + | +LL - const { unsafe { transmute::<_, u8>(true) } }; +LL + const { unsafe { (true) as u8 } }; + | + +error: unnecessary transmute + --> $DIR/unnecessary-transmutation.rs:33:22 | LL | let x: u16 = transmute(*b"01"); - | ^^^^^^^^^^^^^^^^^ help: replace this with: `u16::from_ne_bytes(*b"01")` + | ---------^^^^^^^^ + | | + | help: replace this with: `u16::from_ne_bytes` | = 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 + --> $DIR/unnecessary-transmutation.rs:35:26 | LL | let x: [u8; 2] = transmute(x); - | ^^^^^^^^^^^^ help: replace this with: `u16::to_ne_bytes(x)` + | ---------^^^ + | | + | help: replace this with: `u16::to_ne_bytes` | = 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 + --> $DIR/unnecessary-transmutation.rs:37:22 | LL | let x: u32 = transmute(*b"0123"); - | ^^^^^^^^^^^^^^^^^^^ help: replace this with: `u32::from_ne_bytes(*b"0123")` + | ---------^^^^^^^^^^ + | | + | help: replace this with: `u32::from_ne_bytes` | = 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 + --> $DIR/unnecessary-transmutation.rs:39:26 | LL | let x: [u8; 4] = transmute(x); - | ^^^^^^^^^^^^ help: replace this with: `u32::to_ne_bytes(x)` + | ---------^^^ + | | + | help: replace this with: `u32::to_ne_bytes` | = 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 + --> $DIR/unnecessary-transmutation.rs:41:22 | LL | let x: u64 = transmute(*b"feriscat"); - | ^^^^^^^^^^^^^^^^^^^^^^^ help: replace this with: `u64::from_ne_bytes(*b"feriscat")` + | ---------^^^^^^^^^^^^^^ + | | + | help: replace this with: `u64::from_ne_bytes` | = 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 + --> $DIR/unnecessary-transmutation.rs:43:26 | LL | let x: [u8; 8] = transmute(x); - | ^^^^^^^^^^^^ help: replace this with: `u64::to_ne_bytes(x)` + | ---------^^^ + | | + | help: replace this with: `u64::to_ne_bytes` | = 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 + --> $DIR/unnecessary-transmutation.rs:46:22 | LL | let y: i16 = transmute(*b"01"); - | ^^^^^^^^^^^^^^^^^ help: replace this with: `i16::from_ne_bytes(*b"01")` + | ---------^^^^^^^^ + | | + | help: replace this with: `i16::from_ne_bytes` | = 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 + --> $DIR/unnecessary-transmutation.rs:48:26 | LL | let y: [u8; 2] = transmute(y); - | ^^^^^^^^^^^^ help: replace this with: `i16::to_ne_bytes(y)` + | ---------^^^ + | | + | help: replace this with: `i16::to_ne_bytes` | = 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 + --> $DIR/unnecessary-transmutation.rs:50:22 | LL | let y: i32 = transmute(*b"0123"); - | ^^^^^^^^^^^^^^^^^^^ help: replace this with: `i32::from_ne_bytes(*b"0123")` + | ---------^^^^^^^^^^ + | | + | help: replace this with: `i32::from_ne_bytes` | = 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 + --> $DIR/unnecessary-transmutation.rs:52:26 | LL | let y: [u8; 4] = transmute(y); - | ^^^^^^^^^^^^ help: replace this with: `i32::to_ne_bytes(y)` + | ---------^^^ + | | + | help: replace this with: `i32::to_ne_bytes` | = 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 + --> $DIR/unnecessary-transmutation.rs:54:22 | LL | let y: i64 = transmute(*b"feriscat"); - | ^^^^^^^^^^^^^^^^^^^^^^^ help: replace this with: `i64::from_ne_bytes(*b"feriscat")` + | ---------^^^^^^^^^^^^^^ + | | + | help: replace this with: `i64::from_ne_bytes` | = 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 + --> $DIR/unnecessary-transmutation.rs:56:26 | LL | let y: [u8; 8] = transmute(y); - | ^^^^^^^^^^^^ help: replace this with: `i64::to_ne_bytes(y)` + | ---------^^^ + | | + | help: replace this with: `i64::to_ne_bytes` | = 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 + --> $DIR/unnecessary-transmutation.rs:59:22 | LL | let z: f32 = transmute(*b"0123"); - | ^^^^^^^^^^^^^^^^^^^ help: replace this with: `f32::from_ne_bytes(*b"0123")` + | ---------^^^^^^^^^^ + | | + | help: replace this with: `f32::from_ne_bytes` | = 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 + --> $DIR/unnecessary-transmutation.rs:61:26 | LL | let z: [u8; 4] = transmute(z); - | ^^^^^^^^^^^^ help: replace this with: `f32::to_ne_bytes(z)` + | ---------^^^ + | | + | help: replace this with: `f32::to_ne_bytes` | = 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 + --> $DIR/unnecessary-transmutation.rs:63:22 | LL | let z: f64 = transmute(*b"feriscat"); - | ^^^^^^^^^^^^^^^^^^^^^^^ help: replace this with: `f64::from_ne_bytes(*b"feriscat")` + | ---------^^^^^^^^^^^^^^ + | | + | help: replace this with: `f64::from_ne_bytes` | = 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 + --> $DIR/unnecessary-transmutation.rs:65:26 | LL | let z: [u8; 8] = transmute(z); - | ^^^^^^^^^^^^ help: replace this with: `f64::to_ne_bytes(z)` + | ---------^^^ + | | + | help: replace this with: `f64::to_ne_bytes` | = 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 + --> $DIR/unnecessary-transmutation.rs:68:22 | LL | let y: u32 = transmute('🦀'); - | ^^^^^^^^^^^^^^^ help: replace this with: `u32::from('🦀')` + | ---------^^^^^^ + | | + | help: replace this with: `u32::from` error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:50:23 + --> $DIR/unnecessary-transmutation.rs:70:23 | LL | let y: char = transmute(y); - | ^^^^^^^^^^^^ help: replace this with: `char::from_u32_unchecked(y)` + | ---------^^^ + | | + | help: replace this with: `char::from_u32_unchecked` | - = help: consider `char::from_u32(…).unwrap()` + = help: consider using `char::from_u32(…).unwrap()` error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:52:22 + --> $DIR/unnecessary-transmutation.rs:72:22 | LL | let y: i32 = transmute('🐱'); - | ^^^^^^^^^^^^^^^ help: replace this with: `u32::from('🐱').cast_signed()` + | ^^^^^^^^^^^^^^^ + | +help: replace this with + | +LL - let y: i32 = transmute('🐱'); +LL + let y: i32 = u32::from('🐱').cast_signed(); + | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:54:23 + --> $DIR/unnecessary-transmutation.rs:74:23 | LL | let y: char = transmute(y); - | ^^^^^^^^^^^^ help: replace this with: `char::from_u32_unchecked(i32::cast_unsigned(y))` + | ^^^^^^^^^^^^ + | + = help: consider using `char::from_u32(i32::cast_unsigned(…)).unwrap()` +help: replace this with + | +LL - let y: char = transmute(y); +LL + let y: char = char::from_u32_unchecked(i32::cast_unsigned(y)); | - = help: consider `char::from_u32(i32::cast_unsigned(…)).unwrap()` error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:57:22 + --> $DIR/unnecessary-transmutation.rs:77:22 | LL | let x: u16 = transmute(8i16); - | ^^^^^^^^^^^^^^^ help: replace this with: `i16::cast_unsigned(8i16)` + | ---------^^^^^^ + | | + | help: replace this with: `i16::cast_unsigned` error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:59:22 + --> $DIR/unnecessary-transmutation.rs:79:22 | LL | let x: i16 = transmute(x); - | ^^^^^^^^^^^^ help: replace this with: `u16::cast_signed(x)` + | ---------^^^ + | | + | help: replace this with: `u16::cast_signed` error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:61:22 + --> $DIR/unnecessary-transmutation.rs:81:22 | LL | let x: u32 = transmute(4i32); - | ^^^^^^^^^^^^^^^ help: replace this with: `i32::cast_unsigned(4i32)` + | ---------^^^^^^ + | | + | help: replace this with: `i32::cast_unsigned` error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:63:22 + --> $DIR/unnecessary-transmutation.rs:83:22 | LL | let x: i32 = transmute(x); - | ^^^^^^^^^^^^ help: replace this with: `u32::cast_signed(x)` + | ---------^^^ + | | + | help: replace this with: `u32::cast_signed` error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:65:22 + --> $DIR/unnecessary-transmutation.rs:85:22 | LL | let x: u64 = transmute(7i64); - | ^^^^^^^^^^^^^^^ help: replace this with: `i64::cast_unsigned(7i64)` + | ---------^^^^^^ + | | + | help: replace this with: `i64::cast_unsigned` error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:67:22 + --> $DIR/unnecessary-transmutation.rs:87:22 | LL | let x: i64 = transmute(x); - | ^^^^^^^^^^^^ help: replace this with: `u64::cast_signed(x)` + | ---------^^^ + | | + | help: replace this with: `u64::cast_signed` error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:70:22 + --> $DIR/unnecessary-transmutation.rs:90:22 | LL | let y: f32 = transmute(1u32); - | ^^^^^^^^^^^^^^^ help: replace this with: `f32::from_bits(1u32)` + | ---------^^^^^^ + | | + | help: replace this with: `f32::from_bits` error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:72:22 + --> $DIR/unnecessary-transmutation.rs:92:22 | LL | let y: u32 = transmute(y); - | ^^^^^^^^^^^^ help: replace this with: `f32::to_bits(y)` + | ---------^^^ + | | + | help: replace this with: `f32::to_bits` error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:74:22 + --> $DIR/unnecessary-transmutation.rs:94:22 | LL | let y: f64 = transmute(3u64); - | ^^^^^^^^^^^^^^^ help: replace this with: `f64::from_bits(3u64)` + | ---------^^^^^^ + | | + | help: replace this with: `f64::from_bits` error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:76:22 + --> $DIR/unnecessary-transmutation.rs:96:22 | LL | let y: u64 = transmute(2.0); - | ^^^^^^^^^^^^^^ help: replace this with: `f64::to_bits(2.0)` + | ---------^^^^^ + | | + | help: replace this with: `f64::to_bits` error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:79:22 + --> $DIR/unnecessary-transmutation.rs:99:22 | LL | let y: f64 = transmute(1i64); - | ^^^^^^^^^^^^^^^ help: replace this with: `f64::from_bits(i64::cast_unsigned(1i64))` + | ^^^^^^^^^^^^^^^ + | +help: replace this with + | +LL - let y: f64 = transmute(1i64); +LL + let y: f64 = f64::from_bits(i64::cast_unsigned(1i64)); + | error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:81:22 + --> $DIR/unnecessary-transmutation.rs:101:22 | LL | let y: i64 = transmute(1f64); - | ^^^^^^^^^^^^^^^ help: replace this with: `f64::to_bits(1f64).cast_signed()` - -error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:84:23 + | ^^^^^^^^^^^^^^^ + | +help: replace this with + | +LL - let y: i64 = transmute(1f64); +LL + let y: i64 = f64::to_bits(1f64).cast_signed(); | -LL | let z: bool = transmute(1u8); - | ^^^^^^^^^^^^^^ help: replace this with: `(1u8 == 1)` error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:86:21 + --> $DIR/unnecessary-transmutation.rs:106:21 | LL | let z: u8 = transmute(z); - | ^^^^^^^^^^^^ help: replace this with: `(z) as u8` + | ---------^^^ + | | + | help: replace this with: `u8::from` error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:91:21 + --> $DIR/unnecessary-transmutation.rs:111:21 | LL | let z: i8 = transmute(z); - | ^^^^^^^^^^^^ help: replace this with: `(z) as i8` + | ---------^^^ + | | + | help: replace this with: `i8::from` -error: aborting due to 36 previous errors +error: aborting due to 40 previous errors diff --git a/tests/ui/treat-err-as-bug/err.rs b/tests/ui/treat-err-as-bug/err.rs index 7868c06fee1..6f0e3c55fbb 100644 --- a/tests/ui/treat-err-as-bug/err.rs +++ b/tests/ui/treat-err-as-bug/err.rs @@ -7,7 +7,7 @@ #![crate_type = "rlib"] pub static C: u32 = 0 - 1; -//~^ ERROR could not evaluate static initializer +//~^ ERROR attempt to compute `0_u32 - 1_u32`, which would overflow //~? RAW aborting due to `-Z treat-err-as-bug=1` //~? RAW [eval_static_initializer] evaluating initializer of static `C` diff --git a/tests/ui/treat-err-as-bug/err.stderr b/tests/ui/treat-err-as-bug/err.stderr index 2049df22000..0052dd75626 100644 --- a/tests/ui/treat-err-as-bug/err.stderr +++ b/tests/ui/treat-err-as-bug/err.stderr @@ -1,8 +1,8 @@ -error: internal compiler error[E0080]: could not evaluate static initializer +error: internal compiler error[E0080]: attempt to compute `0_u32 - 1_u32`, which would overflow --> $DIR/err.rs:9:21 | LL | pub static C: u32 = 0 - 1; - | ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow + | ^^^^^ evaluation of `C` failed here error: the compiler unexpectedly panicked. this is a bug. diff --git a/tests/ui/type-alias-impl-trait/constrain_in_projection2.next.stderr b/tests/ui/type-alias-impl-trait/constrain_in_projection2.next.stderr index 7c09ab6a91a..72a253c4be8 100644 --- a/tests/ui/type-alias-impl-trait/constrain_in_projection2.next.stderr +++ b/tests/ui/type-alias-impl-trait/constrain_in_projection2.next.stderr @@ -2,7 +2,7 @@ error[E0283]: type annotations needed: cannot satisfy `Foo: Trait<Bar>` --> $DIR/constrain_in_projection2.rs:28:14 | LL | let x = <Foo as Trait<Bar>>::Assoc::default(); - | ^^^ help: use the fully qualified path to an implementation: `<Type as Trait>::Assoc` + | ^^^ | note: multiple `impl`s satisfying `Foo: Trait<Bar>` found --> $DIR/constrain_in_projection2.rs:18:1 @@ -13,6 +13,11 @@ LL | impl Trait<()> for Foo { LL | impl Trait<u32> for Foo { | ^^^^^^^^^^^^^^^^^^^^^^^ = note: associated types cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` +help: use the fully qualified path to an implementation + | +LL - let x = <Foo as Trait<Bar>>::Assoc::default(); +LL + let x = <<Type as Trait>::Assoc as Trait<Bar>>::Assoc::default(); + | error: aborting due to 1 previous error diff --git a/tests/ui/type-alias-impl-trait/constrain_inputs.stderr b/tests/ui/type-alias-impl-trait/constrain_inputs.stderr index b016715b129..cb299a2021e 100644 --- a/tests/ui/type-alias-impl-trait/constrain_inputs.stderr +++ b/tests/ui/type-alias-impl-trait/constrain_inputs.stderr @@ -25,19 +25,6 @@ LL | type BadTraitRef = dyn Fn(Ty<'_>) -> &str; = note: lifetimes appearing in an associated or opaque type are not considered constrained = note: consider introducing a named lifetime parameter -error: item does not constrain `lifetime_params::Ty::{opaque#0}` - --> $DIR/constrain_inputs.rs:8:8 - | -LL | fn execute(ty: Ty<'_>) -> &str { todo!() } - | ^^^^^^^ - | - = note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]` -note: this opaque type is supposed to be constrained - --> $DIR/constrain_inputs.rs:4:19 - | -LL | type Ty<'a> = impl Sized; - | ^^^^^^^^^^ - error[E0581]: return type references an anonymous lifetime, which is not constrained by the fn input types --> $DIR/constrain_inputs.rs:23:31 | @@ -47,19 +34,6 @@ LL | fn execute(ty: Ty<'_>) -> &str { ty() } = note: lifetimes appearing in an associated or opaque type are not considered constrained = note: consider introducing a named lifetime parameter -error: item does not constrain `lifetime_params_2::Ty::{opaque#0}` - --> $DIR/constrain_inputs.rs:23:8 - | -LL | fn execute(ty: Ty<'_>) -> &str { ty() } - | ^^^^^^^ - | - = note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]` -note: this opaque type is supposed to be constrained - --> $DIR/constrain_inputs.rs:19:19 - | -LL | type Ty<'a> = impl FnOnce() -> &'a str; - | ^^^^^^^^^^^^^^^^^^^^^^^^ - error[E0581]: return type references an anonymous lifetime, which is not constrained by the fn input types --> $DIR/constrain_inputs.rs:34:37 | @@ -78,6 +52,32 @@ LL | type BadTraitRef = dyn Fn(Ty<&str>) -> &str; = note: lifetimes appearing in an associated or opaque type are not considered constrained = note: consider introducing a named lifetime parameter +error: item does not constrain `lifetime_params::Ty::{opaque#0}` + --> $DIR/constrain_inputs.rs:8:8 + | +LL | fn execute(ty: Ty<'_>) -> &str { todo!() } + | ^^^^^^^ + | + = note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]` +note: this opaque type is supposed to be constrained + --> $DIR/constrain_inputs.rs:4:19 + | +LL | type Ty<'a> = impl Sized; + | ^^^^^^^^^^ + +error: item does not constrain `lifetime_params_2::Ty::{opaque#0}` + --> $DIR/constrain_inputs.rs:23:8 + | +LL | fn execute(ty: Ty<'_>) -> &str { ty() } + | ^^^^^^^ + | + = note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]` +note: this opaque type is supposed to be constrained + --> $DIR/constrain_inputs.rs:19:19 + | +LL | type Ty<'a> = impl FnOnce() -> &'a str; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + error: aborting due to 8 previous errors Some errors have detailed explanations: E0581, E0582. diff --git a/tests/ui/type-alias-impl-trait/in-where-clause.stderr b/tests/ui/type-alias-impl-trait/in-where-clause.stderr index 9fcb26c20a6..81be8c8362e 100644 --- a/tests/ui/type-alias-impl-trait/in-where-clause.stderr +++ b/tests/ui/type-alias-impl-trait/in-where-clause.stderr @@ -62,6 +62,11 @@ LL | / fn foo() -> Bar LL | | where LL | | Bar: Send, | |______________^ +note: ...which requires computing revealed normalized predicates of `foo::{constant#0}`... + --> $DIR/in-where-clause.rs:13:9 + | +LL | [0; 1 + 2] + | ^^^^^ = note: ...which requires revealing opaque types in `[Binder { value: TraitPredicate(<Bar as core::marker::Send>, polarity:Positive), bound_vars: [] }]`... note: ...which requires computing type of `Bar::{opaque#0}`... --> $DIR/in-where-clause.rs:5:12 diff --git a/tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.rs b/tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.rs index ef6871bec7c..0aaee5d1764 100644 --- a/tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.rs +++ b/tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.rs @@ -1,10 +1,10 @@ #![feature(type_alias_impl_trait)] type T = impl Copy; -//~^ ERROR cannot resolve opaque type #[define_opaque(T)] fn foo() -> T { + //~^ ERROR cannot resolve opaque type None::<&'static T> } diff --git a/tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.stderr b/tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.stderr index d820df472f9..426a6c29fff 100644 --- a/tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.stderr +++ b/tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.stderr @@ -1,8 +1,8 @@ error[E0720]: cannot resolve opaque type - --> $DIR/infinite-cycle-involving-weak.rs:3:10 + --> $DIR/infinite-cycle-involving-weak.rs:6:13 | -LL | type T = impl Copy; - | ^^^^^^^^^ cannot resolve opaque type +LL | fn foo() -> T { + | ^ error: aborting due to 1 previous error diff --git a/tests/ui/type-alias-impl-trait/issue-53678-coroutine-and-const-fn.rs b/tests/ui/type-alias-impl-trait/issue-53678-coroutine-and-const-fn.rs index f02ccbbb93c..b258d2e156d 100644 --- a/tests/ui/type-alias-impl-trait/issue-53678-coroutine-and-const-fn.rs +++ b/tests/ui/type-alias-impl-trait/issue-53678-coroutine-and-const-fn.rs @@ -1,4 +1,4 @@ -#![feature(coroutines, coroutine_trait, rustc_attrs)] +#![feature(coroutines, coroutine_trait, rustc_attrs, const_async_blocks)] #![feature(type_alias_impl_trait)] //@ check-pass diff --git a/tests/crashes/139817.rs b/tests/ui/type-alias-impl-trait/match-upvar-discriminant-of-opaque.rs index d439ed4cacb..f4e2cb0c037 100644 --- a/tests/crashes/139817.rs +++ b/tests/ui/type-alias-impl-trait/match-upvar-discriminant-of-opaque.rs @@ -1,8 +1,12 @@ -//@ known-bug: #139817 +#![feature(type_alias_impl_trait)] + fn enum_upvar() { type T = impl Copy; let foo: T = Some((42, std::marker::PhantomData::<T>)); let x = move || match foo { None => (), + //~^ ERROR cannot resolve opaque type }; } + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/match-upvar-discriminant-of-opaque.stderr b/tests/ui/type-alias-impl-trait/match-upvar-discriminant-of-opaque.stderr new file mode 100644 index 00000000000..2bfce2d63a8 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/match-upvar-discriminant-of-opaque.stderr @@ -0,0 +1,9 @@ +error[E0720]: cannot resolve opaque type + --> $DIR/match-upvar-discriminant-of-opaque.rs:7:9 + | +LL | None => (), + | ^^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0720`. diff --git a/tests/ui/type-alias-impl-trait/missing_lifetime_bound.rs b/tests/ui/type-alias-impl-trait/missing_lifetime_bound.rs index d77efa39aeb..60d9521621f 100644 --- a/tests/ui/type-alias-impl-trait/missing_lifetime_bound.rs +++ b/tests/ui/type-alias-impl-trait/missing_lifetime_bound.rs @@ -3,7 +3,7 @@ type Opaque2<T> = impl Sized; type Opaque<'a, T> = Opaque2<T>; #[define_opaque(Opaque)] -fn defining<'a, T>(x: &'a i32) -> Opaque<T> { x } //~ WARNING elided lifetime has a name +fn defining<'a, T>(x: &'a i32) -> Opaque<T> { x } //~^ ERROR: hidden type for `Opaque2<T>` captures lifetime that does not appear in bounds fn main() {} diff --git a/tests/ui/type-alias-impl-trait/missing_lifetime_bound.stderr b/tests/ui/type-alias-impl-trait/missing_lifetime_bound.stderr index 61eb76ffc5a..b73e6b8c101 100644 --- a/tests/ui/type-alias-impl-trait/missing_lifetime_bound.stderr +++ b/tests/ui/type-alias-impl-trait/missing_lifetime_bound.stderr @@ -1,13 +1,3 @@ -warning: elided lifetime has a name - --> $DIR/missing_lifetime_bound.rs:6:41 - | -LL | fn defining<'a, T>(x: &'a i32) -> Opaque<T> { x } - | -- ^ this elided lifetime gets resolved as `'a` - | | - | lifetime `'a` declared here - | - = note: `#[warn(elided_named_lifetimes)]` on by default - error[E0700]: hidden type for `Opaque2<T>` captures lifetime that does not appear in bounds --> $DIR/missing_lifetime_bound.rs:6:47 | @@ -19,6 +9,6 @@ LL | fn defining<'a, T>(x: &'a i32) -> Opaque<T> { x } | | | hidden type `&'a i32` captures the lifetime `'a` as defined here -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0700`. diff --git a/tests/ui/type-alias-impl-trait/recursive-fn-tait.rs b/tests/ui/type-alias-impl-trait/recursive-fn-tait.rs index 94597adfed0..fe354cc6545 100644 --- a/tests/ui/type-alias-impl-trait/recursive-fn-tait.rs +++ b/tests/ui/type-alias-impl-trait/recursive-fn-tait.rs @@ -13,7 +13,7 @@ pub fn add( n: Diff, m: Diff, ) -> Diff { - //~^ ERROR concrete type differs + //~^ ERROR cannot resolve opaque type move |x: usize| m(n(x)) } diff --git a/tests/ui/type-alias-impl-trait/recursive-fn-tait.stderr b/tests/ui/type-alias-impl-trait/recursive-fn-tait.stderr index 59ff9917612..847f1cc6c2e 100644 --- a/tests/ui/type-alias-impl-trait/recursive-fn-tait.stderr +++ b/tests/ui/type-alias-impl-trait/recursive-fn-tait.stderr @@ -1,14 +1,9 @@ -error: concrete type differs from previous defining opaque type use +error[E0720]: cannot resolve opaque type --> $DIR/recursive-fn-tait.rs:15:6 | LL | ) -> Diff { - | ^^^^ expected `{closure@$DIR/recursive-fn-tait.rs:8:5: 8:16}`, got `{closure@$DIR/recursive-fn-tait.rs:17:5: 17:20}` - | -note: previous use here - --> $DIR/recursive-fn-tait.rs:7:18 - | -LL | pub fn lift() -> Diff { - | ^^^^ + | ^^^^ error: aborting due to 1 previous error +For more information about this error, try `rustc --explain E0720`. diff --git a/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.rs b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.rs index 858f2a2feb6..7803b3b78db 100644 --- a/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.rs +++ b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.rs @@ -13,7 +13,7 @@ fn transform<S>() -> impl std::fmt::Display { } #[define_opaque(Op)] fn bad() -> Op { - //~^ ERROR concrete type differs from previous defining opaque type use + //~^ ERROR cannot resolve opaque type transform::<Op>() } diff --git a/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.stderr b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.stderr index e527b5bc7f8..837df7f5d43 100644 --- a/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.stderr +++ b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.stderr @@ -1,14 +1,9 @@ -error: concrete type differs from previous defining opaque type use +error[E0720]: cannot resolve opaque type --> $DIR/recursive-tait-conflicting-defn-2.rs:15:13 | LL | fn bad() -> Op { - | ^^ expected `&&str`, got `impl std::fmt::Display` - | -note: previous use here - --> $DIR/recursive-tait-conflicting-defn-2.rs:7:13 - | -LL | fn foo() -> Op { | ^^ error: aborting due to 1 previous error +For more information about this error, try `rustc --explain E0720`. diff --git a/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.rs b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.rs index 90581a98a34..d66ceda5234 100644 --- a/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.rs +++ b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.rs @@ -23,7 +23,7 @@ pub fn test() -> TestImpl { #[define_opaque(TestImpl)] fn make_option2() -> Option<TestImpl> { - //~^ ERROR concrete type differs from previous defining opaque type use + //~^ ERROR cannot resolve opaque type let inner = make_option().unwrap(); Some(B { inner }) } diff --git a/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.stderr b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.stderr index 256f13b6221..c7a3381d615 100644 --- a/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.stderr +++ b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.stderr @@ -1,14 +1,9 @@ -error: concrete type differs from previous defining opaque type use +error[E0720]: cannot resolve opaque type --> $DIR/recursive-tait-conflicting-defn.rs:25:22 | LL | fn make_option2() -> Option<TestImpl> { - | ^^^^^^^^^^^^^^^^ expected `A`, got `B<TestImpl>` - | -note: previous use here - --> $DIR/recursive-tait-conflicting-defn.rs:20:18 - | -LL | pub fn test() -> TestImpl { - | ^^^^^^^^ + | ^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error +For more information about this error, try `rustc --explain E0720`. diff --git a/tests/ui/type-id-higher-rank-2.rs b/tests/ui/type-id-higher-rank-2.rs index 4a76b737e8c..7b0c7b53940 100644 --- a/tests/ui/type-id-higher-rank-2.rs +++ b/tests/ui/type-id-higher-rank-2.rs @@ -5,7 +5,7 @@ use std::any::Any; struct Foo<'a>(&'a str); -fn good(s: &String) -> Foo { Foo(s) } +fn good(s: &String) -> Foo<'_> { Foo(s) } fn bad1(s: String) -> Option<&'static str> { let a: Box<dyn Any> = Box::new(good as fn(&String) -> Foo); diff --git a/tests/ui/type/pattern_types/literals.rs b/tests/ui/type/pattern_types/literals.rs index b2a83a2a8bd..fbca421aa9a 100644 --- a/tests/ui/type/pattern_types/literals.rs +++ b/tests/ui/type/pattern_types/literals.rs @@ -84,12 +84,12 @@ fn single_element_range_exclusive() -> pattern_type!(u32 is 0..1) { } fn empty_range_at_base_type_min() -> pattern_type!(u32 is 0..0) { - //~^ ERROR evaluation of constant value failed + //~^ ERROR evaluation panicked: exclusive range end at minimum value of type 0 } fn empty_range_at_base_type_min2() -> pattern_type!(u32 is 0..0) { - //~^ ERROR evaluation of constant value failed + //~^ ERROR evaluation panicked: exclusive range end at minimum value of type 1 } @@ -104,17 +104,17 @@ fn empty_range2() -> pattern_type!(u32 is 1..1) { } fn wraparound_range_at_base_ty_end() -> pattern_type!(u32 is 1..0) { - //~^ ERROR evaluation of constant value failed + //~^ ERROR evaluation panicked: exclusive range end at minimum value of type 1 } fn wraparound_range_at_base_ty_end2() -> pattern_type!(u32 is 1..0) { - //~^ ERROR evaluation of constant value failed + //~^ ERROR evaluation panicked: exclusive range end at minimum value of type 0 } fn wraparound_range_at_base_ty_end3() -> pattern_type!(u32 is 1..0) { - //~^ ERROR evaluation of constant value failed + //~^ ERROR evaluation panicked: exclusive range end at minimum value of type 2 } diff --git a/tests/ui/type/pattern_types/literals.stderr b/tests/ui/type/pattern_types/literals.stderr index 5c926742f3c..7ab7b81ac23 100644 --- a/tests/ui/type/pattern_types/literals.stderr +++ b/tests/ui/type/pattern_types/literals.stderr @@ -1,32 +1,32 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: exclusive range end at minimum value of type --> $DIR/literals.rs:86:62 | LL | fn empty_range_at_base_type_min() -> pattern_type!(u32 is 0..0) { - | ^ evaluation panicked: exclusive range end at minimum value of type + | ^ evaluation of `empty_range_at_base_type_min::{constant#1}` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: exclusive range end at minimum value of type --> $DIR/literals.rs:91:63 | LL | fn empty_range_at_base_type_min2() -> pattern_type!(u32 is 0..0) { - | ^ evaluation panicked: exclusive range end at minimum value of type + | ^ evaluation of `empty_range_at_base_type_min2::{constant#1}` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: exclusive range end at minimum value of type --> $DIR/literals.rs:106:65 | LL | fn wraparound_range_at_base_ty_end() -> pattern_type!(u32 is 1..0) { - | ^ evaluation panicked: exclusive range end at minimum value of type + | ^ evaluation of `wraparound_range_at_base_ty_end::{constant#1}` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: exclusive range end at minimum value of type --> $DIR/literals.rs:111:66 | LL | fn wraparound_range_at_base_ty_end2() -> pattern_type!(u32 is 1..0) { - | ^ evaluation panicked: exclusive range end at minimum value of type + | ^ evaluation of `wraparound_range_at_base_ty_end2::{constant#1}` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: exclusive range end at minimum value of type --> $DIR/literals.rs:116:66 | LL | fn wraparound_range_at_base_ty_end3() -> pattern_type!(u32 is 1..0) { - | ^ evaluation panicked: exclusive range end at minimum value of type + | ^ evaluation of `wraparound_range_at_base_ty_end3::{constant#1}` failed here error[E0308]: mismatched types --> $DIR/literals.rs:9:5 diff --git a/tests/ui/type/pattern_types/or_patterns.stderr b/tests/ui/type/pattern_types/or_patterns.stderr index 58ca585f4a9..a417e502e35 100644 --- a/tests/ui/type/pattern_types/or_patterns.stderr +++ b/tests/ui/type/pattern_types/or_patterns.stderr @@ -41,9 +41,8 @@ LL | let _: NonNegOneI8 = -128; error: layout_of((i8) is (i8::MIN..=-1 | 1..)) = Layout { size: Size(1 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -80,9 +79,8 @@ 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 { + align: AbiAlign { abi: Align(1 bytes), - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { diff --git a/tests/ui/type/pattern_types/range_patterns.rs b/tests/ui/type/pattern_types/range_patterns.rs index 21c1454d6cd..86b618a8d24 100644 --- a/tests/ui/type/pattern_types/range_patterns.rs +++ b/tests/ui/type/pattern_types/range_patterns.rs @@ -23,7 +23,7 @@ type EMPTY = pattern_type!(u32 is 1..1); //~ ERROR unknown layout #[rustc_layout(debug)] type WRAP = pattern_type!(u32 is 1..0); //~ ERROR unknown layout -//~^ ERROR: evaluation of constant value failed +//~^ ERROR: evaluation panicked: exclusive range end at minimum value of type #[rustc_layout(debug)] type WRAP2 = pattern_type!(u32 is 5..2); //~ ERROR unknown layout diff --git a/tests/ui/type/pattern_types/range_patterns.stderr b/tests/ui/type/pattern_types/range_patterns.stderr index a05995a33f9..abd8b87fffc 100644 --- a/tests/ui/type/pattern_types/range_patterns.stderr +++ b/tests/ui/type/pattern_types/range_patterns.stderr @@ -1,8 +1,7 @@ error: layout_of(NonZero<u32>) = Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -46,9 +45,8 @@ LL | type X = std::num::NonZeroU32; error: layout_of((u32) is 1..) = Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -85,9 +83,8 @@ LL | type Y = pattern_type!(u32 is 1..); error: layout_of(Option<(u32) is 1..>) = Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -125,9 +122,8 @@ error: layout_of(Option<(u32) is 1..>) = Layout { variants: [ Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -147,9 +143,8 @@ error: layout_of(Option<(u32) is 1..>) = Layout { }, Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -199,9 +194,8 @@ LL | type Z = Option<pattern_type!(u32 is 1..)>; error: layout_of(Option<NonZero<u32>>) = Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -239,9 +233,8 @@ error: layout_of(Option<NonZero<u32>>) = Layout { variants: [ Layout { size: Size(0 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $SOME_ALIGN, }, backend_repr: Memory { sized: true, @@ -261,9 +254,8 @@ error: layout_of(Option<NonZero<u32>>) = Layout { }, Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -313,9 +305,8 @@ LL | type A = Option<std::num::NonZeroU32>; error: layout_of(NonZeroU32New) = Layout { size: Size(4 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(4 bytes), - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -365,11 +356,11 @@ error: the type has an unknown layout LL | type EMPTY = pattern_type!(u32 is 1..1); | ^^^^^^^^^^ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: exclusive range end at minimum value of type --> $DIR/range_patterns.rs:25:37 | LL | type WRAP = pattern_type!(u32 is 1..0); - | ^ evaluation panicked: exclusive range end at minimum value of type + | ^ evaluation of `WRAP::{constant#1}` failed here error: the type has an unknown layout --> $DIR/range_patterns.rs:25:1 @@ -387,9 +378,8 @@ LL | type WRAP2 = pattern_type!(u32 is 5..2); error: layout_of((i8) is -10..=10) = Layout { size: Size(1 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { @@ -426,9 +416,8 @@ LL | type SIGN = pattern_type!(i8 is -10..=10); error: layout_of((i8) is i8::MIN..=0) = Layout { size: Size(1 bytes), - align: AbiAndPrefAlign { + align: AbiAlign { abi: Align(1 bytes), - pref: $SOME_ALIGN, }, backend_repr: Scalar( Initialized { diff --git a/tests/ui/type/pattern_types/reverse_range.rs b/tests/ui/type/pattern_types/reverse_range.rs index e698e9dd541..34c931e4e96 100644 --- a/tests/ui/type/pattern_types/reverse_range.rs +++ b/tests/ui/type/pattern_types/reverse_range.rs @@ -5,7 +5,6 @@ use std::pat::pattern_type; const NONE: pattern_type!(u8 is 1..0) = unsafe { std::mem::transmute(3_u8) }; -//~^ NOTE: exclusive range end at minimum value of type -//~| ERROR: evaluation of constant value failed +//~^ ERROR: exclusive range end at minimum value of type fn main() {} diff --git a/tests/ui/type/pattern_types/reverse_range.stderr b/tests/ui/type/pattern_types/reverse_range.stderr index 90f8ef3261a..6e6e34409a3 100644 --- a/tests/ui/type/pattern_types/reverse_range.stderr +++ b/tests/ui/type/pattern_types/reverse_range.stderr @@ -1,8 +1,8 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation panicked: exclusive range end at minimum value of type --> $DIR/reverse_range.rs:7:36 | LL | const NONE: pattern_type!(u8 is 1..0) = unsafe { std::mem::transmute(3_u8) }; - | ^ evaluation panicked: exclusive range end at minimum value of type + | ^ evaluation of `NONE::{constant#1}` failed here error: aborting due to 1 previous error diff --git a/tests/ui/type/pattern_types/validity.rs b/tests/ui/type/pattern_types/validity.rs index c61bb71ac25..a4e49692c98 100644 --- a/tests/ui/type/pattern_types/validity.rs +++ b/tests/ui/type/pattern_types/validity.rs @@ -8,32 +8,32 @@ use std::pat::pattern_type; const BAD: pattern_type!(u32 is 1..) = unsafe { std::mem::transmute(0) }; -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: constructing invalid value: encountered 0 const BAD_UNINIT: pattern_type!(u32 is 1..) = - //~^ ERROR: evaluation of constant value failed + //~^ ERROR: using uninitialized data, but this operation requires initialized memory unsafe { std::mem::transmute(std::mem::MaybeUninit::<u32>::uninit()) }; const BAD_PTR: pattern_type!(usize is 1..) = unsafe { std::mem::transmute(&42) }; -//~^ ERROR: evaluation of constant value failed +//~^ ERROR: unable to turn pointer into integer const BAD_AGGREGATE: (pattern_type!(u32 is 1..), u32) = (unsafe { std::mem::transmute(0) }, 0); -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: constructing invalid value at .0: encountered 0 struct Foo(Bar); struct Bar(pattern_type!(u32 is 1..)); const BAD_FOO: Foo = Foo(Bar(unsafe { std::mem::transmute(0) })); -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: constructing invalid value at .0.0: encountered 0 const CHAR_UNINIT: pattern_type!(char is 'A'..'Z') = - //~^ ERROR: evaluation of constant value failed + //~^ ERROR: using uninitialized data, but this operation requires initialized memory unsafe { std::mem::transmute(std::mem::MaybeUninit::<u32>::uninit()) }; const CHAR_OOB_PAT: pattern_type!(char is 'A'..'Z') = unsafe { std::mem::transmute('a') }; -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: constructing invalid value: encountered 97, but expected something in the range 65..=89 const CHAR_OOB: pattern_type!(char is 'A'..'Z') = unsafe { std::mem::transmute(u32::MAX) }; -//~^ ERROR: it is undefined behavior to use this value +//~^ ERROR: constructing invalid value: encountered 0xffffffff fn main() {} diff --git a/tests/ui/type/pattern_types/validity.stderr b/tests/ui/type/pattern_types/validity.stderr index b990ec2d368..4f4c16028f6 100644 --- a/tests/ui/type/pattern_types/validity.stderr +++ b/tests/ui/type/pattern_types/validity.stderr @@ -1,73 +1,73 @@ -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1 --> $DIR/validity.rs:10:1 | LL | const BAD: pattern_type!(u32 is 1..) = unsafe { std::mem::transmute(0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { HEX_DUMP } -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/validity.rs:13:1 | LL | const BAD_UNINIT: pattern_type!(u32 is 1..) = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_UNINIT` failed here -error[E0080]: evaluation of constant value failed +error[E0080]: unable to turn pointer into integer --> $DIR/validity.rs:17:1 | LL | const BAD_PTR: pattern_type!(usize is 1..) = unsafe { std::mem::transmute(&42) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_PTR` failed here | = help: this code performed an operation that depends on the underlying bytes representing a pointer = 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 +error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 --> $DIR/validity.rs:20:1 | LL | const BAD_AGGREGATE: (pattern_type!(u32 is 1..), u32) = (unsafe { std::mem::transmute(0) }, 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 4) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value at .0.0: encountered 0, but expected something greater or equal to 1 --> $DIR/validity.rs:26:1 | LL | const BAD_FOO: Foo = Foo(Bar(unsafe { std::mem::transmute(0) })); - | ^^^^^^^^^^^^^^^^^^ constructing invalid value at .0.0: encountered 0, but expected something greater or equal to 1 + | ^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { HEX_DUMP } -error[E0080]: evaluation of constant value failed +error[E0080]: using uninitialized data, but this operation requires initialized memory --> $DIR/validity.rs:29:1 | LL | const CHAR_UNINIT: pattern_type!(char is 'A'..'Z') = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `CHAR_UNINIT` failed here -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 97, but expected something in the range 65..=89 --> $DIR/validity.rs:33:1 | LL | const CHAR_OOB_PAT: pattern_type!(char is 'A'..'Z') = unsafe { std::mem::transmute('a') }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 97, but expected something in the range 65..=89 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { HEX_DUMP } -error[E0080]: it is undefined behavior to use this value +error[E0080]: constructing invalid value: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) --> $DIR/validity.rs:36:1 | LL | const CHAR_OOB: pattern_type!(char is 'A'..'Z') = unsafe { std::mem::transmute(u32::MAX) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { diff --git a/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.rs b/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.rs index 444453dc694..b877ef569f6 100644 --- a/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.rs +++ b/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.rs @@ -13,5 +13,4 @@ fn main() { let x: i32 = 5; let y = x as dyn MyAdd<i32>; //~^ ERROR E0038 - //~| ERROR cast to unsized type: `i32` as `dyn MyAdd<i32>` } diff --git a/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr b/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr index eea2e75a238..33478740d65 100644 --- a/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr +++ b/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr @@ -1,20 +1,8 @@ -error[E0620]: cast to unsized type: `i32` as `dyn MyAdd<i32>` - --> $DIR/type-parameter-defaults-referencing-Self-ppaux.rs:14:13 - | -LL | let y = x as dyn MyAdd<i32>; - | ^^^^^^^^^^^^^^^^^^^ - | -help: consider using a box or reference as appropriate - --> $DIR/type-parameter-defaults-referencing-Self-ppaux.rs:14:13 - | -LL | let y = x as dyn MyAdd<i32>; - | ^ - error[E0038]: the trait `MyAdd` is not dyn compatible - --> $DIR/type-parameter-defaults-referencing-Self-ppaux.rs:14:18 + --> $DIR/type-parameter-defaults-referencing-Self-ppaux.rs:14:22 | LL | let y = x as dyn MyAdd<i32>; - | ^^^^^^^^^^^^^^ `MyAdd` is not dyn compatible + | ^^^^^^^^^^ `MyAdd` 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> @@ -25,7 +13,6 @@ LL | trait MyAdd<Rhs=Self> { fn add(&self, other: &Rhs) -> Self; } = help: consider moving `add` to another trait = help: only type `i32` implements `MyAdd`; consider using it directly instead. -error: aborting due to 2 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0038, E0620. -For more information about an error, try `rustc --explain E0038`. +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/typeck/closure-ty-mismatch-issue-128561.rs b/tests/ui/typeck/closure-ty-mismatch-issue-128561.rs new file mode 100644 index 00000000000..589a90e71d6 --- /dev/null +++ b/tests/ui/typeck/closure-ty-mismatch-issue-128561.rs @@ -0,0 +1,10 @@ +fn main() { + b"abc".iter().for_each(|x| x); //~ ERROR: mismatched types + + b"abc".iter().for_each(|x| dbg!(x)); //~ ERROR: mismatched types + + b"abc".iter().for_each(|x| { + println!("{}", x); + x //~ ERROR: mismatched types + }) +} diff --git a/tests/ui/typeck/closure-ty-mismatch-issue-128561.stderr b/tests/ui/typeck/closure-ty-mismatch-issue-128561.stderr new file mode 100644 index 00000000000..31acc5bb10e --- /dev/null +++ b/tests/ui/typeck/closure-ty-mismatch-issue-128561.stderr @@ -0,0 +1,28 @@ +error[E0308]: mismatched types + --> $DIR/closure-ty-mismatch-issue-128561.rs:2:32 + | +LL | b"abc".iter().for_each(|x| x); + | ^ expected `()`, found `&u8` + | +help: consider ignoring the value + | +LL | b"abc".iter().for_each(|x| _ = x); + | +++ + +error[E0308]: mismatched types + --> $DIR/closure-ty-mismatch-issue-128561.rs:4:32 + | +LL | b"abc".iter().for_each(|x| dbg!(x)); + | ^^^^^^^ expected `()`, found `&u8` + | + = note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0308]: mismatched types + --> $DIR/closure-ty-mismatch-issue-128561.rs:8:9 + | +LL | x + | ^ expected `()`, found `&u8` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/consider-borrowing-141810-1.rs b/tests/ui/typeck/consider-borrowing-141810-1.rs new file mode 100644 index 00000000000..94c2d690915 --- /dev/null +++ b/tests/ui/typeck/consider-borrowing-141810-1.rs @@ -0,0 +1,9 @@ +fn main() { + let x = if true { + &true + } else if false { //~ ERROR `if` and `else` have incompatible types [E0308] + true //~ HELP consider borrowing here + } else { + true + }; +} diff --git a/tests/ui/typeck/consider-borrowing-141810-1.stderr b/tests/ui/typeck/consider-borrowing-141810-1.stderr new file mode 100644 index 00000000000..9291721ac71 --- /dev/null +++ b/tests/ui/typeck/consider-borrowing-141810-1.stderr @@ -0,0 +1,28 @@ +error[E0308]: `if` and `else` have incompatible types + --> $DIR/consider-borrowing-141810-1.rs:4:12 + | +LL | let x = if true { + | ______________- +LL | | &true + | | ----- expected because of this +LL | | } else if false { + | | ____________^ +LL | || true +LL | || } else { +LL | || true +LL | || }; + | || ^ + | ||_____| + | |_____`if` and `else` have incompatible types + | expected `&bool`, found `bool` + | +help: consider borrowing here + | +LL ~ &true +LL | } else { +LL ~ &true + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/consider-borrowing-141810-2.rs b/tests/ui/typeck/consider-borrowing-141810-2.rs new file mode 100644 index 00000000000..e32e689efb7 --- /dev/null +++ b/tests/ui/typeck/consider-borrowing-141810-2.rs @@ -0,0 +1,8 @@ +fn main() { + let x = if true { + &() + } else if false { //~ ERROR `if` and `else` have incompatible types [E0308] + } else { + }; + +} diff --git a/tests/ui/typeck/consider-borrowing-141810-2.stderr b/tests/ui/typeck/consider-borrowing-141810-2.stderr new file mode 100644 index 00000000000..dd229897283 --- /dev/null +++ b/tests/ui/typeck/consider-borrowing-141810-2.stderr @@ -0,0 +1,19 @@ +error[E0308]: `if` and `else` have incompatible types + --> $DIR/consider-borrowing-141810-2.rs:4:12 + | +LL | let x = if true { + | ______________- +LL | | &() + | | --- expected because of this +LL | | } else if false { + | | ____________^ +LL | || } else { +LL | || }; + | || ^ + | ||_____| + | |_____`if` and `else` have incompatible types + | expected `&()`, found `()` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/consider-borrowing-141810-3.rs b/tests/ui/typeck/consider-borrowing-141810-3.rs new file mode 100644 index 00000000000..d38828de7c1 --- /dev/null +++ b/tests/ui/typeck/consider-borrowing-141810-3.rs @@ -0,0 +1,7 @@ +fn main() { + let x = if true { + &() + } else if false { //~ ERROR `if` and `else` have incompatible types [E0308] + + }; +} diff --git a/tests/ui/typeck/consider-borrowing-141810-3.stderr b/tests/ui/typeck/consider-borrowing-141810-3.stderr new file mode 100644 index 00000000000..0b0c5f191a0 --- /dev/null +++ b/tests/ui/typeck/consider-borrowing-141810-3.stderr @@ -0,0 +1,22 @@ +error[E0308]: `if` and `else` have incompatible types + --> $DIR/consider-borrowing-141810-3.rs:4:12 + | +LL | let x = if true { + | ______________- +LL | | &() + | | --- expected because of this +LL | | } else if false { + | | ____________^ +LL | || +LL | || }; + | || ^ + | ||_____| + | |_____`if` and `else` have incompatible types + | expected `&()`, found `()` + | + = note: `if` expressions without `else` evaluate to `()` + = note: consider adding an `else` block that evaluates to the expected type + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/consider-borrowing-141810-4.rs b/tests/ui/typeck/consider-borrowing-141810-4.rs new file mode 100644 index 00000000000..754af7920a8 --- /dev/null +++ b/tests/ui/typeck/consider-borrowing-141810-4.rs @@ -0,0 +1,11 @@ +fn baz(x: &String) {} + +fn bar() { + baz({ + String::from("hi") //~ ERROR mismatched types + }); +} + +fn main() { + bar(); +} diff --git a/tests/ui/typeck/consider-borrowing-141810-4.stderr b/tests/ui/typeck/consider-borrowing-141810-4.stderr new file mode 100644 index 00000000000..80869d4a5d5 --- /dev/null +++ b/tests/ui/typeck/consider-borrowing-141810-4.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/consider-borrowing-141810-4.rs:5:9 + | +LL | String::from("hi") + | ^^^^^^^^^^^^^^^^^^ expected `&String`, found `String` + | +help: consider borrowing here + | +LL | &String::from("hi") + | + + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/ice-unexpected-region-123863.stderr b/tests/ui/typeck/ice-unexpected-region-123863.stderr index 8a4d767c143..e5050b4d316 100644 --- a/tests/ui/typeck/ice-unexpected-region-123863.stderr +++ b/tests/ui/typeck/ice-unexpected-region-123863.stderr @@ -39,7 +39,7 @@ LL | Inner::concat_strs::<"a">::A help: if there were a trait named `Example` with associated type `concat_strs` implemented for `Inner<_>`, you could use the fully-qualified path | LL - Inner::concat_strs::<"a">::A -LL + <Inner<_> as Example>::concat_strs::A +LL + <Inner<_> as Example>::concat_strs::<"a">::A | error: aborting due to 3 previous errors diff --git a/tests/ui/typeck/issue-107087.stderr b/tests/ui/typeck/issue-107087.stderr index 289c8d161ae..157ba5a1672 100644 --- a/tests/ui/typeck/issue-107087.stderr +++ b/tests/ui/typeck/issue-107087.stderr @@ -2,7 +2,13 @@ error[E0223]: ambiguous associated type --> $DIR/issue-107087.rs:16:5 | LL | A::B::<>::C - | ^^^^^^^^ help: use fully-qualified syntax: `<A<_> as Foo>::B` + | ^^^^^^^^ + | +help: use fully-qualified syntax + | +LL - A::B::<>::C +LL + <A<_> as Foo>::B::<>::C + | error: aborting due to 1 previous error diff --git a/tests/ui/typeck/issue-31173.stderr b/tests/ui/typeck/issue-31173.stderr index 9598bc61352..5815da4dea9 100644 --- a/tests/ui/typeck/issue-31173.stderr +++ b/tests/ui/typeck/issue-31173.stderr @@ -21,7 +21,7 @@ LL | | }) note: required by a bound in `cloned` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL -error[E0599]: the method `collect` exists for struct `Cloned<TakeWhile<&mut IntoIter<u8>, {closure@issue-31173.rs:7:21}>>`, but its trait bounds were not satisfied +error[E0599]: the method `collect` exists for struct `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, {closure@$DIR/issue-31173.rs:7:21: 7:25}>>`, but its trait bounds were not satisfied --> $DIR/issue-31173.rs:12:10 | LL | let temp: Vec<u8> = it diff --git a/tests/ui/ufcs/ufcs-partially-resolved.stderr b/tests/ui/ufcs/ufcs-partially-resolved.stderr index 0a9c190cb35..69d6bd74a73 100644 --- a/tests/ui/ufcs/ufcs-partially-resolved.stderr +++ b/tests/ui/ufcs/ufcs-partially-resolved.stderr @@ -235,8 +235,6 @@ LL | <u8 as Dr>::X; | ^^^^^^^^^^^^- | | | help: an associated function with a similar name exists: `Z` - | - = note: can't use a type alias as a constructor error[E0575]: expected associated type, found associated function `Dr::Z` --> $DIR/ufcs-partially-resolved.rs:54:12 diff --git a/tests/ui/unboxed-closures/fn-traits-hrtb-coercion.rs b/tests/ui/unboxed-closures/fn-traits-hrtb-coercion.rs new file mode 100644 index 00000000000..4a08bf28bf3 --- /dev/null +++ b/tests/ui/unboxed-closures/fn-traits-hrtb-coercion.rs @@ -0,0 +1,39 @@ +//! Test for issue <github.com/rust-lang/rust/issues/30904> +//! Related to higher-ranked lifetime inference with unboxed closures and FnOnce. + +#![feature(fn_traits, unboxed_closures)] + +fn test<F: for<'x> FnOnce<(&'x str,)>>(_: F) {} + +struct Compose<F, G>(F, G); + +impl<T, F, G> FnOnce<(T,)> for Compose<F, G> +where + F: FnOnce<(T,)>, + G: FnOnce<(F::Output,)>, +{ + type Output = G::Output; + extern "rust-call" fn call_once(self, (x,): (T,)) -> G::Output { + (self.1)((self.0)(x)) + } +} + +struct Str<'a>(&'a str); + +fn mk_str<'a>(s: &'a str) -> Str<'a> { + Str(s) +} + +fn main() { + let _: for<'a> fn(&'a str) -> Str<'a> = mk_str; + let _: for<'a> fn(&'a str) -> Str<'a> = Str; + //~^ ERROR: mismatched types + + test(|_: &str| {}); + test(mk_str); + test(Str); + + test(Compose(|_: &str| {}, |_| {})); + test(Compose(mk_str, |_| {})); + test(Compose(Str, |_| {})); +} diff --git a/tests/ui/unboxed-closures/fn-traits-hrtb-coercion.stderr b/tests/ui/unboxed-closures/fn-traits-hrtb-coercion.stderr new file mode 100644 index 00000000000..a31d99f45d5 --- /dev/null +++ b/tests/ui/unboxed-closures/fn-traits-hrtb-coercion.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/fn-traits-hrtb-coercion.rs:29:45 + | +LL | let _: for<'a> fn(&'a str) -> Str<'a> = Str; + | ------------------------------ ^^^ one type is more general than the other + | | + | expected due to this + | + = note: expected fn pointer `for<'a> fn(&'a _) -> Str<'a>` + found struct constructor `fn(&_) -> Str<'_> {Str::<'_>}` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.stderr b/tests/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.stderr index 4d5e6f47965..db5a49d2b34 100644 --- a/tests/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.stderr +++ b/tests/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `call` found for closure `{closure@$DIR/unboxed-cl --> $DIR/unboxed-closures-static-call-wrong-trait.rs:7:10 | LL | mut_.call((0, )); - | ^^^^ method not found in `{closure@unboxed-closures-static-call-wrong-trait.rs:6:26}` + | ^^^^ method not found in `{closure@$DIR/unboxed-closures-static-call-wrong-trait.rs:6:26: 6:29}` error: aborting due to 1 previous error diff --git a/tests/ui/underscore-lifetimes.rs b/tests/ui/underscore-lifetimes.rs index 6174f8ce036..a372851f9cf 100644 --- a/tests/ui/underscore-lifetimes.rs +++ b/tests/ui/underscore-lifetimes.rs @@ -1,6 +1,6 @@ //@ run-pass -#![allow(dead_code)] +#![allow(dead_code, mismatched_lifetime_syntaxes)] struct Foo<'a>(&'a u8); fn foo(x: &u8) -> Foo<'_> { diff --git a/tests/ui/unsafe-binders/cat-projection.rs b/tests/ui/unsafe-binders/cat-projection.rs new file mode 100644 index 00000000000..0ce8579a688 --- /dev/null +++ b/tests/ui/unsafe-binders/cat-projection.rs @@ -0,0 +1,24 @@ +//@ revisions: e2015 e2021 +//@[e2015] edition: 2015 +//@[e2021] edition: 2021 +//@ check-pass + +#![feature(unsafe_binders)] +#![allow(incomplete_features)] + +use std::unsafe_binder::unwrap_binder; + +#[derive(Copy, Clone)] +pub struct S([usize; 8]); + +// Regression test for <https://github.com/rust-lang/rust/issues/141418>. +pub fn by_value(x: unsafe<'a> S) -> usize { + unsafe { (|| unwrap_binder!(x).0[0])() } +} + +// Regression test for <https://github.com/rust-lang/rust/issues/141417>. +pub fn by_ref(x: unsafe<'a> &'a S) -> usize { + unsafe { (|| unwrap_binder!(x).0[0])() } +} + +fn main() {} diff --git a/tests/ui/unsafe-binders/non-strucutral-type-diag.rs b/tests/ui/unsafe-binders/non-strucutral-type-diag.rs new file mode 100644 index 00000000000..e021e9567e5 --- /dev/null +++ b/tests/ui/unsafe-binders/non-strucutral-type-diag.rs @@ -0,0 +1,17 @@ +// regression test for <https://github.com/rust-lang/rust/issues/141422>. + +#![feature(unsafe_binders)] +#![allow(incomplete_features)] + +#[derive(Copy, Clone)] +struct Adt<'a>(&'a ()); + +const C: Option<(unsafe<'a> Adt<'a>, Box<dyn Send>)> = None; + +fn main() { + match None { + C => {} + //~^ ERROR constant of non-structural type + _ => {} + } +} diff --git a/tests/ui/unsafe-binders/non-strucutral-type-diag.stderr b/tests/ui/unsafe-binders/non-strucutral-type-diag.stderr new file mode 100644 index 00000000000..ab23210b2e5 --- /dev/null +++ b/tests/ui/unsafe-binders/non-strucutral-type-diag.stderr @@ -0,0 +1,13 @@ +error: constant of non-structural type `Option<(unsafe<'a> Adt<'a>, Box<dyn Send>)>` in a pattern + --> $DIR/non-strucutral-type-diag.rs:13:9 + | +LL | const C: Option<(unsafe<'a> Adt<'a>, Box<dyn Send>)> = None; + | ---------------------------------------------------- constant defined here +... +LL | C => {} + | ^ constant of non-structural type + | + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details + +error: aborting due to 1 previous error + diff --git a/tests/ui/unsafe-binders/unused-lifetimes-2.fixed b/tests/ui/unsafe-binders/unused-lifetimes-2.fixed new file mode 100644 index 00000000000..714a5fdaf03 --- /dev/null +++ b/tests/ui/unsafe-binders/unused-lifetimes-2.fixed @@ -0,0 +1,20 @@ +// regression test for #141758 +//@ run-rustfix +//@ check-pass + +#![warn(unused_lifetimes)] +#![allow(incomplete_features, unused_imports, dead_code)] +#![feature(unsafe_binders)] + +use std::unsafe_binder::unwrap_binder; + +#[derive(Copy, Clone)] +pub struct S([usize; 8]); + +// Regression test for <https://github.com/rust-lang/rust/issues/141418>. +pub fn by_value(_x: unsafe<'a> &'a S) -> usize { + //~^ WARN lifetime parameter `'b` never used + 0 +} + +fn main() {} diff --git a/tests/ui/unsafe-binders/unused-lifetimes-2.rs b/tests/ui/unsafe-binders/unused-lifetimes-2.rs new file mode 100644 index 00000000000..5b34cf91163 --- /dev/null +++ b/tests/ui/unsafe-binders/unused-lifetimes-2.rs @@ -0,0 +1,20 @@ +// regression test for #141758 +//@ run-rustfix +//@ check-pass + +#![warn(unused_lifetimes)] +#![allow(incomplete_features, unused_imports, dead_code)] +#![feature(unsafe_binders)] + +use std::unsafe_binder::unwrap_binder; + +#[derive(Copy, Clone)] +pub struct S([usize; 8]); + +// Regression test for <https://github.com/rust-lang/rust/issues/141418>. +pub fn by_value(_x: unsafe<'a, 'b> &'a S) -> usize { + //~^ WARN lifetime parameter `'b` never used + 0 +} + +fn main() {} diff --git a/tests/ui/unsafe-binders/unused-lifetimes-2.stderr b/tests/ui/unsafe-binders/unused-lifetimes-2.stderr new file mode 100644 index 00000000000..bca8a15d56b --- /dev/null +++ b/tests/ui/unsafe-binders/unused-lifetimes-2.stderr @@ -0,0 +1,16 @@ +warning: lifetime parameter `'b` never used + --> $DIR/unused-lifetimes-2.rs:15:32 + | +LL | pub fn by_value(_x: unsafe<'a, 'b> &'a S) -> usize { + | --^^ + | | + | help: elide the unused lifetime + | +note: the lint level is defined here + --> $DIR/unused-lifetimes-2.rs:5:9 + | +LL | #![warn(unused_lifetimes)] + | ^^^^^^^^^^^^^^^^ + +warning: 1 warning emitted + diff --git a/tests/ui/unsafe-binders/unused-lifetimes.fixed b/tests/ui/unsafe-binders/unused-lifetimes.fixed new file mode 100644 index 00000000000..4295b6a848c --- /dev/null +++ b/tests/ui/unsafe-binders/unused-lifetimes.fixed @@ -0,0 +1,20 @@ +// regression test for #141758 +//@ run-rustfix +//@ check-pass + +#![warn(unused_lifetimes)] +#![allow(incomplete_features, unused_imports, dead_code)] +#![feature(unsafe_binders)] + +use std::unsafe_binder::unwrap_binder; + +#[derive(Copy, Clone)] +pub struct S([usize; 8]); + +// Regression test for <https://github.com/rust-lang/rust/issues/141418>. +pub fn by_value(_x: S) -> usize { + //~^ WARN lifetime parameter `'a` never used + 0 +} + +fn main() {} diff --git a/tests/ui/unsafe-binders/unused-lifetimes.rs b/tests/ui/unsafe-binders/unused-lifetimes.rs new file mode 100644 index 00000000000..b1382328318 --- /dev/null +++ b/tests/ui/unsafe-binders/unused-lifetimes.rs @@ -0,0 +1,20 @@ +// regression test for #141758 +//@ run-rustfix +//@ check-pass + +#![warn(unused_lifetimes)] +#![allow(incomplete_features, unused_imports, dead_code)] +#![feature(unsafe_binders)] + +use std::unsafe_binder::unwrap_binder; + +#[derive(Copy, Clone)] +pub struct S([usize; 8]); + +// Regression test for <https://github.com/rust-lang/rust/issues/141418>. +pub fn by_value(_x: unsafe<'a> S) -> usize { + //~^ WARN lifetime parameter `'a` never used + 0 +} + +fn main() {} diff --git a/tests/ui/unsafe-binders/unused-lifetimes.stderr b/tests/ui/unsafe-binders/unused-lifetimes.stderr new file mode 100644 index 00000000000..d9a5216301f --- /dev/null +++ b/tests/ui/unsafe-binders/unused-lifetimes.stderr @@ -0,0 +1,14 @@ +warning: lifetime parameter `'a` never used + --> $DIR/unused-lifetimes.rs:15:28 + | +LL | pub fn by_value(_x: unsafe<'a> S) -> usize { + | -------^^-- help: elide the unused lifetime + | +note: the lint level is defined here + --> $DIR/unused-lifetimes.rs:5:9 + | +LL | #![warn(unused_lifetimes)] + | ^^^^^^^^^^^^^^^^ + +warning: 1 warning emitted + diff --git a/tests/ui/unsafe/move-out-of-non-copy.rs b/tests/ui/unsafe/move-out-of-non-copy.rs new file mode 100644 index 00000000000..ca6bf4277a1 --- /dev/null +++ b/tests/ui/unsafe/move-out-of-non-copy.rs @@ -0,0 +1,15 @@ +//@ compile-flags: -Zvalidate-mir + +// Regression test for <https://github.com/rust-lang/rust/issues/141394>. + +#![feature(unsafe_binders)] +#![allow(incomplete_features)] + +use std::unsafe_binder::unwrap_binder; + +fn id<T>(x: unsafe<> T) -> T { + //~^ ERROR the trait bound `T: Copy` is not satisfied + unsafe { unwrap_binder!(x) } +} + +fn main() {} diff --git a/tests/ui/unsafe/move-out-of-non-copy.stderr b/tests/ui/unsafe/move-out-of-non-copy.stderr new file mode 100644 index 00000000000..4598742c92b --- /dev/null +++ b/tests/ui/unsafe/move-out-of-non-copy.stderr @@ -0,0 +1,14 @@ +error[E0277]: the trait bound `T: Copy` is not satisfied + --> $DIR/move-out-of-non-copy.rs:10:13 + | +LL | fn id<T>(x: unsafe<> T) -> T { + | ^^^^^^^^^^ the trait `Copy` is not implemented for `T` + | +help: consider restricting type parameter `T` with trait `Copy` + | +LL | fn id<T: std::marker::Copy>(x: unsafe<> T) -> T { + | +++++++++++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/wf/wf-dyn-incompatible.stderr b/tests/ui/wf/wf-dyn-incompatible.stderr index e61b37d9293..2ba17b7aaef 100644 --- a/tests/ui/wf/wf-dyn-incompatible.stderr +++ b/tests/ui/wf/wf-dyn-incompatible.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `A` is not dyn compatible - --> $DIR/wf-dyn-incompatible.rs:9:13 + --> $DIR/wf-dyn-incompatible.rs:9:18 | LL | let _x: &dyn A; - | ^^^^^^ `A` is not dyn compatible + | ^ `A` 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> |
