diff options
Diffstat (limited to 'tests')
290 files changed, 2580 insertions, 2113 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/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/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/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/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/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/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/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/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/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/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_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..597f02e837a 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,10 +6,10 @@ 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; 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..597f02e837a 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,10 +6,10 @@ 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; 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..e34723898e4 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,7 +7,7 @@ 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; 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..e34723898e4 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,7 +7,7 @@ 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; 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/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/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/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/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-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..7e6f8dec5ed --- /dev/null +++ b/tests/rustdoc-ui/doc-cfg-check-cfg.cfg_empty.stderr @@ -0,0 +1,12 @@ +warning: unexpected `cfg` condition name: `foo` + --> $DIR/doc-cfg-check-cfg.rs:13: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 + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: 1 warning emitted + diff --git a/tests/rustdoc-ui/doc-cfg-check-cfg.rs b/tests/rustdoc-ui/doc-cfg-check-cfg.rs index e3420dc0789..6bb520b0726 100644 --- a/tests/rustdoc-ui/doc-cfg-check-cfg.rs +++ b/tests/rustdoc-ui/doc-cfg-check-cfg.rs @@ -1,16 +1,21 @@ // 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` pub fn 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..48c8e79ce96 100644 --- a/tests/rustdoc-ui/doc-cfg.stderr +++ b/tests/rustdoc-ui/doc-cfg.stderr @@ -10,17 +10,37 @@ error: multiple `cfg` predicates are specified LL | #[doc(cfg(), cfg(foo, bar))] | ^^^ +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: `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 +error: aborting due to 4 previous errors; 2 warnings emitted 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/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/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/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/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/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/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/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/dyn/mut-is-pointer-like.stderr b/tests/ui/async-await/dyn/mut-is-pointer-like.stderr index 07c3fd3527f..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,24 +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: 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/dyn/works.stderr b/tests/ui/async-await/dyn/works.stderr index 1fe2b28eca8..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,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/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: 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/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-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/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/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/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/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/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/const-ptr/forbidden_slices.stderr b/tests/ui/const-ptr/forbidden_slices.stderr index c73d2ca938c..e618fbf7e0f 100644 --- a/tests/ui/const-ptr/forbidden_slices.stderr +++ b/tests/ui/const-ptr/forbidden_slices.stderr @@ -104,20 +104,12 @@ error[E0080]: could not evaluate static initializer | 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 error[E0080]: could not evaluate static initializer --> $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 error[E0080]: it is undefined behavior to use this value --> $DIR/forbidden_slices.rs:57:1 @@ -170,31 +162,18 @@ error[E0080]: could not evaluate static initializer | 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 error[E0080]: could not evaluate static initializer --> $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 error[E0080]: could not evaluate static initializer --> $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 error: aborting due to 18 previous errors diff --git a/tests/ui/const-ptr/out_of_bounds_read.stderr b/tests/ui/const-ptr/out_of_bounds_read.stderr index 1d625a26b78..8f93793802b 100644 --- a/tests/ui/const-ptr/out_of_bounds_read.stderr +++ b/tests/ui/const-ptr/out_of_bounds_read.stderr @@ -3,31 +3,18 @@ error[E0080]: evaluation of constant value failed | 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 error[E0080]: evaluation of constant value failed --> $DIR/out_of_bounds_read.rs:10:39 | LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() }; | ^^^^^^^^^^^^^^^^^^^ memory access failed: 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 error[E0080]: evaluation of constant value failed --> $DIR/out_of_bounds_read.rs:12:37 | LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: 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 error: aborting due to 3 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/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-pointer-ub.rs b/tests/ui/consts/const-eval/raw-pointer-ub.rs index 1383de63109..1e76104d515 100644 --- a/tests/ui/consts/const-eval/raw-pointer-ub.rs +++ b/tests/ui/consts/const-eval/raw-pointer-ub.rs @@ -18,7 +18,6 @@ const MISALIGNED_COPY: () = unsafe { 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 `std::ptr::copy_nonoverlapping::<u32>` //~| NOTE accessing memory with alignment 1, but alignment 4 is required // The actual error points into the implementation of `copy_to_nonoverlapping`. diff --git a/tests/ui/consts/const-eval/raw-pointer-ub.stderr b/tests/ui/consts/const-eval/raw-pointer-ub.stderr index 0f3dc33f3a3..01a8decc93b 100644 --- a/tests/ui/consts/const-eval/raw-pointer-ub.stderr +++ b/tests/ui/consts/const-eval/raw-pointer-ub.stderr @@ -16,19 +16,17 @@ error[E0080]: evaluation of constant value failed LL | y.copy_to_nonoverlapping(&mut z, 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ accessing memory with alignment 1, but alignment 4 is required | -note: inside `std::ptr::const_ptr::<impl *const u32>::copy_to_nonoverlapping` - --> $SRC_DIR/core/src/ptr/const_ptr.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 + --> $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 error[E0080]: evaluation of constant value failed - --> $DIR/raw-pointer-ub.rs:41:16 + --> $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 diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.stderr b/tests/ui/consts/const-eval/ub-ref-ptr.stderr index de5e721c3f7..cfec1a42f28 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.stderr +++ b/tests/ui/consts/const-eval/ub-ref-ptr.stderr @@ -153,11 +153,6 @@ error[E0080]: evaluation of constant value failed | 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 error: aborting due to 15 previous errors 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_unsafe_unreachable_ub.rs b/tests/ui/consts/const_unsafe_unreachable_ub.rs index a3f7fd46a75..76c6c56d7c5 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` 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..42bf69aded0 100644 --- a/tests/ui/consts/const_unsafe_unreachable_ub.stderr +++ b/tests/ui/consts/const_unsafe_unreachable_ub.stderr @@ -1,5 +1,5 @@ error[E0080]: evaluation of constant value failed - --> $DIR/const_unsafe_unreachable_ub.rs:8:28 + --> $DIR/const_unsafe_unreachable_ub.rs:10:28 | LL | const BAR: bool = unsafe { foo(false) }; | ^^^^^^^^^^ entering unreachable code @@ -8,9 +8,7 @@ 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/issue-miri-1910.stderr b/tests/ui/consts/issue-miri-1910.stderr index 59cbccc13a7..52edad0c389 100644 --- a/tests/ui/consts/issue-miri-1910.stderr +++ b/tests/ui/consts/issue-miri-1910.stderr @@ -4,10 +4,6 @@ error[E0080]: evaluation of constant value failed LL | (&foo as *const _ as *const u8).add(one_and_a_half_pointers).read(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | -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/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/missing_span_in_backtrace.stderr b/tests/ui/consts/missing_span_in_backtrace.stderr index 7c07710332b..f802138c613 100644 --- a/tests/ui/consts/missing_span_in_backtrace.stderr +++ b/tests/ui/consts/missing_span_in_backtrace.stderr @@ -8,8 +8,6 @@ error[E0080]: evaluation of constant value failed 18 | | ); | |_________^ unable to copy parts of a pointer from memory at ALLOC0 | -note: inside `swap_nonoverlapping::<MaybeUninit<u8>>` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL 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>>` @@ -18,7 +16,6 @@ note: inside `std::ptr::copy_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: 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) error: aborting due to 1 previous error diff --git a/tests/ui/consts/offset_ub.stderr b/tests/ui/consts/offset_ub.stderr index 699b63dfd66..31a2a36a669 100644 --- a/tests/ui/consts/offset_ub.stderr +++ b/tests/ui/consts/offset_ub.stderr @@ -3,99 +3,66 @@ error[E0080]: evaluation of constant value failed | 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 error[E0080]: evaluation of constant value failed --> $DIR/offset_ub.rs:9:43 | LL | pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 error[E0080]: evaluation of constant value failed --> $DIR/offset_ub.rs:10:45 | LL | pub const AFTER_ARRAY: *const u8 = unsafe { [0u8; 100].as_ptr().offset(101) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 error[E0080]: evaluation of constant value failed --> $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 error[E0080]: evaluation of constant value failed --> $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 error[E0080]: evaluation of constant value failed --> $DIR/offset_ub.rs:14:56 | LL | pub const OVERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (usize::MAX as *const u8).offset(2) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 error[E0080]: evaluation of constant value failed --> $DIR/offset_ub.rs:15:57 | LL | pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).offset(-2) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 error[E0080]: evaluation of constant value failed --> $DIR/offset_ub.rs:16:49 | LL | pub const NEGATIVE_OFFSET: *const u8 = unsafe { [0u8; 1].as_ptr().wrapping_offset(-2).offset(-2) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 error[E0080]: evaluation of constant value failed --> $DIR/offset_ub.rs:18:50 | LL | pub const ZERO_SIZED_ALLOC: *const u8 = unsafe { [0u8; 0].as_ptr().offset(1) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 error[E0080]: evaluation of constant value failed --> $DIR/offset_ub.rs:19:42 | LL | pub const DANGLING: *const u8 = unsafe { ptr::NonNull::<u8>::dangling().as_ptr().offset(4) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 error[E0080]: evaluation of constant value failed --> $DIR/offset_ub.rs:22:47 | LL | pub const UNDERFLOW_ABS: *const u8 = unsafe { (usize::MAX as *const u8).offset(isize::MIN) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 error: aborting due to 11 previous errors 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..1375ac751f2 100644 --- a/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr @@ -8,9 +8,7 @@ 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..1375ac751f2 100644 --- a/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr @@ -8,9 +8,7 @@ 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/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..b7470864a30 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 @@ -4,4 +4,5 @@ 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..57dbc79a0fd 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 @@ -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:4: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[E0038]: the trait `Copy` is not dyn compatible + --> $DIR/trait-object-reference-without-parens-suggestion.rs:6: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 3 previous errors +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/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/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/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/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-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-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/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/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/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-const-items/def-site-eval.fail.stderr b/tests/ui/generic-const-items/def-site-eval.fail.stderr index fa07f385522..4e7d9d8154a 100644 --- a/tests/ui/generic-const-items/def-site-eval.fail.stderr +++ b/tests/ui/generic-const-items/def-site-eval.fail.stderr @@ -1,5 +1,5 @@ -error[E0080]: evaluation of `_::<'_>` failed - --> $DIR/def-site-eval.rs:14:20 +error[E0080]: evaluation of constant value failed + --> $DIR/def-site-eval.rs:13:20 | LL | const _<'_a>: () = panic!(); | ^^^^^^^^ evaluation panicked: explicit panic diff --git a/tests/ui/generic-const-items/def-site-eval.rs b/tests/ui/generic-const-items/def-site-eval.rs index 3ed7f96aed0..b95e40c05d4 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 of constant value failed 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/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/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/in-trait/dyn-compatibility.rs b/tests/ui/impl-trait/in-trait/dyn-compatibility.rs index 92203c470bb..45b431f6d30 100644 --- a/tests/ui/impl-trait/in-trait/dyn-compatibility.rs +++ b/tests/ui/impl-trait/in-trait/dyn-compatibility.rs @@ -13,6 +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(); } diff --git a/tests/ui/impl-trait/in-trait/dyn-compatibility.stderr b/tests/ui/impl-trait/in-trait/dyn-compatibility.stderr index 5c498548aff..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,24 +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: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 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/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/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/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/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/issues/issue-18959.rs b/tests/ui/issues/issue-18959.rs index dbc73bafce9..415fe818f53 100644 --- a/tests/ui/issues/issue-18959.rs +++ b/tests/ui/issues/issue-18959.rs @@ -17,6 +17,6 @@ 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 7ddfdb49d95..df47d50a019 100644 --- a/tests/ui/issues/issue-18959.stderr +++ b/tests/ui/issues/issue-18959.stderr @@ -15,10 +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:18: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> @@ -29,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:18: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> 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-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-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-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-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/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/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/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/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/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/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/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/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/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/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/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/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..d974f5add50 --- /dev/null +++ b/tests/ui/repeat-expr/copy-check-when-count-inferred-later.stderr @@ -0,0 +1,14 @@ +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` + | help: create an inline `const` block: `const { String::new() }` + | + = note: the `Copy` trait is required because this value will be copied for each element of the array + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. 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/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/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/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/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 1d3d8cb9843..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,7 +193,7 @@ 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; | ^^^^ @@ -239,7 +205,7 @@ 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; | ^^^^ @@ -251,7 +217,7 @@ 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 @@ -260,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 @@ -268,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/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 4ee880da87a..1b7fc55b99a 100644 --- a/tests/ui/traits/test-2.rs +++ b/tests/ui/traits/test-2.rs @@ -12,5 +12,4 @@ fn main() { //~^ ERROR method takes 1 generic argument but 2 (Box::new(10) as Box<dyn bar>).dup(); //~^ ERROR E0038 - //~| ERROR E0038 } diff --git a/tests/ui/traits/test-2.stderr b/tests/ui/traits/test-2.stderr index b52839c300e..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,31 +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: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 4 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/transmute/unnecessary-transmutation.stderr b/tests/ui/transmute/unnecessary-transmutation.stderr index 602e964f5b2..0132ac4776b 100644 --- a/tests/ui/transmute/unnecessary-transmutation.stderr +++ b/tests/ui/transmute/unnecessary-transmutation.stderr @@ -1,9 +1,12 @@ error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:16:29 + --> $DIR/unnecessary-transmutation.rs:7:14 | -LL | pub static X: u8 = unsafe { transmute(true) }; - | ^^^^^^^^^^^^^^^ help: replace this with: `(true) as u8` +LL | unsafe { transmute(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 --> $DIR/unnecessary-transmutation.rs:2:9 | @@ -11,36 +14,72 @@ LL | #![deny(unnecessary_transmutes)] | ^^^^^^^^^^^^^^^^^^^^^^ error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:18:28 + --> $DIR/unnecessary-transmutation.rs:12:14 + | +LL | unsafe { transmute(from) } + | ^^^^^^^^^^^^^^^ + | +help: replace this with + | +LL - unsafe { transmute(from) } +LL + unsafe { (from) as u8 } | -LL | pub const Y: u8 = unsafe { transmute(true) }; - | ^^^^^^^^^^^^^^^ help: replace this with: `(true) as u8` error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:7:14 + --> $DIR/unnecessary-transmutation.rs:16:29 | -LL | unsafe { transmute(x) } - | ^^^^^^^^^^^^ help: replace this with: `u32::to_ne_bytes(x)` +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 }; | - = 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:12:14 + --> $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 }; | -LL | unsafe { transmute(from) } - | ^^^^^^^^^^^^^^^ help: replace this with: `(from) as u8` error: unnecessary transmute --> $DIR/unnecessary-transmutation.rs:24:18 | LL | unsafe { transmute(x) } - | ^^^^^^^^^^^^ help: replace this with: `(x) as u8` + | ^^^^^^^^^^^^ + | +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 @@ -48,7 +87,9 @@ error: unnecessary transmute --> $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 @@ -56,7 +97,9 @@ error: unnecessary transmute --> $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 @@ -64,7 +107,9 @@ error: unnecessary transmute --> $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 @@ -72,7 +117,9 @@ error: unnecessary transmute --> $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 @@ -80,7 +127,9 @@ error: unnecessary transmute --> $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 @@ -88,7 +137,9 @@ error: unnecessary transmute --> $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 @@ -96,7 +147,9 @@ error: unnecessary transmute --> $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 @@ -104,7 +157,9 @@ error: unnecessary transmute --> $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 @@ -112,7 +167,9 @@ error: unnecessary transmute --> $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 @@ -120,7 +177,9 @@ error: unnecessary transmute --> $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 @@ -128,7 +187,9 @@ error: unnecessary transmute --> $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 @@ -136,7 +197,9 @@ error: unnecessary transmute --> $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 @@ -144,7 +207,9 @@ error: unnecessary transmute --> $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 @@ -152,7 +217,9 @@ error: unnecessary transmute --> $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 @@ -160,7 +227,9 @@ error: unnecessary transmute --> $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 @@ -168,119 +237,164 @@ error: unnecessary transmute --> $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: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: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: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: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: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: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: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: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: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: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: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: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: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: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:101:22 | LL | let y: i64 = transmute(1f64); - | ^^^^^^^^^^^^^^^ help: replace this with: `f64::to_bits(1f64).cast_signed()` + | ^^^^^^^^^^^^^^^ + | +help: replace this with + | +LL - let y: i64 = transmute(1f64); +LL + let y: i64 = f64::to_bits(1f64).cast_signed(); + | error: unnecessary transmute --> $DIR/unnecessary-transmutation.rs:106:21 | LL | let z: u8 = transmute(z); - | ^^^^^^^^^^^^ help: replace this with: `u8::from(z)` + | ---------^^^ + | | + | help: replace this with: `u8::from` error: unnecessary transmute --> $DIR/unnecessary-transmutation.rs:111:21 | LL | let z: i8 = transmute(z); - | ^^^^^^^^^^^^ help: replace this with: `i8::from(z)` - -error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:30:22 - | -LL | const { unsafe { transmute::<_, u8>(true) } }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this with: `(true) as u8` + | ---------^^^ + | | + | help: replace this with: `i8::from` error: aborting due to 40 previous errors 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/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/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/unsafe-binders/cat-projection.rs b/tests/ui/unsafe-binders/cat-projection.rs new file mode 100644 index 00000000000..dd7a78d59b3 --- /dev/null +++ b/tests/ui/unsafe-binders/cat-projection.rs @@ -0,0 +1,21 @@ +//@ 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/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> |
